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