[459] | 1 | unit fNotes;
|
---|
| 2 | {$O-}
|
---|
| 3 | {
|
---|
| 4 | NOTES:
|
---|
| 5 | TAB ORDER:
|
---|
| 6 | Becuase of the Dynamic ways of this form, the tab order must be
|
---|
| 7 | coded into the onExit events of the controls. If a new control is
|
---|
| 8 | added that needs access with tab & shift tab you must add the
|
---|
| 9 | code. Right clicking on the form and selecting tab order will not
|
---|
| 10 | be sufficient. See TfrmNotes.memPCEShowExit procedure for example.
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | interface
|
---|
| 14 |
|
---|
| 15 | uses
|
---|
| 16 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 17 | fHSplit, StdCtrls, ExtCtrls, Menus, ComCtrls, ORCtrls, ORFn, uConst, ORDtTm,
|
---|
| 18 | uPCE, ORClasses, fDrawers, ImgList, rTIU, uTIU, uDocTree, fRptBox, fPrintList;
|
---|
| 19 |
|
---|
| 20 | type
|
---|
| 21 | TfrmNotes = class(TfrmHSplit)
|
---|
| 22 | mnuNotes: TMainMenu;
|
---|
| 23 | mnuView: TMenuItem;
|
---|
| 24 | mnuViewChart: TMenuItem;
|
---|
| 25 | mnuChartReports: TMenuItem;
|
---|
| 26 | mnuChartLabs: TMenuItem;
|
---|
| 27 | mnuChartDCSumm: TMenuItem;
|
---|
| 28 | mnuChartCslts: TMenuItem;
|
---|
| 29 | mnuChartNotes: TMenuItem;
|
---|
| 30 | mnuChartOrders: TMenuItem;
|
---|
| 31 | mnuChartMeds: TMenuItem;
|
---|
| 32 | mnuChartProbs: TMenuItem;
|
---|
| 33 | mnuChartCover: TMenuItem;
|
---|
| 34 | Z1: TMenuItem;
|
---|
| 35 | mnuViewDetail: TMenuItem;
|
---|
| 36 | mnuAct: TMenuItem;
|
---|
| 37 | mnuActNew: TMenuItem;
|
---|
| 38 | Z2: TMenuItem;
|
---|
| 39 | mnuActSave: TMenuItem;
|
---|
| 40 | mnuActDelete: TMenuItem;
|
---|
| 41 | mnuActEdit: TMenuItem;
|
---|
| 42 | mnuActSign: TMenuItem;
|
---|
| 43 | mnuActAddend: TMenuItem;
|
---|
| 44 | lblNotes: TOROffsetLabel;
|
---|
| 45 | pnlRead: TPanel;
|
---|
| 46 | lblTitle: TOROffsetLabel;
|
---|
| 47 | memNote: TRichEdit;
|
---|
| 48 | pnlWrite: TPanel;
|
---|
| 49 | memNewNote: TRichEdit;
|
---|
| 50 | Z3: TMenuItem;
|
---|
| 51 | mnuViewAll: TMenuItem;
|
---|
| 52 | mnuViewByAuthor: TMenuItem;
|
---|
| 53 | mnuViewByDate: TMenuItem;
|
---|
| 54 | mnuViewUncosigned: TMenuItem;
|
---|
| 55 | mnuViewUnsigned: TMenuItem;
|
---|
| 56 | mnuActSignList: TMenuItem;
|
---|
| 57 | cmdNewNote: TORAlignButton;
|
---|
| 58 | cmdPCE: TORAlignButton;
|
---|
| 59 | lblSpace1: TLabel;
|
---|
| 60 | popNoteMemo: TPopupMenu;
|
---|
| 61 | popNoteMemoCut: TMenuItem;
|
---|
| 62 | popNoteMemoCopy: TMenuItem;
|
---|
| 63 | popNoteMemoPaste: TMenuItem;
|
---|
| 64 | Z10: TMenuItem;
|
---|
| 65 | popNoteMemoSignList: TMenuItem;
|
---|
| 66 | popNoteMemoDelete: TMenuItem;
|
---|
| 67 | popNoteMemoEdit: TMenuItem;
|
---|
| 68 | popNoteMemoSave: TMenuItem;
|
---|
| 69 | popNoteMemoSign: TMenuItem;
|
---|
| 70 | popNoteList: TPopupMenu;
|
---|
| 71 | popNoteListAll: TMenuItem;
|
---|
| 72 | popNoteListByAuthor: TMenuItem;
|
---|
| 73 | popNoteListByDate: TMenuItem;
|
---|
| 74 | popNoteListUncosigned: TMenuItem;
|
---|
| 75 | popNoteListUnsigned: TMenuItem;
|
---|
| 76 | sptVert: TSplitter;
|
---|
| 77 | memPCEShow: TRichEdit;
|
---|
| 78 | mnuActIdentifyAddlSigners: TMenuItem;
|
---|
| 79 | popNoteMemoAddlSign: TMenuItem;
|
---|
| 80 | Z11: TMenuItem;
|
---|
| 81 | popNoteMemoSpell: TMenuItem;
|
---|
| 82 | popNoteMemoGrammar: TMenuItem;
|
---|
| 83 | mnuViewCustom: TMenuItem;
|
---|
| 84 | N1: TMenuItem;
|
---|
| 85 | mnuViewSaveAsDefault: TMenuItem;
|
---|
| 86 | ReturntoDefault1: TMenuItem;
|
---|
| 87 | pnlDrawers: TPanel;
|
---|
| 88 | lstNotes: TORListBox;
|
---|
| 89 | splDrawers: TSplitter;
|
---|
| 90 | popNoteMemoTemplate: TMenuItem;
|
---|
| 91 | Z12: TMenuItem;
|
---|
| 92 | mnuOptions: TMenuItem;
|
---|
| 93 | mnuEditTemplates: TMenuItem;
|
---|
| 94 | mnuNewTemplate: TMenuItem;
|
---|
| 95 | N2: TMenuItem;
|
---|
| 96 | mnuEditSharedTemplates: TMenuItem;
|
---|
| 97 | mnuNewSharedTemplate: TMenuItem;
|
---|
| 98 | popNoteMemoAddend: TMenuItem;
|
---|
| 99 | pnlFields: TPanel;
|
---|
| 100 | lblNewTitle: TStaticText;
|
---|
| 101 | lblRefDate: TStaticText;
|
---|
| 102 | lblAuthor: TStaticText;
|
---|
| 103 | lblVisit: TStaticText;
|
---|
| 104 | lblCosigner: TStaticText;
|
---|
| 105 | cmdChange: TButton;
|
---|
| 106 | lblSubject: TStaticText;
|
---|
| 107 | txtSubject: TCaptionEdit;
|
---|
| 108 | timAutoSave: TTimer;
|
---|
| 109 | popNoteMemoPaste2: TMenuItem;
|
---|
| 110 | popNoteMemoReformat: TMenuItem;
|
---|
| 111 | Z4: TMenuItem;
|
---|
| 112 | mnuActChange: TMenuItem;
|
---|
| 113 | mnuActLoadBoiler: TMenuItem;
|
---|
| 114 | bvlNewTitle: TBevel;
|
---|
| 115 | popNoteMemoSaveContinue: TMenuItem;
|
---|
| 116 | N3: TMenuItem;
|
---|
| 117 | mnuEditDialgFields: TMenuItem;
|
---|
| 118 | lvNotes: TCaptionListView;
|
---|
| 119 | sptList: TSplitter;
|
---|
| 120 | N4: TMenuItem;
|
---|
| 121 | popNoteListExpandSelected: TMenuItem;
|
---|
| 122 | popNoteListExpandAll: TMenuItem;
|
---|
| 123 | popNoteListCollapseSelected: TMenuItem;
|
---|
| 124 | popNoteListCollapseAll: TMenuItem;
|
---|
| 125 | popNoteListCustom: TMenuItem;
|
---|
| 126 | mnuActDetachFromIDParent: TMenuItem;
|
---|
| 127 | N5: TMenuItem;
|
---|
| 128 | popNoteListDetachFromIDParent: TMenuItem;
|
---|
| 129 | popNoteListAddIDEntry: TMenuItem;
|
---|
| 130 | mnuActAddIDEntry: TMenuItem;
|
---|
| 131 | mnuIconLegend: TMenuItem;
|
---|
| 132 | N6: TMenuItem;
|
---|
| 133 | popNoteMemoFind: TMenuItem;
|
---|
| 134 | dlgFindText: TFindDialog;
|
---|
| 135 | dlgReplaceText: TReplaceDialog;
|
---|
| 136 | popNoteMemoReplace: TMenuItem;
|
---|
| 137 | N7: TMenuItem;
|
---|
| 138 | mnuChartSurgery: TMenuItem;
|
---|
| 139 | mnuActAttachtoIDParent: TMenuItem;
|
---|
| 140 | popNoteListAttachtoIDParent: TMenuItem;
|
---|
| 141 | N8: TMenuItem;
|
---|
| 142 | popNoteMemoPreview: TMenuItem;
|
---|
| 143 | popNoteMemoInsTemplate: TMenuItem;
|
---|
| 144 | popNoteMemoEncounter: TMenuItem;
|
---|
| 145 | tvNotes: TORTreeView;
|
---|
| 146 | procedure mnuChartTabClick(Sender: TObject);
|
---|
| 147 | procedure lstNotesClick(Sender: TObject);
|
---|
| 148 | procedure pnlRightResize(Sender: TObject);
|
---|
| 149 | procedure cmdNewNoteClick(Sender: TObject);
|
---|
| 150 | procedure mnuActNewClick(Sender: TObject);
|
---|
| 151 | procedure mnuActAddIDEntryClick(Sender: TObject);
|
---|
| 152 | procedure mnuActSaveClick(Sender: TObject);
|
---|
| 153 | procedure mnuViewClick(Sender: TObject);
|
---|
| 154 | procedure mnuActAddendClick(Sender: TObject);
|
---|
| 155 | procedure mnuActDetachFromIDParentClick(Sender: TObject);
|
---|
| 156 | procedure mnuActSignListClick(Sender: TObject);
|
---|
| 157 | procedure mnuActDeleteClick(Sender: TObject);
|
---|
| 158 | procedure mnuActEditClick(Sender: TObject);
|
---|
| 159 | procedure mnuActSignClick(Sender: TObject);
|
---|
| 160 | procedure cmdPCEClick(Sender: TObject);
|
---|
| 161 | procedure popNoteMemoCutClick(Sender: TObject);
|
---|
| 162 | procedure popNoteMemoCopyClick(Sender: TObject);
|
---|
| 163 | procedure popNoteMemoPasteClick(Sender: TObject);
|
---|
| 164 | procedure popNoteMemoPopup(Sender: TObject);
|
---|
| 165 | procedure pnlWriteResize(Sender: TObject);
|
---|
| 166 | procedure FormCreate(Sender: TObject);
|
---|
| 167 | procedure mnuViewDetailClick(Sender: TObject);
|
---|
| 168 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 169 | procedure mnuActIdentifyAddlSignersClick(Sender: TObject);
|
---|
| 170 | procedure popNoteMemoAddlSignClick(Sender: TObject);
|
---|
| 171 | procedure popNoteMemoSpellClick(Sender: TObject);
|
---|
| 172 | procedure popNoteMemoGrammarClick(Sender: TObject);
|
---|
| 173 | procedure mnuViewSaveAsDefaultClick(Sender: TObject);
|
---|
| 174 | procedure mnuViewReturntoDefaultClick(Sender: TObject);
|
---|
| 175 | procedure popNoteMemoTemplateClick(Sender: TObject);
|
---|
| 176 | procedure mnuEditTemplatesClick(Sender: TObject);
|
---|
| 177 | procedure mnuNewTemplateClick(Sender: TObject);
|
---|
| 178 | procedure mnuEditSharedTemplatesClick(Sender: TObject);
|
---|
| 179 | procedure mnuNewSharedTemplateClick(Sender: TObject);
|
---|
| 180 | procedure mnuOptionsClick(Sender: TObject);
|
---|
| 181 | procedure FormDestroy(Sender: TObject);
|
---|
| 182 | procedure cmdChangeClick(Sender: TObject);
|
---|
| 183 | procedure pnlFieldsResize(Sender: TObject);
|
---|
| 184 | procedure timAutoSaveTimer(Sender: TObject);
|
---|
| 185 | procedure memNewNoteChange(Sender: TObject);
|
---|
| 186 | procedure popNoteMemoReformatClick(Sender: TObject);
|
---|
| 187 | procedure mnuActChangeClick(Sender: TObject);
|
---|
| 188 | procedure mnuActLoadBoilerClick(Sender: TObject);
|
---|
| 189 | procedure popNoteMemoSaveContinueClick(Sender: TObject);
|
---|
| 190 | procedure mnuEditDialgFieldsClick(Sender: TObject);
|
---|
| 191 | procedure tvNotesChange(Sender: TObject; Node: TTreeNode);
|
---|
| 192 | procedure tvNotesClick(Sender: TObject);
|
---|
| 193 | procedure tvNotesCollapsed(Sender: TObject; Node: TTreeNode);
|
---|
| 194 | procedure tvNotesExpanded(Sender: TObject; Node: TTreeNode);
|
---|
| 195 | procedure tvNotesStartDrag(Sender: TObject;
|
---|
| 196 | var DragObject: TDragObject);
|
---|
| 197 | procedure tvNotesDragDrop(Sender, Source: TObject; X, Y: Integer);
|
---|
| 198 | procedure tvNotesDragOver(Sender, Source: TObject; X, Y: Integer;
|
---|
| 199 | State: TDragState; var Accept: Boolean);
|
---|
| 200 | procedure lvNotesColumnClick(Sender: TObject; Column: TListColumn);
|
---|
| 201 | procedure lvNotesCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
|
---|
| 202 | procedure lvNotesSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
|
---|
| 203 | procedure popNoteListExpandAllClick(Sender: TObject);
|
---|
| 204 | procedure popNoteListCollapseAllClick(Sender: TObject);
|
---|
| 205 | procedure popNoteListExpandSelectedClick(Sender: TObject);
|
---|
| 206 | procedure popNoteListCollapseSelectedClick(Sender: TObject);
|
---|
| 207 | procedure popNoteListPopup(Sender: TObject);
|
---|
| 208 | procedure lvNotesResize(Sender: TObject);
|
---|
| 209 | procedure mnuIconLegendClick(Sender: TObject);
|
---|
| 210 | procedure popNoteMemoFindClick(Sender: TObject);
|
---|
| 211 | procedure dlgFindTextFind(Sender: TObject);
|
---|
| 212 | procedure popNoteMemoReplaceClick(Sender: TObject);
|
---|
| 213 | procedure dlgReplaceTextReplace(Sender: TObject);
|
---|
| 214 | procedure dlgReplaceTextFind(Sender: TObject);
|
---|
| 215 | procedure mnuActAttachtoIDParentClick(Sender: TObject);
|
---|
| 216 | procedure memNewNoteKeyDown(Sender: TObject; var Key: Word;
|
---|
| 217 | Shift: TShiftState);
|
---|
| 218 | procedure sptHorzCanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean);
|
---|
| 219 | procedure popNoteMemoInsTemplateClick(Sender: TObject);
|
---|
| 220 | procedure popNoteMemoPreviewClick(Sender: TObject);
|
---|
| 221 | procedure tvNotesAddition(Sender: TObject; Node: TTreeNode);
|
---|
| 222 | procedure tvNotesDeletion(Sender: TObject; Node: TTreeNode);
|
---|
| 223 | procedure tvNotesExit(Sender: TObject);
|
---|
| 224 | procedure cmdNewNoteExit(Sender: TObject);
|
---|
| 225 | procedure FormHide(Sender: TObject);
|
---|
| 226 | procedure FormShow(Sender: TObject);
|
---|
| 227 | procedure memNewNoteKeyPress(Sender: TObject; var Key: Char);
|
---|
| 228 | procedure memNewNoteKeyUp(Sender: TObject; var Key: Word;
|
---|
| 229 | Shift: TShiftState);
|
---|
| 230 | procedure memPCEShowExit(Sender: TObject);
|
---|
| 231 | procedure cmdChangeExit(Sender: TObject);
|
---|
| 232 | procedure cmdPCEExit(Sender: TObject);
|
---|
| 233 | procedure memNoteExit(Sender: TObject);
|
---|
| 234 | procedure lvNotesExit(Sender: TObject);
|
---|
| 235 | private
|
---|
| 236 | FNavigatingTab : Boolean; //Currently Using tab to navigate
|
---|
| 237 | FEditingIndex: Integer; // index of note being currently edited
|
---|
| 238 | FChanged: Boolean; // true if any text has changed in the note
|
---|
| 239 | FEditCtrl: TCustomEdit;
|
---|
| 240 | FSilent: Boolean;
|
---|
| 241 | FCurrentContext: TTIUContext;
|
---|
| 242 | FDefaultContext: TTIUContext;
|
---|
| 243 | FOrderID: string;
|
---|
| 244 | FImageFlag: TBitmap;
|
---|
| 245 | FEditNote: TEditNoteRec;
|
---|
| 246 | FVerifyNoteTitle: Integer;
|
---|
| 247 | FDocList: TStringList;
|
---|
| 248 | FConfirmed: boolean;
|
---|
| 249 | FLastNoteID: string;
|
---|
| 250 | FNewIDChild: boolean;
|
---|
| 251 | FEditingNotePCEObj: boolean;
|
---|
| 252 | FDeleted: boolean;
|
---|
| 253 | FOldFramePnlPatientExit: TNotifyEvent;
|
---|
| 254 | FOldDrawerPnlTemplatesButtonExit: TNotifyEvent;
|
---|
| 255 | FOldDrawerPnlEncounterButtonExit: TNotifyEvent;
|
---|
| 256 | FOldDrawerEdtSearchExit: TNotifyEvent;
|
---|
| 257 | FStarting: boolean;
|
---|
| 258 | procedure frmFramePnlPatientExit(Sender: TObject);
|
---|
| 259 | procedure frmDrawerPnlTemplatesButtonExit(Sender: TObject);
|
---|
| 260 | procedure frmDrawerPnlEncounterButtonExit(Sender: TObject);
|
---|
| 261 | procedure frmDrawerEdtSearchExit(Sender: TObject);
|
---|
| 262 | procedure ClearEditControls;
|
---|
| 263 | procedure DoAutoSave;
|
---|
| 264 | function GetTitleText(AnIndex: Integer): string;
|
---|
| 265 | procedure InsertAddendum;
|
---|
| 266 | procedure InsertNewNote(IsIDChild: boolean; AnIDParent: integer);
|
---|
| 267 | function LacksRequiredForCreate: Boolean;
|
---|
| 268 | procedure LoadForEdit;
|
---|
| 269 | function LockConsultRequest(AConsult: Integer): Boolean;
|
---|
| 270 | function LockConsultRequestAndNote(AnIEN: Int64): Boolean;
|
---|
| 271 | procedure RemovePCEFromChanges(IEN: Int64; AVisitStr: string = '');
|
---|
| 272 | procedure SaveEditedNote(var Saved: Boolean);
|
---|
| 273 | procedure SaveCurrentNote(var Saved: Boolean);
|
---|
| 274 | procedure SetEditingIndex(const Value: Integer);
|
---|
| 275 | procedure SetSubjectVisible(ShouldShow: Boolean);
|
---|
| 276 | procedure ShowPCEControls(ShouldShow: Boolean);
|
---|
| 277 | function StartNewEdit(NewNoteType: integer): Boolean;
|
---|
| 278 | procedure UnlockConsultRequest(ANote: Int64; AConsult: Integer = 0);
|
---|
| 279 | procedure ProcessNotifications;
|
---|
| 280 | procedure SetViewContext(AContext: TTIUContext);
|
---|
| 281 | property EditingIndex: Integer read FEditingIndex write SetEditingIndex;
|
---|
| 282 | function GetDrawers: TFrmDrawers;
|
---|
| 283 | function CanFinishReminder: boolean;
|
---|
| 284 | procedure DisplayPCE;
|
---|
| 285 | function VerifyNoteTitle: Boolean;
|
---|
| 286 | // added for treeview
|
---|
| 287 | procedure LoadNotes;
|
---|
| 288 | procedure UpdateTreeView(DocList: TStringList; Tree: TORTreeView);
|
---|
| 289 | procedure EnableDisableIDNotes;
|
---|
| 290 | procedure ShowPCEButtons(Editing: boolean);
|
---|
| 291 | procedure DoAttachIDChild(AChild, AParent: TORTreeNode);
|
---|
| 292 | function SetNoteTreeLabel(AContext: TTIUContext): string;
|
---|
| 293 | procedure UpdateNoteAuthor(DocInfo: string);
|
---|
| 294 | public
|
---|
| 295 | function ActiveEditOf(AnIEN: Int64; ARequest: integer): Boolean;
|
---|
| 296 | function AllowContextChange(var WhyNot: string): Boolean; override;
|
---|
| 297 | procedure ClearPtData; override;
|
---|
| 298 | procedure DisplayPage; override;
|
---|
| 299 | procedure RequestPrint; override;
|
---|
| 300 | procedure RequestMultiplePrint(AForm: TfrmPrintList);
|
---|
| 301 | procedure SetFontSize(NewFontSize: Integer); override;
|
---|
| 302 | procedure SaveSignItem(const ItemID, ESCode: string);
|
---|
| 303 | procedure AssignRemForm;
|
---|
| 304 | property OrderID: string read FOrderID;
|
---|
| 305 | procedure LstNotesToPrint;
|
---|
| 306 | published
|
---|
| 307 | property Drawers: TFrmDrawers read GetDrawers; // Keep Drawers published
|
---|
| 308 | end;
|
---|
| 309 |
|
---|
| 310 | var
|
---|
| 311 | frmNotes: TfrmNotes;
|
---|
| 312 |
|
---|
| 313 | implementation
|
---|
| 314 |
|
---|
| 315 | {$R *.DFM}
|
---|
| 316 |
|
---|
| 317 | uses fFrame, fVisit, fEncnt, rCore, uCore, fNoteBA, fNoteBD, fSignItem, fEncounterFrame,
|
---|
| 318 | rPCE, Clipbrd, fNoteCslt, fNotePrt, rVitals, fAddlSigners, fNoteDR, fConsults, uSpell,
|
---|
| 319 | fTIUView, fTemplateEditor, uReminders, fReminderDialog, uOrders, rConsults, fReminderTree,
|
---|
| 320 | fNoteProps, fNotesBP, fTemplateFieldEditor, dShared, rTemplates,
|
---|
| 321 | FIconLegend, fPCEEdit, fNoteIDParents, rSurgery, uSurgery, uTemplates,
|
---|
| 322 | uAccessibleTreeView, uAccessibleTreeNode, fTemplateDialog, DateUtils;
|
---|
| 323 |
|
---|
| 324 | const
|
---|
| 325 |
|
---|
| 326 | NT_NEW_NOTE = -10; // Holder IEN for a new note
|
---|
| 327 | NT_ADDENDUM = -20; // Holder IEN for a new addendum
|
---|
| 328 |
|
---|
| 329 | NT_ACT_NEW_NOTE = 2;
|
---|
| 330 | NT_ACT_ADDENDUM = 3;
|
---|
| 331 | NT_ACT_EDIT_NOTE = 4;
|
---|
| 332 | NT_ACT_ID_ENTRY = 5;
|
---|
| 333 |
|
---|
| 334 | TX_NEED_VISIT = 'A visit is required before creating a new progress note.';
|
---|
| 335 | TX_CREATE_ERR = 'Error Creating Note';
|
---|
| 336 | TX_UPDATE_ERR = 'Error Updating Note';
|
---|
| 337 | TX_NO_NOTE = 'No progress note is currently being edited';
|
---|
| 338 | TX_SAVE_NOTE = 'Save Progress Note';
|
---|
| 339 | TX_ADDEND_NO = 'Cannot make an addendum to a note that is being edited';
|
---|
| 340 | TX_DEL_OK = CRLF + CRLF + 'Delete this progress note?';
|
---|
| 341 | TX_DEL_ERR = 'Unable to Delete Note';
|
---|
| 342 | TX_SIGN = 'Sign Note';
|
---|
| 343 | TX_COSIGN = 'Cosign Note';
|
---|
| 344 | TX_SIGN_ERR = 'Unable to Sign Note';
|
---|
| 345 | // TX_SCREQD = 'This progress note title requires the service connected questions to be '+
|
---|
| 346 | // 'answered. The Encounter form will now be opened. Please answer all '+
|
---|
| 347 | // 'service connected questions.';
|
---|
| 348 | // TX_SCREQD_T = 'Response required for SC questions.';
|
---|
| 349 | TX_NONOTE = 'No progress note is currently selected.';
|
---|
| 350 | TX_NONOTE_CAP = 'No Note Selected';
|
---|
| 351 | TX_NOPRT_NEW = 'This progress note may not be printed until it is saved';
|
---|
| 352 | TX_NOPRT_NEW_CAP = 'Save Progress Note';
|
---|
| 353 | TX_NO_ALERT = 'There is insufficient information to process this alert.' + CRLF +
|
---|
| 354 | 'Either the alert has already been deleted, or it contained invalid data.' + CRLF + CRLF +
|
---|
| 355 | 'Click the NEXT button if you wish to continue processing more alerts.';
|
---|
| 356 | TX_CAP_NO_ALERT = 'Unable to Process Alert';
|
---|
| 357 | TX_ORDER_LOCKED = 'This record is locked by an action underway on the Consults tab';
|
---|
| 358 | TC_ORDER_LOCKED = 'Unable to access record';
|
---|
| 359 | TX_NO_ORD_CHG = 'The note is still associated with the previously selected request.' + CRLF +
|
---|
| 360 | 'Finish the pending action on the consults tab, then try again.';
|
---|
| 361 | TC_NO_ORD_CHG = 'Locked Consult Request';
|
---|
| 362 | TX_NEW_SAVE1 = 'You are currently editing:' + CRLF + CRLF;
|
---|
| 363 | TX_NEW_SAVE2 = CRLF + CRLF + 'Do you wish to save this note and begin a new one?';
|
---|
| 364 | TX_NEW_SAVE3 = CRLF + CRLF + 'Do you wish to save this note and begin a new addendum?';
|
---|
| 365 | TX_NEW_SAVE4 = CRLF + CRLF + 'Do you wish to save this note and edit the one selected?';
|
---|
| 366 | TX_NEW_SAVE5 = CRLF + CRLF + 'Do you wish to save this note and begin a new Interdisciplinary entry?';
|
---|
| 367 | TC_NEW_SAVE2 = 'Create New Note';
|
---|
| 368 | TC_NEW_SAVE3 = 'Create New Addendum';
|
---|
| 369 | TC_NEW_SAVE4 = 'Edit Different Note';
|
---|
| 370 | TC_NEW_SAVE5 = 'Create New Interdisciplinary Entry';
|
---|
| 371 | TX_EMPTY_NOTE = CRLF + CRLF + 'This note contains no text and will not be saved.' + CRLF +
|
---|
| 372 | 'Do you wish to delete this note?';
|
---|
| 373 | TC_EMPTY_NOTE = 'Empty Note';
|
---|
| 374 | TX_EMPTY_NOTE1 = 'This note contains no text and can not be signed.';
|
---|
| 375 | TC_NO_LOCK = 'Unable to Lock Note';
|
---|
| 376 | TX_ABSAVE = 'It appears the session terminated abnormally when this' + CRLF +
|
---|
| 377 | 'note was last edited. Some text may not have been saved.' + CRLF + CRLF +
|
---|
| 378 | 'Do you wish to continue and sign the note?';
|
---|
| 379 | TC_ABSAVE = 'Possible Missing Text';
|
---|
| 380 | TX_NO_BOIL = 'There is no boilerplate text associated with this title.';
|
---|
| 381 | TC_NO_BOIL = 'Load Boilerplate Text';
|
---|
| 382 | TX_BLR_CLEAR = 'Do you want to clear the previously loaded boilerplate text?';
|
---|
| 383 | TC_BLR_CLEAR = 'Clear Previous Boilerplate Text';
|
---|
| 384 | TX_DETACH_CNF = 'Confirm Detachment';
|
---|
| 385 | TX_DETACH_FAILURE = 'Detach failed';
|
---|
| 386 | TX_RETRACT_CAP = 'Retraction Notice';
|
---|
| 387 | TX_RETRACT = 'This document will now be RETRACTED. As Such, it has been removed' +CRLF +
|
---|
| 388 | ' from public view, and from typical Releases of Information,' +CRLF +
|
---|
| 389 | ' but will remain indefinitely discoverable to HIMS.' +CRLF +CRLF;
|
---|
| 390 | TX_AUTH_SIGNED = 'Author has not signed, are you SURE you want to sign.' +CRLF;
|
---|
| 391 |
|
---|
| 392 | var
|
---|
| 393 | uPCEShow, uPCEEdit: TPCEData;
|
---|
| 394 | ViewContext: Integer;
|
---|
| 395 | frmDrawers: TfrmDrawers;
|
---|
| 396 | uTIUContext: TTIUContext;
|
---|
| 397 | ColumnToSort: Integer;
|
---|
| 398 | ColumnSortForward: Boolean;
|
---|
| 399 | uChanging: Boolean;
|
---|
| 400 | uIDNotesActive: Boolean;
|
---|
| 401 |
|
---|
| 402 | { TPage common methods --------------------------------------------------------------------- }
|
---|
| 403 | function TfrmNotes.AllowContextChange(var WhyNot: string): Boolean;
|
---|
| 404 | begin
|
---|
| 405 | dlgFindText.CloseDialog;
|
---|
| 406 | Result := inherited AllowContextChange(WhyNot); // sets result = true
|
---|
| 407 | if Assigned(frmTemplateDialog) then
|
---|
| 408 | if Screen.ActiveForm = frmTemplateDialog then
|
---|
| 409 | //if (fsModal in frmTemplateDialog.FormState) then
|
---|
| 410 | case BOOLCHAR[frmFrame.CCOWContextChanging] of
|
---|
| 411 | '1': begin
|
---|
| 412 | WhyNot := 'A template in progress will be aborted. ';
|
---|
| 413 | Result := False;
|
---|
| 414 | end;
|
---|
| 415 | '0': begin
|
---|
| 416 | if WhyNot = 'COMMIT' then
|
---|
| 417 | begin
|
---|
| 418 | FSilent := True;
|
---|
| 419 | frmTemplateDialog.Silent := True;
|
---|
| 420 | frmTemplateDialog.ModalResult := mrCancel;
|
---|
| 421 | end;
|
---|
| 422 | end;
|
---|
| 423 | end;
|
---|
| 424 | if Assigned(frmRemDlg) then
|
---|
| 425 | case BOOLCHAR[frmFrame.CCOWContextChanging] of
|
---|
| 426 | '1': begin
|
---|
| 427 | WhyNot := 'All current reminder processing information will be discarded. ';
|
---|
| 428 | Result := False;
|
---|
| 429 | end;
|
---|
| 430 | '0': begin
|
---|
| 431 | if WhyNot = 'COMMIT' then
|
---|
| 432 | begin
|
---|
| 433 | FSilent := True;
|
---|
| 434 | frmRemDlg.Silent := True;
|
---|
| 435 | frmRemDlg.btnCancelClick(Self);
|
---|
| 436 | end;
|
---|
| 437 | end;
|
---|
| 438 | end;
|
---|
| 439 | if EditingIndex <> -1 then
|
---|
| 440 | case BOOLCHAR[frmFrame.CCOWContextChanging] of
|
---|
| 441 | '1': begin
|
---|
| 442 | if memNewNote.GetTextLen > 0 then
|
---|
| 443 | WhyNot := WhyNot + 'A note in progress will be saved as unsigned. '
|
---|
| 444 | else
|
---|
| 445 | WhyNot := WhyNot + 'An empty note in progress will be deleted. ';
|
---|
| 446 | Result := False;
|
---|
| 447 | end;
|
---|
| 448 | '0': begin
|
---|
| 449 | if WhyNot = 'COMMIT' then FSilent := True;
|
---|
| 450 | SaveCurrentNote(Result)
|
---|
| 451 | end;
|
---|
| 452 | end;
|
---|
| 453 | if Assigned(frmEncounterFrame) then
|
---|
| 454 | if Screen.ActiveForm = frmEncounterFrame then
|
---|
| 455 | //if (fsModal in frmEncounterFrame.FormState) then
|
---|
| 456 | case BOOLCHAR[frmFrame.CCOWContextChanging] of
|
---|
| 457 | '1': begin
|
---|
| 458 | WhyNot := WhyNot + 'Encounter information being edited will not be saved';
|
---|
| 459 | Result := False;
|
---|
| 460 | end;
|
---|
| 461 | '0': begin
|
---|
| 462 | if WhyNot = 'COMMIT' then
|
---|
| 463 | begin
|
---|
| 464 | FSilent := True;
|
---|
| 465 | frmEncounterFrame.Abort := False;
|
---|
| 466 | frmEncounterFrame.Cancel := True;
|
---|
| 467 | end;
|
---|
| 468 | end;
|
---|
| 469 | end;
|
---|
| 470 | end;
|
---|
| 471 |
|
---|
| 472 | procedure TfrmNotes.LstNotesToPrint;
|
---|
| 473 | var
|
---|
| 474 | AParentID: string;
|
---|
| 475 | SavedDocID: string;
|
---|
| 476 | Saved: boolean;
|
---|
| 477 | begin
|
---|
| 478 | inherited;
|
---|
| 479 | if not uIDNotesActive then exit;
|
---|
| 480 | if lstNotes.ItemIEN = 0 then exit;
|
---|
| 481 | SavedDocID := lstNotes.ItemID;
|
---|
| 482 | if EditingIndex <> -1 then
|
---|
| 483 | begin
|
---|
| 484 | SaveCurrentNote(Saved);
|
---|
| 485 | if not Saved then Exit;
|
---|
| 486 | LoadNotes;
|
---|
| 487 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 488 | end;
|
---|
| 489 | if tvNotes.Selected = nil then exit;
|
---|
| 490 | AParentID := frmPrintList.SelectParentFromList(tvNotes,CT_NOTES);
|
---|
| 491 | if AParentID = '' then exit;
|
---|
| 492 | with tvNotes do Selected := FindPieceNode(AParentID, 1, U, Items.GetFirstNode);
|
---|
| 493 | end;
|
---|
| 494 |
|
---|
| 495 | procedure TfrmNotes.ClearPtData;
|
---|
| 496 | { clear all controls that contain patient specific information }
|
---|
| 497 | begin
|
---|
| 498 | inherited ClearPtData;
|
---|
| 499 | ClearEditControls;
|
---|
| 500 | uChanging := True;
|
---|
| 501 | tvNotes.Items.BeginUpdate;
|
---|
| 502 | KilldocTreeObjects(tvNotes);
|
---|
| 503 | tvNotes.Items.Clear;
|
---|
| 504 | tvNotes.Items.EndUpdate;
|
---|
| 505 | lvNotes.Items.Clear;
|
---|
| 506 | uChanging := False;
|
---|
| 507 | lstNotes.Clear;
|
---|
| 508 | memNote.Clear;
|
---|
| 509 | memPCEShow.Clear;
|
---|
| 510 | uPCEShow.Clear;
|
---|
| 511 | uPCEEdit.Clear;
|
---|
| 512 | frmDrawers.ResetTemplates;
|
---|
| 513 | end;
|
---|
| 514 |
|
---|
| 515 | procedure TfrmNotes.DisplayPage;
|
---|
| 516 | { causes page to be visible and conditionally executes initialization code }
|
---|
| 517 | begin
|
---|
| 518 | inherited DisplayPage;
|
---|
| 519 | frmFrame.ShowHideChartTabMenus(mnuViewChart);
|
---|
| 520 | frmFrame.mnuFilePrint.Tag := CT_NOTES;
|
---|
| 521 | frmFrame.mnuFilePrint.Enabled := True;
|
---|
| 522 | frmFrame.mnuFilePrintSetup.Enabled := True;
|
---|
| 523 | frmFrame.mnuFilePrintSelectedItems.Enabled := True;
|
---|
| 524 | if InitPage then
|
---|
| 525 | begin
|
---|
| 526 | EnableDisableIDNotes;
|
---|
| 527 | FDefaultContext := GetCurrentTIUContext;
|
---|
| 528 | FCurrentContext := FDefaultContext;
|
---|
| 529 | popNoteMemoSpell.Visible := SpellCheckAvailable;
|
---|
| 530 | popNoteMemoGrammar.Visible := popNoteMemoSpell.Visible;
|
---|
| 531 | Z11.Visible := popNoteMemoSpell.Visible;
|
---|
| 532 | timAutoSave.Interval := User.AutoSave * 1000; // convert seconds to milliseconds
|
---|
| 533 | SetEqualTabStops(memNewNote);
|
---|
| 534 | end;
|
---|
| 535 | // to indent the right margin need to set Paragraph.RightIndent for each paragraph?
|
---|
| 536 | if InitPatient and not (CallingContext = CC_NOTIFICATION) then
|
---|
| 537 | begin
|
---|
| 538 | SetViewContext(FDefaultContext);
|
---|
| 539 | end;
|
---|
| 540 | case CallingContext of
|
---|
| 541 | CC_INIT_PATIENT: if not InitPatient then
|
---|
| 542 | begin
|
---|
| 543 | SetViewContext(FDefaultContext);
|
---|
| 544 | end;
|
---|
| 545 | CC_NOTIFICATION: ProcessNotifications;
|
---|
| 546 | end;
|
---|
| 547 | end;
|
---|
| 548 |
|
---|
| 549 | procedure TfrmNotes.RequestPrint;
|
---|
| 550 | var
|
---|
| 551 | Saved: Boolean;
|
---|
| 552 | begin
|
---|
| 553 | with lstNotes do
|
---|
| 554 | begin
|
---|
| 555 | if ItemIndex = EditingIndex then
|
---|
| 556 | //if ItemIEN < 0 then
|
---|
| 557 | begin
|
---|
| 558 | SaveCurrentNote(Saved);
|
---|
| 559 | if not Saved then Exit;
|
---|
| 560 | end;
|
---|
| 561 | if ItemIEN > 0 then PrintNote(ItemIEN, MakeNoteDisplayText(Items[ItemIndex])) else
|
---|
| 562 | begin
|
---|
| 563 | if ItemIEN = 0 then InfoBox(TX_NONOTE, TX_NONOTE_CAP, MB_OK);
|
---|
| 564 | if ItemIEN < 0 then InfoBox(TX_NOPRT_NEW, TX_NOPRT_NEW_CAP, MB_OK);
|
---|
| 565 | end;
|
---|
| 566 | end;
|
---|
| 567 | end;
|
---|
| 568 |
|
---|
| 569 | {for printing multiple notes}
|
---|
| 570 | procedure TfrmNotes.RequestMultiplePrint(AForm: TfrmPrintList);
|
---|
| 571 | var
|
---|
| 572 | NoteIEN: int64;
|
---|
| 573 | i: integer;
|
---|
| 574 | begin
|
---|
| 575 | with AForm.lbIDParents do
|
---|
| 576 | begin
|
---|
| 577 | for i := 0 to Items.Count - 1 do
|
---|
| 578 | begin
|
---|
| 579 | if Selected[i] then
|
---|
| 580 | begin
|
---|
| 581 | NoteIEN := StrToInt64def(Piece(TStringList(Items.Objects[i])[0],U,1),0);
|
---|
| 582 | if NoteIEN > 0 then PrintNote(NoteIEN, Items[i], TRUE) else
|
---|
| 583 | begin
|
---|
| 584 | if NoteIEN = 0 then InfoBox(TX_NONOTE, TX_NONOTE_CAP, MB_OK);
|
---|
| 585 | if NoteIEN < 0 then InfoBox(TX_NOPRT_NEW, TX_NOPRT_NEW_CAP, MB_OK);
|
---|
| 586 | end;
|
---|
| 587 | end; {if selected}
|
---|
| 588 | end; {for}
|
---|
| 589 | end; {with}
|
---|
| 590 | end;
|
---|
| 591 |
|
---|
| 592 | procedure TfrmNotes.SetFontSize(NewFontSize: Integer);
|
---|
| 593 | { adjusts the font size of any controls that don't have ParentFont = True }
|
---|
| 594 | begin
|
---|
| 595 | inherited SetFontSize(NewFontSize);
|
---|
| 596 | frmDrawers.Font.Size := NewFontSize;
|
---|
| 597 | SetEqualTabStops(memNewNote);
|
---|
| 598 | end;
|
---|
| 599 |
|
---|
| 600 | procedure TfrmNotes.mnuChartTabClick(Sender: TObject);
|
---|
| 601 | { reroute to Chart Tab menu of the parent form: frmFrame }
|
---|
| 602 | begin
|
---|
| 603 | inherited;
|
---|
| 604 | frmFrame.mnuChartTabClick(Sender);
|
---|
| 605 | end;
|
---|
| 606 |
|
---|
| 607 | { General procedures ----------------------------------------------------------------------- }
|
---|
| 608 |
|
---|
| 609 | procedure TfrmNotes.ClearEditControls;
|
---|
| 610 | { resets controls used for entering a new progress note }
|
---|
| 611 | begin
|
---|
| 612 | // clear FEditNote (should FEditNote be an object with a clear method?)
|
---|
| 613 | with FEditNote do
|
---|
| 614 | begin
|
---|
| 615 | DocType := 0;
|
---|
| 616 | Title := 0;
|
---|
| 617 | TitleName := '';
|
---|
| 618 | DateTime := 0;
|
---|
| 619 | Author := 0;
|
---|
| 620 | AuthorName := '';
|
---|
| 621 | Cosigner := 0;
|
---|
| 622 | CosignerName := '';
|
---|
| 623 | Subject := '';
|
---|
| 624 | Location := 0;
|
---|
| 625 | LocationName := '';
|
---|
| 626 | PkgIEN := 0;
|
---|
| 627 | PkgPtr := '';
|
---|
| 628 | PkgRef := '';
|
---|
| 629 | NeedCPT := False;
|
---|
| 630 | Addend := 0;
|
---|
| 631 | {LastCosigner & LastCosignerName aren't cleared because they're used as default for next note.}
|
---|
| 632 | Lines := nil;
|
---|
| 633 | end;
|
---|
| 634 | // clear the editing controls (also clear the new labels?)
|
---|
| 635 | txtSubject.Text := '';
|
---|
| 636 | memNewNote.Clear;
|
---|
| 637 | timAutoSave.Enabled := False;
|
---|
| 638 | // clear the PCE object for editing
|
---|
| 639 | uPCEEdit.Clear;
|
---|
| 640 | // set the tracking variables to initial state
|
---|
| 641 | EditingIndex := -1;
|
---|
| 642 | FChanged := False;
|
---|
| 643 | end;
|
---|
| 644 |
|
---|
| 645 | procedure TfrmNotes.ShowPCEControls(ShouldShow: Boolean);
|
---|
| 646 | begin
|
---|
| 647 | sptVert.Visible := ShouldShow;
|
---|
| 648 | memPCEShow.Visible := ShouldShow;
|
---|
| 649 | if(ShouldShow) then
|
---|
| 650 | sptVert.Top := memPCEShow.Top - sptVert.Height;
|
---|
| 651 | memNote.Invalidate;
|
---|
| 652 | end;
|
---|
| 653 |
|
---|
| 654 | procedure TfrmNotes.DisplayPCE;
|
---|
| 655 | { displays PCE information if appropriate & enables/disabled editing of PCE data }
|
---|
| 656 | var
|
---|
| 657 | EnableList, ShowList: TDrawers;
|
---|
| 658 | VitalStr: TStringlist;
|
---|
| 659 | NoPCE: boolean;
|
---|
| 660 | ActionSts: TActionRec;
|
---|
| 661 | AnIEN: integer;
|
---|
| 662 | begin
|
---|
| 663 | memPCEShow.Clear;
|
---|
| 664 | with lstNotes do if ItemIndex = EditingIndex then
|
---|
| 665 | begin
|
---|
| 666 | with uPCEEdit do
|
---|
| 667 | begin
|
---|
| 668 | AddStrData(memPCEShow.Lines);
|
---|
| 669 | NoPCE := (memPCEShow.Lines.Count = 0);
|
---|
| 670 | VitalStr := TStringList.create;
|
---|
| 671 | try
|
---|
| 672 | GetVitalsFromDate(VitalStr, uPCEEdit);
|
---|
| 673 | AddVitalData(VitalStr, memPCEShow.Lines);
|
---|
| 674 | finally
|
---|
| 675 | VitalStr.free;
|
---|
| 676 | end;
|
---|
| 677 | ShowPCEButtons(TRUE);
|
---|
| 678 | ShowPCEControls(cmdPCE.Enabled or (memPCEShow.Lines.Count > 0));
|
---|
| 679 | if(NoPCE and memPCEShow.Visible) then
|
---|
| 680 | memPCEShow.Lines.Insert(0, TX_NOPCE);
|
---|
| 681 | memPCEShow.SelStart := 0;
|
---|
| 682 |
|
---|
| 683 | if(InteractiveRemindersActive) then
|
---|
| 684 | begin
|
---|
| 685 | if(GetReminderStatus = rsNone) then
|
---|
| 686 | EnableList := [odTemplates]
|
---|
| 687 | else
|
---|
| 688 | EnableList := [odTemplates, odReminders];
|
---|
| 689 | ShowList := [odTemplates, odReminders];
|
---|
| 690 | end
|
---|
| 691 | else
|
---|
| 692 | begin
|
---|
| 693 | EnableList := [odTemplates];
|
---|
| 694 | ShowList := [odTemplates];
|
---|
| 695 | end;
|
---|
| 696 | frmDrawers.DisplayDrawers(TRUE, EnableList, ShowList);
|
---|
| 697 | end;
|
---|
| 698 | end else
|
---|
| 699 | begin
|
---|
| 700 | ShowPCEButtons(FALSE);
|
---|
| 701 | frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]);
|
---|
| 702 | AnIEN := lstNotes.ItemIEN;
|
---|
| 703 | ActOnDocument(ActionSts, AnIEN, 'VIEW');
|
---|
| 704 | if ActionSts.Success then
|
---|
| 705 | begin
|
---|
| 706 | StatusText('Retrieving encounter information...');
|
---|
| 707 | with uPCEShow do
|
---|
| 708 | begin
|
---|
| 709 | NoteDateTime := MakeFMDateTime(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
|
---|
| 710 | PCEForNote(AnIEN, uPCEEdit);
|
---|
| 711 | AddStrData(memPCEShow.Lines);
|
---|
| 712 | NoPCE := (memPCEShow.Lines.Count = 0);
|
---|
| 713 | VitalStr := TStringList.create;
|
---|
| 714 | try
|
---|
| 715 | GetVitalsFromNote(VitalStr, uPCEShow, AnIEN);
|
---|
| 716 | AddVitalData(VitalStr, memPCEShow.Lines);
|
---|
| 717 | finally
|
---|
| 718 | VitalStr.free;
|
---|
| 719 | end;
|
---|
| 720 | ShowPCEControls(memPCEShow.Lines.Count > 0);
|
---|
| 721 | if(NoPCE and memPCEShow.Visible) then
|
---|
| 722 | memPCEShow.Lines.Insert(0, TX_NOPCE);
|
---|
| 723 | memPCEShow.SelStart := 0;
|
---|
| 724 | end;
|
---|
| 725 | StatusText('');
|
---|
| 726 | end
|
---|
| 727 | else
|
---|
| 728 | ShowPCEControls(FALSE);
|
---|
| 729 | end; {if ItemIndex}
|
---|
| 730 | end;
|
---|
| 731 |
|
---|
| 732 | { supporting calls for writing notes }
|
---|
| 733 |
|
---|
| 734 | function TfrmNotes.GetTitleText(AnIndex: Integer): string;
|
---|
| 735 | { returns non-tabbed text for the title of a note given the ItemIndex in lstNotes }
|
---|
| 736 | begin
|
---|
| 737 | with lstNotes do
|
---|
| 738 | Result := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(Items[AnIndex], U, 3))) +
|
---|
| 739 | ' ' + Piece(Items[AnIndex], U, 2) + ', ' + Piece(Items[AnIndex], U, 6) + ', ' +
|
---|
| 740 | Piece(Piece(Items[AnIndex], U, 5), ';', 2)
|
---|
| 741 | end;
|
---|
| 742 |
|
---|
| 743 | function TfrmNotes.LacksRequiredForCreate: Boolean;
|
---|
| 744 | { determines if the fields required to create the note are present }
|
---|
| 745 | var
|
---|
| 746 | CurTitle: Integer;
|
---|
| 747 | begin
|
---|
| 748 | Result := False;
|
---|
| 749 | with FEditNote do
|
---|
| 750 | begin
|
---|
| 751 | if Title <= 0 then Result := True;
|
---|
| 752 | if Author <= 0 then Result := True;
|
---|
| 753 | if DateTime <= 0 then Result := True;
|
---|
| 754 | if IsConsultTitle(Title) and (PkgIEN = 0) then Result := True;
|
---|
| 755 | if IsSurgeryTitle(Title) and (PkgIEN = 0) then Result := True;
|
---|
| 756 | if (DocType = TYP_ADDENDUM) then
|
---|
| 757 | begin
|
---|
| 758 | if AskCosignerForDocument(Addend, Author) and (Cosigner <= 0) then Result := True;
|
---|
| 759 | end else
|
---|
| 760 | begin
|
---|
| 761 | if Title > 0 then CurTitle := Title else CurTitle := DocType;
|
---|
| 762 | if AskCosignerForTitle(CurTitle, Author) and (Cosigner <= 0) then Result := True;
|
---|
| 763 | end;
|
---|
| 764 | end;
|
---|
| 765 | end;
|
---|
| 766 |
|
---|
| 767 | function TfrmNotes.VerifyNoteTitle: Boolean;
|
---|
| 768 | const
|
---|
| 769 | VNT_UNKNOWN = 0;
|
---|
| 770 | VNT_NO = 1;
|
---|
| 771 | VNT_YES = 2;
|
---|
| 772 | var
|
---|
| 773 | AParam: string;
|
---|
| 774 | begin
|
---|
| 775 | if FVerifyNoteTitle = VNT_UNKNOWN then
|
---|
| 776 | begin
|
---|
| 777 | AParam := GetUserParam('ORWOR VERIFY NOTE TITLE');
|
---|
| 778 | if AParam = '1' then FVerifyNoteTitle := VNT_YES else FVerifyNoteTitle := VNT_NO;
|
---|
| 779 | end;
|
---|
| 780 | Result := FVerifyNoteTitle = VNT_YES;
|
---|
| 781 | end;
|
---|
| 782 |
|
---|
| 783 | procedure TfrmNotes.SetSubjectVisible(ShouldShow: Boolean);
|
---|
| 784 | { hide/show subject & resize panel accordingly - leave 6 pixel margin above memNewNote }
|
---|
| 785 | begin
|
---|
| 786 | if ShouldShow then
|
---|
| 787 | begin
|
---|
| 788 | lblSubject.Visible := True;
|
---|
| 789 | txtSubject.Visible := True;
|
---|
| 790 | pnlFields.Height := txtSubject.Top + txtSubject.Height + 6;
|
---|
| 791 | end else
|
---|
| 792 | begin
|
---|
| 793 | lblSubject.Visible := False;
|
---|
| 794 | txtSubject.Visible := False;
|
---|
| 795 | pnlFields.Height := lblVisit.Top + lblVisit.Height + 6;
|
---|
| 796 | end;
|
---|
| 797 | end;
|
---|
| 798 |
|
---|
| 799 | { consult request and note locking }
|
---|
| 800 |
|
---|
| 801 | function TfrmNotes.LockConsultRequest(AConsult: Integer): Boolean;
|
---|
| 802 | { returns true if consult successfully locked }
|
---|
| 803 | begin
|
---|
| 804 | // *** I'm not sure about the FOrderID field - if the user is editing one note and
|
---|
| 805 | // deletes another, FOrderID will be for editing note, then delete note, then null
|
---|
| 806 | Result := True;
|
---|
| 807 | FOrderID := GetConsultOrderIEN(AConsult);
|
---|
| 808 | if (FOrderID <> '') and (FOrderID = frmConsults.OrderID) then
|
---|
| 809 | begin
|
---|
| 810 | InfoBox(TX_ORDER_LOCKED, TC_ORDER_LOCKED, MB_OK);
|
---|
| 811 | Result := False;
|
---|
| 812 | Exit;
|
---|
| 813 | end;
|
---|
| 814 | if (FOrderId <> '') then
|
---|
| 815 | if not OrderCanBeLocked(FOrderID) then Result := False;
|
---|
| 816 | if not Result then FOrderID := '';
|
---|
| 817 | end;
|
---|
| 818 |
|
---|
| 819 | function TfrmNotes.LockConsultRequestAndNote(AnIEN: Int64): Boolean;
|
---|
| 820 | { returns true if note and associated request successfully locked }
|
---|
| 821 | var
|
---|
| 822 | AConsult: Integer;
|
---|
| 823 | LockMsg, x: string;
|
---|
| 824 | begin
|
---|
| 825 | Result := True;
|
---|
| 826 | AConsult := 0;
|
---|
| 827 | if frmConsults.ActiveEditOf(AnIEN) then
|
---|
| 828 | begin
|
---|
| 829 | InfoBox(TX_ORDER_LOCKED, TC_ORDER_LOCKED, MB_OK);
|
---|
| 830 | Result := False;
|
---|
| 831 | Exit;
|
---|
| 832 | end;
|
---|
| 833 | if Changes.Exist(CH_DOC, IntToStr(AnIEN)) then Exit; // already locked
|
---|
| 834 | // try to lock the consult request first, if there is one
|
---|
| 835 | if IsConsultTitle(TitleForNote(AnIEN)) then
|
---|
| 836 | begin
|
---|
| 837 | x := GetPackageRefForNote(lstNotes.ItemIEN);
|
---|
| 838 | AConsult := StrToIntDef(Piece(x, ';', 1), 0);
|
---|
| 839 | Result := LockConsultRequest(AConsult);
|
---|
| 840 | end;
|
---|
| 841 | // now try to lock the note
|
---|
| 842 | if Result then
|
---|
| 843 | begin
|
---|
| 844 | LockDocument(AnIEN, LockMsg);
|
---|
| 845 | if LockMsg <> '' then
|
---|
| 846 | begin
|
---|
| 847 | Result := False;
|
---|
| 848 | // if can't lock the note, unlock the consult request that was just locked
|
---|
| 849 | if AConsult > 0 then
|
---|
| 850 | begin
|
---|
| 851 | UnlockOrderIfAble(FOrderID);
|
---|
| 852 | FOrderID := '';
|
---|
| 853 | end;
|
---|
| 854 | InfoBox(LockMsg, TC_NO_LOCK, MB_OK);
|
---|
| 855 | end;
|
---|
| 856 | end;
|
---|
| 857 | end;
|
---|
| 858 |
|
---|
| 859 | procedure TfrmNotes.UnlockConsultRequest(ANote: Int64; AConsult: Integer = 0);
|
---|
| 860 | (*var
|
---|
| 861 | x: string;*)
|
---|
| 862 | begin
|
---|
| 863 | (* if (AConsult = 0) and IsConsultTitle(TitleForNote(ANote)) then
|
---|
| 864 | begin
|
---|
| 865 | x := GetPackageRefForNote(ANote);
|
---|
| 866 | AConsult := StrToIntDef(Piece(x, ';', 1), 0);
|
---|
| 867 | end;
|
---|
| 868 | if AConsult = 0 then Exit;*)
|
---|
| 869 | if AConsult = 0 then AConsult := GetConsultIENForNote(ANote);
|
---|
| 870 | if AConsult <= 0 then exit;
|
---|
| 871 | FOrderID := GetConsultOrderIEN(AConsult);
|
---|
| 872 | UnlockOrderIfAble(FOrderID);
|
---|
| 873 | FOrderID := '';
|
---|
| 874 | end;
|
---|
| 875 |
|
---|
| 876 | function TfrmNotes.ActiveEditOf(AnIEN: Int64; ARequest: integer): Boolean;
|
---|
| 877 | begin
|
---|
| 878 | Result := False;
|
---|
| 879 | if EditingIndex < 0 then Exit;
|
---|
| 880 | if lstNotes.GetIEN(EditingIndex) = AnIEN then
|
---|
| 881 | begin
|
---|
| 882 | Result := True;
|
---|
| 883 | Exit;
|
---|
| 884 | end;
|
---|
| 885 | with FEditNote do if (PkgIEN = ARequest) and (PkgPtr = PKG_CONSULTS) then Result := True;
|
---|
| 886 | end;
|
---|
| 887 |
|
---|
| 888 | { create, edit & save notes }
|
---|
| 889 |
|
---|
| 890 | procedure TfrmNotes.InsertNewNote(IsIDChild: boolean; AnIDParent: integer);
|
---|
| 891 | { creates the editing context for a new progress note & inserts stub into top of view list }
|
---|
| 892 | var
|
---|
| 893 | EnableAutosave, HaveRequired: Boolean;
|
---|
| 894 | CreatedNote: TCreatedDoc;
|
---|
| 895 | TmpBoilerPlate: TStringList;
|
---|
| 896 | tmpNode: TTreeNode;
|
---|
| 897 | x, WhyNot, DocInfo: string;
|
---|
| 898 | begin
|
---|
| 899 | FNewIDChild := IsIDChild;
|
---|
| 900 | EnableAutosave := FALSE;
|
---|
| 901 | TmpBoilerPlate := nil;
|
---|
| 902 | try
|
---|
| 903 | ClearEditControls;
|
---|
| 904 | FillChar(FEditNote, SizeOf(FEditNote), 0); //v15.7
|
---|
| 905 | with FEditNote do
|
---|
| 906 | begin
|
---|
| 907 | DocType := TYP_PROGRESS_NOTE;
|
---|
| 908 | IsNewNote := True;
|
---|
| 909 | Title := DfltNoteTitle;
|
---|
| 910 | TitleName := DfltNoteTitleName;
|
---|
| 911 | if IsIDChild and (not CanTitleBeIDChild(Title, WhyNot)) then
|
---|
| 912 | begin
|
---|
| 913 | Title := 0;
|
---|
| 914 | TitleName := '';
|
---|
| 915 | end;
|
---|
| 916 | if IsSurgeryTitle(Title) then // Don't want surgery title sneaking in unchallenged
|
---|
| 917 | begin
|
---|
| 918 | Title := 0;
|
---|
| 919 | TitleName := '';
|
---|
| 920 | end;
|
---|
| 921 | DateTime := FMNow;
|
---|
| 922 | Author := User.DUZ;
|
---|
| 923 | AuthorName := User.Name;
|
---|
| 924 | Location := Encounter.Location;
|
---|
| 925 | LocationName := Encounter.LocationName;
|
---|
| 926 | VisitDate := Encounter.DateTime;
|
---|
| 927 | if IsIDChild then
|
---|
| 928 | IDParent := AnIDParent
|
---|
| 929 | else
|
---|
| 930 | IDParent := 0;
|
---|
| 931 | // Cosigner & PkgRef, if needed, will be set by fNoteProps
|
---|
| 932 | end;
|
---|
| 933 | // check to see if interaction necessary to get required fields
|
---|
| 934 | if LacksRequiredForCreate or VerifyNoteTitle or UnresolvedConsultsExist
|
---|
| 935 | then HaveRequired := ExecuteNoteProperties(FEditNote, CT_NOTES, IsIDChild, FNewIDChild, '', 0)
|
---|
| 936 | else HaveRequired := True;
|
---|
| 937 | // lock the consult request if there is a consult
|
---|
| 938 | with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then HaveRequired := LockConsultRequest(PkgIEN);
|
---|
| 939 | if HaveRequired then
|
---|
| 940 | begin
|
---|
| 941 | // set up uPCEEdit for entry of new note
|
---|
| 942 | uPCEEdit.UseEncounter := True;
|
---|
| 943 | uPCEEdit.NoteDateTime := FEditNote.DateTime;
|
---|
| 944 | uPCEEdit.PCEForNote(USE_CURRENT_VISITSTR, uPCEShow);
|
---|
| 945 | FEditNote.NeedCPT := uPCEEdit.CPTRequired;
|
---|
| 946 | // create the note
|
---|
| 947 | PutNewNote(CreatedNote, FEditNote);
|
---|
| 948 | uPCEEdit.NoteIEN := CreatedNote.IEN;
|
---|
| 949 | if CreatedNote.IEN > 0 then LockDocument(CreatedNote.IEN, CreatedNote.ErrorText);
|
---|
| 950 | if CreatedNote.ErrorText = '' then
|
---|
| 951 | begin
|
---|
| 952 | //x := $$RESOLVE^TIUSRVLO formatted string
|
---|
| 953 | //7348^Note Title^3000913^NERD, YOURA (N0165)^1329;Rich Vertigan;VERTIGAN,RICH^8E REHAB MED^complete^Adm: 11/05/98;2981105.095547^ ;^^0^^^2
|
---|
| 954 | with FEditNote do
|
---|
| 955 | begin
|
---|
| 956 | x := IntToStr(CreatedNote.IEN) + U + TitleName + U + FloatToStr(FEditNote.DateTime) + U +
|
---|
| 957 | Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
|
---|
| 958 | U + U + U + U + U + U + U;
|
---|
| 959 | end;
|
---|
| 960 |
|
---|
| 961 | lstNotes.Items.Insert(0, x);
|
---|
| 962 | uChanging := True;
|
---|
| 963 | tvNotes.Items.BeginUpdate;
|
---|
| 964 | if IsIDChild then
|
---|
| 965 | begin
|
---|
| 966 | tmpNode := tvNotes.FindPieceNode(IntToStr(AnIDParent), 1, U, tvNotes.Items.GetFirstNode);
|
---|
| 967 | tmpNode.ImageIndex := IMG_IDNOTE_OPEN;
|
---|
| 968 | tmpNode.SelectedIndex := IMG_IDNOTE_OPEN;
|
---|
| 969 | tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
|
---|
| 970 | tmpNode.ImageIndex := IMG_ID_CHILD;
|
---|
| 971 | tmpNode.SelectedIndex := IMG_ID_CHILD;
|
---|
| 972 | end
|
---|
| 973 | else
|
---|
| 974 | begin
|
---|
| 975 | tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'New Note in Progress',
|
---|
| 976 | MakeNoteTreeObject('NEW^New Note in Progress^^^^^^^^^^^%^0'));
|
---|
| 977 | TORTreeNode(tmpNode).StringData := 'NEW^New Note in Progress^^^^^^^^^^^%^0';
|
---|
| 978 | tmpNode.ImageIndex := IMG_TOP_LEVEL;
|
---|
| 979 | tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
|
---|
| 980 | tmpNode.ImageIndex := IMG_SINGLE;
|
---|
| 981 | tmpNode.SelectedIndex := IMG_SINGLE;
|
---|
| 982 | end;
|
---|
| 983 | tmpNode.StateIndex := IMG_NO_IMAGES;
|
---|
| 984 | TORTreeNode(tmpNode).StringData := x;
|
---|
| 985 | tvNotes.Selected := tmpNode;
|
---|
| 986 | tvNotes.Items.EndUpdate;
|
---|
| 987 | uChanging := False;
|
---|
| 988 | Changes.Add(CH_DOC, IntToStr(CreatedNote.IEN), GetTitleText(0), '', CH_SIGN_YES);
|
---|
| 989 | lstNotes.ItemIndex := 0;
|
---|
| 990 | EditingIndex := 0;
|
---|
| 991 | SetSubjectVisible(AskSubjectForNotes);
|
---|
| 992 | if not assigned(TmpBoilerPlate) then
|
---|
| 993 | TmpBoilerPlate := TStringList.Create;
|
---|
| 994 | LoadBoilerPlate(TmpBoilerPlate, FEditNote.Title);
|
---|
| 995 | FChanged := False;
|
---|
| 996 | cmdChangeClick(Self); // will set captions, sign state for Changes
|
---|
| 997 | lstNotesClick(Self); // will makepnlWrite visible
|
---|
| 998 | if timAutoSave.Interval <> 0 then EnableAutosave := TRUE;
|
---|
| 999 | if txtSubject.Visible then txtSubject.SetFocus else memNewNote.SetFocus;
|
---|
| 1000 | end else
|
---|
| 1001 | begin
|
---|
| 1002 | // if note creation failed or failed to get note lock (both unlikely), unlock consult
|
---|
| 1003 | with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then UnlockConsultRequest(0, PkgIEN);
|
---|
| 1004 | InfoBox(CreatedNote.ErrorText, TX_CREATE_ERR, MB_OK);
|
---|
| 1005 | HaveRequired := False;
|
---|
| 1006 | end; {if CreatedNote.IEN}
|
---|
| 1007 | end; {if HaveRequired}
|
---|
| 1008 | if not HaveRequired then
|
---|
| 1009 | begin
|
---|
| 1010 | ClearEditControls;
|
---|
| 1011 | ShowPCEButtons(False);
|
---|
| 1012 | end;
|
---|
| 1013 | finally
|
---|
| 1014 | if assigned(TmpBoilerPlate) then
|
---|
| 1015 | begin
|
---|
| 1016 | DocInfo := MakeXMLParamTIU(IntToStr(CreatedNote.IEN), FEditNote);
|
---|
| 1017 | ExecuteTemplateOrBoilerPlate(TmpBoilerPlate, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
|
---|
| 1018 | memNewNote.Lines.Assign(TmpBoilerPlate);
|
---|
| 1019 | UpdateNoteAuthor(DocInfo);
|
---|
| 1020 | TmpBoilerPlate.Free;
|
---|
| 1021 | end;
|
---|
| 1022 | if EnableAutosave then // Don't enable autosave until after dialog fields have been resolved
|
---|
| 1023 | timAutoSave.Enabled := True;
|
---|
| 1024 | end;
|
---|
| 1025 | frmNotes.pnlWriteResize(Self);
|
---|
| 1026 | end;
|
---|
| 1027 |
|
---|
| 1028 | procedure TfrmNotes.InsertAddendum;
|
---|
| 1029 | { sets up fields of pnlWrite to write an addendum for the selected note }
|
---|
| 1030 | const
|
---|
| 1031 | AS_ADDENDUM = True;
|
---|
| 1032 | IS_ID_CHILD = False;
|
---|
| 1033 | var
|
---|
| 1034 | HaveRequired: Boolean;
|
---|
| 1035 | CreatedNote: TCreatedDoc;
|
---|
| 1036 | tmpNode: TTreeNode;
|
---|
| 1037 | x: string;
|
---|
| 1038 | begin
|
---|
| 1039 | ClearEditControls;
|
---|
| 1040 | with FEditNote do
|
---|
| 1041 | begin
|
---|
| 1042 | DocType := TYP_ADDENDUM;
|
---|
| 1043 | IsNewNote := False;
|
---|
| 1044 | Title := TitleForNote(lstNotes.ItemIEN);
|
---|
| 1045 | TitleName := Piece(lstNotes.Items[lstNotes.ItemIndex], U, 2);
|
---|
| 1046 | if Copy(TitleName,1,1) = '+' then TitleName := Copy(TitleName, 3, 199);
|
---|
| 1047 | DateTime := FMNow;
|
---|
| 1048 | Author := User.DUZ;
|
---|
| 1049 | AuthorName := User.Name;
|
---|
| 1050 | x := GetPackageRefForNote(lstNotes.ItemIEN);
|
---|
| 1051 | if Piece(x, U, 1) <> '-1' then
|
---|
| 1052 | begin
|
---|
| 1053 | PkgRef := GetPackageRefForNote(lstNotes.ItemIEN);
|
---|
| 1054 | PkgIEN := StrToIntDef(Piece(PkgRef, ';', 1), 0);
|
---|
| 1055 | PkgPtr := Piece(PkgRef, ';', 2);
|
---|
| 1056 | end;
|
---|
| 1057 | Addend := lstNotes.ItemIEN;
|
---|
| 1058 | //Lines := memNewNote.Lines;
|
---|
| 1059 | // Cosigner, if needed, will be set by fNoteProps
|
---|
| 1060 | // Location info will be set after the encounter is loaded
|
---|
| 1061 | end;
|
---|
| 1062 | // check to see if interaction necessary to get required fields
|
---|
| 1063 | if LacksRequiredForCreate
|
---|
| 1064 | then HaveRequired := ExecuteNoteProperties(FEditNote, CT_NOTES, IS_ID_CHILD, False, '', 0)
|
---|
| 1065 | else HaveRequired := True;
|
---|
| 1066 | // lock the consult request if there is a consult
|
---|
| 1067 | with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then HaveRequired := LockConsultRequest(PkgIEN);
|
---|
| 1068 | if HaveRequired then
|
---|
| 1069 | begin
|
---|
| 1070 | uPCEEdit.NoteDateTime := FEditNote.DateTime;
|
---|
| 1071 | uPCEEdit.PCEForNote(FEditNote.Addend, uPCEShow);
|
---|
| 1072 | FEditNote.Location := uPCEEdit.Location;
|
---|
| 1073 | FEditNote.LocationName := ExternalName(uPCEEdit.Location, 44);
|
---|
| 1074 | FEditNote.VisitDate := uPCEEdit.DateTime;
|
---|
| 1075 | PutAddendum(CreatedNote, FEditNote, FEditNote.Addend);
|
---|
| 1076 | uPCEEdit.NoteIEN := CreatedNote.IEN;
|
---|
| 1077 | if CreatedNote.IEN > 0 then LockDocument(CreatedNote.IEN, CreatedNote.ErrorText);
|
---|
| 1078 | if CreatedNote.ErrorText = '' then
|
---|
| 1079 | begin
|
---|
| 1080 | with FEditNote do
|
---|
| 1081 | begin
|
---|
| 1082 | x := IntToStr(CreatedNote.IEN) + U + 'Addendum to ' + TitleName + U + FloatToStr(DateTime) + U +
|
---|
| 1083 | Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
|
---|
| 1084 | U + U + U + U + U + U + U;
|
---|
| 1085 | end;
|
---|
| 1086 |
|
---|
| 1087 | lstNotes.Items.Insert(0, x);
|
---|
| 1088 | uChanging := True;
|
---|
| 1089 | tvNotes.Items.BeginUpdate;
|
---|
| 1090 | tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'New Addendum in Progress',
|
---|
| 1091 | MakeNoteTreeObject('ADDENDUM^New Addendum in Progress^^^^^^^^^^^%^0'));
|
---|
| 1092 | TORTreeNode(tmpNode).StringData := 'ADDENDUM^New Addendum in Progress^^^^^^^^^^^%^0';
|
---|
| 1093 | tmpNode.ImageIndex := IMG_TOP_LEVEL;
|
---|
| 1094 | tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
|
---|
| 1095 | TORTreeNode(tmpNode).StringData := x;
|
---|
| 1096 |
|
---|
| 1097 | tmpNode.ImageIndex := IMG_ADDENDUM;
|
---|
| 1098 | tmpNode.SelectedIndex := IMG_ADDENDUM;
|
---|
| 1099 | tvNotes.Selected := tmpNode;
|
---|
| 1100 | tvNotes.Items.EndUpdate;
|
---|
| 1101 | uChanging := False;
|
---|
| 1102 | Changes.Add(CH_DOC, IntToStr(CreatedNote.IEN), GetTitleText(0), '', CH_SIGN_YES);
|
---|
| 1103 | lstNotes.ItemIndex := 0;
|
---|
| 1104 | EditingIndex := 0;
|
---|
| 1105 | SetSubjectVisible(AskSubjectForNotes);
|
---|
| 1106 | cmdChangeClick(Self); // will set captions, sign state for Changes
|
---|
| 1107 | lstNotesClick(Self); // will make pnlWrite visible
|
---|
| 1108 | if timAutoSave.Interval <> 0 then timAutoSave.Enabled := True;
|
---|
| 1109 | memNewNote.SetFocus;
|
---|
| 1110 | end else
|
---|
| 1111 | begin
|
---|
| 1112 | // if note creation failed or failed to get note lock (both unlikely), unlock consult
|
---|
| 1113 | with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then UnlockConsultRequest(0, PkgIEN);
|
---|
| 1114 | InfoBox(CreatedNote.ErrorText, TX_CREATE_ERR, MB_OK);
|
---|
| 1115 | HaveRequired := False;
|
---|
| 1116 | end; {if CreatedNote.IEN}
|
---|
| 1117 | end; {if HaveRequired}
|
---|
| 1118 | if not HaveRequired then ClearEditControls;
|
---|
| 1119 | end;
|
---|
| 1120 |
|
---|
| 1121 | procedure TfrmNotes.LoadForEdit;
|
---|
| 1122 | { retrieves an existing note and places the data in the fields of pnlWrite }
|
---|
| 1123 | var
|
---|
| 1124 | tmpNode: TTreeNode;
|
---|
| 1125 | x: string;
|
---|
| 1126 | begin
|
---|
| 1127 | ClearEditControls;
|
---|
| 1128 | if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
|
---|
| 1129 | EditingIndex := lstNotes.ItemIndex;
|
---|
| 1130 | Changes.Add(CH_DOC, lstNotes.ItemID, GetTitleText(EditingIndex), '', CH_SIGN_YES);
|
---|
| 1131 | GetNoteForEdit(FEditNote, lstNotes.ItemIEN);
|
---|
| 1132 | memNewNote.Lines.Assign(FEditNote.Lines);
|
---|
| 1133 | FChanged := False;
|
---|
| 1134 | if FEditNote.Title = TYP_ADDENDUM then
|
---|
| 1135 | begin
|
---|
| 1136 | FEditNote.DocType := TYP_ADDENDUM;
|
---|
| 1137 | FEditNote.TitleName := Piece(lstNotes.Items[lstNotes.ItemIndex], U, 2);
|
---|
| 1138 | if Copy(FEditNote.TitleName,1,1) = '+' then FEditNote.TitleName := Copy(FEditNote.TitleName, 3, 199);
|
---|
| 1139 | if CompareText(Copy(FEditNote.TitleName, 1, 8), 'Addendum') <> 0
|
---|
| 1140 | then FEditNote.TitleName := FEditNote.TitleName + 'Addendum to ';
|
---|
| 1141 | end;
|
---|
| 1142 |
|
---|
| 1143 | uChanging := True;
|
---|
| 1144 | tvNotes.Items.BeginUpdate;
|
---|
| 1145 |
|
---|
| 1146 | tmpNode := tvNotes.FindPieceNode('EDIT', 1, U, nil);
|
---|
| 1147 | if tmpNode = nil then
|
---|
| 1148 | begin
|
---|
| 1149 | tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'Note being edited',
|
---|
| 1150 | MakeNoteTreeObject('EDIT^Note being edited^^^^^^^^^^^%^0'));
|
---|
| 1151 | TORTreeNode(tmpNode).StringData := 'EDIT^Note being edited^^^^^^^^^^^%^0';
|
---|
| 1152 | end
|
---|
| 1153 | else
|
---|
| 1154 | tmpNode.DeleteChildren;
|
---|
| 1155 | x := lstNotes.Items[lstNotes.ItemIndex];
|
---|
| 1156 | tmpNode.ImageIndex := IMG_TOP_LEVEL;
|
---|
| 1157 | tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
|
---|
| 1158 | TORTreeNode(tmpNode).StringData := x;
|
---|
| 1159 | if CompareText(Copy(FEditNote.TitleName, 1, 8), 'Addendum') <> 0 then
|
---|
| 1160 | tmpNode.ImageIndex := IMG_SINGLE
|
---|
| 1161 | else
|
---|
| 1162 | tmpNode.ImageIndex := IMG_ADDENDUM;
|
---|
| 1163 | tmpNode.SelectedIndex := tmpNode.ImageIndex;
|
---|
| 1164 | tvNotes.Selected := tmpNode;
|
---|
| 1165 | tvNotes.Items.EndUpdate;
|
---|
| 1166 | uChanging := False;
|
---|
| 1167 |
|
---|
| 1168 | uPCEEdit.NoteDateTime := MakeFMDateTime(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
|
---|
| 1169 | uPCEEdit.PCEForNote(lstNotes.ItemIEN, uPCEShow);
|
---|
| 1170 | FEditNote.NeedCPT := uPCEEdit.CPTRequired;
|
---|
| 1171 | txtSubject.Text := FEditNote.Subject;
|
---|
| 1172 | SetSubjectVisible(AskSubjectForNotes);
|
---|
| 1173 | cmdChangeClick(Self); // will set captions, sign state for Changes
|
---|
| 1174 | lstNotesClick(Self); // will make pnlWrite visible
|
---|
| 1175 | if timAutoSave.Interval <> 0 then timAutoSave.Enabled := True;
|
---|
| 1176 | memNewNote.SetFocus;
|
---|
| 1177 | end;
|
---|
| 1178 |
|
---|
| 1179 | procedure TfrmNotes.SaveEditedNote(var Saved: Boolean);
|
---|
| 1180 | { validates fields and sends the updated note to the server }
|
---|
| 1181 | var
|
---|
| 1182 | UpdatedNote: TCreatedDoc;
|
---|
| 1183 | x: string;
|
---|
| 1184 | begin
|
---|
| 1185 | Saved := False;
|
---|
| 1186 | if (memNewNote.GetTextLen = 0) or (not ContainsVisibleChar(memNewNote.Text)) then
|
---|
| 1187 | begin
|
---|
| 1188 | lstNotes.ItemIndex := EditingIndex;
|
---|
| 1189 | x := lstNotes.ItemID;
|
---|
| 1190 | uChanging := True;
|
---|
| 1191 | tvNotes.Selected := tvNotes.FindPieceNode(x, 1, U, tvNotes.Items.GetFirstNode);
|
---|
| 1192 | uChanging := False;
|
---|
| 1193 | tvNotesChange(Self, tvNotes.Selected);
|
---|
| 1194 | if FSilent or
|
---|
| 1195 | ((not FSilent) and
|
---|
| 1196 | (InfoBox(GetTitleText(EditingIndex) + TX_EMPTY_NOTE, TC_EMPTY_NOTE, MB_YESNO) = IDYES))
|
---|
| 1197 | then
|
---|
| 1198 | begin
|
---|
| 1199 | FConfirmed := True;
|
---|
| 1200 | mnuActDeleteClick(Self);
|
---|
| 1201 | Saved := True;
|
---|
| 1202 | FDeleted := True;
|
---|
| 1203 | end
|
---|
| 1204 | else
|
---|
| 1205 | FConfirmed := False;
|
---|
| 1206 | Exit;
|
---|
| 1207 | end;
|
---|
| 1208 | //ExpandTabsFilter(memNewNote.Lines, TAB_STOP_CHARS);
|
---|
| 1209 | FEditNote.Lines := memNewNote.Lines;
|
---|
| 1210 | //FEditNote.Lines:= SetLinesTo74ForSave(memNewNote.Lines, Self);
|
---|
| 1211 | FEditNote.Subject := txtSubject.Text;
|
---|
| 1212 | FEditNote.NeedCPT := uPCEEdit.CPTRequired;
|
---|
| 1213 | timAutoSave.Enabled := False;
|
---|
| 1214 | try
|
---|
| 1215 | PutEditedNote(UpdatedNote, FEditNote, lstNotes.GetIEN(EditingIndex));
|
---|
| 1216 | finally
|
---|
| 1217 | timAutoSave.Enabled := True;
|
---|
| 1218 | end;
|
---|
| 1219 | // there's no unlocking here since the note is still in Changes after a save
|
---|
| 1220 | if UpdatedNote.IEN > 0 then
|
---|
| 1221 | begin
|
---|
| 1222 | if lstNotes.ItemIndex = EditingIndex then
|
---|
| 1223 | begin
|
---|
| 1224 | EditingIndex := -1;
|
---|
| 1225 | lstNotesClick(Self);
|
---|
| 1226 | end;
|
---|
| 1227 | EditingIndex := -1; // make sure EditingIndex reset even if not viewing edited note
|
---|
| 1228 | Saved := True;
|
---|
| 1229 | FNewIDChild := False;
|
---|
| 1230 | FChanged := False;
|
---|
| 1231 | end else
|
---|
| 1232 | begin
|
---|
| 1233 | if not FSilent then
|
---|
| 1234 | InfoBox(TX_SAVE_ERROR1 + UpdatedNote.ErrorText + TX_SAVE_ERROR2, TC_SAVE_ERROR, MB_OK or MB_ICONWARNING);
|
---|
| 1235 | end;
|
---|
| 1236 | end;
|
---|
| 1237 |
|
---|
| 1238 | procedure TfrmNotes.SaveCurrentNote(var Saved: Boolean);
|
---|
| 1239 | { called whenever a note should be saved - uses IEN to call appropriate save logic }
|
---|
| 1240 | begin
|
---|
| 1241 | if EditingIndex < 0 then Exit;
|
---|
| 1242 | SaveEditedNote(Saved);
|
---|
| 1243 | end;
|
---|
| 1244 |
|
---|
| 1245 | { Form events ------------------------------------------------------------------------------ }
|
---|
| 1246 |
|
---|
| 1247 | procedure TfrmNotes.FormCreate(Sender: TObject);
|
---|
| 1248 | begin
|
---|
| 1249 | inherited;
|
---|
| 1250 | PageID := CT_NOTES;
|
---|
| 1251 | memNote.Color := ReadOnlyColor;
|
---|
| 1252 | memPCEShow.Color := ReadOnlyColor;
|
---|
| 1253 | lblNewTitle.Color := ReadOnlyColor;
|
---|
| 1254 | EditingIndex := -1;
|
---|
| 1255 | FEditNote.LastCosigner := 0;
|
---|
| 1256 | FEditNote.LastCosignerName := '';
|
---|
| 1257 | FLastNoteID := '';
|
---|
| 1258 | frmDrawers := TfrmDrawers.CreateDrawers(Self, pnlDrawers, [],[]);
|
---|
| 1259 | frmDrawers.Align := alBottom;
|
---|
| 1260 | frmDrawers.RichEditControl := memNewNote;
|
---|
| 1261 | frmDrawers.NewNoteButton := cmdNewNote;
|
---|
| 1262 | frmDrawers.Splitter := splDrawers;
|
---|
| 1263 | frmDrawers.DefTempPiece := 1;
|
---|
| 1264 | tvNotes.Images := dmodShared.imgNotes;
|
---|
| 1265 | tvNotes.StateImages := dmodShared.imgImages;
|
---|
| 1266 | lvNotes.StateImages := dmodShared.imgImages;
|
---|
| 1267 | lvNotes.SmallImages := dmodShared.imgNotes;
|
---|
| 1268 | FImageFlag := TBitmap.Create;
|
---|
| 1269 | FDocList := TStringList.Create;
|
---|
| 1270 | TAccessibleTreeView.WrapControl(tvNotes);
|
---|
| 1271 | end;
|
---|
| 1272 |
|
---|
| 1273 | procedure TfrmNotes.pnlRightResize(Sender: TObject);
|
---|
| 1274 | { memNote (TRichEdit) doesn't repaint appropriately unless it's parent panel is refreshed }
|
---|
| 1275 | begin
|
---|
| 1276 | inherited;
|
---|
| 1277 | pnlRight.Refresh;
|
---|
| 1278 | memNote.Repaint;
|
---|
| 1279 | end;
|
---|
| 1280 |
|
---|
| 1281 | procedure TfrmNotes.pnlWriteResize(Sender: TObject);
|
---|
| 1282 | const
|
---|
| 1283 | LEFT_MARGIN = 4;
|
---|
| 1284 | begin
|
---|
| 1285 | inherited;
|
---|
| 1286 | LimitEditWidth(memNewNote, MAX_PROGRESSNOTE_WIDTH - 1);
|
---|
| 1287 | memNewNote.Constraints.MinWidth := TextWidthByFont(memNewNote.Font.Handle, StringOfChar('X', MAX_PROGRESSNOTE_WIDTH)) + (LEFT_MARGIN * 2) + ScrollBarWidth;
|
---|
| 1288 | pnlLeft.Width := self.ClientWidth - pnlWrite.Width - sptHorz.Width;
|
---|
| 1289 | end;
|
---|
| 1290 |
|
---|
| 1291 | { Left panel (selector) events ------------------------------------------------------------- }
|
---|
| 1292 |
|
---|
| 1293 | procedure TfrmNotes.lstNotesClick(Sender: TObject);
|
---|
| 1294 | { loads the text for the selected note or displays the editing panel for the selected note }
|
---|
| 1295 | begin
|
---|
| 1296 | inherited;
|
---|
| 1297 | with lstNotes do if ItemIndex = -1 then Exit
|
---|
| 1298 | else if ItemIndex = EditingIndex then
|
---|
| 1299 | begin
|
---|
| 1300 | pnlWrite.Visible := True;
|
---|
| 1301 | pnlRead.Visible := False;
|
---|
| 1302 | mnuViewDetail.Enabled := False;
|
---|
| 1303 | if (FEditNote.IDParent <> 0) and (not FNewIDChild) then
|
---|
| 1304 | mnuActChange.Enabled := False
|
---|
| 1305 | else
|
---|
| 1306 | mnuActChange.Enabled := True;
|
---|
| 1307 | mnuActLoadBoiler.Enabled := True;
|
---|
| 1308 | UpdateReminderFinish;
|
---|
| 1309 | end else
|
---|
| 1310 | begin
|
---|
| 1311 | StatusText('Retrieving selected progress note...');
|
---|
| 1312 | Screen.Cursor := crHourGlass;
|
---|
| 1313 | pnlRead.Visible := True;
|
---|
| 1314 | pnlWrite.Visible := False;
|
---|
| 1315 | UpdateReminderFinish;
|
---|
| 1316 | lblTitle.Caption := Piece(Piece(Items[ItemIndex], U, 8), ';', 1) + #9 + Piece(Items[ItemIndex], U, 2) + ', ' +
|
---|
| 1317 | Piece(Items[ItemIndex], U, 6) + ', ' + Piece(Piece(Items[ItemIndex], U, 5), ';', 2) +
|
---|
| 1318 | ' (' + FormatFMDateTime('mmm dd,yy@hh:nn', MakeFMDateTime(Piece(Items[ItemIndex], U, 3)))
|
---|
| 1319 | + ')';
|
---|
| 1320 | lvNotes.Caption := lblTitle.Caption;
|
---|
| 1321 | LoadDocumentText(memNote.Lines, ItemIEN);
|
---|
| 1322 | memNote.SelStart := 0;
|
---|
| 1323 | mnuViewDetail.Enabled := True;
|
---|
| 1324 | mnuViewDetail.Checked := False;
|
---|
| 1325 | mnuActChange.Enabled := False;
|
---|
| 1326 | mnuActLoadBoiler.Enabled := False;
|
---|
| 1327 | Screen.Cursor := crDefault;
|
---|
| 1328 | StatusText('');
|
---|
| 1329 | end;
|
---|
| 1330 | if(assigned(frmReminderTree)) then
|
---|
| 1331 | frmReminderTree.EnableActions;
|
---|
| 1332 | DisplayPCE;
|
---|
| 1333 | pnlRight.Refresh;
|
---|
| 1334 | memNewNote.Repaint;
|
---|
| 1335 | memNote.Repaint;
|
---|
| 1336 | NotifyOtherApps(NAE_REPORT, 'TIU^' + lstNotes.ItemID);
|
---|
| 1337 | end;
|
---|
| 1338 |
|
---|
| 1339 | procedure TfrmNotes.cmdNewNoteClick(Sender: TObject);
|
---|
| 1340 | { maps 'New Note' button to the New Progress Note menu item }
|
---|
| 1341 | begin
|
---|
| 1342 | inherited;
|
---|
| 1343 | mnuActNewClick(Self);
|
---|
| 1344 | end;
|
---|
| 1345 |
|
---|
| 1346 | procedure TfrmNotes.cmdPCEClick(Sender: TObject);
|
---|
| 1347 | var
|
---|
| 1348 | Refresh: boolean;
|
---|
| 1349 | ActionSts: TActionRec;
|
---|
| 1350 | AnIEN: integer;
|
---|
| 1351 | PCEObj, tmpPCEEdit: TPCEData;
|
---|
| 1352 |
|
---|
| 1353 | procedure UpdateEncounterInfo;
|
---|
| 1354 | begin
|
---|
| 1355 | if not FEditingNotePCEObj then
|
---|
| 1356 | begin
|
---|
| 1357 | PCEObj := nil;
|
---|
| 1358 | AnIEN := lstNotes.ItemIEN;
|
---|
| 1359 | if (AnIEN <> 0) and (memNote.Lines.Count > 0) then
|
---|
| 1360 | begin
|
---|
| 1361 | ActOnDocument(ActionSts, AnIEN, 'VIEW');
|
---|
| 1362 | if ActionSts.Success then
|
---|
| 1363 | begin
|
---|
| 1364 | uPCEShow.CopyPCEData(uPCEEdit);
|
---|
| 1365 | PCEObj := uPCEEdit;
|
---|
| 1366 | end;
|
---|
| 1367 | end;
|
---|
| 1368 | Refresh := EditPCEData(PCEObj);
|
---|
| 1369 | end
|
---|
| 1370 | else
|
---|
| 1371 | begin
|
---|
| 1372 | UpdatePCE(uPCEEdit);
|
---|
| 1373 | Refresh := TRUE;
|
---|
| 1374 | end;
|
---|
| 1375 | if Refresh and (not frmFrame.Closing) then
|
---|
| 1376 | DisplayPCE;
|
---|
| 1377 | end;
|
---|
| 1378 |
|
---|
| 1379 | begin
|
---|
| 1380 | inherited;
|
---|
| 1381 | cmdPCE.Enabled := FALSE;
|
---|
| 1382 | if lstNotes.ItemIndex <> EditingIndex then
|
---|
| 1383 | // save uPCEEdit for note being edited, before updating current note's encounter, then restore (RV - TAM-0801-31056)
|
---|
| 1384 | begin
|
---|
| 1385 | tmpPCEEdit := TPCEData.Create;
|
---|
| 1386 | try
|
---|
| 1387 | uPCEEdit.CopyPCEData(tmpPCEEdit);
|
---|
| 1388 | UpdateEncounterInfo;
|
---|
| 1389 | tmpPCEEdit.CopyPCEData(uPCEEdit);
|
---|
| 1390 | finally
|
---|
| 1391 | tmpPCEEdit.Free;
|
---|
| 1392 | end;
|
---|
| 1393 | end
|
---|
| 1394 | else
|
---|
| 1395 | // no other note being edited, so just proceed as before.
|
---|
| 1396 | UpdateEncounterInfo;
|
---|
| 1397 | cmdPCE.Enabled := TRUE;
|
---|
| 1398 | end;
|
---|
| 1399 |
|
---|
| 1400 | { Right panel (editor) events -------------------------------------------------------------- }
|
---|
| 1401 |
|
---|
| 1402 | procedure TfrmNotes.mnuActChangeClick(Sender: TObject);
|
---|
| 1403 | begin
|
---|
| 1404 | inherited;
|
---|
| 1405 | if (FEditingIndex < 0) or (lstNotes.ItemIndex <> FEditingIndex) then Exit;
|
---|
| 1406 | cmdChangeClick(Sender);
|
---|
| 1407 | end;
|
---|
| 1408 |
|
---|
| 1409 | procedure TfrmNotes.mnuActLoadBoilerClick(Sender: TObject);
|
---|
| 1410 | var
|
---|
| 1411 | NoteEmpty: Boolean;
|
---|
| 1412 | BoilerText: TStringList;
|
---|
| 1413 | DocInfo: string;
|
---|
| 1414 |
|
---|
| 1415 | procedure AssignBoilerText;
|
---|
| 1416 | begin
|
---|
| 1417 | ExecuteTemplateOrBoilerPlate(BoilerText, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
|
---|
| 1418 | memNewNote.Lines.Assign(BoilerText);
|
---|
| 1419 | UpdateNoteAuthor(DocInfo);
|
---|
| 1420 | FChanged := False;
|
---|
| 1421 | end;
|
---|
| 1422 |
|
---|
| 1423 | begin
|
---|
| 1424 | inherited;
|
---|
| 1425 | if (FEditingIndex < 0) or (lstNotes.ItemIndex <> FEditingIndex) then Exit;
|
---|
| 1426 | BoilerText := TStringList.Create;
|
---|
| 1427 | try
|
---|
| 1428 | NoteEmpty := memNewNote.Text = '';
|
---|
| 1429 | LoadBoilerPlate(BoilerText, FEditNote.Title);
|
---|
| 1430 | if (BoilerText.Text <> '') or
|
---|
| 1431 | assigned(GetLinkedTemplate(IntToStr(FEditNote.Title), ltTitle)) then
|
---|
| 1432 | begin
|
---|
| 1433 | DocInfo := MakeXMLParamTIU(IntToStr(lstNotes.ItemIEN), FEditNote);
|
---|
| 1434 | if NoteEmpty then AssignBoilerText else
|
---|
| 1435 | begin
|
---|
| 1436 | case QueryBoilerPlate(BoilerText) of
|
---|
| 1437 | 0: { do nothing } ; // ignore
|
---|
| 1438 | 1: begin
|
---|
| 1439 | ExecuteTemplateOrBoilerPlate(BoilerText, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
|
---|
| 1440 | memNewNote.Lines.AddStrings(BoilerText); // append
|
---|
| 1441 | UpdateNoteAuthor(DocInfo);
|
---|
| 1442 | end;
|
---|
| 1443 | 2: AssignBoilerText; // replace
|
---|
| 1444 | end;
|
---|
| 1445 | end;
|
---|
| 1446 | end else
|
---|
| 1447 | begin
|
---|
| 1448 | if Sender = mnuActLoadBoiler
|
---|
| 1449 | then InfoBox(TX_NO_BOIL, TC_NO_BOIL, MB_OK)
|
---|
| 1450 | else
|
---|
| 1451 | begin
|
---|
| 1452 | if not NoteEmpty then
|
---|
| 1453 | // if not FChanged and (InfoBox(TX_BLR_CLEAR, TC_BLR_CLEAR, MB_YESNO) = ID_YES)
|
---|
| 1454 | if (InfoBox(TX_BLR_CLEAR, TC_BLR_CLEAR, MB_YESNO) = ID_YES)
|
---|
| 1455 | then memNewNote.Lines.Clear;
|
---|
| 1456 | end;
|
---|
| 1457 | end; {if BoilerText.Text <> ''}
|
---|
| 1458 | finally
|
---|
| 1459 | BoilerText.Free;
|
---|
| 1460 | end;
|
---|
| 1461 | end;
|
---|
| 1462 |
|
---|
| 1463 | procedure TfrmNotes.cmdChangeClick(Sender: TObject);
|
---|
| 1464 | var
|
---|
| 1465 | LastTitle, LastConsult: Integer;
|
---|
| 1466 | OKPressed, IsIDChild: Boolean;
|
---|
| 1467 | x: string;
|
---|
| 1468 | begin
|
---|
| 1469 | inherited;
|
---|
| 1470 | IsIDChild := uIDNotesActive and (FEditNote.IDParent > 0);
|
---|
| 1471 | LastTitle := FEditNote.Title;
|
---|
| 1472 | FEditNote.IsNewNote := False;
|
---|
| 1473 | if FEditNote.PkgPtr = PKG_CONSULTS then LastConsult := FEditNote.PkgIEN else LastConsult := 0;;
|
---|
| 1474 | if Sender <> Self then OKPressed := ExecuteNoteProperties(FEditNote, CT_NOTES, IsIDChild, FNewIDChild, '', 0)
|
---|
| 1475 | else OKPressed := True;
|
---|
| 1476 | if not OKPressed then Exit;
|
---|
| 1477 | // update display fields & uPCEEdit
|
---|
| 1478 | lblNewTitle.Caption := ' ' + FEditNote.TitleName + ' ';
|
---|
| 1479 | if (FEditNote.Addend > 0) and (CompareText(Copy(lblNewTitle.Caption, 2, 8), 'Addendum') <> 0)
|
---|
| 1480 | then lblNewTitle.Caption := ' Addendum to:' + lblNewTitle.Caption;
|
---|
| 1481 | with lblNewTitle do bvlNewTitle.SetBounds(Left - 1, Top - 1, Width + 2, Height + 2);
|
---|
| 1482 | lblRefDate.Caption := FormatFMDateTime('mmm dd,yyyy@hh:nn', FEditNote.DateTime);
|
---|
| 1483 | lblAuthor.Caption := FEditNote.AuthorName;
|
---|
| 1484 | if uPCEEdit.Inpatient then x := 'Adm: ' else x := 'Vst: ';
|
---|
| 1485 | x := x + FormatFMDateTime('mm/dd/yy', FEditNote.VisitDate) + ' ' + FEditNote.LocationName;
|
---|
| 1486 | lblVisit.Caption := x;
|
---|
| 1487 | if Length(FEditNote.CosignerName) > 0
|
---|
| 1488 | then lblCosigner.Caption := 'Expected Cosigner: ' + FEditNote.CosignerName
|
---|
| 1489 | else lblCosigner.Caption := '';
|
---|
| 1490 | uPCEEdit.NoteTitle := FEditNote.Title;
|
---|
| 1491 | // modify signature requirements if author or cosigner changed
|
---|
| 1492 | if (User.DUZ <> FEditNote.Author) and (User.DUZ <> FEditNote.Cosigner)
|
---|
| 1493 | then Changes.ReplaceSignState(CH_DOC, lstNotes.ItemID, CH_SIGN_NA)
|
---|
| 1494 | else Changes.ReplaceSignState(CH_DOC, lstNotes.ItemID, CH_SIGN_YES);
|
---|
| 1495 | x := lstNotes.Items[EditingIndex];
|
---|
| 1496 | SetPiece(x, U, 2, lblNewTitle.Caption);
|
---|
| 1497 | SetPiece(x, U, 3, FloatToStr(FEditNote.DateTime));
|
---|
| 1498 | tvNotes.Selected.Text := MakeNoteDisplayText(x);
|
---|
| 1499 | TORTreeNode(tvNotes.Selected).StringData := x;
|
---|
| 1500 | lstNotes.Items[EditingIndex] := x;
|
---|
| 1501 | Changes.ReplaceText(CH_DOC, lstNotes.ItemID, GetTitleText(EditingIndex));
|
---|
| 1502 | with FEditNote do if (PkgPtr = PKG_CONSULTS) and (LastConsult <> PkgIEN) then
|
---|
| 1503 | begin
|
---|
| 1504 | // try to lock the new consult, reset to previous if unable
|
---|
| 1505 | if (PkgIEN > 0) and not LockConsultRequest(PkgIEN) then
|
---|
| 1506 | begin
|
---|
| 1507 | Infobox(TX_NO_ORD_CHG, TC_NO_ORD_CHG, MB_OK);
|
---|
| 1508 | PkgIEN := LastConsult;
|
---|
| 1509 | end else
|
---|
| 1510 | begin
|
---|
| 1511 | // unlock the previous consult
|
---|
| 1512 | if LastConsult > 0 then UnlockOrderIfAble(GetConsultOrderIEN(LastConsult));
|
---|
| 1513 | if PkgIEN = 0 then FOrderID := '';
|
---|
| 1514 | end;
|
---|
| 1515 | end;
|
---|
| 1516 | if LastTitle <> FEditNote.Title then mnuActLoadBoilerClick(Self);
|
---|
| 1517 | end;
|
---|
| 1518 |
|
---|
| 1519 | procedure TfrmNotes.memNewNoteChange(Sender: TObject);
|
---|
| 1520 | begin
|
---|
| 1521 | inherited;
|
---|
| 1522 | FChanged := True;
|
---|
| 1523 | end;
|
---|
| 1524 |
|
---|
| 1525 | procedure TfrmNotes.pnlFieldsResize(Sender: TObject);
|
---|
| 1526 | { center the reference date on the panel }
|
---|
| 1527 | begin
|
---|
| 1528 | inherited;
|
---|
| 1529 | lblRefDate.Left := (pnlFields.Width - lblRefDate.Width) div 2;
|
---|
| 1530 | if lblRefDate.Left < (lblNewTitle.Left + lblNewTitle.Width + 6)
|
---|
| 1531 | then lblRefDate.Left := (lblNewTitle.Left + lblNewTitle.Width);
|
---|
| 1532 | end;
|
---|
| 1533 |
|
---|
| 1534 | procedure TfrmNotes.DoAutoSave;
|
---|
| 1535 | var
|
---|
| 1536 | ErrMsg: string;
|
---|
| 1537 | begin
|
---|
| 1538 | if (EditingIndex > -1) and FChanged then
|
---|
| 1539 | begin
|
---|
| 1540 | StatusText('Autosaving note...');
|
---|
| 1541 | //PutTextOnly(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex));
|
---|
| 1542 | timAutoSave.Enabled := False;
|
---|
| 1543 | try
|
---|
| 1544 | SetText(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex),1);
|
---|
| 1545 | finally
|
---|
| 1546 | timAutoSave.Enabled := True;
|
---|
| 1547 | end;
|
---|
| 1548 | FChanged := False;
|
---|
| 1549 | StatusText('');
|
---|
| 1550 | end;
|
---|
| 1551 | if ErrMsg <> '' then
|
---|
| 1552 | InfoBox(TX_SAVE_ERROR1 + ErrMsg + TX_SAVE_ERROR2, TC_SAVE_ERROR, MB_OK or MB_ICONWARNING);
|
---|
| 1553 | //Assert(ErrMsg = '', 'AutoSave: ' + ErrMsg);
|
---|
| 1554 | end;
|
---|
| 1555 |
|
---|
| 1556 | procedure TfrmNotes.timAutoSaveTimer(Sender: TObject);
|
---|
| 1557 | begin
|
---|
| 1558 | inherited;
|
---|
| 1559 | DoAutoSave;
|
---|
| 1560 | end;
|
---|
| 1561 |
|
---|
| 1562 | { View menu events ------------------------------------------------------------------------- }
|
---|
| 1563 |
|
---|
| 1564 | procedure TfrmNotes.mnuViewClick(Sender: TObject);
|
---|
| 1565 | { changes the list of notes available for viewing }
|
---|
| 1566 | var
|
---|
| 1567 | AuthCtxt: TAuthorContext;
|
---|
| 1568 | DateRange: TNoteDateRange;
|
---|
| 1569 | Saved: Boolean;
|
---|
| 1570 | begin
|
---|
| 1571 | inherited;
|
---|
| 1572 | // save note at EditingIndex?
|
---|
| 1573 | if EditingIndex <> -1 then
|
---|
| 1574 | begin
|
---|
| 1575 | SaveCurrentNote(Saved);
|
---|
| 1576 | if not Saved then Exit;
|
---|
| 1577 | end;
|
---|
| 1578 | FLastNoteID := lstNotes.ItemID;
|
---|
| 1579 | mnuViewDetail.Checked := False;
|
---|
| 1580 | StatusText('Retrieving progress note list...');
|
---|
| 1581 | if Sender is TMenuItem then ViewContext := TMenuItem(Sender).Tag
|
---|
| 1582 | else if FCurrentContext.Status <> '' then ViewContext := NC_CUSTOM
|
---|
| 1583 | else ViewContext := NC_RECENT;
|
---|
| 1584 | case ViewContext of
|
---|
| 1585 | NC_RECENT: begin
|
---|
| 1586 | FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
|
---|
| 1587 | lblNotes.Caption := 'Last ' + IntToStr(ReturnMaxNotes) + ' Notes';
|
---|
| 1588 | FCurrentContext.Status := IntToStr(ViewContext);
|
---|
| 1589 | FCurrentContext.MaxDocs := ReturnMaxNotes;
|
---|
| 1590 | LoadNotes;
|
---|
| 1591 | end;
|
---|
| 1592 | NC_ALL: begin
|
---|
| 1593 | FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
|
---|
| 1594 | lblNotes.Caption := 'All Signed Notes';
|
---|
| 1595 | FCurrentContext.Status := IntToStr(ViewContext);
|
---|
| 1596 | LoadNotes;
|
---|
| 1597 | end;
|
---|
| 1598 | NC_UNSIGNED: begin
|
---|
| 1599 | FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
|
---|
| 1600 | lblNotes.Caption := 'Unsigned Notes';
|
---|
| 1601 | FCurrentContext.Status := IntToStr(ViewContext);
|
---|
| 1602 | LoadNotes;
|
---|
| 1603 | end;
|
---|
| 1604 | NC_UNCOSIGNED: begin
|
---|
| 1605 | FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
|
---|
| 1606 | lblNotes.Caption := 'Uncosigned Notes';
|
---|
| 1607 | FCurrentContext.Status := IntToStr(ViewContext);
|
---|
| 1608 | LoadNotes;
|
---|
| 1609 | end;
|
---|
| 1610 | NC_BY_AUTHOR: begin
|
---|
| 1611 | SelectAuthor(Font.Size, FCurrentContext, AuthCtxt);
|
---|
| 1612 | with AuthCtxt do if Changed then
|
---|
| 1613 | begin
|
---|
| 1614 | FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
|
---|
| 1615 | lblNotes.Caption := AuthorName + ': Signed Notes';
|
---|
| 1616 | FCurrentContext.Status := IntToStr(NC_BY_AUTHOR);
|
---|
| 1617 | FCurrentContext.Author := Author;
|
---|
| 1618 | FCurrentContext.TreeAscending := Ascending;
|
---|
| 1619 | LoadNotes;
|
---|
| 1620 | end;
|
---|
| 1621 | end;
|
---|
| 1622 | NC_BY_DATE: begin
|
---|
| 1623 | SelectNoteDateRange(Font.Size, FCurrentContext, DateRange);
|
---|
| 1624 | with DateRange do if Changed then
|
---|
| 1625 | begin
|
---|
| 1626 | FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
|
---|
| 1627 | lblNotes.Caption := FormatFMDateTime('mmm dd,yy', FMBeginDate) + ' to ' +
|
---|
| 1628 | FormatFMDateTime('mmm dd,yy', FMEndDate) + ': Signed Notes';
|
---|
| 1629 | FCurrentContext.BeginDate := BeginDate;
|
---|
| 1630 | FCurrentContext.EndDate := EndDate;
|
---|
| 1631 | FCurrentContext.FMBeginDate := FMBeginDate;
|
---|
| 1632 | FCurrentContext.FMEndDate := FMEndDate;
|
---|
| 1633 | FCurrentContext.TreeAscending := Ascending;
|
---|
| 1634 | FCurrentContext.Status := IntToStr(NC_BY_DATE);
|
---|
| 1635 | LoadNotes;
|
---|
| 1636 | end;
|
---|
| 1637 | end;
|
---|
| 1638 | NC_CUSTOM: begin
|
---|
| 1639 | if Sender is TMenuItem then
|
---|
| 1640 | begin
|
---|
| 1641 | SelectTIUView(Font.Size, True, FCurrentContext, uTIUContext);
|
---|
| 1642 | //lblNotes.Caption := 'Custom List';
|
---|
| 1643 | end;
|
---|
| 1644 | with uTIUContext do if Changed then
|
---|
| 1645 | begin
|
---|
| 1646 | //if not (Sender is TMenuItem) then lblNotes.Caption := 'Default List';
|
---|
| 1647 | //if MaxDocs = 0 then MaxDocs := ReturnMaxNotes;
|
---|
| 1648 | FCurrentContext.BeginDate := BeginDate;
|
---|
| 1649 | FCurrentContext.EndDate := EndDate;
|
---|
| 1650 | FCurrentContext.FMBeginDate := FMBeginDate;
|
---|
| 1651 | FCurrentContext.FMEndDate := FMEndDate;
|
---|
| 1652 | FCurrentContext.Status := Status;
|
---|
| 1653 | FCurrentContext.Author := Author;
|
---|
| 1654 | FCurrentContext.MaxDocs := MaxDocs;
|
---|
| 1655 | FCurrentContext.ShowSubject := ShowSubject;
|
---|
| 1656 | // NEW PREFERENCES:
|
---|
| 1657 | FCurrentContext.SortBy := SortBy;
|
---|
| 1658 | FCurrentContext.ListAscending := ListAscending;
|
---|
| 1659 | FCurrentContext.GroupBy := GroupBy;
|
---|
| 1660 | FCurrentContext.TreeAscending := TreeAscending;
|
---|
| 1661 | FCurrentContext.SearchField := SearchField;
|
---|
| 1662 | FCurrentContext.Keyword := Keyword;
|
---|
| 1663 | FCurrentContext.Filtered := Filtered;
|
---|
| 1664 | LoadNotes;
|
---|
| 1665 | end;
|
---|
| 1666 | end;
|
---|
| 1667 | end; {case}
|
---|
| 1668 | lblNotes.Caption := SetNoteTreeLabel(FCurrentContext);
|
---|
| 1669 | lblNotes.hint := lblNotes.Caption;
|
---|
| 1670 | tvNotes.Caption := lblNotes.Caption;
|
---|
| 1671 | StatusText('');
|
---|
| 1672 | end;
|
---|
| 1673 |
|
---|
| 1674 | { Action menu events ----------------------------------------------------------------------- }
|
---|
| 1675 |
|
---|
| 1676 | function TfrmNotes.StartNewEdit(NewNoteType: integer): Boolean;
|
---|
| 1677 | { if currently editing a note, returns TRUE if the user wants to start a new one }
|
---|
| 1678 | var
|
---|
| 1679 | Saved: Boolean;
|
---|
| 1680 | Msg, CapMsg: string;
|
---|
| 1681 | begin
|
---|
| 1682 | FStarting := False;
|
---|
| 1683 | Result := True;
|
---|
| 1684 | cmdNewNote.Enabled := False;
|
---|
| 1685 | if EditingIndex > -1 then
|
---|
| 1686 | begin
|
---|
| 1687 | FStarting := True;
|
---|
| 1688 | case NewNoteType of
|
---|
| 1689 | NT_ACT_ADDENDUM: begin
|
---|
| 1690 | Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE3;
|
---|
| 1691 | CapMsg := TC_NEW_SAVE3;
|
---|
| 1692 | end;
|
---|
| 1693 | NT_ACT_EDIT_NOTE: begin
|
---|
| 1694 | Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE4;
|
---|
| 1695 | CapMsg := TC_NEW_SAVE4;
|
---|
| 1696 | end;
|
---|
| 1697 | NT_ACT_ID_ENTRY: begin
|
---|
| 1698 | Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE5;
|
---|
| 1699 | CapMsg := TC_NEW_SAVE5;
|
---|
| 1700 | end;
|
---|
| 1701 | else
|
---|
| 1702 | begin
|
---|
| 1703 | Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE2;
|
---|
| 1704 | CapMsg := TC_NEW_SAVE2;
|
---|
| 1705 | end;
|
---|
| 1706 | end;
|
---|
| 1707 | if InfoBox(Msg, CapMsg, MB_YESNO) = IDNO then
|
---|
| 1708 | begin
|
---|
| 1709 | Result := False;
|
---|
| 1710 | FStarting := False;
|
---|
| 1711 | end
|
---|
| 1712 | else
|
---|
| 1713 | begin
|
---|
| 1714 | SaveCurrentNote(Saved);
|
---|
| 1715 | if not Saved then Result := False else LoadNotes;
|
---|
| 1716 | FStarting := False;
|
---|
| 1717 | end;
|
---|
| 1718 | end;
|
---|
| 1719 | cmdNewNote.Enabled := (Result = False) and (FStarting = False);
|
---|
| 1720 | end;
|
---|
| 1721 |
|
---|
| 1722 | procedure TfrmNotes.mnuActNewClick(Sender: TObject);
|
---|
| 1723 | const
|
---|
| 1724 | IS_ID_CHILD = False;
|
---|
| 1725 | { switches to current new note or creates a new note if none is being edited already }
|
---|
| 1726 | begin
|
---|
| 1727 | inherited;
|
---|
| 1728 | if not StartNewEdit(NT_ACT_NEW_NOTE) then Exit;
|
---|
| 1729 | //LoadNotes;
|
---|
| 1730 | // make sure a visit (time & location) is available before creating the note
|
---|
| 1731 | if Encounter.NeedVisit then
|
---|
| 1732 | begin
|
---|
| 1733 | UpdateVisit(Font.Size, DfltTIULocation);
|
---|
| 1734 | frmFrame.DisplayEncounterText;
|
---|
| 1735 | end;
|
---|
| 1736 | if Encounter.NeedVisit then
|
---|
| 1737 | begin
|
---|
| 1738 | InfoBox(TX_NEED_VISIT, TX_NO_VISIT, MB_OK or MB_ICONWARNING);
|
---|
| 1739 | ShowPCEButtons(False);
|
---|
| 1740 | Exit;
|
---|
| 1741 | end;
|
---|
| 1742 | InsertNewNote(IS_ID_CHILD, 0);
|
---|
| 1743 | end;
|
---|
| 1744 |
|
---|
| 1745 | procedure TfrmNotes.mnuActAddIDEntryClick(Sender: TObject);
|
---|
| 1746 | const
|
---|
| 1747 | IS_ID_CHILD = True;
|
---|
| 1748 | var
|
---|
| 1749 | AnIDParent: integer;
|
---|
| 1750 | { switches to current new note or creates a new note if none is being edited already }
|
---|
| 1751 | begin
|
---|
| 1752 | inherited;
|
---|
| 1753 | AnIDParent := lstNotes.ItemIEN;
|
---|
| 1754 | if not StartNewEdit(NT_ACT_ID_ENTRY) then Exit;
|
---|
| 1755 | //LoadNotes;
|
---|
| 1756 | with tvNotes do Selected := FindPieceNode(IntToStr(AnIDParent), U, Items.GetFirstNode);
|
---|
| 1757 | // make sure a visit (time & location) is available before creating the note
|
---|
| 1758 | if Encounter.NeedVisit then
|
---|
| 1759 | begin
|
---|
| 1760 | UpdateVisit(Font.Size, DfltTIULocation);
|
---|
| 1761 | frmFrame.DisplayEncounterText;
|
---|
| 1762 | end;
|
---|
| 1763 | if Encounter.NeedVisit then
|
---|
| 1764 | begin
|
---|
| 1765 | InfoBox(TX_NEED_VISIT, TX_NO_VISIT, MB_OK or MB_ICONWARNING);
|
---|
| 1766 | Exit;
|
---|
| 1767 | end;
|
---|
| 1768 | InsertNewNote(IS_ID_CHILD, AnIDParent);
|
---|
| 1769 | end;
|
---|
| 1770 |
|
---|
| 1771 | procedure TfrmNotes.mnuActAddendClick(Sender: TObject);
|
---|
| 1772 | { make an addendum to an existing note }
|
---|
| 1773 | var
|
---|
| 1774 | ActionSts: TActionRec;
|
---|
| 1775 | ANoteID: string;
|
---|
| 1776 | begin
|
---|
| 1777 | inherited;
|
---|
| 1778 | if lstNotes.ItemIEN <= 0 then Exit;
|
---|
| 1779 | ANoteID := lstNotes.ItemID;
|
---|
| 1780 | if not StartNewEdit(NT_ACT_ADDENDUM) then Exit;
|
---|
| 1781 | //LoadNotes;
|
---|
| 1782 | with tvNotes do Selected := FindPieceNode(ANoteID, 1, U, Items.GetFirstNode);
|
---|
| 1783 | if lstNotes.ItemIndex = EditingIndex then
|
---|
| 1784 | begin
|
---|
| 1785 | InfoBox(TX_ADDEND_NO, TX_ADDEND_MK, MB_OK);
|
---|
| 1786 | Exit;
|
---|
| 1787 | end;
|
---|
| 1788 | ActOnDocument(ActionSts, lstNotes.ItemIEN, 'MAKE ADDENDUM');
|
---|
| 1789 | if not ActionSts.Success then
|
---|
| 1790 | begin
|
---|
| 1791 | InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
|
---|
| 1792 | Exit;
|
---|
| 1793 | end;
|
---|
| 1794 | with lstNotes do if TitleForNote(lstNotes.ItemIEN) = TYP_ADDENDUM then
|
---|
| 1795 | begin
|
---|
| 1796 | InfoBox(TX_ADDEND_AD, TX_ADDEND_MK, MB_OK);
|
---|
| 1797 | Exit;
|
---|
| 1798 | end;
|
---|
| 1799 | InsertAddendum;
|
---|
| 1800 | end;
|
---|
| 1801 |
|
---|
| 1802 | procedure TfrmNotes.mnuActDetachFromIDParentClick(Sender: TObject);
|
---|
| 1803 | var
|
---|
| 1804 | DocID, WhyNot: string;
|
---|
| 1805 | Saved: boolean;
|
---|
| 1806 | SavedDocID: string;
|
---|
| 1807 | begin
|
---|
| 1808 | if lstNotes.ItemIEN = 0 then exit;
|
---|
| 1809 | SavedDocID := lstNotes.ItemID;
|
---|
| 1810 | if EditingIndex <> -1 then
|
---|
| 1811 | begin
|
---|
| 1812 | SaveCurrentNote(Saved);
|
---|
| 1813 | if not Saved then Exit;
|
---|
| 1814 | LoadNotes;
|
---|
| 1815 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 1816 | end;
|
---|
| 1817 | if not CanBeAttached(PDocTreeObject(tvNotes.Selected.Data)^.DocID, WhyNot) then
|
---|
| 1818 | begin
|
---|
| 1819 | WhyNot := StringReplace(WhyNot, 'ATTACH', 'DETACH', [rfIgnoreCase]);
|
---|
| 1820 | WhyNot := StringReplace(WhyNot, 'to an ID', 'from an ID', [rfIgnoreCase]);
|
---|
| 1821 | InfoBox(WhyNot, TX_DETACH_FAILURE, MB_OK);
|
---|
| 1822 | Exit;
|
---|
| 1823 | end;
|
---|
| 1824 | if (InfoBox('DETACH: ' + tvNotes.Selected.Text + CRLF + CRLF +
|
---|
| 1825 | ' FROM: ' + tvNotes.Selected.Parent.Text + CRLF + CRLF +
|
---|
| 1826 | 'Are you sure?', TX_DETACH_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES)
|
---|
| 1827 | then Exit;
|
---|
| 1828 | DocID := PDocTreeObject(tvNotes.Selected.Data)^.DocID;
|
---|
| 1829 | SavedDocID := PDocTreeObject(tvNotes.Selected.Parent.Data)^.DocID;
|
---|
| 1830 | if DetachEntryFromParent(DocID, WhyNot) then
|
---|
| 1831 | begin
|
---|
| 1832 | LoadNotes;
|
---|
| 1833 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 1834 | if tvNotes.Selected <> nil then tvNotes.Selected.Expand(False);
|
---|
| 1835 | end
|
---|
| 1836 | else
|
---|
| 1837 | begin
|
---|
| 1838 | WhyNot := StringReplace(WhyNot, 'ATTACH', 'DETACH', [rfIgnoreCase]);
|
---|
| 1839 | WhyNot := StringReplace(WhyNot, 'to an ID', 'from an ID', [rfIgnoreCase]);
|
---|
| 1840 | InfoBox(WhyNot, TX_DETACH_FAILURE, MB_OK);
|
---|
| 1841 | end;
|
---|
| 1842 | end;
|
---|
| 1843 |
|
---|
| 1844 | procedure TfrmNotes.mnuActSignListClick(Sender: TObject);
|
---|
| 1845 | { add the note to the Encounter object, see mnuActSignClick - copied}
|
---|
| 1846 | const
|
---|
| 1847 | SIG_COSIGN = 'COSIGNATURE';
|
---|
| 1848 | SIG_SIGN = 'SIGNATURE';
|
---|
| 1849 | var
|
---|
| 1850 | ActionType, SignTitle: string;
|
---|
| 1851 | ActionSts: TActionRec;
|
---|
| 1852 | begin
|
---|
| 1853 | inherited;
|
---|
| 1854 | if lstNotes.ItemIEN = 0 then Exit;
|
---|
| 1855 | if lstNotes.ItemIndex = EditingIndex then Exit; // already in signature list
|
---|
| 1856 | if not NoteHasText(lstNotes.ItemIEN) then
|
---|
| 1857 | begin
|
---|
| 1858 | InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
|
---|
| 1859 | Exit;
|
---|
| 1860 | end;
|
---|
| 1861 | if not LastSaveClean(lstNotes.ItemIEN) and
|
---|
| 1862 | (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES) then Exit;
|
---|
| 1863 | if CosignDocument(lstNotes.ItemIEN) then
|
---|
| 1864 | begin
|
---|
| 1865 | SignTitle := TX_COSIGN;
|
---|
| 1866 | ActionType := SIG_COSIGN;
|
---|
| 1867 | end else
|
---|
| 1868 | begin
|
---|
| 1869 | SignTitle := TX_SIGN;
|
---|
| 1870 | ActionType := SIG_SIGN;
|
---|
| 1871 | end;
|
---|
| 1872 | ActOnDocument(ActionSts, lstNotes.ItemIEN, ActionType);
|
---|
| 1873 | if not ActionSts.Success then
|
---|
| 1874 | begin
|
---|
| 1875 | InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
|
---|
| 1876 | Exit;
|
---|
| 1877 | end;
|
---|
| 1878 | LockConsultRequestAndNote(lstNotes.ItemIEN);
|
---|
| 1879 | with lstNotes do Changes.Add(CH_DOC, ItemID, GetTitleText(ItemIndex), '', CH_SIGN_YES);
|
---|
| 1880 | end;
|
---|
| 1881 |
|
---|
| 1882 | procedure TfrmNotes.RemovePCEFromChanges(IEN: Int64; AVisitStr: string = '');
|
---|
| 1883 | begin
|
---|
| 1884 | if IEN = NT_ADDENDUM then Exit; // no PCE information entered for an addendum
|
---|
| 1885 | // do we need to call DeletePCE(AVisitStr), as was done with NT_NEW_NOTE (ien=-10)???
|
---|
| 1886 | if AVisitStr = '' then AVisitStr := VisitStrForNote(IEN);
|
---|
| 1887 | Changes.Remove(CH_PCE, 'V' + AVisitStr);
|
---|
| 1888 | Changes.Remove(CH_PCE, 'P' + AVisitStr);
|
---|
| 1889 | Changes.Remove(CH_PCE, 'D' + AVisitStr);
|
---|
| 1890 | Changes.Remove(CH_PCE, 'I' + AVisitStr);
|
---|
| 1891 | Changes.Remove(CH_PCE, 'S' + AVisitStr);
|
---|
| 1892 | Changes.Remove(CH_PCE, 'A' + AVisitStr);
|
---|
| 1893 | Changes.Remove(CH_PCE, 'H' + AVisitStr);
|
---|
| 1894 | Changes.Remove(CH_PCE, 'E' + AVisitStr);
|
---|
| 1895 | Changes.Remove(CH_PCE, 'T' + AVisitStr);
|
---|
| 1896 | end;
|
---|
| 1897 |
|
---|
| 1898 | procedure TfrmNotes.mnuActDeleteClick(Sender: TObject);
|
---|
| 1899 | { delete the selected progress note & remove from the Encounter object if necessary }
|
---|
| 1900 | var
|
---|
| 1901 | DeleteSts, ActionSts: TActionRec;
|
---|
| 1902 | SaveConsult, SavedDocIEN: Integer;
|
---|
| 1903 | ReasonForDelete, AVisitStr, SavedDocID, x: string;
|
---|
| 1904 | Saved: boolean;
|
---|
| 1905 | begin
|
---|
| 1906 | inherited;
|
---|
| 1907 | if lstNotes.ItemIEN = 0 then Exit;
|
---|
| 1908 | ActOnDocument(ActionSts, lstNotes.ItemIEN, 'DELETE RECORD');
|
---|
| 1909 | if ShowMsgOn(not ActionSts.Success, ActionSts.Reason, TX_IN_AUTH) then Exit;
|
---|
| 1910 | ReasonForDelete := SelectDeleteReason(lstNotes.ItemIEN);
|
---|
| 1911 | if ReasonForDelete = DR_CANCEL then Exit;
|
---|
| 1912 | // suppress prompt for deletion when called from SaveEditedNote (Sender = Self)
|
---|
| 1913 | if (Sender <> Self) and (InfoBox(MakeNoteDisplayText(lstNotes.Items[lstNotes.ItemIndex]) + TX_DEL_OK,
|
---|
| 1914 | TX_DEL_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) then Exit;
|
---|
| 1915 | // do the appropriate locking
|
---|
| 1916 | if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
|
---|
| 1917 | // retraction notification message
|
---|
| 1918 | if JustifyDocumentDelete(lstNotes.ItemIEN) then
|
---|
| 1919 | InfoBox(TX_RETRACT, TX_RETRACT_CAP, MB_OK);
|
---|
| 1920 | SavedDocID := lstNotes.ItemID;
|
---|
| 1921 | SavedDocIEN := lstNotes.ItemIEN;
|
---|
| 1922 | if (EditingIndex > -1) and (not FConfirmed) and (lstNotes.ItemIndex <> EditingIndex) and (memNewNote.GetTextLen > 0) then
|
---|
| 1923 | begin
|
---|
| 1924 | SaveCurrentNote(Saved);
|
---|
| 1925 | if not Saved then Exit;
|
---|
| 1926 | end;
|
---|
| 1927 | EditingIndex := -1;
|
---|
| 1928 | FConfirmed := False;
|
---|
| 1929 | (* if Saved then
|
---|
| 1930 | begin
|
---|
| 1931 | EditingIndex := -1;
|
---|
| 1932 | mnuViewClick(Self);
|
---|
| 1933 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 1934 | end;*)
|
---|
| 1935 | // remove the note
|
---|
| 1936 | DeleteSts.Success := True;
|
---|
| 1937 | x := GetPackageRefForNote(SavedDocIEN);
|
---|
| 1938 | SaveConsult := StrToIntDef(Piece(x, ';', 1), 0);
|
---|
| 1939 | AVisitStr := VisitStrForNote(SavedDocIEN);
|
---|
| 1940 | RemovePCEFromChanges(SavedDocIEN, AVisitStr);
|
---|
| 1941 | if (SavedDocIEN > 0) and (lstNotes.ItemIEN = SavedDocIEN) then DeleteDocument(DeleteSts, SavedDocIEN, ReasonForDelete);
|
---|
| 1942 | if not Changes.Exist(CH_DOC, SavedDocID) then UnlockDocument(SavedDocIEN);
|
---|
| 1943 | Changes.Remove(CH_DOC, SavedDocID); // this will unlock the document if in Changes
|
---|
| 1944 | UnlockConsultRequest(0, SaveConsult); // note has been deleted, so 1st param = 0
|
---|
| 1945 | // reset the display now that the note is gone
|
---|
| 1946 | if DeleteSts.Success then
|
---|
| 1947 | begin
|
---|
| 1948 | DeletePCE(AVisitStr); // removes PCE data if this was the only note pointing to it
|
---|
| 1949 | ClearEditControls;
|
---|
| 1950 | //ClearPtData; WRONG - fixed in v15.10 - RV
|
---|
| 1951 | LoadNotes;
|
---|
| 1952 | (* with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 1953 | if tvNotes.Selected <> nil then tvNotesChange(Self, tvNotes.Selected) else
|
---|
| 1954 | begin*)
|
---|
| 1955 | pnlWrite.Visible := False;
|
---|
| 1956 | pnlRead.Visible := True;
|
---|
| 1957 | UpdateReminderFinish;
|
---|
| 1958 | ShowPCEControls(False);
|
---|
| 1959 | frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]); //FALSE);
|
---|
| 1960 | ShowPCEButtons(FALSE);
|
---|
| 1961 | //end; {if ItemIndex}
|
---|
| 1962 | end {if DeleteSts}
|
---|
| 1963 | else InfoBox(DeleteSts.Reason, TX_DEL_ERR, MB_OK or MB_ICONWARNING);
|
---|
| 1964 | end;
|
---|
| 1965 |
|
---|
| 1966 | procedure TfrmNotes.mnuActEditClick(Sender: TObject);
|
---|
| 1967 | { load the selected progress note for editing }
|
---|
| 1968 | var
|
---|
| 1969 | ActionSts: TActionRec;
|
---|
| 1970 | ANoteID: string;
|
---|
| 1971 | begin
|
---|
| 1972 | inherited;
|
---|
| 1973 | if lstNotes.ItemIndex = EditingIndex then Exit;
|
---|
| 1974 | ANoteID := lstNotes.ItemID;
|
---|
| 1975 | if not StartNewEdit(NT_ACT_EDIT_NOTE) then Exit;
|
---|
| 1976 | //LoadNotes;
|
---|
| 1977 | with tvNotes do Selected := FindPieceNode(ANoteID, 1, U, Items.GetFirstNode);
|
---|
| 1978 | ActOnDocument(ActionSts, lstNotes.ItemIEN, 'EDIT RECORD');
|
---|
| 1979 | if not ActionSts.Success then
|
---|
| 1980 | begin
|
---|
| 1981 | InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
|
---|
| 1982 | Exit;
|
---|
| 1983 | end;
|
---|
| 1984 | LoadForEdit;
|
---|
| 1985 | end;
|
---|
| 1986 |
|
---|
| 1987 | procedure TfrmNotes.mnuActSaveClick(Sender: TObject);
|
---|
| 1988 | { saves the note that is currently being edited }
|
---|
| 1989 | var
|
---|
| 1990 | Saved: Boolean;
|
---|
| 1991 | SavedDocID: string;
|
---|
| 1992 | begin
|
---|
| 1993 | inherited;
|
---|
| 1994 | if EditingIndex > -1 then
|
---|
| 1995 | begin
|
---|
| 1996 | SavedDocID := Piece(lstNotes.Items[EditingIndex], U, 1);
|
---|
| 1997 | FLastNoteID := SavedDocID;
|
---|
| 1998 | SaveCurrentNote(Saved);
|
---|
| 1999 | if Saved and (EditingIndex < 0) and (not FDeleted) then
|
---|
| 2000 | //if Saved then
|
---|
| 2001 | begin
|
---|
| 2002 | LoadNotes;
|
---|
| 2003 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 2004 | end;
|
---|
| 2005 | end
|
---|
| 2006 | else InfoBox(TX_NO_NOTE, TX_SAVE_NOTE, MB_OK or MB_ICONWARNING);
|
---|
| 2007 | end;
|
---|
| 2008 |
|
---|
| 2009 | procedure TfrmNotes.mnuActSignClick(Sender: TObject);
|
---|
| 2010 | { sign the currently selected note, save first if necessary }
|
---|
| 2011 | const
|
---|
| 2012 | SIG_COSIGN = 'COSIGNATURE';
|
---|
| 2013 | SIG_SIGN = 'SIGNATURE';
|
---|
| 2014 | var
|
---|
| 2015 | Saved, NoteUnlocked: Boolean;
|
---|
| 2016 | ActionType, ESCode, SignTitle: string;
|
---|
| 2017 | ActionSts, SignSts: TActionRec;
|
---|
| 2018 | OK: boolean;
|
---|
| 2019 | SavedDocID, tmpItem: string;
|
---|
| 2020 | EditingID: string; //v22.12 - RV
|
---|
| 2021 | tmpNode: TTreeNode;
|
---|
| 2022 | begin
|
---|
| 2023 | inherited;
|
---|
| 2024 | (* if lstNotes.ItemIndex = EditingIndex then //v22.12 - RV
|
---|
| 2025 | begin //v22.12 - RV
|
---|
| 2026 | SaveCurrentNote(Saved); //v22.12 - RV
|
---|
| 2027 | if (not Saved) or FDeleted then Exit; //v22.12 - RV
|
---|
| 2028 | end //v22.12 - RV
|
---|
| 2029 | else if EditingIndex > -1 then //v22.12 - RV
|
---|
| 2030 | tmpItem := lstNotes.Items[EditingIndex]; //v22.12 - RV
|
---|
| 2031 | SavedDocID := lstNotes.ItemID;*) //v22.12 - RV
|
---|
| 2032 | SavedDocID := lstNotes.ItemID; //v22.12 - RV
|
---|
| 2033 | FLastNoteID := SavedDocID; //v22.12 - RV
|
---|
| 2034 | if lstNotes.ItemIndex = EditingIndex then //v22.12 - RV
|
---|
| 2035 | begin //v22.12 - RV
|
---|
| 2036 | SaveCurrentNote(Saved); //v22.12 - RV
|
---|
| 2037 | if (not Saved) or FDeleted then Exit; //v22.12 - RV
|
---|
| 2038 | end //v22.12 - RV
|
---|
| 2039 | else if EditingIndex > -1 then //v22.12 - RV
|
---|
| 2040 | begin //v22.12 - RV
|
---|
| 2041 | tmpItem := lstNotes.Items[EditingIndex]; //v22.12 - RV
|
---|
| 2042 | EditingID := Piece(tmpItem, U, 1); //v22.12 - RV
|
---|
| 2043 | end; //v22.12 - RV
|
---|
| 2044 | if not NoteHasText(lstNotes.ItemIEN) then
|
---|
| 2045 | begin
|
---|
| 2046 | InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
|
---|
| 2047 | Exit;
|
---|
| 2048 | end;
|
---|
| 2049 | if not LastSaveClean(lstNotes.ItemIEN) and
|
---|
| 2050 | (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES) then Exit;
|
---|
| 2051 | if CosignDocument(lstNotes.ItemIEN) then
|
---|
| 2052 | begin
|
---|
| 2053 | SignTitle := TX_COSIGN;
|
---|
| 2054 | ActionType := SIG_COSIGN;
|
---|
| 2055 | end else
|
---|
| 2056 | begin
|
---|
| 2057 | SignTitle := TX_SIGN;
|
---|
| 2058 | ActionType := SIG_SIGN;
|
---|
| 2059 | end;
|
---|
| 2060 | if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
|
---|
| 2061 | // no exits after things are locked
|
---|
| 2062 | NoteUnlocked := False;
|
---|
| 2063 | ActOnDocument(ActionSts, lstNotes.ItemIEN, ActionType);
|
---|
| 2064 | if ActionSts.Success then
|
---|
| 2065 | begin
|
---|
| 2066 | OK := IsOK2Sign(uPCEShow, lstNotes.ItemIEN);
|
---|
| 2067 | if frmFrame.Closing then exit;
|
---|
| 2068 | if(uPCEShow.Updated) then
|
---|
| 2069 | begin
|
---|
| 2070 | uPCEShow.CopyPCEData(uPCEEdit);
|
---|
| 2071 | uPCEShow.Updated := FALSE;
|
---|
| 2072 | lstNotesClick(Self);
|
---|
| 2073 | end;
|
---|
| 2074 | if not AuthorSignedDocument(lstNotes.ItemIEN) then
|
---|
| 2075 | begin
|
---|
| 2076 | if (InfoBox(TX_AUTH_SIGNED +
|
---|
| 2077 | GetTitleText(lstNotes.ItemIndex),TX_SIGN ,MB_YESNO)= ID_NO) then exit;
|
---|
| 2078 | end;
|
---|
| 2079 | if(OK) then
|
---|
| 2080 | begin
|
---|
| 2081 | with lstNotes do SignatureForItem(Font.Size, MakeNoteDisplayText(Items[ItemIndex]), SignTitle, ESCode);
|
---|
| 2082 | if Length(ESCode) > 0 then
|
---|
| 2083 | begin
|
---|
| 2084 | SignDocument(SignSts, lstNotes.ItemIEN, ESCode);
|
---|
| 2085 | RemovePCEFromChanges(lstNotes.ItemIEN);
|
---|
| 2086 | NoteUnlocked := Changes.Exist(CH_DOC, lstNotes.ItemID);
|
---|
| 2087 | Changes.Remove(CH_DOC, lstNotes.ItemID); // this will unlock if in Changes
|
---|
| 2088 | if SignSts.Success then
|
---|
| 2089 | begin
|
---|
| 2090 | SendMessage(frmConsults.Handle, UM_NEWORDER, ORDER_SIGN, 0); {*REV*}
|
---|
| 2091 | lstNotesClick(Self);
|
---|
| 2092 | end
|
---|
| 2093 | else InfoBox(SignSts.Reason, TX_SIGN_ERR, MB_OK);
|
---|
| 2094 | end {if Length(ESCode)}
|
---|
| 2095 | else
|
---|
| 2096 | NoteUnlocked := Changes.Exist(CH_DOC, lstNotes.ItemID);
|
---|
| 2097 | end;
|
---|
| 2098 | end
|
---|
| 2099 | else InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
|
---|
| 2100 | if not NoteUnlocked then UnlockDocument(lstNotes.ItemIEN);
|
---|
| 2101 | UnlockConsultRequest(lstNotes.ItemIEN);
|
---|
| 2102 | //SetViewContext(FCurrentContext); //v22.12 - RV
|
---|
| 2103 | LoadNotes; //v22.12 - RV
|
---|
| 2104 | //if EditingIndex > -1 then //v22.12 - RV
|
---|
| 2105 | if (EditingID <> '') then //v22.12 - RV
|
---|
| 2106 | begin
|
---|
| 2107 | lstNotes.Items.Insert(0, tmpItem);
|
---|
| 2108 | tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'Note being edited',
|
---|
| 2109 | MakeNoteTreeObject('EDIT^Note being edited^^^^^^^^^^^%^0'));
|
---|
| 2110 | TORTreeNode(tmpNode).StringData := 'EDIT^Note being edited^^^^^^^^^^^%^0';
|
---|
| 2111 | tmpNode.ImageIndex := IMG_TOP_LEVEL;
|
---|
| 2112 | tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(tmpItem), MakeNoteTreeObject(tmpItem));
|
---|
| 2113 | TORTreeNode(tmpNode).StringData := tmpItem;
|
---|
| 2114 | SetTreeNodeImagesAndFormatting(TORTreeNode(tmpNode), FCurrentContext, CT_NOTES);
|
---|
| 2115 | EditingIndex := lstNotes.SelectByID(EditingID); //v22.12 - RV
|
---|
| 2116 | end;
|
---|
| 2117 | //with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode); //v22.12 - RV
|
---|
| 2118 | with tvNotes do //v22.12 - RV
|
---|
| 2119 | begin //v22.12 - RV
|
---|
| 2120 | Selected := FindPieceNode(FLastNoteID, U, Items.GetFirstNode); //v22.12 - RV
|
---|
| 2121 | if Selected <> nil then
|
---|
| 2122 | tvNotesChange(Self, Selected) //v22.12 - RV
|
---|
| 2123 | else
|
---|
| 2124 | tvNotes.Selected := tvNotes.Items[0]; //first Node in treeview
|
---|
| 2125 | end; //v22.12 - RV
|
---|
| 2126 | end;
|
---|
| 2127 |
|
---|
| 2128 | procedure TfrmNotes.SaveSignItem(const ItemID, ESCode: string);
|
---|
| 2129 | { saves and optionally signs a progress note or addendum }
|
---|
| 2130 | var
|
---|
| 2131 | AnIndex, IEN, i: Integer;
|
---|
| 2132 | Saved, ContinueSign: Boolean; {*RAB* 8/26/99}
|
---|
| 2133 | SignSts: TActionRec;
|
---|
| 2134 | APCEObject: TPCEData;
|
---|
| 2135 | OK: boolean;
|
---|
| 2136 |
|
---|
| 2137 | begin
|
---|
| 2138 | AnIndex := -1;
|
---|
| 2139 | IEN := StrToIntDef(ItemID, 0);
|
---|
| 2140 | if IEN = 0 then Exit;
|
---|
| 2141 | if frmFrame.TimedOut and (EditingIndex <> -1) then FSilent := True;
|
---|
| 2142 | with lstNotes do for i := 0 to Items.Count - 1 do if lstNotes.GetIEN(i) = IEN then
|
---|
| 2143 | begin
|
---|
| 2144 | AnIndex := i;
|
---|
| 2145 | break;
|
---|
| 2146 | end;
|
---|
| 2147 | if (AnIndex > -1) and (AnIndex = EditingIndex) then
|
---|
| 2148 | begin
|
---|
| 2149 | SaveCurrentNote(Saved);
|
---|
| 2150 | if not Saved then Exit;
|
---|
| 2151 | if FDeleted then
|
---|
| 2152 | begin
|
---|
| 2153 | FDeleted := False;
|
---|
| 2154 | Exit;
|
---|
| 2155 | end;
|
---|
| 2156 | AnIndex := lstNotes.SelectByIEN(IEN);
|
---|
| 2157 | //IEN := lstNotes.GetIEN(AnIndex); // saving will change IEN
|
---|
| 2158 | end;
|
---|
| 2159 | if Length(ESCode) > 0 then
|
---|
| 2160 | begin
|
---|
| 2161 | if not NoteHasText(IEN) then
|
---|
| 2162 | begin
|
---|
| 2163 | InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
|
---|
| 2164 | ContinueSign := False;
|
---|
| 2165 | end
|
---|
| 2166 | else if not LastSaveClean(IEN) and
|
---|
| 2167 | (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES)
|
---|
| 2168 | then ContinueSign := False
|
---|
| 2169 | else ContinueSign := True;
|
---|
| 2170 | if ContinueSign then
|
---|
| 2171 | begin
|
---|
| 2172 | if (AnIndex >= 0) and (AnIndex = lstNotes.ItemIndex) then
|
---|
| 2173 | APCEObject := uPCEShow
|
---|
| 2174 | else
|
---|
| 2175 | APCEObject := nil;
|
---|
| 2176 | OK := IsOK2Sign(APCEObject, IEN);
|
---|
| 2177 | if frmFrame.Closing then exit;
|
---|
| 2178 | if(assigned(APCEObject)) and (uPCEShow.Updated) then
|
---|
| 2179 | begin
|
---|
| 2180 | uPCEShow.CopyPCEData(uPCEEdit);
|
---|
| 2181 | uPCEShow.Updated := FALSE;
|
---|
| 2182 | lstNotesClick(Self);
|
---|
| 2183 | end
|
---|
| 2184 | else
|
---|
| 2185 | uPCEEdit.Clear;
|
---|
| 2186 | if(OK) then
|
---|
| 2187 | begin
|
---|
| 2188 | //if ((not FSilent) and IsSurgeryTitle(TitleForNote(IEN))) then DisplayOpTop(IEN);
|
---|
| 2189 | SignDocument(SignSts, IEN, ESCode);
|
---|
| 2190 | if not SignSts.Success then InfoBox(SignSts.Reason, TX_SIGN_ERR, MB_OK);
|
---|
| 2191 | end; {if OK}
|
---|
| 2192 | end; {if ContinueSign}
|
---|
| 2193 | end; {if Length(ESCode)}
|
---|
| 2194 |
|
---|
| 2195 | UnlockConsultRequest(IEN);
|
---|
| 2196 | if (AnIndex = lstNotes.ItemIndex) and (not frmFrame.ContextChanging) then
|
---|
| 2197 | begin
|
---|
| 2198 | LoadNotes;
|
---|
| 2199 | with tvNotes do Selected := FindPieceNode(IntToStr(IEN), U, Items.GetFirstNode);
|
---|
| 2200 | end;
|
---|
| 2201 | end;
|
---|
| 2202 |
|
---|
| 2203 | procedure TfrmNotes.popNoteMemoPopup(Sender: TObject);
|
---|
| 2204 | begin
|
---|
| 2205 | inherited;
|
---|
| 2206 | if PopupComponent(Sender, popNoteMemo) is TCustomEdit
|
---|
| 2207 | then FEditCtrl := TCustomEdit(PopupComponent(Sender, popNoteMemo))
|
---|
| 2208 | else FEditCtrl := nil;
|
---|
| 2209 | if FEditCtrl <> nil then
|
---|
| 2210 | begin
|
---|
| 2211 | popNoteMemoCut.Enabled := FEditCtrl.SelLength > 0;
|
---|
| 2212 | popNoteMemoCopy.Enabled := popNoteMemoCut.Enabled;
|
---|
| 2213 | popNoteMemoPaste.Enabled := (not TORExposedCustomEdit(FEditCtrl).ReadOnly) and
|
---|
| 2214 | Clipboard.HasFormat(CF_TEXT);
|
---|
| 2215 | popNoteMemoTemplate.Enabled := frmDrawers.CanEditTemplates and popNoteMemoCut.Enabled;
|
---|
| 2216 | popNoteMemoFind.Enabled := FEditCtrl.GetTextLen > 0;
|
---|
| 2217 | end else
|
---|
| 2218 | begin
|
---|
| 2219 | popNoteMemoCut.Enabled := False;
|
---|
| 2220 | popNoteMemoCopy.Enabled := False;
|
---|
| 2221 | popNoteMemoPaste.Enabled := False;
|
---|
| 2222 | popNoteMemoTemplate.Enabled := False;
|
---|
| 2223 | end;
|
---|
| 2224 | if pnlWrite.Visible then
|
---|
| 2225 | begin
|
---|
| 2226 | popNoteMemoSpell.Enabled := True;
|
---|
| 2227 | popNoteMemoGrammar.Enabled := True;
|
---|
| 2228 | popNoteMemoReformat.Enabled := True;
|
---|
| 2229 | popNoteMemoReplace.Enabled := (FEditCtrl.GetTextLen > 0);
|
---|
| 2230 | popNoteMemoPreview.Enabled := (frmDrawers.TheOpenDrawer = odTemplates) and Assigned(frmDrawers.tvTemplates.Selected);
|
---|
| 2231 | popNoteMemoInsTemplate.Enabled := (frmDrawers.TheOpenDrawer = odTemplates) and Assigned(frmDrawers.tvTemplates.Selected);
|
---|
| 2232 | end else
|
---|
| 2233 | begin
|
---|
| 2234 | popNoteMemoSpell.Enabled := False;
|
---|
| 2235 | popNoteMemoGrammar.Enabled := False;
|
---|
| 2236 | popNoteMemoReformat.Enabled := False;
|
---|
| 2237 | popNoteMemoReplace.Enabled := False;
|
---|
| 2238 | popNoteMemoPreview.Enabled := False;
|
---|
| 2239 | popNoteMemoInsTemplate.Enabled := False;
|
---|
| 2240 | end;
|
---|
| 2241 | end;
|
---|
| 2242 |
|
---|
| 2243 | procedure TfrmNotes.popNoteMemoCutClick(Sender: TObject);
|
---|
| 2244 | begin
|
---|
| 2245 | inherited;
|
---|
| 2246 | FEditCtrl.CutToClipboard;
|
---|
| 2247 | end;
|
---|
| 2248 |
|
---|
| 2249 | procedure TfrmNotes.popNoteMemoCopyClick(Sender: TObject);
|
---|
| 2250 | begin
|
---|
| 2251 | inherited;
|
---|
| 2252 | FEditCtrl.CopyToClipboard;
|
---|
| 2253 | end;
|
---|
| 2254 |
|
---|
| 2255 | procedure TfrmNotes.popNoteMemoPasteClick(Sender: TObject);
|
---|
| 2256 | begin
|
---|
| 2257 | inherited;
|
---|
| 2258 | FEditCtrl.SelText := Clipboard.AsText; {*KCM*}
|
---|
| 2259 | frmNotes.pnlWriteResize(Self);
|
---|
| 2260 | //FEditCtrl.PasteFromClipboard; // use AsText to prevent formatting
|
---|
| 2261 | end;
|
---|
| 2262 |
|
---|
| 2263 | procedure TfrmNotes.popNoteMemoReformatClick(Sender: TObject);
|
---|
| 2264 | begin
|
---|
| 2265 | inherited;
|
---|
| 2266 | if Screen.ActiveControl <> memNewNote then Exit;
|
---|
| 2267 | ReformatMemoParagraph(memNewNote);
|
---|
| 2268 | end;
|
---|
| 2269 |
|
---|
| 2270 | procedure TfrmNotes.popNoteMemoSaveContinueClick(Sender: TObject);
|
---|
| 2271 | begin
|
---|
| 2272 | inherited;
|
---|
| 2273 | FChanged := True;
|
---|
| 2274 | DoAutoSave;
|
---|
| 2275 | end;
|
---|
| 2276 |
|
---|
| 2277 | procedure TfrmNotes.popNoteMemoFindClick(Sender: TObject);
|
---|
| 2278 | begin
|
---|
| 2279 | inherited;
|
---|
| 2280 | SendMessage(TRichEdit(popNoteMemo.PopupComponent).Handle, WM_VSCROLL, SB_TOP, 0);
|
---|
| 2281 | with dlgFindText do
|
---|
| 2282 | begin
|
---|
| 2283 | Position := Point(Application.MainForm.Left + pnlLeft.Width, Application.MainForm.Top);
|
---|
| 2284 | FindText := '';
|
---|
| 2285 | Options := [frDown, frHideUpDown];
|
---|
| 2286 | Execute;
|
---|
| 2287 | end;
|
---|
| 2288 | end;
|
---|
| 2289 |
|
---|
| 2290 | procedure TfrmNotes.dlgFindTextFind(Sender: TObject);
|
---|
| 2291 | begin
|
---|
| 2292 | dmodShared.FindRichEditText(dlgFindText, TRichEdit(popNoteMemo.PopupComponent));
|
---|
| 2293 | end;
|
---|
| 2294 |
|
---|
| 2295 | procedure TfrmNotes.popNoteMemoReplaceClick(Sender: TObject);
|
---|
| 2296 | begin
|
---|
| 2297 | inherited;
|
---|
| 2298 | SendMessage(TRichEdit(popNoteMemo.PopupComponent).Handle, WM_VSCROLL, SB_TOP, 0);
|
---|
| 2299 | with dlgReplaceText do
|
---|
| 2300 | begin
|
---|
| 2301 | Position := Point(Application.MainForm.Left + pnlLeft.Width, Application.MainForm.Top);
|
---|
| 2302 | FindText := '';
|
---|
| 2303 | ReplaceText := '';
|
---|
| 2304 | Options := [frDown, frHideUpDown];
|
---|
| 2305 | Execute;
|
---|
| 2306 | end;
|
---|
| 2307 | end;
|
---|
| 2308 |
|
---|
| 2309 | procedure TfrmNotes.dlgReplaceTextFind(Sender: TObject);
|
---|
| 2310 | begin
|
---|
| 2311 | inherited;
|
---|
| 2312 | dmodShared.FindRichEditText(dlgFindText, TRichEdit(popNoteMemo.PopupComponent));
|
---|
| 2313 | end;
|
---|
| 2314 |
|
---|
| 2315 | procedure TfrmNotes.dlgReplaceTextReplace(Sender: TObject);
|
---|
| 2316 | begin
|
---|
| 2317 | inherited;
|
---|
| 2318 | dmodShared.ReplaceRichEditText(dlgReplaceText, TRichEdit(popNoteMemo.PopupComponent));
|
---|
| 2319 | end;
|
---|
| 2320 |
|
---|
| 2321 | procedure TfrmNotes.popNoteMemoSpellClick(Sender: TObject);
|
---|
| 2322 | begin
|
---|
| 2323 | inherited;
|
---|
| 2324 | DoAutoSave;
|
---|
| 2325 | timAutoSave.Enabled := False;
|
---|
| 2326 | try
|
---|
| 2327 | SpellCheckForControl(memNewNote);
|
---|
| 2328 | finally
|
---|
| 2329 | timAutoSave.Enabled := True;
|
---|
| 2330 | end;
|
---|
| 2331 | end;
|
---|
| 2332 |
|
---|
| 2333 | procedure TfrmNotes.popNoteMemoGrammarClick(Sender: TObject);
|
---|
| 2334 | begin
|
---|
| 2335 | inherited;
|
---|
| 2336 | DoAutoSave;
|
---|
| 2337 | timAutoSave.Enabled := False;
|
---|
| 2338 | try
|
---|
| 2339 | GrammarCheckForControl(memNewNote);
|
---|
| 2340 | finally
|
---|
| 2341 | timAutoSave.Enabled := True;
|
---|
| 2342 | end;
|
---|
| 2343 | end;
|
---|
| 2344 |
|
---|
| 2345 | procedure TfrmNotes.mnuViewDetailClick(Sender: TObject);
|
---|
| 2346 | begin
|
---|
| 2347 | inherited;
|
---|
| 2348 | if lstNotes.ItemIEN <= 0 then Exit;
|
---|
| 2349 | mnuViewDetail.Checked := not mnuViewDetail.Checked;
|
---|
| 2350 | if mnuViewDetail.Checked then
|
---|
| 2351 | begin
|
---|
| 2352 | StatusText('Retrieving progress note details...');
|
---|
| 2353 | Screen.Cursor := crHourGlass;
|
---|
| 2354 | LoadDetailText(memNote.Lines, lstNotes.ItemIEN);
|
---|
| 2355 | Screen.Cursor := crDefault;
|
---|
| 2356 | StatusText('');
|
---|
| 2357 | memNote.SelStart := 0;
|
---|
| 2358 | memNote.Repaint;
|
---|
| 2359 | end
|
---|
| 2360 | else
|
---|
| 2361 | lstNotesClick(Self);
|
---|
| 2362 | SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
|
---|
| 2363 | end;
|
---|
| 2364 |
|
---|
| 2365 | procedure TfrmNotes.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 2366 | var
|
---|
| 2367 | Saved: Boolean;
|
---|
| 2368 | IEN: Int64;
|
---|
| 2369 | ErrMsg: string;
|
---|
| 2370 | DeleteSts: TActionRec;
|
---|
| 2371 | begin
|
---|
| 2372 | inherited;
|
---|
| 2373 | if frmFrame.TimedOut and (EditingIndex <> -1) then
|
---|
| 2374 | begin
|
---|
| 2375 | FSilent := True;
|
---|
| 2376 | if memNewNote.GetTextLen > 0 then SaveCurrentNote(Saved)
|
---|
| 2377 | else
|
---|
| 2378 | begin
|
---|
| 2379 | IEN := lstNotes.GetIEN(EditingIndex);
|
---|
| 2380 | if not LastSaveClean(IEN) then // means note hasn't been committed yet
|
---|
| 2381 | begin
|
---|
| 2382 | LockDocument(IEN, ErrMsg);
|
---|
| 2383 | if ErrMsg = '' then
|
---|
| 2384 | begin
|
---|
| 2385 | DeleteDocument(DeleteSts, IEN, '');
|
---|
| 2386 | UnlockDocument(IEN);
|
---|
| 2387 | end; {if ErrMsg}
|
---|
| 2388 | end; {if not LastSaveClean}
|
---|
| 2389 | end; {else}
|
---|
| 2390 | end; {if frmFrame}
|
---|
| 2391 | end;
|
---|
| 2392 |
|
---|
| 2393 | procedure TfrmNotes.mnuActIdentifyAddlSignersClick(Sender: TObject);
|
---|
| 2394 | var
|
---|
| 2395 | Exclusions: TStrings;
|
---|
| 2396 | Saved, x, y: boolean;
|
---|
| 2397 | SignerList: TSignerList;
|
---|
| 2398 | ActionSts: TActionRec;
|
---|
| 2399 | SigAction: integer;
|
---|
| 2400 | SavedDocID: string;
|
---|
| 2401 | begin
|
---|
| 2402 | inherited;
|
---|
| 2403 | if lstNotes.ItemIEN = 0 then exit;
|
---|
| 2404 | SavedDocID := lstNotes.ItemID;
|
---|
| 2405 | if lstNotes.ItemIndex = EditingIndex then
|
---|
| 2406 | begin
|
---|
| 2407 | SaveCurrentNote(Saved);
|
---|
| 2408 | if not Saved then Exit;
|
---|
| 2409 | LoadNotes;
|
---|
| 2410 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 2411 | end;
|
---|
| 2412 | x := CanChangeCosigner(lstNotes.ItemIEN);
|
---|
| 2413 | ActOnDocument(ActionSts, lstNotes.ItemIEN, 'IDENTIFY SIGNERS');
|
---|
| 2414 | y := ActionSts.Success;
|
---|
| 2415 | if x and not y then
|
---|
| 2416 | begin
|
---|
| 2417 | if InfoBox(ActionSts.Reason + CRLF + CRLF +
|
---|
| 2418 | 'Would you like to change the cosigner?',
|
---|
| 2419 | TX_IN_AUTH, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES then
|
---|
| 2420 | SigAction := SG_COSIGNER
|
---|
| 2421 | else
|
---|
| 2422 | Exit;
|
---|
| 2423 | end
|
---|
| 2424 | else if y and not x then SigAction := SG_ADDITIONAL
|
---|
| 2425 | else if x and y then SigAction := SG_BOTH
|
---|
| 2426 | else
|
---|
| 2427 | begin
|
---|
| 2428 | InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
|
---|
| 2429 | Exit;
|
---|
| 2430 | end;
|
---|
| 2431 |
|
---|
| 2432 | if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
|
---|
| 2433 | Exclusions := GetCurrentSigners(lstNotes.ItemIEN);
|
---|
| 2434 | SelectAdditionalSigners(Font.Size, lstNotes.ItemIEN, SigAction, Exclusions, SignerList, CT_NOTES);
|
---|
| 2435 | with SignerList do
|
---|
| 2436 | begin
|
---|
| 2437 | case SigAction of
|
---|
| 2438 | SG_ADDITIONAL: if Changed and (Signers <> nil) and (Signers.Count > 0) then
|
---|
| 2439 | UpdateAdditionalSigners(lstNotes.ItemIEN, Signers);
|
---|
| 2440 | SG_COSIGNER: if Changed then ChangeCosigner(lstNotes.ItemIEN, Cosigner);
|
---|
| 2441 | SG_BOTH: if Changed then
|
---|
| 2442 | begin
|
---|
| 2443 | if (Signers <> nil) and (Signers.Count > 0) then
|
---|
| 2444 | UpdateAdditionalSigners(lstNotes.ItemIEN, Signers);
|
---|
| 2445 | ChangeCosigner(lstNotes.ItemIEN, Cosigner);
|
---|
| 2446 | end;
|
---|
| 2447 | end;
|
---|
| 2448 | lstNotesClick(Self);
|
---|
| 2449 | end;
|
---|
| 2450 | UnlockDocument(lstNotes.ItemIEN);
|
---|
| 2451 | UnlockConsultRequest(lstNotes.ItemIEN);
|
---|
| 2452 | end;
|
---|
| 2453 |
|
---|
| 2454 | procedure TfrmNotes.popNoteMemoAddlSignClick(Sender: TObject);
|
---|
| 2455 | begin
|
---|
| 2456 | inherited;
|
---|
| 2457 | mnuActIdentifyAddlSignersClick(Self);
|
---|
| 2458 | end;
|
---|
| 2459 |
|
---|
| 2460 | procedure TfrmNotes.ProcessNotifications;
|
---|
| 2461 | var
|
---|
| 2462 | x: string;
|
---|
| 2463 | Saved: boolean;
|
---|
| 2464 | tmpNode: TTreeNode;
|
---|
| 2465 | AnObject: PDocTreeObject;
|
---|
| 2466 | begin
|
---|
| 2467 | if EditingIndex <> -1 then
|
---|
| 2468 | begin
|
---|
| 2469 | SaveCurrentNote(Saved);
|
---|
| 2470 | if not Saved then Exit;
|
---|
| 2471 | end;
|
---|
| 2472 | lblNotes.Caption := Notifications.Text;
|
---|
| 2473 | tvNotes.Caption := Notifications.Text;
|
---|
| 2474 | EditingIndex := -1;
|
---|
| 2475 | lstNotes.Enabled := True ;
|
---|
| 2476 | pnlRead.BringToFront ;
|
---|
| 2477 | // show ALL unsigned/uncosigned for a patient, not just the alerted one
|
---|
| 2478 | // what about cosignature? How to get correct list? ORB FOLLOWUP TYPE = OR alerts only
|
---|
| 2479 | x := Notifications.AlertData;
|
---|
| 2480 | if StrToIntDef(Piece(x, U, 1), 0) = 0 then
|
---|
| 2481 | begin
|
---|
| 2482 | InfoBox(TX_NO_ALERT, TX_CAP_NO_ALERT, MB_OK);
|
---|
| 2483 | Exit;
|
---|
| 2484 | end;
|
---|
| 2485 | uChanging := True;
|
---|
| 2486 | tvNotes.Items.BeginUpdate;
|
---|
| 2487 | lstNotes.Clear;
|
---|
| 2488 | KillDocTreeObjects(tvNotes);
|
---|
| 2489 | tvNotes.Items.Clear;
|
---|
| 2490 | lstNotes.Items.Add(x);
|
---|
| 2491 | AnObject := MakeNoteTreeObject('ALERT^Alerted Note^^^^^^^^^^^%^0');
|
---|
| 2492 | tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, AnObject.NodeText, AnObject);
|
---|
| 2493 | TORTreeNode(tmpNode).StringData := 'ALERT^Alerted Note^^^^^^^^^^^%^0';
|
---|
| 2494 | tmpNode.ImageIndex := IMG_TOP_LEVEL;
|
---|
| 2495 | AnObject := MakeNoteTreeObject(x);
|
---|
| 2496 | tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, AnObject.NodeText, AnObject);
|
---|
| 2497 | TORTreeNode(tmpNode).StringData := x;
|
---|
| 2498 | SetTreeNodeImagesAndFormatting(TORTreeNode(tmpNode), FCurrentContext, CT_NOTES);
|
---|
| 2499 | tvNotes.Selected := tmpNode;
|
---|
| 2500 | tvNotes.Items.EndUpdate;
|
---|
| 2501 | uChanging := False;
|
---|
| 2502 | tvNotesChange(Self, tvNotes.Selected);
|
---|
| 2503 | case Notifications.Followup of
|
---|
| 2504 | NF_NOTES_UNSIGNED_NOTE: ; //Automatically deleted by sig action!!!
|
---|
| 2505 | end;
|
---|
| 2506 | if Copy(Piece(Notifications.RecordID, U, 2), 1, 6) = 'TIUADD' then Notifications.Delete;
|
---|
| 2507 | if Copy(Piece(Notifications.RecordID, U, 2), 1, 5) = 'TIUID' then Notifications.Delete;
|
---|
| 2508 | end;
|
---|
| 2509 |
|
---|
| 2510 | procedure TfrmNotes.SetViewContext(AContext: TTIUContext);
|
---|
| 2511 | var
|
---|
| 2512 | Saved: boolean;
|
---|
| 2513 | begin
|
---|
| 2514 | if EditingIndex <> -1 then
|
---|
| 2515 | begin
|
---|
| 2516 | SaveCurrentNote(Saved);
|
---|
| 2517 | if not Saved then Exit;
|
---|
| 2518 | end;
|
---|
| 2519 | FCurrentContext := AContext;
|
---|
| 2520 | EditingIndex := -1;
|
---|
| 2521 | tvNotes.Enabled := True ;
|
---|
| 2522 | pnlRead.BringToFront ;
|
---|
| 2523 | if FCurrentContext.Status <> '' then with uTIUContext do
|
---|
| 2524 | begin
|
---|
| 2525 | BeginDate := FCurrentContext.BeginDate;
|
---|
| 2526 | EndDate := FCurrentContext.EndDate;
|
---|
| 2527 | FMBeginDate := FCurrentContext.FMBeginDate;
|
---|
| 2528 | FMEndDate := FCurrentContext.FMEndDate;
|
---|
| 2529 | Status := FCurrentContext.Status;
|
---|
| 2530 | Author := FCurrentContext.Author;
|
---|
| 2531 | MaxDocs := FCurrentContext.MaxDocs;
|
---|
| 2532 | ShowSubject := FCurrentContext.ShowSubject;
|
---|
| 2533 | GroupBy := FCurrentContext.GroupBy;
|
---|
| 2534 | SortBy := FCurrentContext.SortBy;
|
---|
| 2535 | ListAscending := FCurrentContext.ListAscending;
|
---|
| 2536 | TreeAscending := FCurrentContext.TreeAscending;
|
---|
| 2537 | Keyword := FCurrentContext.Keyword;
|
---|
| 2538 | SearchField := FCurrentContext.SearchField;
|
---|
| 2539 | Filtered := FCurrentContext.Filtered;
|
---|
| 2540 | Changed := True;
|
---|
| 2541 | mnuViewClick(Self);
|
---|
| 2542 | end
|
---|
| 2543 | else
|
---|
| 2544 | begin
|
---|
| 2545 | ViewContext := NC_RECENT ;
|
---|
| 2546 | mnuViewClick(Self);
|
---|
| 2547 | end;
|
---|
| 2548 | end;
|
---|
| 2549 |
|
---|
| 2550 | procedure TfrmNotes.mnuViewSaveAsDefaultClick(Sender: TObject);
|
---|
| 2551 | const
|
---|
| 2552 | TX_NO_MAX = 'You have not specified a maximum number of notes to be returned.' + CRLF +
|
---|
| 2553 | 'If you save this preference, the result will be that ALL notes for every' + CRLF +
|
---|
| 2554 | 'patient will be saved as your default view.' + CRLF + CRLF +
|
---|
| 2555 | 'For patients with large numbers of notes, this could result in some lengthy' + CRLF +
|
---|
| 2556 | 'delays in loading the list of notes.' + CRLF + CRLF +
|
---|
| 2557 | 'Are you sure you mean to do this?';
|
---|
| 2558 | TX_REPLACE = 'Replace current defaults?';
|
---|
| 2559 | begin
|
---|
| 2560 | inherited;
|
---|
| 2561 | if FCurrentContext.MaxDocs = 0 then
|
---|
| 2562 | if InfoBox(TX_NO_MAX,'Warning', MB_YESNO or MB_ICONWARNING) = IDNO then
|
---|
| 2563 | begin
|
---|
| 2564 | mnuViewClick(mnuViewCustom);
|
---|
| 2565 | Exit;
|
---|
| 2566 | end;
|
---|
| 2567 | if InfoBox(TX_REPLACE,'Confirmation', MB_YESNO or MB_ICONQUESTION) = IDYES then
|
---|
| 2568 | begin
|
---|
| 2569 | SaveCurrentTIUContext(FCurrentContext);
|
---|
| 2570 | FDefaultContext := FCurrentContext;
|
---|
| 2571 | //lblNotes.Caption := 'Default List';
|
---|
| 2572 | end;
|
---|
| 2573 | end;
|
---|
| 2574 |
|
---|
| 2575 | procedure TfrmNotes.mnuViewReturntoDefaultClick(Sender: TObject);
|
---|
| 2576 | begin
|
---|
| 2577 | inherited;
|
---|
| 2578 | SetViewContext(FDefaultContext);
|
---|
| 2579 | end;
|
---|
| 2580 |
|
---|
| 2581 | procedure TfrmNotes.popNoteMemoTemplateClick(Sender: TObject);
|
---|
| 2582 | begin
|
---|
| 2583 | inherited;
|
---|
| 2584 | EditTemplates(Self, TRUE, FEditCtrl.SelText);
|
---|
| 2585 | end;
|
---|
| 2586 |
|
---|
| 2587 | procedure TfrmNotes.popNoteListPopup(Sender: TObject);
|
---|
| 2588 | begin
|
---|
| 2589 | inherited;
|
---|
| 2590 | N4.Visible := (popNoteList.PopupComponent is TORTreeView);
|
---|
| 2591 | popNoteListExpandAll.Visible := N4.Visible;
|
---|
| 2592 | popNoteListExpandSelected.Visible := N4.Visible;
|
---|
| 2593 | popNoteListCollapseAll.Visible := N4.Visible;
|
---|
| 2594 | popNoteListCollapseSelected.Visible := N4.Visible;
|
---|
| 2595 | end;
|
---|
| 2596 |
|
---|
| 2597 | procedure TfrmNotes.popNoteListExpandAllClick(Sender: TObject);
|
---|
| 2598 | begin
|
---|
| 2599 | inherited;
|
---|
| 2600 | tvNotes.FullExpand;
|
---|
| 2601 | end;
|
---|
| 2602 |
|
---|
| 2603 | procedure TfrmNotes.popNoteListCollapseAllClick(Sender: TObject);
|
---|
| 2604 | begin
|
---|
| 2605 | inherited;
|
---|
| 2606 | tvNotes.Selected := nil;
|
---|
| 2607 | lvNotes.Items.Clear;
|
---|
| 2608 | memNote.Clear;
|
---|
| 2609 | tvNotes.FullCollapse;
|
---|
| 2610 | tvNotes.Selected := tvNotes.TopItem;
|
---|
| 2611 | end;
|
---|
| 2612 |
|
---|
| 2613 | procedure TfrmNotes.popNoteListExpandSelectedClick(Sender: TObject);
|
---|
| 2614 | begin
|
---|
| 2615 | inherited;
|
---|
| 2616 | if tvNotes.Selected = nil then exit;
|
---|
| 2617 | with tvNotes.Selected do if HasChildren then Expand(True);
|
---|
| 2618 | end;
|
---|
| 2619 |
|
---|
| 2620 | procedure TfrmNotes.popNoteListCollapseSelectedClick(Sender: TObject);
|
---|
| 2621 | begin
|
---|
| 2622 | inherited;
|
---|
| 2623 | if tvNotes.Selected = nil then exit;
|
---|
| 2624 | with tvNotes.Selected do if HasChildren then Collapse(True);
|
---|
| 2625 | end;
|
---|
| 2626 |
|
---|
| 2627 | procedure TfrmNotes.mnuEditTemplatesClick(Sender: TObject);
|
---|
| 2628 | begin
|
---|
| 2629 | inherited;
|
---|
| 2630 | EditTemplates(Self);
|
---|
| 2631 | end;
|
---|
| 2632 |
|
---|
| 2633 | procedure TfrmNotes.mnuNewTemplateClick(Sender: TObject);
|
---|
| 2634 | begin
|
---|
| 2635 | inherited;
|
---|
| 2636 | EditTemplates(Self, TRUE);
|
---|
| 2637 | end;
|
---|
| 2638 |
|
---|
| 2639 | procedure TfrmNotes.mnuEditSharedTemplatesClick(Sender: TObject);
|
---|
| 2640 | begin
|
---|
| 2641 | inherited;
|
---|
| 2642 | EditTemplates(Self, FALSE, '', TRUE);
|
---|
| 2643 | end;
|
---|
| 2644 |
|
---|
| 2645 | procedure TfrmNotes.mnuNewSharedTemplateClick(Sender: TObject);
|
---|
| 2646 | begin
|
---|
| 2647 | inherited;
|
---|
| 2648 | EditTemplates(Self, TRUE, '', TRUE);
|
---|
| 2649 | end;
|
---|
| 2650 |
|
---|
| 2651 | procedure TfrmNotes.mnuOptionsClick(Sender: TObject);
|
---|
| 2652 | begin
|
---|
| 2653 | inherited;
|
---|
| 2654 | mnuEditTemplates.Enabled := frmDrawers.CanEditTemplates;
|
---|
| 2655 | mnuNewTemplate.Enabled := frmDrawers.CanEditTemplates;
|
---|
| 2656 | mnuEditSharedTemplates.Enabled := frmDrawers.CanEditShared;
|
---|
| 2657 | mnuNewSharedTemplate.Enabled := frmDrawers.CanEditShared;
|
---|
| 2658 | mnuEditDialgFields.Enabled := CanEditTemplateFields;
|
---|
| 2659 | end;
|
---|
| 2660 |
|
---|
| 2661 | procedure TfrmNotes.SetEditingIndex(const Value: Integer);
|
---|
| 2662 | begin
|
---|
| 2663 | FEditingIndex := Value;
|
---|
| 2664 | if(FEditingIndex < 0) then
|
---|
| 2665 | KillReminderDialog(Self);
|
---|
| 2666 | if(assigned(frmReminderTree)) then
|
---|
| 2667 | frmReminderTree.EnableActions;
|
---|
| 2668 | end;
|
---|
| 2669 |
|
---|
| 2670 | function TfrmNotes.CanFinishReminder: boolean;
|
---|
| 2671 | begin
|
---|
| 2672 | if(EditingIndex < 0) then
|
---|
| 2673 | Result := FALSE
|
---|
| 2674 | else
|
---|
| 2675 | Result := (lstNotes.ItemIndex = EditingIndex);
|
---|
| 2676 | end;
|
---|
| 2677 |
|
---|
| 2678 | procedure TfrmNotes.FormDestroy(Sender: TObject);
|
---|
| 2679 | begin
|
---|
| 2680 | TAccessibleTreeView.UnwrapControl(tvNotes);
|
---|
| 2681 | FDocList.Free;
|
---|
| 2682 | FImageFlag.Free;
|
---|
| 2683 | KillDocTreeObjects(tvNotes);
|
---|
| 2684 | inherited;
|
---|
| 2685 | end;
|
---|
| 2686 |
|
---|
| 2687 | function TfrmNotes.GetDrawers: TFrmDrawers;
|
---|
| 2688 | begin
|
---|
| 2689 | Result := frmDrawers;
|
---|
| 2690 | end;
|
---|
| 2691 |
|
---|
| 2692 | procedure TfrmNotes.AssignRemForm;
|
---|
| 2693 | begin
|
---|
| 2694 | with RemForm do
|
---|
| 2695 | begin
|
---|
| 2696 | Form := Self;
|
---|
| 2697 | PCEObj := uPCEEdit;
|
---|
| 2698 | RightPanel := pnlRight;
|
---|
| 2699 | CanFinishProc := CanFinishReminder;
|
---|
| 2700 | DisplayPCEProc := DisplayPCE;
|
---|
| 2701 | Drawers := frmDrawers;
|
---|
| 2702 | NewNoteRE := memNewNote;
|
---|
| 2703 | NoteList := lstNotes;
|
---|
| 2704 | end;
|
---|
| 2705 | end;
|
---|
| 2706 |
|
---|
| 2707 | procedure TfrmNotes.mnuEditDialgFieldsClick(Sender: TObject);
|
---|
| 2708 | begin
|
---|
| 2709 | inherited;
|
---|
| 2710 | EditDialogFields;
|
---|
| 2711 | end;
|
---|
| 2712 |
|
---|
| 2713 | //=================== Added for sort/search enhancements ======================
|
---|
| 2714 | procedure TfrmNotes.LoadNotes;
|
---|
| 2715 | var
|
---|
| 2716 | tmpList: TStringList;
|
---|
| 2717 | ANode: TORTreeNode;
|
---|
| 2718 | begin
|
---|
| 2719 | tmpList := TStringList.Create;
|
---|
| 2720 | try
|
---|
| 2721 | FDocList.Clear;
|
---|
| 2722 | uChanging := True;
|
---|
| 2723 | RedrawSuspend(memNote.Handle);
|
---|
| 2724 | RedrawSuspend(lvNotes.Handle);
|
---|
| 2725 | tvNotes.Items.BeginUpdate;
|
---|
| 2726 | lstNotes.Items.Clear;
|
---|
| 2727 | KillDocTreeObjects(tvNotes);
|
---|
| 2728 | tvNotes.Items.Clear;
|
---|
| 2729 | tvNotes.Items.EndUpdate;
|
---|
| 2730 | lvNotes.Items.Clear;
|
---|
| 2731 | memNote.Clear;
|
---|
| 2732 | memNote.Invalidate;
|
---|
| 2733 | lblTitle.Caption := '';
|
---|
| 2734 | lvNotes.Caption := '';
|
---|
| 2735 | with FCurrentContext do
|
---|
| 2736 | begin
|
---|
| 2737 | if Status <> IntToStr(NC_UNSIGNED) then
|
---|
| 2738 | begin
|
---|
| 2739 | ListNotesForTree(tmpList, NC_UNSIGNED, 0, 0, 0, 0, TreeAscending);
|
---|
| 2740 | if tmpList.Count > 0 then
|
---|
| 2741 | begin
|
---|
| 2742 | CreateListItemsforDocumentTree(FDocList, tmpList, NC_UNSIGNED, GroupBy, TreeAscending, CT_NOTES);
|
---|
| 2743 | UpdateTreeView(FDocList, tvNotes);
|
---|
| 2744 | end;
|
---|
| 2745 | tmpList.Clear;
|
---|
| 2746 | FDocList.Clear;
|
---|
| 2747 | end;
|
---|
| 2748 | if Status <> IntToStr(NC_UNCOSIGNED) then
|
---|
| 2749 | begin
|
---|
| 2750 | ListNotesForTree(tmpList, NC_UNCOSIGNED, 0, 0, 0, 0, TreeAscending);
|
---|
| 2751 | if tmpList.Count > 0 then
|
---|
| 2752 | begin
|
---|
| 2753 | CreateListItemsforDocumentTree(FDocList, tmpList, NC_UNCOSIGNED, GroupBy, TreeAscending, CT_NOTES);
|
---|
| 2754 | UpdateTreeView(FDocList, tvNotes);
|
---|
| 2755 | end;
|
---|
| 2756 | tmpList.Clear;
|
---|
| 2757 | FDocList.Clear;
|
---|
| 2758 | end;
|
---|
| 2759 | ListNotesForTree(tmpList, StrToIntDef(Status, 0), FMBeginDate, FMEndDate, Author, MaxDocs, TreeAscending);
|
---|
| 2760 | CreateListItemsforDocumentTree(FDocList, tmpList, StrToIntDef(Status, 0), GroupBy, TreeAscending, CT_NOTES);
|
---|
| 2761 | UpdateTreeView(FDocList, tvNotes);
|
---|
| 2762 | end;
|
---|
| 2763 | with tvNotes do
|
---|
| 2764 | begin
|
---|
| 2765 | uChanging := True;
|
---|
| 2766 | tvNotes.Items.BeginUpdate;
|
---|
| 2767 | RemoveParentsWithNoChildren(tvNotes, FCurrentContext); // moved here in v15.9 (RV)
|
---|
| 2768 | if FLastNoteID <> '' then
|
---|
| 2769 | Selected := FindPieceNode(FLastNoteID, 1, U, nil);
|
---|
| 2770 | if Selected = nil then
|
---|
| 2771 | begin
|
---|
| 2772 | if (FCurrentContext.GroupBy <> '') or (FCurrentContext.Filtered) then
|
---|
| 2773 | begin
|
---|
| 2774 | ANode := TORTreeNode(Items.GetFirstNode);
|
---|
| 2775 | while ANode <> nil do
|
---|
| 2776 | begin
|
---|
| 2777 | ANode.Expand(False);
|
---|
| 2778 | Selected := ANode;
|
---|
| 2779 | ANode := TORTreeNode(ANode.GetNextSibling);
|
---|
| 2780 | end;
|
---|
| 2781 | end
|
---|
| 2782 | else
|
---|
| 2783 | begin
|
---|
| 2784 | ANode := tvNotes.FindPieceNode(FCurrentContext.Status, 1, U, nil);
|
---|
| 2785 | if ANode <> nil then ANode.Expand(False);
|
---|
| 2786 | ANode := tvNotes.FindPieceNode(IntToStr(NC_UNSIGNED), 1, U, nil);
|
---|
| 2787 | if ANode = nil then
|
---|
| 2788 | ANode := tvNotes.FindPieceNode(IntToStr(NC_UNCOSIGNED), 1, U, nil);
|
---|
| 2789 | if ANode = nil then
|
---|
| 2790 | ANode := tvNotes.FindPieceNode(FCurrentContext.Status, 1, U, nil);
|
---|
| 2791 | if ANode <> nil then
|
---|
| 2792 | begin
|
---|
| 2793 | if ANode.getFirstChild <> nil then
|
---|
| 2794 | Selected := ANode.getFirstChild
|
---|
| 2795 | else
|
---|
| 2796 | Selected := ANode;
|
---|
| 2797 | end;
|
---|
| 2798 | end;
|
---|
| 2799 | end;
|
---|
| 2800 | memNote.Clear;
|
---|
| 2801 | with lvNotes do
|
---|
| 2802 | begin
|
---|
| 2803 | Selected := nil;
|
---|
| 2804 | if FCurrentContext.SortBy <> '' then
|
---|
| 2805 | ColumnToSort := Pos(FCurrentContext.SortBy, 'RDSAL') - 1;
|
---|
| 2806 | if not FCurrentContext.ShowSubject then
|
---|
| 2807 | begin
|
---|
| 2808 | Columns[1].Width := 2 * (Width div 5);
|
---|
| 2809 | Columns[2].Width := 0;
|
---|
| 2810 | end
|
---|
| 2811 | else
|
---|
| 2812 | begin
|
---|
| 2813 | Columns[1].Width := Width div 5;
|
---|
| 2814 | Columns[2].Width := Columns[1].Width;
|
---|
| 2815 | end;
|
---|
| 2816 | end;
|
---|
| 2817 | //RemoveParentsWithNoChildren(tvNotes, FCurrentContext); // moved FROM here in v15.9 (RV)
|
---|
| 2818 | tvNotes.Items.EndUpdate;
|
---|
| 2819 | uChanging := False;
|
---|
| 2820 | SendMessage(tvNotes.Handle, WM_VSCROLL, SB_TOP, 0);
|
---|
| 2821 | if Selected <> nil then tvNotesChange(Self, Selected);
|
---|
| 2822 | end;
|
---|
| 2823 | finally
|
---|
| 2824 | RedrawActivate(memNote.Handle);
|
---|
| 2825 | RedrawActivate(lvNotes.Handle);
|
---|
| 2826 | tmpList.Free;
|
---|
| 2827 | end;
|
---|
| 2828 | end;
|
---|
| 2829 |
|
---|
| 2830 | procedure TfrmNotes.UpdateTreeView(DocList: TStringList; Tree: TORTreeView);
|
---|
| 2831 | begin
|
---|
| 2832 | with Tree do
|
---|
| 2833 | begin
|
---|
| 2834 | uChanging := True;
|
---|
| 2835 | Items.BeginUpdate;
|
---|
| 2836 | lstNotes.Items.AddStrings(DocList);
|
---|
| 2837 | BuildDocumentTree(DocList, '0', Tree, nil, FCurrentContext, CT_NOTES);
|
---|
| 2838 | Items.EndUpdate;
|
---|
| 2839 | uChanging := False;
|
---|
| 2840 | end;
|
---|
| 2841 | end;
|
---|
| 2842 |
|
---|
| 2843 | procedure TfrmNotes.tvNotesChange(Sender: TObject; Node: TTreeNode);
|
---|
| 2844 | var
|
---|
| 2845 | x, MySearch, MyNodeID: string;
|
---|
| 2846 | i: integer;
|
---|
| 2847 | WhyNot: string;
|
---|
| 2848 | begin
|
---|
| 2849 | if uChanging then Exit;
|
---|
| 2850 | //This gives the change a chance to occur when keyboarding, so that WindowEyes
|
---|
| 2851 | //doesn't use the old value.
|
---|
| 2852 | Application.ProcessMessages;
|
---|
| 2853 | with tvNotes do
|
---|
| 2854 | begin
|
---|
| 2855 | memNote.Clear;
|
---|
| 2856 | if Selected = nil then Exit;
|
---|
| 2857 | if uIDNotesActive then
|
---|
| 2858 | begin
|
---|
| 2859 | mnuActDetachFromIDParent.Enabled := (Selected.ImageIndex in [IMG_ID_CHILD, IMG_ID_CHILD_ADD]);
|
---|
| 2860 | popNoteListDetachFromIDParent.Enabled := mnuActDetachFromIDParent.Enabled;
|
---|
| 2861 | if (Selected.ImageIndex in [IMG_SINGLE, IMG_PARENT, IMG_ID_CHILD, IMG_ID_CHILD_ADD]) then
|
---|
| 2862 | mnuActAttachtoIDParent.Enabled := CanBeAttached(PDocTreeObject(Selected.Data)^.DocID, WhyNot)
|
---|
| 2863 | else
|
---|
| 2864 | mnuActAttachtoIDParent.Enabled := False;
|
---|
| 2865 | popNoteListAttachtoIDParent.Enabled := mnuActAttachtoIDParent.Enabled;
|
---|
| 2866 | if (Selected.ImageIndex in [IMG_SINGLE, IMG_PARENT,
|
---|
| 2867 | IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT,
|
---|
| 2868 | IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT]) then
|
---|
| 2869 | mnuActAddIDEntry.Enabled := CanReceiveAttachment(PDocTreeObject(Selected.Data)^.DocID, WhyNot)
|
---|
| 2870 | else
|
---|
| 2871 | mnuActAddIDEntry.Enabled := False;
|
---|
| 2872 | popNoteListAddIDEntry.Enabled := mnuActAddIDEntry.Enabled
|
---|
| 2873 | end;
|
---|
| 2874 | RedrawSuspend(lvNotes.Handle);
|
---|
| 2875 | RedrawSuspend(memNote.Handle);
|
---|
| 2876 | popNoteListExpandSelected.Enabled := Selected.HasChildren;
|
---|
| 2877 | popNoteListCollapseSelected.Enabled := Selected.HasChildren;
|
---|
| 2878 | x := TORTreeNode(Selected).StringData;
|
---|
| 2879 | if (Selected.ImageIndex in [IMG_TOP_LEVEL, IMG_GROUP_OPEN, IMG_GROUP_SHUT]) then
|
---|
| 2880 | begin
|
---|
| 2881 | lvNotes.Visible := True;
|
---|
| 2882 | lvNotes.Items.Clear;
|
---|
| 2883 | lvNotes.Height := (2 * lvNotes.Parent.Height) div 5;
|
---|
| 2884 | with lblTitle do
|
---|
| 2885 | begin
|
---|
| 2886 | Caption := Trim(Selected.Text);
|
---|
| 2887 | if (FCurrentContext.SearchField <> '') and (FCurrentContext.Filtered) then
|
---|
| 2888 | begin
|
---|
| 2889 | case FCurrentContext.SearchField[1] of
|
---|
| 2890 | 'T': MySearch := 'TITLE';
|
---|
| 2891 | 'S': MySearch := 'SUBJECT';
|
---|
| 2892 | 'B': MySearch := 'TITLE or SUBJECT';
|
---|
| 2893 | end;
|
---|
| 2894 | Caption := Caption + ' where ' + MySearch + ' contains "' + UpperCase(FCurrentContext.Keyword) + '"';
|
---|
| 2895 | end;
|
---|
| 2896 | lvNotes.Caption := Caption;
|
---|
| 2897 | end;
|
---|
| 2898 |
|
---|
| 2899 | if Selected.ImageIndex = IMG_TOP_LEVEL then
|
---|
| 2900 | MyNodeID := Piece(TORTreeNode(Selected).StringData, U, 1)
|
---|
| 2901 | else if Selected.Parent.ImageIndex = IMG_TOP_LEVEL then
|
---|
| 2902 | MyNodeID := Piece(TORTreeNode(Selected.Parent).StringData, U, 1)
|
---|
| 2903 | else if Selected.Parent.Parent.ImageIndex = IMG_TOP_LEVEL then
|
---|
| 2904 | MyNodeID := Piece(TORTreeNode(Selected.Parent.Parent).StringData, U, 1);
|
---|
| 2905 |
|
---|
| 2906 | uChanging := True;
|
---|
| 2907 | TraverseTree(tvNotes, lvNotes, Selected.GetFirstChild, MyNodeID, FCurrentContext);
|
---|
| 2908 | with lvNotes do
|
---|
| 2909 | begin
|
---|
| 2910 | for i := 0 to Columns.Count - 1 do
|
---|
| 2911 | Columns[i].ImageIndex := IMG_NONE;
|
---|
| 2912 | ColumnSortForward := FCurrentContext.ListAscending;
|
---|
| 2913 | if ColumnToSort = 5 then ColumnToSort := 0;
|
---|
| 2914 | if ColumnSortForward then
|
---|
| 2915 | Columns[ColumnToSort].ImageIndex := IMG_ASCENDING
|
---|
| 2916 | else
|
---|
| 2917 | Columns[ColumnToSort].ImageIndex := IMG_DESCENDING;
|
---|
| 2918 | if ColumnToSort = 0 then ColumnToSort := 5;
|
---|
| 2919 | AlphaSort;
|
---|
| 2920 | Columns[5].Width := 0;
|
---|
| 2921 | Columns[6].Width := 0;
|
---|
| 2922 | end;
|
---|
| 2923 | uChanging := False;
|
---|
| 2924 | with lvNotes do
|
---|
| 2925 | if Items.Count > 0 then
|
---|
| 2926 | begin
|
---|
| 2927 | Selected := Items[0];
|
---|
| 2928 | lvNotesSelectItem(Self, Selected, True);
|
---|
| 2929 | end
|
---|
| 2930 | else
|
---|
| 2931 | begin
|
---|
| 2932 | Selected := nil;
|
---|
| 2933 | lstNotes.ItemIndex := -1;
|
---|
| 2934 | memPCEShow.Clear;
|
---|
| 2935 | ShowPCEControls(False);
|
---|
| 2936 | end;
|
---|
| 2937 | pnlWrite.Visible := False;
|
---|
| 2938 | pnlRead.Visible := True;
|
---|
| 2939 | // uncommented next 4 lines in v17.5 (RV)
|
---|
| 2940 | //-----------------------------
|
---|
| 2941 | UpdateReminderFinish;
|
---|
| 2942 | ShowPCEControls(False);
|
---|
| 2943 | frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]); //FALSE);
|
---|
| 2944 | ShowPCEButtons(FALSE);
|
---|
| 2945 | //-----------------------------
|
---|
| 2946 | //memNote.Clear;
|
---|
| 2947 | end
|
---|
| 2948 | else if StrToIntDef(Piece(x, U, 1), 0) > 0 then
|
---|
| 2949 | begin
|
---|
| 2950 | memNote.Clear;
|
---|
| 2951 | lvNotes.Visible := False;
|
---|
| 2952 | lstNotes.SelectByID(Piece(x, U, 1));
|
---|
| 2953 | lstNotesClick(Self);
|
---|
| 2954 | SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
|
---|
| 2955 | end;
|
---|
| 2956 | SendMessage(tvNotes.Handle, WM_HSCROLL, SB_THUMBTRACK, 0);
|
---|
| 2957 | RedrawActivate(lvNotes.Handle);
|
---|
| 2958 | RedrawActivate(memNote.Handle);
|
---|
| 2959 | end;
|
---|
| 2960 | end;
|
---|
| 2961 |
|
---|
| 2962 | procedure TfrmNotes.tvNotesCollapsed(Sender: TObject; Node: TTreeNode);
|
---|
| 2963 | begin
|
---|
| 2964 | with Node do
|
---|
| 2965 | begin
|
---|
| 2966 | if (ImageIndex in [IMG_GROUP_OPEN, IMG_IDNOTE_OPEN, IMG_IDPAR_ADDENDA_OPEN]) then
|
---|
| 2967 | ImageIndex := ImageIndex - 1;
|
---|
| 2968 | if (SelectedIndex in [IMG_GROUP_OPEN, IMG_IDNOTE_OPEN, IMG_IDPAR_ADDENDA_OPEN]) then
|
---|
| 2969 | SelectedIndex := SelectedIndex - 1;
|
---|
| 2970 | end;
|
---|
| 2971 | end;
|
---|
| 2972 |
|
---|
| 2973 | procedure TfrmNotes.tvNotesExpanded(Sender: TObject; Node: TTreeNode);
|
---|
| 2974 |
|
---|
| 2975 | function SortByTitle(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall;
|
---|
| 2976 | begin
|
---|
| 2977 | { Within an ID parent node, sorts in ascending order by title
|
---|
| 2978 | BUT - addenda to parent document are always at the top of the sort, in date order}
|
---|
| 2979 | if (Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum') and
|
---|
| 2980 | (Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum') then
|
---|
| 2981 | begin
|
---|
| 2982 | Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
|
---|
| 2983 | PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
|
---|
| 2984 | end
|
---|
| 2985 | else if Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := -1
|
---|
| 2986 | else if Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := 1
|
---|
| 2987 | else
|
---|
| 2988 | begin
|
---|
| 2989 | if Data = 0 then
|
---|
| 2990 | Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocTitle),
|
---|
| 2991 | PChar(PDocTreeObject(Node2.Data)^.DocTitle))
|
---|
| 2992 | else
|
---|
| 2993 | Result := -AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocTitle),
|
---|
| 2994 | PChar(PDocTreeObject(Node2.Data)^.DocTitle));
|
---|
| 2995 | end
|
---|
| 2996 | end;
|
---|
| 2997 |
|
---|
| 2998 | function SortByDate(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall;
|
---|
| 2999 | begin
|
---|
| 3000 | { Within an ID parent node, sorts in ascending order by document date
|
---|
| 3001 | BUT - addenda to parent document are always at the top of the sort, in date order}
|
---|
| 3002 | if (Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum') and
|
---|
| 3003 | (Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum') then
|
---|
| 3004 | begin
|
---|
| 3005 | Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
|
---|
| 3006 | PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
|
---|
| 3007 | end
|
---|
| 3008 | else if Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := -1
|
---|
| 3009 | else if Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := 1
|
---|
| 3010 | else
|
---|
| 3011 | begin
|
---|
| 3012 | if Data = 0 then
|
---|
| 3013 | Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
|
---|
| 3014 | PChar(PDocTreeObject(Node2.Data)^.DocFMDate))
|
---|
| 3015 | else
|
---|
| 3016 | Result := -AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
|
---|
| 3017 | PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
|
---|
| 3018 | end;
|
---|
| 3019 | end;
|
---|
| 3020 |
|
---|
| 3021 | begin
|
---|
| 3022 | with Node do
|
---|
| 3023 | begin
|
---|
| 3024 | if Assigned(Data) then
|
---|
| 3025 | if (Pos('<', PDocTreeObject(Data)^.DocHasChildren) > 0) then
|
---|
| 3026 | begin
|
---|
| 3027 | if (PDocTreeObject(Node.Data)^.OrderByTitle) then
|
---|
| 3028 | CustomSort(@SortByTitle, 0)
|
---|
| 3029 | else
|
---|
| 3030 | CustomSort(@SortByDate, 0);
|
---|
| 3031 | end;
|
---|
| 3032 | if (ImageIndex in [IMG_GROUP_SHUT, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_SHUT]) then
|
---|
| 3033 | ImageIndex := ImageIndex + 1;
|
---|
| 3034 | if (SelectedIndex in [IMG_GROUP_SHUT, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_SHUT]) then
|
---|
| 3035 | SelectedIndex := SelectedIndex + 1;
|
---|
| 3036 | end;
|
---|
| 3037 | end;
|
---|
| 3038 |
|
---|
| 3039 | procedure TfrmNotes.tvNotesClick(Sender: TObject);
|
---|
| 3040 | begin
|
---|
| 3041 | (* if tvNotes.Selected = nil then exit;
|
---|
| 3042 | if (tvNotes.Selected.ImageIndex in [IMG_TOP_LEVEL, IMG_GROUP_OPEN, IMG_GROUP_SHUT]) then
|
---|
| 3043 | begin
|
---|
| 3044 | uChanging := True;
|
---|
| 3045 | lvNotes.Selected := nil;
|
---|
| 3046 | uChanging := False;
|
---|
| 3047 | memNote.Clear;
|
---|
| 3048 | end;*)
|
---|
| 3049 | end;
|
---|
| 3050 |
|
---|
| 3051 | procedure TfrmNotes.tvNotesDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
|
---|
| 3052 | var
|
---|
| 3053 | AnItem: TORTreeNode;
|
---|
| 3054 | begin
|
---|
| 3055 | Accept := False;
|
---|
| 3056 | if not uIDNotesActive then exit;
|
---|
| 3057 | AnItem := TORTreeNode(tvNotes.GetNodeAt(X, Y));
|
---|
| 3058 | if (AnItem = nil) or (AnItem.ImageIndex in [IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) then Exit;
|
---|
| 3059 | with tvNotes.Selected do
|
---|
| 3060 | if (ImageIndex in [IMG_SINGLE, IMG_PARENT, IMG_ID_CHILD, IMG_ID_CHILD_ADD]) then
|
---|
| 3061 | Accept := (AnItem.ImageIndex in [IMG_SINGLE, IMG_PARENT,
|
---|
| 3062 | IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT,
|
---|
| 3063 | IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT])
|
---|
| 3064 | else if (ImageIndex in [IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT]) then
|
---|
| 3065 | Accept := (AnItem.ImageIndex in [IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL])
|
---|
| 3066 | else if (ImageIndex in [IMG_ADDENDUM, IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) then
|
---|
| 3067 | Accept := False;
|
---|
| 3068 | end;
|
---|
| 3069 |
|
---|
| 3070 | procedure TfrmNotes.tvNotesDragDrop(Sender, Source: TObject; X, Y: Integer);
|
---|
| 3071 | var
|
---|
| 3072 | HT: THitTests;
|
---|
| 3073 | Saved: boolean;
|
---|
| 3074 | ADestNode: TORTreeNode;
|
---|
| 3075 | begin
|
---|
| 3076 | if not uIDNotesActive then
|
---|
| 3077 | begin
|
---|
| 3078 | CancelDrag;
|
---|
| 3079 | exit;
|
---|
| 3080 | end;
|
---|
| 3081 | if tvNotes.Selected = nil then exit;
|
---|
| 3082 | if EditingIndex <> -1 then
|
---|
| 3083 | begin
|
---|
| 3084 | SaveCurrentNote(Saved);
|
---|
| 3085 | if not Saved then Exit;
|
---|
| 3086 | end;
|
---|
| 3087 | HT := tvNotes.GetHitTestInfoAt(X, Y);
|
---|
| 3088 | ADestNode := TORTreeNode(tvNotes.GetNodeAt(X, Y));
|
---|
| 3089 | DoAttachIDChild(TORTreeNode(tvNotes.Selected), ADestNode);
|
---|
| 3090 | end;
|
---|
| 3091 |
|
---|
| 3092 | procedure TfrmNotes.tvNotesStartDrag(Sender: TObject; var DragObject: TDragObject);
|
---|
| 3093 | const
|
---|
| 3094 | TX_CAP_NO_DRAG = 'Item cannot be moved';
|
---|
| 3095 | TX_NO_EDIT_DRAG = 'Items can not be dragged while a note is being edited.';
|
---|
| 3096 | var
|
---|
| 3097 | WhyNot: string;
|
---|
| 3098 | begin
|
---|
| 3099 | if EditingIndex <> -1 then
|
---|
| 3100 | begin
|
---|
| 3101 | InfoBox(TX_NO_EDIT_DRAG, TX_CAP_NO_DRAG, MB_ICONERROR or MB_OK);
|
---|
| 3102 | CancelDrag;
|
---|
| 3103 | Exit;
|
---|
| 3104 | end;
|
---|
| 3105 | if (tvNotes.Selected.ImageIndex in [IMG_ADDENDUM, IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) or
|
---|
| 3106 | (not uIDNotesActive) or
|
---|
| 3107 | (lstNotes.ItemIEN = 0) then
|
---|
| 3108 | begin
|
---|
| 3109 | CancelDrag;
|
---|
| 3110 | Exit;
|
---|
| 3111 | end;
|
---|
| 3112 | (* if EditingIndex <> -1 then
|
---|
| 3113 | begin
|
---|
| 3114 | SaveCurrentNote(Saved);
|
---|
| 3115 | if not Saved then Exit;
|
---|
| 3116 | end;*)
|
---|
| 3117 | if not CanBeAttached(PDocTreeObject(tvNotes.Selected.Data)^.DocID, WhyNot) then
|
---|
| 3118 | begin
|
---|
| 3119 | InfoBox(WhyNot, TX_CAP_NO_DRAG, MB_OK);
|
---|
| 3120 | CancelDrag;
|
---|
| 3121 | end;
|
---|
| 3122 | end;
|
---|
| 3123 |
|
---|
| 3124 | //===================== Listview events =================================
|
---|
| 3125 |
|
---|
| 3126 | procedure TfrmNotes.lvNotesColumnClick(Sender: TObject; Column: TListColumn);
|
---|
| 3127 | var
|
---|
| 3128 | i, ClickedColumn: Integer;
|
---|
| 3129 | begin
|
---|
| 3130 | if Column.Index = 0 then ClickedColumn := 5 else ClickedColumn := Column.Index;
|
---|
| 3131 | if ClickedColumn = ColumnToSort then
|
---|
| 3132 | ColumnSortForward := not ColumnSortForward
|
---|
| 3133 | else
|
---|
| 3134 | ColumnSortForward := True;
|
---|
| 3135 | for i := 0 to lvNotes.Columns.Count - 1 do
|
---|
| 3136 | lvNotes.Columns[i].ImageIndex := IMG_NONE;
|
---|
| 3137 | if ColumnSortForward then lvNotes.Columns[Column.Index].ImageIndex := IMG_ASCENDING
|
---|
| 3138 | else lvNotes.Columns[Column.Index].ImageIndex := IMG_DESCENDING;
|
---|
| 3139 | ColumnToSort := ClickedColumn;
|
---|
| 3140 | case ColumnToSort of
|
---|
| 3141 | 5: FCurrentContext.SortBy := 'R';
|
---|
| 3142 | 1: FCurrentContext.SortBy := 'D';
|
---|
| 3143 | 2: FCurrentContext.SortBy := 'S';
|
---|
| 3144 | 3: FCurrentContext.SortBy := 'A';
|
---|
| 3145 | 4: FCurrentContext.SortBy := 'L';
|
---|
| 3146 | else
|
---|
| 3147 | FCurrentContext.SortBy := 'R';
|
---|
| 3148 | end;
|
---|
| 3149 | FCurrentContext.ListAscending := ColumnSortForward;
|
---|
| 3150 | (Sender as TCustomListView).AlphaSort;
|
---|
| 3151 | //with lvNotes do if Selected <> nil then Scroll(0, Selected.Top - TopItem.Top);
|
---|
| 3152 | end;
|
---|
| 3153 |
|
---|
| 3154 | procedure TfrmNotes.lvNotesCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
|
---|
| 3155 | var
|
---|
| 3156 | ix: Integer;
|
---|
| 3157 | begin
|
---|
| 3158 | if ColumnToSort = 0 then
|
---|
| 3159 | Compare := CompareText(Item1.Caption,Item2.Caption)
|
---|
| 3160 | else begin
|
---|
| 3161 | ix := ColumnToSort - 1;
|
---|
| 3162 | Compare := CompareText(Item1.SubItems[ix],Item2.SubItems[ix]);
|
---|
| 3163 | end;
|
---|
| 3164 | if not ColumnSortForward then Compare := -Compare;
|
---|
| 3165 | end;
|
---|
| 3166 |
|
---|
| 3167 | procedure TfrmNotes.lvNotesSelectItem(Sender: TObject; Item: TListItem;
|
---|
| 3168 | Selected: Boolean);
|
---|
| 3169 | begin
|
---|
| 3170 | if uChanging or (not Selected) then Exit;
|
---|
| 3171 | with lvNotes do
|
---|
| 3172 | begin
|
---|
| 3173 | StatusText('Retrieving selected progress note...');
|
---|
| 3174 | lstNotes.SelectByID(Item.SubItems[5]);
|
---|
| 3175 | lstNotesClick(Self);
|
---|
| 3176 | SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
|
---|
| 3177 | end;
|
---|
| 3178 | end;
|
---|
| 3179 |
|
---|
| 3180 | procedure TfrmNotes.lvNotesResize(Sender: TObject);
|
---|
| 3181 | begin
|
---|
| 3182 | inherited;
|
---|
| 3183 | with lvNotes do
|
---|
| 3184 | begin
|
---|
| 3185 | if not FCurrentContext.ShowSubject then
|
---|
| 3186 | begin
|
---|
| 3187 | Columns[1].Width := 2 * (Width div 5);
|
---|
| 3188 | Columns[2].Width := 0;
|
---|
| 3189 | end
|
---|
| 3190 | else
|
---|
| 3191 | begin
|
---|
| 3192 | Columns[1].Width := Width div 5;
|
---|
| 3193 | Columns[2].Width := Columns[1].Width;
|
---|
| 3194 | end;
|
---|
| 3195 | end;
|
---|
| 3196 | end;
|
---|
| 3197 |
|
---|
| 3198 | procedure TfrmNotes.EnableDisableIDNotes;
|
---|
| 3199 | begin
|
---|
| 3200 | uIDNotesActive := IDNotesInstalled;
|
---|
| 3201 | mnuActDetachFromIDParent.Visible := uIDNotesActive;
|
---|
| 3202 | popNoteListDetachFromIDParent.Visible := uIDNotesActive;
|
---|
| 3203 | mnuActAddIDEntry.Visible := uIDNotesActive;
|
---|
| 3204 | popNoteListAddIDEntry.Visible := uIDNotesActive;
|
---|
| 3205 | mnuActAttachtoIDParent.Visible := uIDNotesActive;
|
---|
| 3206 | popNoteListAttachtoIDParent.Visible := uIDNotesActive;
|
---|
| 3207 | if uIDNotesActive then
|
---|
| 3208 | tvNotes.DragMode := dmAutomatic
|
---|
| 3209 | else
|
---|
| 3210 | tvNotes.DragMode := dmManual;
|
---|
| 3211 | end;
|
---|
| 3212 |
|
---|
| 3213 | procedure TfrmNotes.ShowPCEButtons(Editing: boolean);
|
---|
| 3214 | begin
|
---|
| 3215 | FEditingNotePCEObj := Editing;
|
---|
| 3216 | if Editing or AnytimeEncounters then
|
---|
| 3217 | begin
|
---|
| 3218 | cmdPCE.Visible := TRUE;
|
---|
| 3219 | if Editing then
|
---|
| 3220 | begin
|
---|
| 3221 | cmdPCE.Enabled := CanEditPCE(uPCEEdit);
|
---|
| 3222 | cmdNewNote.Visible := AnytimeEncounters;
|
---|
| 3223 | cmdNewNote.Enabled := FALSE;
|
---|
| 3224 | end
|
---|
| 3225 | else
|
---|
| 3226 | begin
|
---|
| 3227 | cmdPCE.Enabled := (GetAskPCE(0) <> apDisable);
|
---|
| 3228 | cmdNewNote.Visible := TRUE;
|
---|
| 3229 | cmdNewNote.Enabled := (FStarting = False); //TRUE;
|
---|
| 3230 | end;
|
---|
| 3231 | if cmdNewNote.Visible then
|
---|
| 3232 | cmdPCE.Top := cmdNewNote.Top-cmdPCE.Height;
|
---|
| 3233 | end
|
---|
| 3234 | else
|
---|
| 3235 | begin
|
---|
| 3236 | cmdPCE.Enabled := FALSE;
|
---|
| 3237 | cmdPCE.Visible := FALSE;
|
---|
| 3238 | cmdNewNote.Visible := TRUE;
|
---|
| 3239 | cmdNewNote.Enabled := (FStarting = False); //TRUE;
|
---|
| 3240 | end;
|
---|
| 3241 | if cmdPCE.Visible then
|
---|
| 3242 | lblSpace1.Top := cmdPCE.Top - lblSpace1.Height
|
---|
| 3243 | else
|
---|
| 3244 | lblSpace1.Top := cmdNewNote.Top - lblSpace1.Height;
|
---|
| 3245 | popNoteMemoEncounter.Enabled := cmdPCE.Enabled;
|
---|
| 3246 | popNoteMemoEncounter.Visible := cmdPCE.Visible;
|
---|
| 3247 | end;
|
---|
| 3248 |
|
---|
| 3249 | procedure TfrmNotes.mnuIconLegendClick(Sender: TObject);
|
---|
| 3250 | begin
|
---|
| 3251 | inherited;
|
---|
| 3252 | ShowIconLegend(ilNotes);
|
---|
| 3253 | end;
|
---|
| 3254 |
|
---|
| 3255 | procedure TfrmNotes.mnuActAttachtoIDParentClick(Sender: TObject);
|
---|
| 3256 | var
|
---|
| 3257 | AChildNode: TORTreeNode;
|
---|
| 3258 | AParentID: string;
|
---|
| 3259 | SavedDocID: string;
|
---|
| 3260 | Saved: boolean;
|
---|
| 3261 | begin
|
---|
| 3262 | inherited;
|
---|
| 3263 | if not uIDNotesActive then exit;
|
---|
| 3264 | if lstNotes.ItemIEN = 0 then exit;
|
---|
| 3265 | SavedDocID := lstNotes.ItemID;
|
---|
| 3266 | if EditingIndex <> -1 then
|
---|
| 3267 | begin
|
---|
| 3268 | SaveCurrentNote(Saved);
|
---|
| 3269 | if not Saved then Exit;
|
---|
| 3270 | LoadNotes;
|
---|
| 3271 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 3272 | end;
|
---|
| 3273 | if tvNotes.Selected = nil then exit;
|
---|
| 3274 | AChildNode := TORTreeNode(tvNotes.Selected);
|
---|
| 3275 | AParentID := SelectParentNodeFromList(tvNotes);
|
---|
| 3276 | if AParentID = '' then exit;
|
---|
| 3277 | with tvNotes do Selected := FindPieceNode(AParentID, 1, U, Items.GetFirstNode);
|
---|
| 3278 | DoAttachIDChild(AChildNode, TORTreeNode(tvNotes.Selected));
|
---|
| 3279 | end;
|
---|
| 3280 |
|
---|
| 3281 | procedure TfrmNotes.DoAttachIDChild(AChild, AParent: TORTreeNode);
|
---|
| 3282 | const
|
---|
| 3283 | TX_ATTACH_CNF = 'Confirm Attachment';
|
---|
| 3284 | TX_ATTACH_FAILURE = 'Attachment failed';
|
---|
| 3285 | var
|
---|
| 3286 | ErrMsg, WhyNot: string;
|
---|
| 3287 | SavedDocID: string;
|
---|
| 3288 | begin
|
---|
| 3289 | if (AChild = nil) or (AParent = nil) then exit;
|
---|
| 3290 | ErrMsg := '';
|
---|
| 3291 | if not CanBeAttached(PDocTreeObject(AChild.Data)^.DocID, WhyNot) then
|
---|
| 3292 | ErrMsg := ErrMsg + WhyNot + CRLF + CRLF;
|
---|
| 3293 | if not CanReceiveAttachment(PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
|
---|
| 3294 | ErrMsg := ErrMsg + WhyNot;
|
---|
| 3295 | if ErrMsg <> '' then
|
---|
| 3296 | begin
|
---|
| 3297 | InfoBox(ErrMsg, TX_ATTACH_FAILURE, MB_OK);
|
---|
| 3298 | Exit;
|
---|
| 3299 | end
|
---|
| 3300 | else
|
---|
| 3301 | begin
|
---|
| 3302 | WhyNot := '';
|
---|
| 3303 | if (InfoBox('ATTACH: ' + AChild.Text + CRLF + CRLF +
|
---|
| 3304 | ' TO: ' + AParent.Text + CRLF + CRLF +
|
---|
| 3305 | 'Are you sure?', TX_ATTACH_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES)
|
---|
| 3306 | then Exit;
|
---|
| 3307 | SavedDocID := PDocTreeObject(AParent.Data)^.DocID;
|
---|
| 3308 | end;
|
---|
| 3309 | if AChild.ImageIndex in [IMG_ID_CHILD, IMG_ID_CHILD_ADD] then
|
---|
| 3310 | begin
|
---|
| 3311 | if DetachEntryFromParent(PDocTreeObject(AChild.Data)^.DocID, WhyNot) then
|
---|
| 3312 | begin
|
---|
| 3313 | if AttachEntryToParent(PDocTreeObject(AChild.Data)^.DocID, PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
|
---|
| 3314 | begin
|
---|
| 3315 | LoadNotes;
|
---|
| 3316 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 3317 | if tvNotes.Selected <> nil then tvNotes.Selected.Expand(False);
|
---|
| 3318 | end
|
---|
| 3319 | else
|
---|
| 3320 | InfoBox(WhyNot, TX_ATTACH_FAILURE, MB_OK);
|
---|
| 3321 | end
|
---|
| 3322 | else
|
---|
| 3323 | begin
|
---|
| 3324 | WhyNot := StringReplace(WhyNot, 'ATTACH', 'DETACH', [rfIgnoreCase]);
|
---|
| 3325 | WhyNot := StringReplace(WhyNot, 'to an ID', 'from an ID', [rfIgnoreCase]);
|
---|
| 3326 | InfoBox(WhyNot, TX_DETACH_FAILURE, MB_OK);
|
---|
| 3327 | Exit;
|
---|
| 3328 | end;
|
---|
| 3329 | end
|
---|
| 3330 | else
|
---|
| 3331 | begin
|
---|
| 3332 | if AttachEntryToParent(PDocTreeObject(AChild.Data)^.DocID, PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
|
---|
| 3333 | begin
|
---|
| 3334 | LoadNotes;
|
---|
| 3335 | with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
|
---|
| 3336 | if tvNotes.Selected <> nil then tvNotes.Selected.Expand(False);
|
---|
| 3337 | end
|
---|
| 3338 | else
|
---|
| 3339 | InfoBox(WhyNot, TX_ATTACH_FAILURE, MB_OK);
|
---|
| 3340 | end;
|
---|
| 3341 | end;
|
---|
| 3342 |
|
---|
| 3343 | function TfrmNotes.SetNoteTreeLabel(AContext: TTIUContext): string;
|
---|
| 3344 | var
|
---|
| 3345 | x: string;
|
---|
| 3346 |
|
---|
| 3347 | function SetDateRangeText(AContext: TTIUContext): string;
|
---|
| 3348 | var
|
---|
| 3349 | x1: string;
|
---|
| 3350 | begin
|
---|
| 3351 | with AContext do
|
---|
| 3352 | if BeginDate <> '' then
|
---|
| 3353 | begin
|
---|
| 3354 | x1 := ' from ' + UpperCase(BeginDate);
|
---|
| 3355 | if EndDate <> '' then x1 := x1 + ' to ' + UpperCase(EndDate)
|
---|
| 3356 | else x1 := x1 + ' to TODAY';
|
---|
| 3357 | end;
|
---|
| 3358 | Result := x1;
|
---|
| 3359 | end;
|
---|
| 3360 |
|
---|
| 3361 | begin
|
---|
| 3362 | with AContext do
|
---|
| 3363 | begin
|
---|
| 3364 | if MaxDocs > 0 then x := 'Last ' + IntToStr(MaxDocs) + ' ' else x := 'All ';
|
---|
| 3365 | case StrToIntDef(Status, 0) of
|
---|
| 3366 | NC_ALL : x := x + 'Signed Notes';
|
---|
| 3367 | NC_UNSIGNED : begin
|
---|
| 3368 | x := x + 'Unsigned Notes for ';
|
---|
| 3369 | if Author > 0 then x := x + ExternalName(Author, 200)
|
---|
| 3370 | else x := x + User.Name;
|
---|
| 3371 | x := x + SetDateRangeText(AContext);
|
---|
| 3372 | end;
|
---|
| 3373 | NC_UNCOSIGNED : begin
|
---|
| 3374 | x := x + 'Uncosigned Notes for ';
|
---|
| 3375 | if Author > 0 then x := x + ExternalName(Author, 200)
|
---|
| 3376 | else x := x + User.Name;
|
---|
| 3377 | x := x + SetDateRangeText(AContext);
|
---|
| 3378 | end;
|
---|
| 3379 | NC_BY_AUTHOR : x := x + 'Signed Notes for ' + ExternalName(Author, 200) + SetDateRangeText(AContext);
|
---|
| 3380 | NC_BY_DATE : x := x + 'Signed Notes ' + SetDateRangeText(AContext);
|
---|
| 3381 | else
|
---|
| 3382 | x := 'Custom List';
|
---|
| 3383 | end;
|
---|
| 3384 | end;
|
---|
| 3385 | Result := x;
|
---|
| 3386 | end;
|
---|
| 3387 |
|
---|
| 3388 | procedure TfrmNotes.memNewNoteKeyDown(Sender: TObject; var Key: Word;
|
---|
| 3389 | Shift: TShiftState);
|
---|
| 3390 | begin
|
---|
| 3391 | inherited;
|
---|
| 3392 | FNavigatingTab := (Key = VK_TAB) and ([ssShift,ssCtrl] * Shift <> []);
|
---|
| 3393 | if FNavigatingTab then
|
---|
| 3394 | Key := 0;
|
---|
| 3395 | end;
|
---|
| 3396 |
|
---|
| 3397 | procedure TfrmNotes.UpdateNoteAuthor(DocInfo: string);
|
---|
| 3398 | const
|
---|
| 3399 | TX_INVALID_AUTHOR1 = 'The author returned by the template (';
|
---|
| 3400 | TX_INVALID_AUTHOR2 = ') is not valid.' + #13#10 + 'The note''s author will remain as ';
|
---|
| 3401 | TC_INVALID_AUTHOR = 'Invalid Author';
|
---|
| 3402 | TX_COSIGNER_REQD = ' requires a cosigner for this note.';
|
---|
| 3403 | TC_COSIGNER_REQD = 'Cosigner Required';
|
---|
| 3404 | var
|
---|
| 3405 | NewAuth, NewAuthName, AuthNameCheck, x: string;
|
---|
| 3406 | ADummySender: TObject;
|
---|
| 3407 | begin
|
---|
| 3408 | if DocInfo = '' then Exit;
|
---|
| 3409 | NewAuth := GetXMLParamReturnValueTIU(DocInfo, 'AUTHOR_IEN');
|
---|
| 3410 | if NewAuth = '' then Exit;
|
---|
| 3411 | AuthNameCheck := ExternalName(StrToInt64Def(NewAuth, 0), 200);
|
---|
| 3412 | if AuthNameCheck = '' then
|
---|
| 3413 | begin
|
---|
| 3414 | NewAuthName := GetXMLParamReturnValueTIU(DocInfo, 'AUTHOR_NAME');
|
---|
| 3415 | InfoBox(TX_INVALID_AUTHOR1 + UpperCase(NewAuthName) + TX_INVALID_AUTHOR2 + UpperCase(FEditNote.AuthorName),
|
---|
| 3416 | TC_INVALID_AUTHOR, MB_OK and MB_ICONERROR);
|
---|
| 3417 | Exit;
|
---|
| 3418 | end;
|
---|
| 3419 | with FEditNote do if StrToInt64Def(NewAuth, 0) <> Author then
|
---|
| 3420 | begin
|
---|
| 3421 | Author := StrToInt64Def(NewAuth, 0);
|
---|
| 3422 | AuthorName := AuthNameCheck;
|
---|
| 3423 | x := lstNotes.Items[EditingIndex];
|
---|
| 3424 | SetPiece(x, U, 5, NewAuth + ';' + AuthNameCheck);
|
---|
| 3425 | lstNotes.Items[EditingIndex] := x;
|
---|
| 3426 | if AskCosignerForTitle(Title, Author) then
|
---|
| 3427 | begin
|
---|
| 3428 | InfoBox(UpperCase(AuthNameCheck) + TX_COSIGNER_REQD, TC_COSIGNER_REQD, MB_OK);
|
---|
| 3429 | //Cosigner := 0; CosignerName := ''; // not sure about this yet
|
---|
| 3430 | ADummySender := TObject.Create;
|
---|
| 3431 | try
|
---|
| 3432 | cmdChangeClick(ADummySender);
|
---|
| 3433 | finally
|
---|
| 3434 | FreeAndNil(ADummySender);
|
---|
| 3435 | end;
|
---|
| 3436 | end
|
---|
| 3437 | else cmdChangeClick(Self);
|
---|
| 3438 | end;
|
---|
| 3439 | end;
|
---|
| 3440 |
|
---|
| 3441 | procedure TfrmNotes.sptHorzCanResize(Sender: TObject; var NewSize: Integer;
|
---|
| 3442 | var Accept: Boolean);
|
---|
| 3443 | begin
|
---|
| 3444 | inherited;
|
---|
| 3445 | if pnlWrite.Visible then
|
---|
| 3446 | if NewSize > frmNotes.ClientWidth - memNewNote.Constraints.MinWidth - sptHorz.Width then
|
---|
| 3447 | NewSize := frmNotes.ClientWidth - memNewNote.Constraints.MinWidth - sptHorz.Width;
|
---|
| 3448 | end;
|
---|
| 3449 |
|
---|
| 3450 | procedure TfrmNotes.popNoteMemoInsTemplateClick(Sender: TObject);
|
---|
| 3451 | begin
|
---|
| 3452 | frmDrawers.mnuInsertTemplateClick(Sender);
|
---|
| 3453 | end;
|
---|
| 3454 |
|
---|
| 3455 | procedure TfrmNotes.popNoteMemoPreviewClick(Sender: TObject);
|
---|
| 3456 | begin
|
---|
| 3457 | frmDrawers.mnuPreviewTemplateClick(Sender);
|
---|
| 3458 | end;
|
---|
| 3459 |
|
---|
| 3460 | procedure TfrmNotes.tvNotesAddition(Sender: TObject; Node: TTreeNode);
|
---|
| 3461 | begin
|
---|
| 3462 | inherited;
|
---|
| 3463 | TAccessibleTreeNode.WrapControl(Node as TORTreeNode);
|
---|
| 3464 | end;
|
---|
| 3465 |
|
---|
| 3466 | procedure TfrmNotes.tvNotesDeletion(Sender: TObject; Node: TTreeNode);
|
---|
| 3467 | begin
|
---|
| 3468 | TAccessibleTreeNode.UnwrapControl(Node as TORTreeNode);
|
---|
| 3469 | inherited;
|
---|
| 3470 | end;
|
---|
| 3471 |
|
---|
| 3472 | {Tab Order tricks. Need to change
|
---|
| 3473 | tvNotes
|
---|
| 3474 |
|
---|
| 3475 | frmDrawers.pnlTemplateButton
|
---|
| 3476 | frmDrawers.pnlEncounterButton
|
---|
| 3477 | cmdNewNote
|
---|
| 3478 | cmdPCE
|
---|
| 3479 |
|
---|
| 3480 | lvNotes
|
---|
| 3481 | memNote
|
---|
| 3482 |
|
---|
| 3483 | to
|
---|
| 3484 | tvNotes
|
---|
| 3485 |
|
---|
| 3486 | lvNotes
|
---|
| 3487 | memNote
|
---|
| 3488 |
|
---|
| 3489 | frmDrawers.pnlTemplateButton
|
---|
| 3490 | frmDrawers.pnlEncounterButton
|
---|
| 3491 | cmdNewNote
|
---|
| 3492 | cmdPCE
|
---|
| 3493 | }
|
---|
| 3494 |
|
---|
| 3495 | procedure TfrmNotes.tvNotesExit(Sender: TObject);
|
---|
| 3496 | begin
|
---|
| 3497 | if Boolean(Hi(GetKeyState(VK_TAB))) and (not Boolean(Hi(GetKeyState(VK_SHIFT))))then
|
---|
| 3498 | begin
|
---|
| 3499 | if (Screen.ActiveControl = frmDrawers.pnlTemplatesButton) or
|
---|
| 3500 | (Screen.ActiveControl = frmDrawers.pnlEncounterButton) or
|
---|
| 3501 | (Screen.ActiveControl = cmdNewNote) or
|
---|
| 3502 | (Screen.ActiveControl = cmdPCE) then
|
---|
| 3503 | FindNextControl( cmdPCE, True, True, False).SetFocus;
|
---|
| 3504 | end;
|
---|
| 3505 | end;
|
---|
| 3506 |
|
---|
| 3507 | procedure TfrmNotes.cmdNewNoteExit(Sender: TObject);
|
---|
| 3508 | begin
|
---|
| 3509 | inherited;
|
---|
| 3510 | if Boolean(Hi(GetKeyState(VK_TAB))) and
|
---|
| 3511 | (not frmDrawers.pnlEncounterButton.CanFocus) and
|
---|
| 3512 | (not Boolean(Hi(GetKeyState(VK_SHIFT)))) then
|
---|
| 3513 | if (memPCEShow.CanFocus) then
|
---|
| 3514 | memPCEShow.SetFocus
|
---|
| 3515 | else
|
---|
| 3516 | frmFrame.pnlPatient.SetFocus;
|
---|
| 3517 | end;
|
---|
| 3518 |
|
---|
| 3519 | procedure TfrmNotes.frmFramePnlPatientExit(Sender: TObject);
|
---|
| 3520 | begin
|
---|
| 3521 | FOldFramePnlPatientExit(Sender);
|
---|
| 3522 | if Boolean(Hi(GetKeyState(VK_TAB))) then
|
---|
| 3523 | begin
|
---|
| 3524 | if (Screen.ActiveControl = lvNotes) or
|
---|
| 3525 | (Screen.ActiveControl = memNote) then
|
---|
| 3526 | FindNextControl( lvNotes, False, True, False).SetFocus;
|
---|
| 3527 | end;
|
---|
| 3528 | end;
|
---|
| 3529 |
|
---|
| 3530 | procedure TfrmNotes.FormHide(Sender: TObject);
|
---|
| 3531 | begin
|
---|
| 3532 | inherited;
|
---|
| 3533 | frmFrame.pnlPatient.OnExit := FOldFramePnlPatientExit;
|
---|
| 3534 | frmDrawers.pnlTemplatesButton.OnExit := FOldDrawerPnlTemplatesButtonExit;
|
---|
| 3535 | frmDrawers.pnlEncounterButton.OnExit := FOldDrawerPnlEncounterButtonExit;
|
---|
| 3536 | frmDrawers.edtSearch.OnExit := FOldDrawerEdtSearchExit;
|
---|
| 3537 | end;
|
---|
| 3538 |
|
---|
| 3539 | procedure TfrmNotes.FormShow(Sender: TObject);
|
---|
| 3540 | begin
|
---|
| 3541 | inherited;
|
---|
| 3542 | FOldFramePnlPatientExit := frmFrame.pnlPatient.OnExit;
|
---|
| 3543 | frmFrame.pnlPatient.OnExit := frmFramePnlPatientExit;
|
---|
| 3544 | FOldDrawerPnlTemplatesButtonExit := frmDrawers.pnlTemplatesButton.OnExit;
|
---|
| 3545 | frmDrawers.pnlTemplatesButton.OnExit := frmDrawerPnlTemplatesButtonExit;
|
---|
| 3546 | FOldDrawerPnlEncounterButtonExit := frmDrawers.pnlEncounterButton.OnExit;
|
---|
| 3547 | frmDrawers.pnlEncounterButton.OnExit := frmDrawerPnlEncounterButtonExit;
|
---|
| 3548 | FOldDrawerEdtSearchExit := frmDrawers.edtSearch.OnExit;
|
---|
| 3549 | frmDrawers.edtSearch.OnExit := frmDrawerEdtSearchExit;
|
---|
| 3550 | end;
|
---|
| 3551 |
|
---|
| 3552 | procedure TfrmNotes.frmDrawerEdtSearchExit(Sender: TObject);
|
---|
| 3553 | begin
|
---|
| 3554 | FOldDrawerEdtSearchExit(Sender);
|
---|
| 3555 | cmdNewNoteExit(Sender);
|
---|
| 3556 | end;
|
---|
| 3557 |
|
---|
| 3558 | procedure TfrmNotes.frmDrawerPnlTemplatesButtonExit(Sender: TObject);
|
---|
| 3559 | begin
|
---|
| 3560 | FOldDrawerPnlTemplatesButtonExit(Sender);
|
---|
| 3561 | if Boolean(Hi(GetKeyState(VK_TAB))) and Boolean(Hi(GetKeyState(VK_SHIFT))) then
|
---|
| 3562 | if memNewNote.CanFocus then
|
---|
| 3563 | memNewNote.SetFocus
|
---|
| 3564 | else if memNote.CanFocus then
|
---|
| 3565 | memNote.SetFocus;
|
---|
| 3566 | end;
|
---|
| 3567 |
|
---|
| 3568 | procedure TfrmNotes.frmDrawerPnlEncounterButtonExit(Sender: TObject);
|
---|
| 3569 | begin
|
---|
| 3570 | FOldDrawerPnlEncounterButtonExit(Sender);
|
---|
| 3571 | cmdNewNoteExit(Sender);
|
---|
| 3572 | end;
|
---|
| 3573 |
|
---|
| 3574 | procedure TfrmNotes.memNewNoteKeyPress(Sender: TObject; var Key: Char);
|
---|
| 3575 | begin
|
---|
| 3576 | inherited;
|
---|
| 3577 | if FNavigatingTab then
|
---|
| 3578 | Key := #0; //Disable shift-tab processinend;
|
---|
| 3579 | end;
|
---|
| 3580 |
|
---|
| 3581 | procedure TfrmNotes.memNewNoteKeyUp(Sender: TObject; var Key: Word;
|
---|
| 3582 | Shift: TShiftState);
|
---|
| 3583 | begin
|
---|
| 3584 | inherited;
|
---|
| 3585 | if FNavigatingTab then
|
---|
| 3586 | begin
|
---|
| 3587 | if ssShift in Shift then
|
---|
| 3588 | FindNextControl(Sender as TWinControl, False, True, False).SetFocus //previous control
|
---|
| 3589 | else if ssCtrl in Shift then
|
---|
| 3590 | if frmDrawers.pnlTemplatesButton.CanFocus then
|
---|
| 3591 | frmDrawers.pnlTemplatesButton.SetFocus
|
---|
| 3592 | else
|
---|
| 3593 | FindNextControl(Sender as TWinControl, True, True, False).SetFocus; //next control
|
---|
| 3594 | FNavigatingTab := False;
|
---|
| 3595 | end;
|
---|
| 3596 | if (key = VK_ESCAPE) then begin
|
---|
| 3597 | FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
|
---|
| 3598 | key := 0;
|
---|
| 3599 | end;
|
---|
| 3600 | end;
|
---|
| 3601 |
|
---|
| 3602 | procedure TfrmNotes.memPCEShowExit(Sender: TObject);
|
---|
| 3603 | begin
|
---|
| 3604 | inherited;
|
---|
| 3605 | //Fix the Tab Order Make Drawers Buttons Accessible
|
---|
| 3606 | if Boolean(Hi(GetKeyState(VK_TAB))) then
|
---|
| 3607 | if Boolean(Hi(GetKeyState(VK_SHIFT))) then
|
---|
| 3608 | if cmdPCE.CanFocus then
|
---|
| 3609 | cmdPCE.SetFocus
|
---|
| 3610 | else
|
---|
| 3611 | cmdNewNote.SetFocus
|
---|
| 3612 | else
|
---|
| 3613 | frmFrame.pnlPatient.SetFocus;
|
---|
| 3614 | end;
|
---|
| 3615 |
|
---|
| 3616 | procedure TfrmNotes.cmdChangeExit(Sender: TObject);
|
---|
| 3617 | begin
|
---|
| 3618 | inherited;
|
---|
| 3619 | //Fix the Tab Order Make Drawers Buttons Accessible
|
---|
| 3620 | if Boolean(Hi(GetKeyState(VK_TAB))) and
|
---|
| 3621 | Boolean(Hi(GetKeyState(VK_SHIFT))) then
|
---|
| 3622 | tvNotes.SetFocus;
|
---|
| 3623 | end;
|
---|
| 3624 |
|
---|
| 3625 | procedure TfrmNotes.cmdPCEExit(Sender: TObject);
|
---|
| 3626 | begin
|
---|
| 3627 | inherited;
|
---|
| 3628 | //Fix the Tab Order Make Drawers Buttons Accessible
|
---|
| 3629 | if Boolean(Hi(GetKeyState(VK_TAB))) and
|
---|
| 3630 | Not Boolean(Hi(GetKeyState(VK_SHIFT))) then
|
---|
| 3631 | memPCEShow.SetFocus;
|
---|
| 3632 | end;
|
---|
| 3633 |
|
---|
| 3634 | procedure TfrmNotes.memNoteExit(Sender: TObject);
|
---|
| 3635 | begin
|
---|
| 3636 | inherited;
|
---|
| 3637 | //Fix the Tab Order Make Drawers Buttons Accessible
|
---|
| 3638 | if Boolean(Hi(GetKeyState(VK_TAB))) then
|
---|
| 3639 | if Boolean(Hi(GetKeyState(VK_SHIFT))) then
|
---|
| 3640 | begin
|
---|
| 3641 | if lvNotes.CanFocus then
|
---|
| 3642 | lvNotes.SetFocus
|
---|
| 3643 | else if tvNotes.CanFocus then
|
---|
| 3644 | tvNotes.SetFocus;
|
---|
| 3645 | end
|
---|
| 3646 | else if frmDrawers.pnlTemplatesButton.CanFocus then
|
---|
| 3647 | frmDrawers.pnlTemplatesButton.SetFocus
|
---|
| 3648 |
|
---|
| 3649 | end;
|
---|
| 3650 |
|
---|
| 3651 | procedure TfrmNotes.lvNotesExit(Sender: TObject);
|
---|
| 3652 | begin
|
---|
| 3653 | inherited;
|
---|
| 3654 | if Boolean(Hi(GetKeyState(VK_TAB))) and Boolean(Hi(GetKeyState(VK_SHIFT))) then
|
---|
| 3655 | if tvNotes.CanFocus then
|
---|
| 3656 | tvNotes.SetFocus
|
---|
| 3657 | end;
|
---|
| 3658 |
|
---|
| 3659 | initialization
|
---|
| 3660 | uPCEEdit := TPCEData.Create;
|
---|
| 3661 | uPCEShow := TPCEData.Create;
|
---|
| 3662 |
|
---|
| 3663 | finalization
|
---|
| 3664 | uPCEEdit.Free;
|
---|
| 3665 | uPCEShow.Free;
|
---|
| 3666 |
|
---|
| 3667 | end.
|
---|
| 3668 |
|
---|