source: cprs/branches/HealthSevak-CPRS/CPRS-Chart/fSurgery.pas@ 1710

Last change on this file since 1710 was 1704, checked in by healthsevak, 10 years ago

Implemented the OpenSource based spell check feature

File size: 95.9 KB
Line 
1unit fSurgery;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 fHSplit, StdCtrls, ExtCtrls, Menus, ComCtrls, ORCtrls, ORFn, uConst, ORDtTm,
8 uPCE, ORClasses, fDrawers, ImgList, fSurgeryView, rSurgery, uSurgery,
9 uCaseTree, uTIU, fBase508Form, VA508AccessibilityManager,
10 VA508ImageListLabeler;
11
12type
13 TfrmSurgery = class(TfrmHSplit)
14 mnuNotes: TMainMenu;
15 mnuView: TMenuItem;
16 mnuViewChart: TMenuItem;
17 mnuChartReports: TMenuItem;
18 mnuChartLabs: TMenuItem;
19 mnuChartDCSumm: TMenuItem;
20 mnuChartCslts: TMenuItem;
21 mnuChartNotes: TMenuItem;
22 mnuChartOrders: TMenuItem;
23 mnuChartMeds: TMenuItem;
24 mnuChartProbs: TMenuItem;
25 mnuChartCover: TMenuItem;
26 Z1: TMenuItem;
27 mnuViewDetail: TMenuItem;
28 mnuAct: TMenuItem;
29 mnuActNew: TMenuItem;
30 Z2: TMenuItem;
31 mnuActSave: TMenuItem;
32 mnuActDelete: TMenuItem;
33 mnuActEdit: TMenuItem;
34 mnuActSign: TMenuItem;
35 mnuActAddend: TMenuItem;
36 lblCases: TOROffsetLabel;
37 pnlRead: TPanel;
38 lblTitle: TOROffsetLabel;
39 memSurgery: TRichEdit;
40 pnlWrite: TPanel;
41 memNewNote: TRichEdit;
42 Z3: TMenuItem;
43 mnuViewAll: TMenuItem;
44 mnuViewBySurgeon: TMenuItem;
45 mnuViewByDate: TMenuItem;
46 mnuViewUncosigned: TMenuItem;
47 mnuViewUnsigned: TMenuItem;
48 mnuActSignList: TMenuItem;
49 cmdNewNote: TORAlignButton;
50 lblSpace1: TLabel;
51 popNoteMemo: TPopupMenu;
52 popNoteMemoCut: TMenuItem;
53 popNoteMemoCopy: TMenuItem;
54 popNoteMemoPaste: TMenuItem;
55 Z10: TMenuItem;
56 popNoteMemoSignList: TMenuItem;
57 popNoteMemoDelete: TMenuItem;
58 popNoteMemoEdit: TMenuItem;
59 popNoteMemoSave: TMenuItem;
60 popNoteMemoSign: TMenuItem;
61 popNoteList: TPopupMenu;
62 popNoteListAll: TMenuItem;
63 popNoteListByDate: TMenuItem;
64 mnuActIdentifyAddlSigners: TMenuItem;
65 popNoteMemoAddlSign: TMenuItem;
66 Z11: TMenuItem;
67 popNoteMemoSpell: TMenuItem;
68 popNoteMemoGrammar: TMenuItem;
69 mnuViewCustom: TMenuItem;
70 N1: TMenuItem;
71 mnuViewSaveAsDefault: TMenuItem;
72 ReturntoDefault1: TMenuItem;
73 pnlDrawers: TPanel;
74 splDrawers: TSplitter;
75 popNoteMemoTemplate: TMenuItem;
76 Z12: TMenuItem;
77 mnuOptions: TMenuItem;
78 mnuEditTemplates: TMenuItem;
79 mnuNewTemplate: TMenuItem;
80 N2: TMenuItem;
81 mnuEditSharedTemplates: TMenuItem;
82 mnuNewSharedTemplate: TMenuItem;
83 popNoteMemoAddend: TMenuItem;
84 pnlFields: TPanel;
85 lblNewTitle: TLabel;
86 lblRefDate: TLabel;
87 lblAuthor: TLabel;
88 lblVisit: TLabel;
89 lblCosigner: TLabel;
90 cmdChange: TButton;
91 lblSubject: TLabel;
92 txtSubject: TCaptionEdit;
93 timAutoSave: TTimer;
94 popNoteMemoPaste2: TMenuItem;
95 popNoteMemoReformat: TMenuItem;
96 Z4: TMenuItem;
97 mnuActChange: TMenuItem;
98 mnuActLoadBoiler: TMenuItem;
99 bvlNewTitle: TBevel;
100 popNoteMemoSaveContinue: TMenuItem;
101 N3: TMenuItem;
102 mnuEditDialgFields: TMenuItem;
103 N4: TMenuItem;
104 popNoteListExpandSelected: TMenuItem;
105 popNoteListExpandAll: TMenuItem;
106 popNoteListCollapseSelected: TMenuItem;
107 popNoteListCollapseAll: TMenuItem;
108 popNoteListCustom: TMenuItem;
109 mnuActDetachFromIDParent: TMenuItem;
110 N5: TMenuItem;
111 popNoteListDetachFromIDParent: TMenuItem;
112 popNoteListAddIDEntry: TMenuItem;
113 mnuActAddIDEntry: TMenuItem;
114 mnuIconLegend: TMenuItem;
115 N6: TMenuItem;
116 popNoteMemoFind: TMenuItem;
117 dlgFindText: TFindDialog;
118 dlgReplaceText: TReplaceDialog;
119 popNoteMemoReplace: TMenuItem;
120 N7: TMenuItem;
121 tvSurgery: TORTreeView;
122 mnuChartSurgery: TMenuItem;
123 lstNotes: TORListBox;
124 sptVert: TSplitter;
125 memPCEShow: TRichEdit;
126 cmdPCE: TORAlignButton;
127 popNoteListBySurgeon: TMenuItem;
128 popNoteListUnsigned: TMenuItem;
129 popNoteListUncosigned: TMenuItem;
130 N8: TMenuItem;
131 popNoteMemoPreview: TMenuItem;
132 popNoteMemoInsTemplate: TMenuItem;
133 popNoteMemoEncounter: TMenuItem;
134 mnuViewInformation: TMenuItem;
135 mnuViewDemo: TMenuItem;
136 mnuViewVisits: TMenuItem;
137 mnuViewPrimaryCare: TMenuItem;
138 mnuViewMyHealtheVet: TMenuItem;
139 mnuInsurance: TMenuItem;
140 mnuViewFlags: TMenuItem;
141 mnuViewReminders: TMenuItem;
142 mnuViewRemoteData: TMenuItem;
143 mnuViewPostings: TMenuItem;
144 imgLblImages: TVA508ImageListLabeler;
145 imgLblSurgery: TVA508ImageListLabeler;
146 popNoteMemoSpellOpenSource: TMenuItem;//WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
147 procedure mnuChartTabClick(Sender: TObject);
148 procedure pnlRightResize(Sender: TObject);
149 procedure cmdNewNoteClick(Sender: TObject);
150 procedure mnuActNewClick(Sender: TObject);
151 procedure mnuActSaveClick(Sender: TObject);
152 procedure mnuViewClick(Sender: TObject);
153 procedure mnuActAddendClick(Sender: TObject);
154 procedure mnuActSignListClick(Sender: TObject);
155 procedure mnuActDeleteClick(Sender: TObject);
156 procedure mnuActEditClick(Sender: TObject);
157 procedure mnuActSignClick(Sender: TObject);
158 procedure cmdPCEClick(Sender: TObject);
159 procedure popNoteMemoCutClick(Sender: TObject);
160 procedure popNoteMemoCopyClick(Sender: TObject);
161 procedure popNoteMemoPasteClick(Sender: TObject);
162 procedure popNoteMemoPopup(Sender: TObject);
163 procedure pnlWriteResize(Sender: TObject);
164 procedure FormCreate(Sender: TObject);
165 procedure mnuViewDetailClick(Sender: TObject);
166 procedure FormClose(Sender: TObject; var Action: TCloseAction);
167 procedure mnuActIdentifyAddlSignersClick(Sender: TObject);
168 procedure popNoteMemoAddlSignClick(Sender: TObject);
169 procedure popNoteMemoSpellClick(Sender: TObject);
170 procedure popNoteMemoGrammarClick(Sender: TObject);
171 procedure mnuViewSaveAsDefaultClick(Sender: TObject);
172 procedure mnuViewReturntoDefaultClick(Sender: TObject);
173 procedure popNoteMemoTemplateClick(Sender: TObject);
174 procedure mnuEditTemplatesClick(Sender: TObject);
175 procedure mnuNewTemplateClick(Sender: TObject);
176 procedure mnuEditSharedTemplatesClick(Sender: TObject);
177 procedure mnuNewSharedTemplateClick(Sender: TObject);
178 procedure mnuOptionsClick(Sender: TObject);
179 procedure FormDestroy(Sender: TObject);
180 procedure cmdChangeClick(Sender: TObject);
181 procedure pnlFieldsResize(Sender: TObject);
182 procedure timAutoSaveTimer(Sender: TObject);
183 procedure memNewNoteChange(Sender: TObject);
184 procedure popNoteMemoReformatClick(Sender: TObject);
185 procedure mnuActChangeClick(Sender: TObject);
186 procedure mnuActLoadBoilerClick(Sender: TObject);
187 procedure popNoteMemoSaveContinueClick(Sender: TObject);
188 procedure mnuEditDialgFieldsClick(Sender: TObject);
189 procedure popNoteListExpandAllClick(Sender: TObject);
190 procedure popNoteListCollapseAllClick(Sender: TObject);
191 procedure popNoteListExpandSelectedClick(Sender: TObject);
192 procedure popNoteListCollapseSelectedClick(Sender: TObject);
193 procedure popNoteListPopup(Sender: TObject);
194 procedure mnuIconLegendClick(Sender: TObject);
195 procedure popNoteMemoFindClick(Sender: TObject);
196 procedure dlgFindTextFind(Sender: TObject);
197 procedure popNoteMemoReplaceClick(Sender: TObject);
198 procedure dlgReplaceTextReplace(Sender: TObject);
199 procedure dlgReplaceTextFind(Sender: TObject);
200 procedure tvSurgeryClick(Sender: TObject);
201 procedure tvSurgeryChange(Sender: TObject; Node: TTreeNode);
202 procedure tvSurgeryExpanded(Sender: TObject; Node: TTreeNode);
203 procedure tvSurgeryCollapsed(Sender: TObject; Node: TTreeNode);
204 procedure lstNotesClick(Sender: TObject);
205 procedure memNewNoteKeyDown(Sender: TObject; var Key: Word;
206 Shift: TShiftState);
207 procedure sptHorzCanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean);
208 procedure popNoteMemoPreviewClick(Sender: TObject);
209 procedure popNoteMemoInsTemplateClick(Sender: TObject);
210 procedure ViewInfo(Sender: TObject);
211 procedure mnuViewInformationClick(Sender: TObject);
212 private
213 FEditingIndex: Integer; // index of note being currently edited
214 FCurrentContext: TSurgCaseContext;
215 FDefaultContext: TSurgCaseContext;
216 FImageFlag: TBitmap;
217 FCaseList: TStringList;
218 FChanged: Boolean; // true if any text has changed in the note
219 FEditCtrl: TCustomEdit;
220 FSilent: Boolean;
221 FEditNote: TEditNoteRec;
222 FVerifyNoteTitle: Integer;
223 FConfirmed: boolean;
224 FLastNoteID: string;
225 FEditingNotePCEObj: boolean;
226 FDeleted: boolean;
227 procedure ClearEditControls;
228 procedure DoAutoSave(Suppress: integer = 1);
229 function GetTitleText(AnIndex: Integer): string;
230 procedure InsertAddendum;
231 procedure InsertNewNote(IsIDChild: boolean; AnIDParent: integer);
232 function LacksRequiredForCreate: Boolean;
233 procedure LoadForEdit;
234 procedure LoadSurgeryCases;
235 procedure UpdateTreeView(DocList: TStringList; Tree: TORTreeView);
236 procedure SetViewContext(AContext: TSurgCaseContext);
237 function GetDrawers: TFrmDrawers;
238 procedure SetEditingIndex(const Value: Integer);
239 property EditingIndex: Integer read FEditingIndex write SetEditingIndex;
240 procedure ProcessNotifications;
241 function SetSurgTreeLabel(AContext: TSurgCaseContext): string;
242 procedure RemovePCEFromChanges(IEN: Int64; AVisitStr: string = '');
243 procedure SaveEditedNote(var Saved: Boolean);
244 procedure SaveCurrentNote(var Saved: Boolean);
245 procedure SetSubjectVisible(ShouldShow: Boolean);
246 procedure ShowPCEControls(ShouldShow: Boolean);
247 function StartNewEdit(NewNoteType: integer): Boolean;
248 //function CanFinishReminder: boolean;
249 procedure DisplayPCE;
250 function VerifyNoteTitle: Boolean;
251 procedure ShowPCEButtons(Editing: boolean);
252 procedure EnableDisableMenus(IsTIUDocument: boolean);
253 public
254 function AllowContextChange(var WhyNot: string): Boolean; override;
255 procedure ClearPtData; override;
256 procedure DisplayPage; override;
257 procedure RequestPrint; override;
258 procedure SetFontSize(NewFontSize: Integer); override;
259 procedure SaveSignItem(const ItemID, ESCode: string);
260 procedure AssignRemForm;
261 published
262 property Drawers: TFrmDrawers read GetDrawers; // Keep Drawers published
263 end;
264
265var
266 frmSurgery: TfrmSurgery;
267 uSurgeryContext: TSurgCaseContext;
268
269implementation
270
271{$R *.DFM}
272
273uses fFrame, fVisit, fEncnt, rCore, uCore, fNoteBA, fNoteBD, fSignItem, fEncounterFrame,
274 rPCE, Clipbrd, fNoteCslt, fNotePrt, rVitals, fAddlSigners, fNoteDR, fConsults, uSpell,
275 fTIUView, fTemplateEditor, uReminders, fReminderDialog, uOrders, rConsults, fReminderTree,
276 fNoteProps, fNotesBP, fTemplateFieldEditor, uTemplates, dShared, rTemplates,
277 FIconLegend, fPCEEdit, rTIU, fRptBox, fTemplateDialog, VA508AccessibilityRouter;
278
279const
280 CT_SURGERY = 11; // chart tab - surgery
281
282 NT_NEW_NOTE = -10; // Holder IEN for a new note
283 NT_ADDENDUM = -20; // Holder IEN for a new addendum
284
285 NT_ACT_NEW_NOTE = 2;
286 NT_ACT_ADDENDUM = 3;
287 NT_ACT_EDIT_NOTE = 4;
288 NT_ACT_ID_ENTRY = 5;
289
290 TX_NEED_VISIT = 'A visit is required before creating a new surgery report.';
291 TX_CREATE_ERR = 'Error Creating Report';
292 TX_UPDATE_ERR = 'Error Updating Report';
293 TX_NO_NOTE = 'No surgery report is currently being edited';
294 TX_SAVE_NOTE = 'Save Surgery Report';
295 TX_ADDEND_NO = 'Cannot make an addendum to a report that is being edited';
296 TX_DEL_OK = CRLF + CRLF + 'Delete this surgery report?';
297 TX_DEL_ERR = 'Unable to Delete Report';
298 TX_SIGN = 'Sign Report';
299 TX_COSIGN = 'Cosign Report';
300 TX_SIGN_ERR = 'Unable to Sign Report';
301// TX_SCREQD = 'This progress note title requires the service connected questions to be '+
302// 'answered. The Encounter form will now be opened. Please answer all '+
303// 'service connected questions.';
304// TX_SCREQD_T = 'Response required for SC questions.';
305 TX_NONOTE = 'No surgery report is currently selected.';
306 TX_NONOTE_CAP = 'No Report Selected';
307 TX_NOPRT_NEW = 'This surgery report may not be printed until it is saved';
308 TX_NOPRT_NEW_CAP = 'Save Surgery Report';
309 TX_NO_ALERT = 'There is insufficient information to process this alert.' + CRLF +
310 'Either the alert has already been deleted, or it contained invalid data.' + CRLF + CRLF +
311 'Click the NEXT button if you wish to continue processing more alerts.';
312 TX_CAP_NO_ALERT = 'Unable to Process Alert';
313 //TX_ORDER_LOCKED = 'This record is locked by an action underway on the Consults tab';
314 //TC_ORDER_LOCKED = 'Unable to access record';
315 //TX_NO_ORD_CHG = 'The note is still associated with the previously selected request.' + CRLF +
316 // 'Finish the pending action on the consults tab, then try again.';
317 //TC_NO_ORD_CHG = 'Locked Consult Request';
318 TX_NEW_SAVE1 = 'You are currently editing:' + CRLF + CRLF;
319 TX_NEW_SAVE2 = CRLF + CRLF + 'Do you wish to save this report and begin a new one?';
320 TX_NEW_SAVE3 = CRLF + CRLF + 'Do you wish to save this report and begin a new addendum?';
321 TX_NEW_SAVE4 = CRLF + CRLF + 'Do you wish to save this report and edit the one selected?';
322 //TX_NEW_SAVE5 = CRLF + CRLF + 'Do you wish to save this report and begin a new Interdisciplinary entry?';
323 TC_NEW_SAVE2 = 'Create New Report';
324 TC_NEW_SAVE3 = 'Create New Addendum';
325 TC_NEW_SAVE4 = 'Edit Different Report';
326 //TC_NEW_SAVE5 = 'Create New Interdisciplinary Entry';
327 TX_EMPTY_NOTE = CRLF + CRLF + 'This report contains no text and will not be saved.' + CRLF +
328 'Do you wish to delete this report?';
329 TC_EMPTY_NOTE = 'Empty Report';
330 TX_EMPTY_NOTE1 = 'This report contains no text and can not be signed.';
331 TC_NO_LOCK = 'Unable to Lock Report';
332 TX_ABSAVE = 'It appears the session terminated abnormally when this' + CRLF +
333 'report was last edited. Some text may not have been saved.' + CRLF + CRLF +
334 'Do you wish to continue and sign the report?';
335 TC_ABSAVE = 'Possible Missing Text';
336 TX_NO_BOIL = 'There is no boilerplate text associated with this title.';
337 TC_NO_BOIL = 'Load Boilerplate Text';
338 TX_BLR_CLEAR = 'Do you want to clear the previously loaded boilerplate text?';
339 TC_BLR_CLEAR = 'Clear Previous Boilerplate Text';
340 TX_DETACH_CNF = 'Confirm Detachment';
341 TX_DETACH_FAILURE = 'Detach failed';
342 TX_RETRACT_CAP = 'Retraction Notice';
343 TX_RETRACT = 'This document will now be RETRACTED. As Such, it has been removed' +CRLF +
344 ' from public view, and from typical Releases of Information,' +CRLF +
345 ' but will remain indefinitely discoverable to HIMS.' +CRLF +CRLF;
346
347var
348 uPCEShow, uPCEEdit: TPCEData;
349 ViewContext: Integer;
350 frmDrawers: TfrmDrawers;
351 uChanging: Boolean;
352
353{ TPage common methods --------------------------------------------------------------------- }
354
355function TfrmSurgery.AllowContextChange(var WhyNot: string): Boolean;
356begin
357 dlgFindText.CloseDialog;
358 Result := inherited AllowContextChange(WhyNot); // sets result = true
359 if Assigned(frmTemplateDialog) then
360 if Screen.ActiveForm = frmTemplateDialog then
361 //if (fsModal in frmTemplateDialog.FormState) then
362 case BOOLCHAR[frmFrame.CCOWContextChanging] of
363 '1': begin
364 WhyNot := 'A template in progress will be aborted. ';
365 Result := False;
366 end;
367 '0': begin
368 if WhyNot = 'COMMIT' then
369 begin
370 FSilent := True;
371 frmTemplateDialog.Silent := True;
372 frmTemplateDialog.ModalResult := mrCancel;
373 end;
374 end;
375 end;
376 if EditingIndex <> -1 then
377 case BOOLCHAR[frmFrame.CCOWContextChanging] of
378 '1': begin
379 if memNewNote.GetTextLen > 0 then
380 WhyNot := 'A report in progress will be saved as unsigned. '
381 else
382 WhyNot := 'An empty report in progress will be deleted. ';
383 Result := False;
384 end;
385 '0': begin
386 if WhyNot = 'COMMIT' then FSilent := True;
387 SaveCurrentNote(Result)
388 end;
389 end;
390 if Assigned(frmEncounterFrame) then
391 if Screen.ActiveForm = frmEncounterFrame then
392 //if (fsModal in frmEncounterFrame.FormState) then
393 case BOOLCHAR[frmFrame.CCOWContextChanging] of
394 '1': begin
395 WhyNot := WhyNot + 'Encounter information being edited will not be saved';
396 Result := False;
397 end;
398 '0': begin
399 if WhyNot = 'COMMIT' then
400 begin
401 FSilent := True;
402 frmEncounterFrame.Abort := False;
403 frmEncounterFrame.Cancel := True;
404 end;
405 end;
406 end;
407end;
408
409procedure TfrmSurgery.ClearPtData;
410{ clear all controls that contain patient specific information }
411begin
412 inherited ClearPtData;
413 ClearEditControls;
414 uChanging := True;
415 tvSurgery.Items.BeginUpdate;
416 KillCaseTreeObjects(tvSurgery);
417 tvSurgery.Items.Clear;
418 tvSurgery.Items.EndUpdate;
419 lstNotes.Clear;
420 uChanging := False;
421 memSurgery.Clear;
422 uPCEShow.Clear;
423 uPCEEdit.Clear;
424 frmDrawers.ResetTemplates;
425end;
426
427procedure TfrmSurgery.DisplayPage;
428{ causes page to be visible and conditionally executes initialization code }
429begin
430 inherited DisplayPage;
431 frmFrame.ShowHideChartTabMenus(mnuViewChart);
432 frmFrame.mnuFilePrint.Tag := CT_SURGERY;
433 frmFrame.mnuFilePrint.Enabled := True;
434 frmFrame.mnuFilePrintSetup.Enabled := True;
435 if InitPage then
436 begin
437 FDefaultContext := GetCurrentSurgCaseContext;
438 FCurrentContext := FDefaultContext;
439 popNoteMemoSpell.Visible := SpellCheckAvailable;
440 popNoteMemoSpellOpenSource.Visible := SpellCheckAvailable; //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
441 popNoteMemoGrammar.Visible := popNoteMemoSpell.Visible;
442 Z11.Visible := popNoteMemoSpell.Visible;
443 timAutoSave.Interval := User.AutoSave * 1000; // convert seconds to milliseconds
444 SetEqualTabStops(memNewNote);
445 end;
446 // to indent the right margin need to set Paragraph.RightIndent for each paragraph?
447 if InitPatient and not (CallingContext = CC_NOTIFICATION) then
448 begin
449 SetViewContext(FDefaultContext);
450 end;
451 case CallingContext of
452 CC_INIT_PATIENT: if not InitPatient then
453 begin
454 SetViewContext(FDefaultContext);
455 end;
456 CC_NOTIFICATION: ProcessNotifications;
457 end;
458end;
459
460{ Form events ------------------------------------------------------------------------------ }
461
462procedure TfrmSurgery.FormCreate(Sender: TObject);
463begin
464 inherited;
465 PageID := CT_SURGERY;
466 EditingIndex := -1;
467 FEditNote.LastCosigner := 0;
468 FEditNote.LastCosignerName := '';
469 FLastNoteID := '';
470 frmDrawers := TfrmDrawers.CreateDrawers(Self, pnlDrawers, [],[]);
471 frmDrawers.Align := alBottom;
472 frmDrawers.RichEditControl := memNewNote;
473 frmDrawers.NewNoteButton := cmdNewNote;
474 frmDrawers.Splitter := splDrawers;
475 frmDrawers.DefTempPiece := 1;
476 FImageFlag := TBitmap.Create;
477 FCaseList := TStringList.Create;
478end;
479
480procedure TfrmSurgery.pnlRightResize(Sender: TObject);
481{ memSurgery (TRichEdit) doesn't repaint appropriately unless it's parent panel is refreshed }
482begin
483 inherited;
484 pnlRight.Refresh;
485 memSurgery.Repaint;
486end;
487
488procedure TfrmSurgery.pnlWriteResize(Sender: TObject);
489const
490 LEFT_MARGIN = 4;
491begin
492 inherited;
493 LimitEditWidth(memNewNote, MAX_ENTRY_WIDTH - 1);
494 memNewNote.Constraints.MinWidth := TextWidthByFont(memNewNote.Font.Handle, StringOfChar('X', MAX_ENTRY_WIDTH)) + (LEFT_MARGIN * 2) + ScrollBarWidth;
495 pnlLeft.Width := self.ClientWidth - pnlWrite.Width - sptHorz.Width;
496end;
497
498procedure TfrmSurgery.SetViewContext(AContext: TSurgCaseContext);
499var
500 Saved: boolean;
501begin
502 inherited;
503 if EditingIndex <> -1 then
504 begin
505 SaveCurrentNote(Saved);
506 if not Saved then Exit;
507 end;
508 FCurrentContext := AContext;
509 EditingIndex := -1;
510 tvSurgery.Enabled := True ;
511 pnlRead.BringToFront ;
512 with uSurgeryContext do
513 begin
514 Changed := True;
515 OpProc := FCurrentContext.OpProc;
516 BeginDate := FCurrentContext.BeginDate;
517 EndDate := FCurrentContext.EndDate;
518 FMBeginDate := FCurrentContext.FMBeginDate;
519 FMEndDate := FCurrentContext.FMEndDate;
520 MaxDocs := FCurrentContext.MaxDocs;
521 Status := FCurrentContext.Status;
522 GroupBy := FCurrentContext.GroupBy;
523 TreeAscending := FCurrentContext.TreeAscending;
524 mnuViewClick(Self);
525 end;
526end;
527
528procedure TfrmSurgery.FormDestroy(Sender: TObject);
529begin
530 FCaseList.Free;
531 FImageFlag.Free;
532 KillCaseTreeObjects(tvSurgery);
533 inherited;
534end;
535
536function TfrmSurgery.GetDrawers: TFrmDrawers;
537begin
538 Result := frmDrawers ;
539end;
540
541procedure TfrmSurgery.UpdateTreeView(DocList: TStringList; Tree: TORTreeView);
542var
543 i: integer;
544begin
545 with Tree do
546 begin
547 uChanging := True;
548 Items.BeginUpdate;
549 for i := 0 to DocList.Count - 1 do
550 begin
551 if Piece(DocList[i], U, 10) <> '' then
552 lstNotes.Items.Add(DocList[i]);
553 end;
554 BuildCaseTree(DocList, '0', Tree, nil, uSurgeryContext);
555 Items.EndUpdate;
556 uChanging := False;
557 end;
558end;
559
560procedure TfrmSurgery.RequestPrint;
561var
562 Saved: Boolean;
563begin
564 with lstNotes do
565 begin
566 if ItemIndex = EditingIndex then
567 begin
568 SaveCurrentNote(Saved);
569 if not Saved then Exit;
570 end;
571 if ItemIEN > 0 then PrintNote(ItemIEN, MakeNoteDisplayText(Items[ItemIndex])) else
572 begin
573 if ItemIEN = 0 then InfoBox(TX_NONOTE, TX_NONOTE_CAP, MB_OK);
574 if ItemIEN < 0 then InfoBox(TX_NOPRT_NEW, TX_NOPRT_NEW_CAP, MB_OK);
575 end;
576 end;
577end;
578
579procedure TfrmSurgery.mnuChartTabClick(Sender: TObject);
580{ reroute to Chart Tab menu of the parent form: frmFrame }
581begin
582 inherited;
583 frmFrame.mnuChartTabClick(Sender);
584end;
585
586procedure TfrmSurgery.SetFontSize(NewFontSize: Integer);
587{ adjusts the font size of any controls that don't have ParentFont = True }
588begin
589 inherited SetFontSize(NewFontSize);
590 pnlLeft.Width := pnlLeft.Constraints.MinWidth;
591 sptHorz.Left := pnlLeft.Width;
592 memSurgery.Font.Size := NewFontSize;
593 memNewNote.Font.Size := NewFontSize;
594 lblTitle.Font.Size := NewFontSize;
595 frmDrawers.Font.Size := NewFontSize;
596 SetEqualTabStops(memNewNote);
597 // adjust heights of pnlAction, pnlFields, and lstEncntShow
598end;
599
600procedure TfrmSurgery.mnuViewClick(Sender: TObject);
601{ changes the list of notes available for viewing }
602var
603 //AuthCtxt: TAuthorContext;
604 //DateRange: TNoteDateRange;
605 AContext: TSurgCaseContext;
606 Saved: Boolean;
607begin
608 inherited;
609 // save note at EditingIndex?
610 if EditingIndex <> -1 then
611 begin
612 SaveCurrentNote(Saved);
613 if not Saved then Exit;
614 end;
615 FLastNoteID := lstNotes.ItemID;
616 mnuViewDetail.Checked := False;
617 uChanging := True;
618 AContext := GetCurrentSurgCaseContext;
619 StatusText('Retrieving surgery case list...');
620 if Sender is TMenuItem then ViewContext := TMenuItem(Sender).Tag
621 else with AContext do
622 begin
623 if ((BeginDate + EndDate + Status + GroupBy + IntToStr(MaxDocs)) <> '0') then
624 ViewContext := SR_CUSTOM
625 else
626 ViewContext := SR_ALL;
627 end;
628 with tvSurgery do if (Selected <> nil) and (Piece(TORTreeNode(Selected).StringData, U, 10) <> '') then
629 FLastNoteID := Piece(TORTreeNode(Selected).StringData, U, 1);
630 case ViewContext of
631 SR_RECENT, SR_ALL: begin
632 FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
633 FillChar(uSurgeryContext, SizeOf(uSurgeryContext), 0);
634 //FCurrentContext.MaxDocs := uSurgeryContext.MaxDocs;
635 FCurrentContext.Status := IntToStr(ViewContext);
636 LoadSurgeryCases;
637 end;
638 SR_CUSTOM: begin
639 if Sender is TMenuItem then
640 begin
641 SelectSurgeryView(Font.Size, True, FCurrentContext, uSurgeryContext);
642 end;
643 with uSurgeryContext do (*if Changed then*)
644 begin
645 FCurrentContext.OpProc := OpProc;
646 FCurrentContext.BeginDate := BeginDate;
647 FCurrentContext.EndDate := EndDate;
648 FCurrentContext.FMBeginDate := FMBeginDate;
649 FCurrentContext.FMEndDate := FMEndDate;
650 if (FMBeginDate > 0) and (FMEndDate > 0) then
651 FCurrentContext.Status := IntToStr(SR_BY_DATE)
652 else
653 FCurrentContext.Status := Status;
654 FCurrentContext.MaxDocs := MaxDocs;
655 FCurrentContext.GroupBy := GroupBy;
656 FCurrentContext.TreeAscending := TreeAscending;
657 LoadSurgeryCases;
658 end;
659 end;
660 end; {case}
661 lblCases.Caption := SetSurgTreeLabel(FCurrentContext);
662 tvSurgery.Caption := lblCases.Caption;
663 StatusText('');
664end;
665
666procedure TfrmSurgery.popNoteMemoFindClick(Sender: TObject);
667begin
668 inherited;
669 SendMessage(TRichEdit(popNoteMemo.PopupComponent).Handle, WM_VSCROLL, SB_TOP, 0);
670 with dlgFindText do
671 begin
672 Position := Point(Application.MainForm.Left + pnlLeft.Width, Application.MainForm.Top);
673 FindText := '';
674 Options := [frDown, frHideUpDown];
675 Execute;
676 end;
677end;
678
679procedure TfrmSurgery.dlgFindTextFind(Sender: TObject);
680begin
681 dmodShared.FindRichEditText(dlgFindText, TRichEdit(popNoteMemo.PopupComponent));
682end;
683
684{ General procedures ----------------------------------------------------------------------- }
685
686procedure TfrmSurgery.ClearEditControls;
687{ resets controls used for entering a new progress note }
688begin
689 // clear FEditNote (should FEditNote be an object with a clear method?)
690 with FEditNote do
691 begin
692 DocType := 0;
693 Title := 0;
694 TitleName := '';
695 DateTime := 0;
696 Author := 0;
697 AuthorName := '';
698 Cosigner := 0;
699 CosignerName := '';
700 Subject := '';
701 Location := 0;
702 LocationName := '';
703 PkgRef := '';
704 PkgIEN := 0;
705 PkgPtr := '';
706 NeedCPT := False;
707 Addend := 0;
708 {LastCosigner & LastCosignerName aren't cleared because they're used as default for next note.}
709 Lines := nil;
710 end;
711 // clear the editing controls (also clear the new labels?)
712 txtSubject.Text := '';
713 memNewNote.Clear;
714 timAutoSave.Enabled := False;
715 // clear the PCE object for editing
716 uPCEEdit.Clear;
717 // set the tracking variables to initial state
718 EditingIndex := -1;
719 FChanged := False;
720end;
721
722procedure TfrmSurgery.ShowPCEControls(ShouldShow: Boolean);
723begin
724 sptVert.Visible := ShouldShow;
725 memPCEShow.Visible := ShouldShow;
726 if(ShouldShow) then
727 sptVert.Top := memPCEShow.Top - sptVert.Height;
728 memSurgery.Invalidate;
729end;
730
731procedure TfrmSurgery.DisplayPCE;
732{ displays PCE information if appropriate & enables/disabled editing of PCE data }
733var
734 EnableList, ShowList: TDrawers;
735 VitalStr: TStringlist;
736 NoPCE: boolean;
737 ActionSts: TActionRec;
738 AnIEN: integer;
739
740begin
741 memPCEShow.Clear;
742 with lstNotes do if ItemIndex = -1 then
743 begin
744 ShowPCEControls(FALSE);
745 frmDrawers.DisplayDrawers(FALSE);
746 end
747 else if ItemIndex = EditingIndex then
748 begin
749 with uPCEEdit do
750 begin
751 AddStrData(memPCEShow.Lines);
752 NoPCE := (memPCEShow.Lines.Count = 0);
753 VitalStr := TStringList.create;
754 try
755 GetVitalsFromDate(VitalStr, uPCEEdit);
756 AddVitalData(VitalStr, memPCEShow.Lines);
757 finally
758 VitalStr.free;
759 end;
760 ShowPCEButtons(TRUE);
761 ShowPCEControls(cmdPCE.Enabled or (memPCEShow.Lines.Count > 0));
762 if(NoPCE and memPCEShow.Visible) then
763 memPCEShow.Lines.Insert(0, TX_NOPCE);
764
765 if(InteractiveRemindersActive) then
766 begin
767 if(GetReminderStatus = rsNone) then
768 EnableList := [odTemplates]
769 else
770 EnableList := [odTemplates, odReminders];
771 ShowList := [odTemplates, odReminders];
772 end
773 else
774 begin
775 EnableList := [odTemplates];
776 ShowList := [odTemplates];
777 end;
778 frmDrawers.DisplayDrawers(TRUE, EnableList, ShowList);
779 end;
780 end else
781 begin
782 ShowPCEButtons(FALSE);
783 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]);
784 AnIEN := lstNotes.ItemIEN;
785 ActOnDocument(ActionSts, AnIEN, 'VIEW');
786 if ActionSts.Success then
787 begin
788 StatusText('Retrieving encounter information...');
789 with uPCEShow do
790 begin
791 NoteDateTime := MakeFMDateTime(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
792 PCEForNote(AnIEN, uPCEEdit);
793 AddStrData(memPCEShow.Lines);
794 NoPCE := (memPCEShow.Lines.Count = 0);
795 VitalStr := TStringList.create;
796 try
797 GetVitalsFromNote(VitalStr, uPCEShow, AnIEN);
798 AddVitalData(VitalStr, memPCEShow.Lines);
799 finally
800 VitalStr.free;
801 end;
802 ShowPCEControls(memPCEShow.Lines.Count > 0);
803 if(NoPCE and memPCEShow.Visible) then
804 memPCEShow.Lines.Insert(0, TX_NOPCE);
805 end;
806 StatusText('');
807 end
808 else
809 ShowPCEControls(FALSE);
810 end; {if ItemIndex}
811end;
812
813{ supporting calls for writing notes }
814
815function TfrmSurgery.GetTitleText(AnIndex: Integer): string;
816{ returns non-tabbed text for the title of a note given the ItemIndex in lstNotes }
817begin
818 with lstNotes do if ItemIndex > -1 then
819 Result := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(Items[AnIndex], U, 3))) +
820 ' ' + Piece(Items[AnIndex], U, 2) + ', ' + Piece(Items[AnIndex], U, 6) + ', ' +
821 Piece(Piece(Items[AnIndex], U, 5), ';', 2)
822end;
823
824function TfrmSurgery.LacksRequiredForCreate: Boolean;
825{ determines if the fields required to create the note are present }
826var
827 CurTitle: Integer;
828begin
829 Result := False;
830 with FEditNote do
831 begin
832 if Title <= 0 then Result := True;
833 if Author <= 0 then Result := True;
834 if DateTime <= 0 then Result := True;
835 if (DocType = TYP_ADDENDUM) then
836 begin
837 if AskCosignerForDocument(Addend, Author, DateTime) and (Cosigner <= 0) then Result := True;
838 end else
839 begin
840 if Title > 0 then CurTitle := Title else CurTitle := DocType;
841 if AskCosignerForTitle(CurTitle, Author, DateTime) and (Cosigner <= 0) then Result := True;
842 end;
843 end;
844end;
845
846function TfrmSurgery.VerifyNoteTitle: Boolean;
847const
848 VNT_UNKNOWN = 0;
849 VNT_NO = 1;
850 VNT_YES = 2;
851var
852 AParam: string;
853begin
854 if FVerifyNoteTitle = VNT_UNKNOWN then
855 begin
856 AParam := GetUserParam('ORWOR VERIFY NOTE TITLE');
857 if AParam = '1' then FVerifyNoteTitle := VNT_YES else FVerifyNoteTitle := VNT_NO;
858 end;
859 Result := FVerifyNoteTitle = VNT_YES;
860end;
861
862procedure TfrmSurgery.SetSubjectVisible(ShouldShow: Boolean);
863{ hide/show subject & resize panel accordingly - leave 6 pixel margin above memNewNote }
864begin
865 if ShouldShow then
866 begin
867 lblSubject.Visible := True;
868 txtSubject.Visible := True;
869 pnlFields.Height := txtSubject.Top + txtSubject.Height + 6;
870 end else
871 begin
872 lblSubject.Visible := False;
873 txtSubject.Visible := False;
874 pnlFields.Height := lblVisit.Top + lblVisit.Height + 6;
875 end;
876end;
877
878
879{ create, edit & save notes }
880
881procedure TfrmSurgery.InsertNewNote(IsIDChild: boolean; AnIDParent: integer);
882{ creates the editing context for a new progress note & inserts stub into top of view list }
883const
884 IS_ID_CHILD = False;
885var
886 EnableAutosave, HaveRequired: Boolean;
887 CreatedNote: TCreatedDoc;
888 TmpBoilerPlate: TStringList;
889 tmpNode: TTreeNode;
890 x, AClassName: string;
891 DocInfo: string;
892begin
893 if tvSurgery.Selected = nil then exit;
894 if PCaseTreeObject(tvSurgery.Selected.Data)^.OperativeProc = '' then
895 begin
896 InfoBox('You must first select the case to which this document will apply', 'Select a case', 0);
897 exit;
898 end;
899 EnableAutosave := FALSE;
900 TmpBoilerPlate := nil;
901 try
902 ClearEditControls;
903 FillChar(FEditNote, SizeOf(FEditNote), 0); //v15.7
904 with FEditNote do
905 begin
906 DocType := TYP_PROGRESS_NOTE;
907 Title := DfltNoteTitle;
908 TitleName := DfltNoteTitleName;
909 DateTime := FMNow;
910 Author := User.DUZ;
911 AuthorName := User.Name;
912 Location := Encounter.Location;
913 LocationName := Encounter.LocationName;
914 VisitDate := Encounter.DateTime;
915 if IsIDChild then
916 IDParent := AnIDParent
917 else
918 IDParent := 0;
919 // Cosigner & PkgRef, if needed, will be set by fNoteProps
920 end;
921 // check to see if interaction necessary to get required fields
922 if PCaseTreeObject(tvSurgery.Selected.Data)^.IsNonORProc then AClassName := DCL_SURG_NON_OR else AClassName := DCL_SURG_OR;
923 if LacksRequiredForCreate or VerifyNoteTitle
924 then HaveRequired := ExecuteNoteProperties(FEditNote, CT_SURGERY, IS_ID_CHILD, IS_ID_CHILD, AClassName, 0)
925 else HaveRequired := True;
926 if HaveRequired then
927 begin
928 // set up uPCEEdit for entry of new note
929 uPCEEdit.UseEncounter := True;
930 uPCEEdit.NoteDateTime := FEditNote.DateTime;
931 uPCEEdit.PCEForNote(USE_CURRENT_VISITSTR, uPCEShow);
932 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
933 // create the note
934 PutNewNote(CreatedNote, FEditNote);
935 uPCEEdit.NoteIEN := CreatedNote.IEN;
936 if CreatedNote.IEN > 0 then LockDocument(CreatedNote.IEN, CreatedNote.ErrorText);
937 if CreatedNote.ErrorText = '' then
938 begin
939 //x := $$RESOLVE^TIUSRVLO formatted string
940 //7348^Note Title^3000913^NERD, YOURA (N0165)^1329;Rich Vertigan;VERTIGAN,RICH^8E REHAB MED^complete^Adm: 11/05/98;2981105.095547^ ;^^0^^^2
941 with FEditNote do
942 begin
943 x := IntToStr(CreatedNote.IEN) + U + TitleName + U + FloatToStr(FEditNote.DateTime) + U +
944 Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
945 U + U + U + U + U + U + U;
946 end;
947
948 lstNotes.Items.Insert(0, x);
949 uChanging := True;
950 tvSurgery.Items.BeginUpdate;
951(* if IsIDChild then
952 begin
953 tmpNode := tvSurgery.FindPieceNode(IntToStr(AnIDParent), 1, U, tvSurgery.Items.GetFirstNode);
954 tmpNode.ImageIndex := IMG_IDNOTE_OPEN;
955 tmpNode.SelectedIndex := IMG_IDNOTE_OPEN;
956 tmpNode := tvSurgery.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeCaseTreeObject(x));
957 tmpNode.ImageIndex := IMG_ID_CHILD;
958 tmpNode.SelectedIndex := IMG_ID_CHILD;
959 end
960 else*)
961 begin
962 tmpNode := tvSurgery.Items.AddObjectFirst(tvSurgery.Items.GetFirstNode, 'New Note in Progress',
963 MakeCaseTreeObject('NEW^New Note in Progress^^^^^^^^^^^%^0'));
964 TORTreeNode(tmpNode).StringData := 'NEW^New Note in Progress^^^^^^^^^^^%^0';
965 tmpNode.ImageIndex := IMG_SURG_TOP_LEVEL;
966 tmpNode := tvSurgery.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeCaseTreeObject(x));
967 tmpNode.ImageIndex := IMG_SURG_RPT_SINGLE;
968 tmpNode.SelectedIndex := IMG_SURG_RPT_SINGLE;
969 end;
970 tmpNode.StateIndex := IMG_NO_IMAGES;
971 TORTreeNode(tmpNode).StringData := x;
972 tvSurgery.Selected := tmpNode;
973 tvSurgery.Items.EndUpdate;
974 uChanging := False;
975 Changes.Add(CH_SUR, IntToStr(CreatedNote.IEN), GetTitleText(0), '', CH_SIGN_YES);
976 lstNotes.ItemIndex := 0;
977 EditingIndex := 0;
978 SetSubjectVisible(AskSubjectForNotes);
979 if not assigned(TmpBoilerPlate) then
980 TmpBoilerPlate := TStringList.Create;
981 LoadBoilerPlate(TmpBoilerPlate, FEditNote.Title);
982 FChanged := False;
983 cmdChangeClick(Self); // will set captions, sign state for Changes
984 lstNotesClick(Self); // will make pnlWrite visible
985 if timAutoSave.Interval <> 0 then EnableAutosave := TRUE;
986 if txtSubject.Visible then txtSubject.SetFocus else memNewNote.SetFocus;
987 end else
988 begin
989 // if note creation failed or failed to get note lock (both unlikely), unlock consult
990 InfoBox(CreatedNote.ErrorText, TX_CREATE_ERR, MB_OK);
991 HaveRequired := False;
992 end; {if CreatedNote.IEN}
993 end; {if HaveRequired}
994 if not HaveRequired then ClearEditControls;
995 finally
996 if assigned(TmpBoilerPlate) then
997 begin
998 DocInfo := MakeXMLParamTIU(IntToStr(CreatedNote.IEN), FEditNote);
999 ExecuteTemplateOrBoilerPlate(TmpBoilerPlate, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
1000 QuickCopy(TmpBoilerPlate, memNewNote);
1001 TmpBoilerPlate.Free;
1002 end;
1003 if EnableAutosave then // Don't enable autosave until after dialog fields have been resolved
1004 timAutoSave.Enabled := True;
1005 end;
1006end;
1007
1008procedure TfrmSurgery.InsertAddendum;
1009{ sets up fields of pnlWrite to write an addendum for the selected note }
1010const
1011 AS_ADDENDUM = True;
1012 IS_ID_CHILD = False;
1013var
1014 HaveRequired: Boolean;
1015 CreatedNote: TCreatedDoc;
1016 tmpNode: TTreeNode;
1017 x: string;
1018begin
1019 ClearEditControls;
1020 with FEditNote do
1021 begin
1022 DocType := TYP_ADDENDUM;
1023 Title := TitleForNote(lstNotes.ItemIEN);
1024 TitleName := Piece(lstNotes.Items[lstNotes.ItemIndex], U, 2);
1025 if Copy(TitleName,1,1) = '+' then TitleName := Copy(TitleName, 3, 199);
1026 DateTime := FMNow;
1027 Author := User.DUZ;
1028 AuthorName := User.Name;
1029 Addend := lstNotes.ItemIEN;
1030 x := GetPackageRefForNote(lstNotes.ItemIEN);
1031 if Piece(x, U, 1) <> '-1' then
1032 begin
1033 PkgRef := GetPackageRefForNote(lstNotes.ItemIEN);
1034 PkgIEN := StrToIntDef(Piece(PkgRef, ';', 1), 0);
1035 PkgPtr := Piece(PkgRef, ';', 2);
1036 end;
1037 //Lines := memNewNote.Lines;
1038 // Cosigner, if needed, will be set by fNoteProps
1039 // Location info will be set after the encounter is loaded
1040 end;
1041 // check to see if interaction necessary to get required fields
1042 if LacksRequiredForCreate
1043 then HaveRequired := ExecuteNoteProperties(FEditNote, CT_SURGERY, IS_ID_CHILD, False, '', 0)
1044 else HaveRequired := True;
1045 if HaveRequired then
1046 begin
1047 uPCEEdit.NoteDateTime := FEditNote.DateTime;
1048 uPCEEdit.PCEForNote(FEditNote.Addend, uPCEShow);
1049 FEditNote.Location := uPCEEdit.Location;
1050 FEditNote.LocationName := ExternalName(uPCEEdit.Location, 44);
1051 FEditNote.VisitDate := uPCEEdit.DateTime;
1052 PutAddendum(CreatedNote, FEditNote, FEditNote.Addend);
1053 uPCEEdit.NoteIEN := CreatedNote.IEN;
1054 if CreatedNote.IEN > 0 then LockDocument(CreatedNote.IEN, CreatedNote.ErrorText);
1055 if CreatedNote.ErrorText = '' then
1056 begin
1057 with FEditNote do
1058 begin
1059 x := IntToStr(CreatedNote.IEN) + U + 'Addendum to ' + TitleName + U + FloatToStr(DateTime) + U +
1060 Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
1061 U + U + PkgRef + U + U + U + U + U;
1062 end;
1063
1064
1065 lstNotes.Items.Insert(0, x);
1066 uChanging := True;
1067 tvSurgery.Items.BeginUpdate;
1068 tmpNode := tvSurgery.Items.AddObjectFirst(tvSurgery.Items.GetFirstNode, 'New Addendum in Progress',
1069 MakeCaseTreeObject('ADDENDUM^New Addendum in Progress^^^^^^^^^^^%^0'));
1070 TORTreeNode(tmpNode).StringData := 'ADDENDUM^New Addendum in Progress^^^^^^^^^^^%^0';
1071 tmpNode.ImageIndex := IMG_SURG_TOP_LEVEL;
1072 tmpNode := tvSurgery.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeCaseTreeObject(x));
1073 TORTreeNode(tmpNode).StringData := x;
1074
1075 tmpNode.ImageIndex := IMG_SURG_ADDENDUM;
1076 tmpNode.SelectedIndex := IMG_SURG_ADDENDUM;
1077 tvSurgery.Selected := tmpNode;
1078 tvSurgery.Items.EndUpdate;
1079 uChanging := False;
1080 Changes.Add(CH_SUR, IntToStr(CreatedNote.IEN), GetTitleText(0), '', CH_SIGN_YES);
1081 lstNotes.ItemIndex := 0;
1082 EditingIndex := 0;
1083 SetSubjectVisible(AskSubjectForNotes);
1084 cmdChangeClick(Self); // will set captions, sign state for Changes
1085 lstNotesClick(Self); // will make pnlWrite visible
1086 if timAutoSave.Interval <> 0 then timAutoSave.Enabled := True;
1087 memNewNote.SetFocus;
1088 end else
1089 begin
1090 // if note creation failed or failed to get note lock (both unlikely), unlock consult
1091 InfoBox(CreatedNote.ErrorText, TX_CREATE_ERR, MB_OK);
1092 HaveRequired := False;
1093 end; {if CreatedNote.IEN}
1094 end; {if HaveRequired}
1095 if not HaveRequired then ClearEditControls;
1096end;
1097
1098procedure TfrmSurgery.LoadForEdit;
1099{ retrieves an existing note and places the data in the fields of pnlWrite }
1100var
1101 tmpNode: TTreeNode;
1102 x: string;
1103begin
1104 ClearEditControls;
1105 EditingIndex := lstNotes.ItemIndex;
1106 Changes.Add(CH_SUR, lstNotes.ItemID, GetTitleText(EditingIndex), '', CH_SIGN_YES);
1107 GetNoteForEdit(FEditNote, lstNotes.ItemIEN);
1108 memNewNote.Lines.Assign(FEditNote.Lines);
1109 FChanged := False;
1110 if FEditNote.Title = TYP_ADDENDUM then
1111 begin
1112 FEditNote.DocType := TYP_ADDENDUM;
1113 FEditNote.TitleName := Piece(lstNotes.Items[lstNotes.ItemIndex], U, 2);
1114 if Copy(FEditNote.TitleName,1,1) = '+' then FEditNote.TitleName := Copy(FEditNote.TitleName, 3, 199);
1115 if CompareText(Copy(FEditNote.TitleName, 1, 8), 'Addendum') <> 0
1116 then FEditNote.TitleName := FEditNote.TitleName + 'Addendum to ';
1117 end;
1118
1119 uChanging := True;
1120 tvSurgery.Items.BeginUpdate;
1121
1122 tmpNode := tvSurgery.FindPieceNode('EDIT', 1, U, nil);
1123 if tmpNode = nil then
1124 begin
1125 tmpNode := tvSurgery.Items.AddObjectFirst(tvSurgery.Items.GetFirstNode, 'Note being edited',
1126 MakeCaseTreeObject('EDIT^Note being edited^^^^^^^^^^^%^0'));
1127 TORTreeNode(tmpNode).StringData := 'EDIT^Note being edited^^^^^^^^^^^%^0';
1128 end
1129 else
1130 tmpNode.DeleteChildren;
1131 x := lstNotes.Items[lstNotes.ItemIndex];
1132 tmpNode.ImageIndex := IMG_SURG_TOP_LEVEL;
1133 tmpNode := tvSurgery.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeCaseTreeObject(x));
1134 TORTreeNode(tmpNode).StringData := x;
1135 if CompareText(Copy(FEditNote.TitleName, 1, 8), 'Addendum') <> 0 then
1136 tmpNode.ImageIndex := IMG_SURG_RPT_SINGLE
1137 else
1138 tmpNode.ImageIndex := IMG_SURG_ADDENDUM;
1139 tmpNode.SelectedIndex := tmpNode.ImageIndex;
1140 tvSurgery.Selected := tmpNode;
1141 tvSurgery.Items.EndUpdate;
1142 uChanging := False;
1143
1144 uPCEEdit.NoteDateTime := MakeFMDateTime(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
1145 uPCEEdit.PCEForNote(lstNotes.ItemIEN, uPCEShow);
1146 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
1147 txtSubject.Text := FEditNote.Subject;
1148 SetSubjectVisible(AskSubjectForNotes);
1149 cmdChangeClick(Self); // will set captions, sign state for Changes
1150 lstNotesClick(Self); // will make pnlWrite visible
1151 if timAutoSave.Interval <> 0 then timAutoSave.Enabled := True;
1152 memNewNote.SetFocus;
1153end;
1154
1155procedure TfrmSurgery.SaveEditedNote(var Saved: Boolean);
1156{ validates fields and sends the updated note to the server }
1157var
1158 UpdatedNote: TCreatedDoc;
1159 x: string;
1160begin
1161 Saved := False;
1162 if (memNewNote.GetTextLen = 0) or (not ContainsVisibleChar(memNewNote.Text)) then
1163 begin
1164 lstNotes.ItemIndex := EditingIndex;
1165 x := lstNotes.ItemID;
1166 uChanging := True;
1167 with tvSurgery do Selected := FindPieceNode(x, 1, U, Items.GetFirstNode);
1168 uChanging := False;
1169 tvSurgeryChange(Self, tvSurgery.Selected);
1170 if FSilent or
1171 ((not FSilent) and
1172 (InfoBox(GetTitleText(EditingIndex) + TX_EMPTY_NOTE, TC_EMPTY_NOTE, MB_YESNO) = IDYES))
1173 then
1174 begin
1175 FConfirmed := True;
1176 mnuActDeleteClick(Self);
1177 Saved := True;
1178 FDeleted := True;
1179 end
1180 else
1181 FConfirmed := False;
1182 Exit;
1183 end;
1184 //ExpandTabsFilter(memNewNote.Lines, TAB_STOP_CHARS);
1185 FEditNote.Lines := memNewNote.Lines;
1186 FEditNote.Subject := txtSubject.Text;
1187 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
1188 timAutoSave.Enabled := False;
1189 try
1190 PutEditedNote(UpdatedNote, FEditNote, lstNotes.GetIEN(EditingIndex));
1191 finally
1192 timAutoSave.Enabled := True;
1193 end;
1194 // there's no unlocking here since the note is still in Changes after a save
1195 if UpdatedNote.IEN > 0 then
1196 begin
1197 if lstNotes.ItemIndex = EditingIndex then
1198 begin
1199 EditingIndex := -1;
1200 lstNotesClick(Self);
1201 end;
1202 EditingIndex := -1; // make sure EditingIndex reset even if not viewing edited note
1203 Saved := True;
1204 FChanged := False;
1205 end else
1206 begin
1207 if not FSilent then
1208 InfoBox(TX_SAVE_ERROR1 + UpdatedNote.ErrorText + TX_SAVE_ERROR2, TC_SAVE_ERROR, MB_OK or MB_ICONWARNING);
1209 end;
1210end;
1211
1212procedure TfrmSurgery.SaveCurrentNote(var Saved: Boolean);
1213{ called whenever a note should be saved - uses IEN to call appropriate save logic }
1214begin
1215 if EditingIndex < 0 then Exit;
1216 SaveEditedNote(Saved);
1217end;
1218
1219{ Left panel (selector) events ------------------------------------------------------------- }
1220
1221procedure TfrmSurgery.cmdNewNoteClick(Sender: TObject);
1222{ maps 'New Note' button to the New Progress Note menu item }
1223begin
1224 inherited;
1225 mnuActNewClick(Self);
1226end;
1227
1228procedure TfrmSurgery.cmdPCEClick(Sender: TObject);
1229var
1230 Refresh: boolean;
1231 ActionSts: TActionRec;
1232 AnIEN: integer;
1233 PCEObj: TPCEData;
1234
1235begin
1236 inherited;
1237 cmdPCE.Enabled := False;
1238 if not FEditingNotePCEObj then
1239 begin
1240 PCEObj := nil;
1241 AnIEN := lstNotes.ItemIEN;
1242 if (AnIEN <> 0) and (memSurgery.Lines.Count > 0) then
1243 begin
1244 ActOnDocument(ActionSts, AnIEN, 'VIEW');
1245 if ActionSts.Success then
1246 begin
1247 uPCEShow.CopyPCEData(uPCEEdit);
1248 PCEObj := uPCEEdit;
1249 end;
1250 end;
1251 Refresh := EditPCEData(PCEObj);
1252 end
1253 else
1254 begin
1255 UpdatePCE(uPCEEdit);
1256 Refresh := TRUE;
1257 end;
1258 cmdPCE.Enabled := True;
1259 if Refresh and (not frmFrame.Closing) then
1260 DisplayPCE;
1261end;
1262
1263{ Right panel (editor) events -------------------------------------------------------------- }
1264
1265procedure TfrmSurgery.mnuActChangeClick(Sender: TObject);
1266begin
1267 inherited;
1268 if (FEditingIndex < 0) or (lstNotes.ItemIndex <> FEditingIndex) then Exit;
1269 cmdChangeClick(Sender);
1270end;
1271
1272procedure TfrmSurgery.mnuActLoadBoilerClick(Sender: TObject);
1273var
1274 NoteEmpty: Boolean;
1275 BoilerText: TStringList;
1276 DocInfo: string;
1277
1278 procedure AssignBoilerText;
1279 begin
1280 ExecuteTemplateOrBoilerPlate(BoilerText, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
1281 QuickCopy(BoilerText, memNewNote);
1282 FChanged := False;
1283 end;
1284
1285begin
1286 inherited;
1287 if (FEditingIndex < 0) or (lstNotes.ItemIndex <> FEditingIndex) then Exit;
1288 BoilerText := TStringList.Create;
1289 try
1290 NoteEmpty := memNewNote.Text = '';
1291 LoadBoilerPlate(BoilerText, FEditNote.Title);
1292 if (BoilerText.Text <> '') or
1293 assigned(GetLinkedTemplate(IntToStr(FEditNote.Title), ltTitle)) then
1294 begin
1295 if NoteEmpty then AssignBoilerText else
1296 begin
1297 DocInfo := MakeXMLParamTIU(IntToStr(lstNotes.ItemIEN), FEditNote);
1298 case QueryBoilerPlate(BoilerText) of
1299 0: { do nothing } ; // ignore
1300 1: begin
1301 ExecuteTemplateOrBoilerPlate(BoilerText, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
1302 QuickAdd(BoilerText, memNewNote); // append
1303 end;
1304 2: AssignBoilerText; // replace
1305 end;
1306 end;
1307 end else
1308 begin
1309 if Sender = mnuActLoadBoiler
1310 then InfoBox(TX_NO_BOIL, TC_NO_BOIL, MB_OK)
1311 else
1312 begin
1313 if not NoteEmpty then
1314 if not FChanged and (InfoBox(TX_BLR_CLEAR, TC_BLR_CLEAR, MB_YESNO) = ID_YES)
1315 then memNewNote.Lines.Clear;
1316 end;
1317 end; {if BoilerText.Text <> ''}
1318 finally
1319 BoilerText.Free;
1320 end;
1321end;
1322
1323procedure TfrmSurgery.cmdChangeClick(Sender: TObject);
1324const
1325 IS_ID_CHILD = False;
1326var
1327 LastTitle: Integer;
1328 OKPressed: boolean;
1329 x, AClassName: string;
1330begin
1331 inherited;
1332 LastTitle := FEditNote.Title;
1333 if IsNonORProcedure(FEditNote.PkgIEN) then AClassName := DCL_SURG_NON_OR else AClassName := DCL_SURG_OR;
1334 if Sender <> Self then OKPressed := ExecuteNoteProperties(FEditNote, CT_SURGERY, IS_ID_CHILD, IS_ID_CHILD, AClassName, 0)
1335 else OKPressed := True;
1336 if not OKPressed then Exit;
1337 // update display fields & uPCEEdit
1338 lblNewTitle.Caption := ' ' + FEditNote.TitleName + ' ';
1339 if (FEditNote.Addend > 0) and (CompareText(Copy(lblNewTitle.Caption, 2, 8), 'Addendum') <> 0)
1340 then lblNewTitle.Caption := ' Addendum to:' + lblNewTitle.Caption;
1341 with lblNewTitle do bvlNewTitle.SetBounds(Left - 1, Top - 1, Width + 2, Height + 2);
1342 lblRefDate.Caption := FormatFMDateTime('mmm dd,yyyy@hh:nn', FEditNote.DateTime);
1343 lblAuthor.Caption := FEditNote.AuthorName;
1344 if uPCEEdit.Inpatient then x := 'Adm: ' else x := 'Vst: ';
1345 x := x + FormatFMDateTime('mm/dd/yy', FEditNote.VisitDate) + ' ' + FEditNote.LocationName;
1346 lblVisit.Caption := x;
1347 if Length(FEditNote.CosignerName) > 0
1348 then lblCosigner.Caption := 'Expected Cosigner: ' + FEditNote.CosignerName
1349 else lblCosigner.Caption := '';
1350 uPCEEdit.NoteTitle := FEditNote.Title;
1351 // modify signature requirements if author or cosigner changed
1352 if (User.DUZ <> FEditNote.Author) and (User.DUZ <> FEditNote.Cosigner)
1353 then Changes.ReplaceSignState(CH_SUR, lstNotes.ItemID, CH_SIGN_NA)
1354 else Changes.ReplaceSignState(CH_SUR, lstNotes.ItemID, CH_SIGN_YES);
1355 x := lstNotes.Items[EditingIndex];
1356 SetPiece(x, U, 2, lblNewTitle.Caption);
1357 SetPiece(x, U, 3, FloatToStr(FEditNote.DateTime));
1358 tvSurgery.Selected.Text := MakeNoteDisplayText(x);
1359 TORTreeNode(tvSurgery.Selected).StringData := x;
1360 lstNotes.Items[EditingIndex] := x;
1361 Changes.ReplaceText(CH_SUR, lstNotes.ItemID, GetTitleText(EditingIndex));
1362 if LastTitle <> FEditNote.Title then mnuActLoadBoilerClick(Self);
1363end;
1364
1365procedure TfrmSurgery.memNewNoteChange(Sender: TObject);
1366begin
1367 inherited;
1368 FChanged := True;
1369end;
1370
1371procedure TfrmSurgery.pnlFieldsResize(Sender: TObject);
1372{ center the reference date on the panel }
1373begin
1374 inherited;
1375 lblRefDate.Left := (pnlFields.Width - lblRefDate.Width) div 2;
1376 if lblRefDate.Left < (lblNewTitle.Left + lblNewTitle.Width + 6)
1377 then lblRefDate.Left := (lblNewTitle.Left + lblNewTitle.Width);
1378end;
1379
1380procedure TfrmSurgery.DoAutoSave(Suppress: integer = 1);
1381var
1382 ErrMsg: string;
1383begin
1384 if fFrame.frmFrame.DLLActive = true then Exit;
1385 if (EditingIndex > -1) and FChanged then
1386 begin
1387 StatusText('Autosaving note...');
1388 //PutTextOnly(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex));
1389 timAutoSave.Enabled := False;
1390 try
1391 SetText(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex), Suppress);
1392 finally
1393 timAutoSave.Enabled := True;
1394 end;
1395 FChanged := False;
1396 StatusText('');
1397 end;
1398 if ErrMsg <> '' then
1399 InfoBox(TX_SAVE_ERROR1 + ErrMsg + TX_SAVE_ERROR2, TC_SAVE_ERROR, MB_OK or MB_ICONWARNING);
1400 //Assert(ErrMsg = '', 'AutoSave: ' + ErrMsg);
1401end;
1402
1403procedure TfrmSurgery.timAutoSaveTimer(Sender: TObject);
1404begin
1405 inherited;
1406 DoAutoSave;
1407end;
1408
1409{ Action menu events ----------------------------------------------------------------------- }
1410
1411function TfrmSurgery.StartNewEdit(NewNoteType: integer): Boolean;
1412{ if currently editing a note, returns TRUE if the user wants to start a new one }
1413var
1414 Saved: Boolean;
1415 Msg, CapMsg: string;
1416begin
1417 Result := True;
1418 if EditingIndex > -1 then
1419 begin
1420 case NewNoteType of
1421 NT_ACT_ADDENDUM: begin
1422 Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE3;
1423 CapMsg := TC_NEW_SAVE3;
1424 end;
1425 NT_ACT_EDIT_NOTE: begin
1426 Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE4;
1427 CapMsg := TC_NEW_SAVE4;
1428 end;
1429 else
1430 begin
1431 Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE2;
1432 CapMsg := TC_NEW_SAVE2;
1433 end;
1434 end;
1435 if InfoBox(Msg, CapMsg, MB_YESNO) = IDNO then Result := False
1436 else
1437 begin
1438 SaveCurrentNote(Saved);
1439 if not Saved then Result := False else LoadSurgeryCases;
1440 end;
1441 end;
1442end;
1443
1444procedure TfrmSurgery.mnuActNewClick(Sender: TObject);
1445const
1446 IS_ID_CHILD = False;
1447{ switches to current new note or creates a new note if none is being edited already }
1448begin
1449 inherited;
1450 if not StartNewEdit(NT_ACT_NEW_NOTE) then Exit;
1451 //LoadNotes;
1452 // make sure a visit (time & location) is available before creating the note
1453 if Encounter.NeedVisit then
1454 begin
1455 UpdateVisit(Font.Size, DfltTIULocation);
1456 frmFrame.DisplayEncounterText;
1457 end;
1458 if Encounter.NeedVisit then
1459 begin
1460 InfoBox(TX_NEED_VISIT, TX_NO_VISIT, MB_OK or MB_ICONWARNING);
1461 Exit;
1462 end;
1463 InsertNewNote(IS_ID_CHILD, 0);
1464end;
1465
1466
1467procedure TfrmSurgery.mnuActAddendClick(Sender: TObject);
1468{ make an addendum to an existing note }
1469var
1470 ActionSts: TActionRec;
1471 ANoteID: string;
1472begin
1473 inherited;
1474 if lstNotes.ItemIEN <= 0 then Exit;
1475 ANoteID := lstNotes.ItemID;
1476 if not StartNewEdit(NT_ACT_ADDENDUM) then Exit;
1477 //LoadNotes;
1478 with tvSurgery do Selected := FindPieceNode(ANoteID, 1, U, Items.GetFirstNode);
1479 if lstNotes.ItemIndex = EditingIndex then
1480 begin
1481 InfoBox(TX_ADDEND_NO, TX_ADDEND_MK, MB_OK);
1482 Exit;
1483 end;
1484 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'MAKE ADDENDUM');
1485 if not ActionSts.Success then
1486 begin
1487 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
1488 Exit;
1489 end;
1490 with lstNotes do if TitleForNote(lstNotes.ItemIEN) = TYP_ADDENDUM then
1491 begin
1492 InfoBox(TX_ADDEND_AD, TX_ADDEND_MK, MB_OK);
1493 Exit;
1494 end;
1495 InsertAddendum;
1496end;
1497
1498
1499procedure TfrmSurgery.mnuActSignListClick(Sender: TObject);
1500{ add the note to the Encounter object, see mnuActSignClick - copied}
1501const
1502 SIG_COSIGN = 'COSIGNATURE';
1503 SIG_SIGN = 'SIGNATURE';
1504var
1505 ActionType, SignTitle: string;
1506 ActionSts: TActionRec;
1507begin
1508 inherited;
1509 if lstNotes.ItemIEN = 0 then Exit;
1510 if lstNotes.ItemIndex = EditingIndex then Exit; // already in signature list
1511 if not NoteHasText(lstNotes.ItemIEN) then
1512 begin
1513 InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
1514 Exit;
1515 end;
1516 if not LastSaveClean(lstNotes.ItemIEN) and
1517 (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES) then Exit;
1518 if CosignDocument(lstNotes.ItemIEN) then
1519 begin
1520 SignTitle := TX_COSIGN;
1521 ActionType := SIG_COSIGN;
1522 end else
1523 begin
1524 SignTitle := TX_SIGN;
1525 ActionType := SIG_SIGN;
1526 end;
1527 ActOnDocument(ActionSts, lstNotes.ItemIEN, ActionType);
1528 if not ActionSts.Success then
1529 begin
1530 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
1531 Exit;
1532 end;
1533 with lstNotes do Changes.Add(CH_SUR, ItemID, GetTitleText(ItemIndex), '', CH_SIGN_YES);
1534end;
1535
1536procedure TfrmSurgery.RemovePCEFromChanges(IEN: Int64; AVisitStr: string = '');
1537begin
1538 if IEN = NT_ADDENDUM then Exit; // no PCE information entered for an addendum
1539 // do we need to call DeletePCE(AVisitStr), as was done with NT_NEW_NOTE (ien=-10)???
1540 if AVisitStr = '' then AVisitStr := VisitStrForNote(IEN);
1541 Changes.Remove(CH_PCE, 'V' + AVisitStr);
1542 Changes.Remove(CH_PCE, 'P' + AVisitStr);
1543 Changes.Remove(CH_PCE, 'D' + AVisitStr);
1544 Changes.Remove(CH_PCE, 'I' + AVisitStr);
1545 Changes.Remove(CH_PCE, 'S' + AVisitStr);
1546 Changes.Remove(CH_PCE, 'A' + AVisitStr);
1547 Changes.Remove(CH_PCE, 'H' + AVisitStr);
1548 Changes.Remove(CH_PCE, 'E' + AVisitStr);
1549 Changes.Remove(CH_PCE, 'T' + AVisitStr);
1550end;
1551
1552procedure TfrmSurgery.mnuActDeleteClick(Sender: TObject);
1553{ delete the selected progress note & remove from the Encounter object if necessary }
1554var
1555 DeleteSts, ActionSts: TActionRec;
1556 SavedDocIEN: Integer;
1557 ReasonForDelete, AVisitStr, SavedDocID, ErrMsg: string;
1558 Saved: boolean;
1559begin
1560 inherited;
1561 if lstNotes.ItemIEN = 0 then Exit;
1562 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'DELETE RECORD');
1563 if ShowMsgOn(not ActionSts.Success, ActionSts.Reason, TX_IN_AUTH) then Exit;
1564 ReasonForDelete := SelectDeleteReason(lstNotes.ItemIEN);
1565 if ReasonForDelete = DR_CANCEL then Exit;
1566 // suppress prompt for deletion when called from SaveEditedNote (Sender = Self)
1567 if (Sender <> Self) and (InfoBox(MakeNoteDisplayText(lstNotes.Items[lstNotes.ItemIndex]) + TX_DEL_OK,
1568 TX_DEL_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) then Exit;
1569 // do the appropriate locking
1570 ErrMsg := '';
1571 LockDocument(lstNotes.ItemIEN, ErrMsg);
1572 if ErrMsg <> '' then
1573 begin
1574 InfoBox(ErrMsg, TC_NO_LOCK, MB_OK);
1575 Exit;
1576 end;
1577 // retraction notification message
1578 if JustifyDocumentDelete(lstNotes.ItemIEN) then
1579 InfoBox(TX_RETRACT, TX_RETRACT_CAP, MB_OK);
1580 SavedDocID := lstNotes.ItemID;
1581 SavedDocIEN := lstNotes.ItemIEN;
1582 if (EditingIndex > -1) and (not FConfirmed) and (lstNotes.ItemIndex <> EditingIndex) and (memNewNote.GetTextLen > 0) then
1583 begin
1584 SaveCurrentNote(Saved);
1585 if not Saved then Exit;
1586 end;
1587 EditingIndex := -1;
1588 FConfirmed := False;
1589 // remove the note
1590 DeleteSts.Success := True;
1591 AVisitStr := VisitStrForNote(SavedDocIEN);
1592 RemovePCEFromChanges(SavedDocIEN, AVisitStr);
1593 if (SavedDocIEN > 0) and (lstNotes.ItemIEN = SavedDocIEN) then DeleteDocument(DeleteSts, SavedDocIEN, ReasonForDelete);
1594 if not Changes.Exist(CH_SUR, SavedDocID) then UnlockDocument(SavedDocIEN);
1595 Changes.Remove(CH_SUR, SavedDocID); // this will unlock the document if in Changes
1596 // reset the display now that the note is gone
1597 if DeleteSts.Success then
1598 begin
1599 DeletePCE(AVisitStr); // removes PCE data if this was the only note pointing to it
1600 ClearEditControls;
1601 LoadSurgeryCases;
1602 pnlWrite.Visible := False;
1603 pnlRead.Visible := True;
1604 UpdateReminderFinish;
1605 ShowPCEControls(False);
1606 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]); //FALSE);
1607 ShowPCEButtons(FALSE);
1608 //end; {if ItemIndex}
1609 end {if DeleteSts}
1610 else InfoBox(DeleteSts.Reason, TX_DEL_ERR, MB_OK or MB_ICONWARNING);
1611end;
1612
1613procedure TfrmSurgery.mnuActEditClick(Sender: TObject);
1614{ load the selected progress note for editing }
1615var
1616 ActionSts: TActionRec;
1617 ANoteID: string;
1618begin
1619 inherited;
1620 if lstNotes.ItemIndex = EditingIndex then Exit;
1621 ANoteID := lstNotes.ItemID;
1622 if not StartNewEdit(NT_ACT_EDIT_NOTE) then Exit;
1623 //LoadNotes;
1624 with tvSurgery do Selected := FindPieceNode(ANoteID, 1, U, Items.GetFirstNode);
1625 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'EDIT RECORD');
1626 if not ActionSts.Success then
1627 begin
1628 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
1629 Exit;
1630 end;
1631 LoadForEdit;
1632end;
1633
1634procedure TfrmSurgery.mnuActSaveClick(Sender: TObject);
1635{ saves the note that is currently being edited }
1636var
1637 Saved: Boolean;
1638 SavedDocID: string;
1639begin
1640 inherited;
1641 if EditingIndex > -1 then
1642 begin
1643 SavedDocID := Piece(lstNotes.Items[EditingIndex], U, 1);
1644 FLastNoteID := SavedDocID;
1645 SaveCurrentNote(Saved);
1646 if Saved and (EditingIndex < 0) and (not FDeleted) then
1647 //if Saved then
1648 begin
1649 LoadSurgeryCases;
1650 with tvSurgery do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
1651 end;
1652 end
1653 else InfoBox(TX_NO_NOTE, TX_SAVE_NOTE, MB_OK or MB_ICONWARNING);
1654end;
1655
1656procedure TfrmSurgery.mnuActSignClick(Sender: TObject);
1657{ sign the currently selected note, save first if necessary }
1658const
1659 SIG_COSIGN = 'COSIGNATURE';
1660 SIG_SIGN = 'SIGNATURE';
1661var
1662 Saved, NoteUnlocked: Boolean;
1663 ActionType, ESCode, SignTitle: string;
1664 ActionSts, SignSts: TActionRec;
1665 OK: boolean;
1666 SavedDocID, tmpItem: string;
1667 EditingID: string; //v22.12 - RV
1668 tmpNode: TTreeNode;
1669begin
1670 inherited;
1671(* if lstNotes.ItemIndex = EditingIndex then //v22.12 - RV
1672 begin //v22.12 - RV
1673 SaveCurrentNote(Saved); //v22.12 - RV
1674 if (not Saved) or FDeleted then Exit; //v22.12 - RV
1675 end //v22.12 - RV
1676 else if EditingIndex > -1 then //v22.12 - RV
1677 tmpItem := lstNotes.Items[EditingIndex]; //v22.12 - RV
1678 SavedDocID := lstNotes.ItemID;*) //v22.12 - RV
1679 SavedDocID := lstNotes.ItemID; //v22.12 - RV
1680 FLastNoteID := SavedDocID; //v22.12 - RV
1681 if lstNotes.ItemIndex = EditingIndex then //v22.12 - RV
1682 begin //v22.12 - RV
1683 SaveCurrentNote(Saved); //v22.12 - RV
1684 if (not Saved) or FDeleted then Exit; //v22.12 - RV
1685 end //v22.12 - RV
1686 else if EditingIndex > -1 then //v22.12 - RV
1687 begin //v22.12 - RV
1688 tmpItem := lstNotes.Items[EditingIndex]; //v22.12 - RV
1689 EditingID := Piece(tmpItem, U, 1); //v22.12 - RV
1690 end; //v22.12 - RV
1691 if not NoteHasText(lstNotes.ItemIEN) then
1692 begin
1693 InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
1694 Exit;
1695 end;
1696 if not LastSaveClean(lstNotes.ItemIEN) and
1697 (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES) then Exit;
1698 if CosignDocument(lstNotes.ItemIEN) then
1699 begin
1700 SignTitle := TX_COSIGN;
1701 ActionType := SIG_COSIGN;
1702 end else
1703 begin
1704 SignTitle := TX_SIGN;
1705 ActionType := SIG_SIGN;
1706 end;
1707 // no exits after things are locked
1708 NoteUnlocked := False;
1709 ActOnDocument(ActionSts, lstNotes.ItemIEN, ActionType);
1710 if ActionSts.Success then
1711 begin
1712 OK := IsOK2Sign(uPCEShow, lstNotes.ItemIEN);
1713 if frmFrame.Closing then exit;
1714 if(uPCEShow.Updated) then
1715 begin
1716 uPCEShow.CopyPCEData(uPCEEdit);
1717 uPCEShow.Updated := FALSE;
1718 lstNotesClick(Self);
1719 end;
1720 if(OK) then
1721 begin
1722 //DisplayOpTop(lstNotes.ItemIEN); v24.2 - RV
1723 with lstNotes do SignatureForItem(Font.Size, MakeNoteDisplayText(Items[ItemIndex]), SignTitle, ESCode);
1724 if Length(ESCode) > 0 then
1725 begin
1726 SignDocument(SignSts, lstNotes.ItemIEN, ESCode);
1727 RemovePCEFromChanges(lstNotes.ItemIEN);
1728 NoteUnlocked := Changes.Exist(CH_SUR, lstNotes.ItemID);
1729 Changes.Remove(CH_SUR, lstNotes.ItemID); // this will unlock if in Changes
1730 if SignSts.Success then
1731 begin
1732 SendMessage(frmConsults.Handle, UM_NEWORDER, ORDER_SIGN, 0); {*REV*}
1733 lstNotesClick(Self);
1734 end
1735 else InfoBox(SignSts.Reason, TX_SIGN_ERR, MB_OK);
1736 end; {if Length(ESCode)}
1737 end;
1738 end
1739 else InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
1740 if not NoteUnlocked then UnlockDocument(lstNotes.ItemIEN);
1741 LoadSurgeryCases;
1742 //if EditingIndex > -1 then //v22.12 - RV
1743 if (EditingID <> '') then //v22.12 - RV
1744 begin
1745 lstNotes.Items.Insert(0, tmpItem);
1746 tmpNode := tvSurgery.Items.AddObjectFirst(tvSurgery.Items.GetFirstNode, 'Note being edited',
1747 MakeCaseTreeObject('EDIT^Note being edited^^^^^^^^^^^%^0'));
1748 TORTreeNode(tmpNode).StringData := 'EDIT^Note being edited^^^^^^^^^^^%^0';
1749 tmpNode.ImageIndex := IMG_SURG_TOP_LEVEL;
1750 tmpNode := tvSurgery.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(tmpItem), MakeCaseTreeObject(tmpItem));
1751 TORTreeNode(tmpNode).StringData := tmpItem;
1752 SetCaseTreeNodeImagesAndFormatting(TORTreeNode(tmpNode), FCurrentContext);
1753 EditingIndex := lstNotes.SelectByID(EditingID); //v22.12 - RV
1754 end;
1755 //with tvSurgery do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode); //v22.12 - RV
1756 with tvSurgery do //v22.12 - RV
1757 begin //v22.12 - RV
1758 Selected := FindPieceNode(FLastNoteID, U, Items.GetFirstNode); //v22.12 - RV
1759 if Selected <> nil then tvSurgeryChange(Self, Selected); //v22.12 - RV
1760 end; //v22.12 - RV
1761end;
1762
1763procedure TfrmSurgery.SaveSignItem(const ItemID, ESCode: string);
1764{ saves and optionally signs a progress note or addendum }
1765const
1766 SIG_COSIGN = 'COSIGNATURE';
1767 SIG_SIGN = 'SIGNATURE';
1768var
1769 AnIndex, IEN, i: Integer;
1770 Saved, ContinueSign: Boolean; {*RAB* 8/26/99}
1771 ActionSts, SignSts: TActionRec;
1772 APCEObject: TPCEData;
1773 OK: boolean;
1774 ActionType, SignTitle: string;
1775begin
1776 AnIndex := -1;
1777 IEN := StrToIntDef(ItemID, 0);
1778 if IEN = 0 then Exit;
1779 if frmFrame.TimedOut and (EditingIndex <> -1) then FSilent := True;
1780 with lstNotes do for i := 0 to Items.Count - 1 do if lstNotes.GetIEN(i) = IEN then
1781 begin
1782 AnIndex := i;
1783 break;
1784 end;
1785 if (AnIndex > -1) and (AnIndex = EditingIndex) then
1786 begin
1787 SaveCurrentNote(Saved);
1788 if not Saved then Exit;
1789 if FDeleted then
1790 begin
1791 FDeleted := False;
1792 Exit;
1793 end;
1794 AnIndex := lstNotes.SelectByIEN(IEN);
1795 //IEN := lstNotes.GetIEN(AnIndex); // saving will change IEN
1796 end;
1797 if Length(ESCode) > 0 then
1798 begin
1799 if CosignDocument(IEN) then
1800 begin
1801 SignTitle := TX_COSIGN;
1802 ActionType := SIG_COSIGN;
1803 end else
1804 begin
1805 SignTitle := TX_SIGN;
1806 ActionType := SIG_SIGN;
1807 end;
1808 ActOnDocument(ActionSts, IEN, ActionType);
1809 if not ActionSts.Success then
1810 begin
1811 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
1812 ContinueSign := False;
1813 end
1814 else if not NoteHasText(IEN) then
1815 begin
1816 InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
1817 ContinueSign := False;
1818 end
1819 else if not LastSaveClean(IEN) and
1820 (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES)
1821 then ContinueSign := False
1822 else ContinueSign := True;
1823 if ContinueSign then
1824 begin
1825 if (AnIndex >= 0) and (AnIndex = lstNotes.ItemIndex) then
1826 APCEObject := uPCEShow
1827 else
1828 APCEObject := nil;
1829 OK := IsOK2Sign(APCEObject, IEN);
1830 if frmFrame.Closing then exit;
1831 if(assigned(APCEObject)) and (uPCEShow.Updated) then
1832 begin
1833 uPCEShow.CopyPCEData(uPCEEdit);
1834 uPCEShow.Updated := FALSE;
1835 lstNotesClick(Self);
1836 end
1837 else
1838 uPCEEdit.Clear;
1839 if(OK) then
1840 begin
1841 //if not FSilent then DisplayOpTop(IEN);
1842 SignDocument(SignSts, IEN, ESCode);
1843 if not SignSts.Success then InfoBox(SignSts.Reason, TX_SIGN_ERR, MB_OK);
1844 end; {if OK}
1845 end; {if ContinueSign}
1846 end; {if Length(ESCode)}
1847
1848 if (AnIndex = lstNotes.ItemIndex) and (not frmFrame.ContextChanging) then
1849 begin
1850 LoadSurgeryCases; //????????????????
1851 with tvSurgery do Selected := FindPieceNode(IntToStr(IEN), U, Items.GetFirstNode);
1852 end;
1853end;
1854
1855procedure TfrmSurgery.popNoteMemoPopup(Sender: TObject);
1856begin
1857 inherited;
1858 if PopupComponent(Sender, popNoteMemo) is TCustomEdit
1859 then FEditCtrl := TCustomEdit(PopupComponent(Sender, popNoteMemo))
1860 else FEditCtrl := nil;
1861 if FEditCtrl <> nil then
1862 begin
1863 popNoteMemoCut.Enabled := FEditCtrl.SelLength > 0;
1864 popNoteMemoCopy.Enabled := popNoteMemoCut.Enabled;
1865 popNoteMemoPaste.Enabled := (not TORExposedCustomEdit(FEditCtrl).ReadOnly) and
1866 Clipboard.HasFormat(CF_TEXT);
1867 popNoteMemoTemplate.Enabled := frmDrawers.CanEditTemplates and popNoteMemoCut.Enabled;
1868 popNoteMemoFind.Enabled := FEditCtrl.GetTextLen > 0;
1869 end else
1870 begin
1871 popNoteMemoCut.Enabled := False;
1872 popNoteMemoCopy.Enabled := False;
1873 popNoteMemoPaste.Enabled := False;
1874 popNoteMemoTemplate.Enabled := False;
1875 end;
1876 if pnlWrite.Visible then
1877 begin
1878 popNoteMemoSpell.Enabled := True;
1879 popNoteMemoSpellOpenSource.Enabled := True; //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
1880 popNoteMemoGrammar.Enabled := True;
1881 popNoteMemoReformat.Enabled := True;
1882 popNoteMemoReplace.Enabled := (FEditCtrl.GetTextLen > 0);
1883 popNoteMemoPreview.Enabled := (frmDrawers.TheOpenDrawer = odTemplates) and Assigned(frmDrawers.tvTemplates.Selected);
1884 popNoteMemoInsTemplate.Enabled := (frmDrawers.TheOpenDrawer = odTemplates) and Assigned(frmDrawers.tvTemplates.Selected);
1885 end else
1886 begin
1887 popNoteMemoSpell.Enabled := False;
1888 popNoteMemoSpellOpenSource.Enabled := False; //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
1889 popNoteMemoGrammar.Enabled := False;
1890 popNoteMemoReformat.Enabled := False;
1891 popNoteMemoReplace.Enabled := False;
1892 popNoteMemoPreview.Enabled := False;
1893 popNoteMemoInsTemplate.Enabled := False;
1894 end;
1895end;
1896
1897procedure TfrmSurgery.popNoteMemoCutClick(Sender: TObject);
1898begin
1899 inherited;
1900 FEditCtrl.CutToClipboard;
1901end;
1902
1903procedure TfrmSurgery.popNoteMemoCopyClick(Sender: TObject);
1904begin
1905 inherited;
1906 FEditCtrl.CopyToClipboard;
1907end;
1908
1909procedure TfrmSurgery.popNoteMemoPasteClick(Sender: TObject);
1910begin
1911 inherited;
1912 FEditCtrl.SelText := Clipboard.AsText; {*KCM*}
1913 //FEditCtrl.PasteFromClipboard; // use AsText to prevent formatting
1914end;
1915
1916procedure TfrmSurgery.popNoteMemoReformatClick(Sender: TObject);
1917begin
1918 inherited;
1919 if Screen.ActiveControl <> memNewNote then Exit;
1920 ReformatMemoParagraph(memNewNote);
1921end;
1922
1923procedure TfrmSurgery.popNoteMemoSaveContinueClick(Sender: TObject);
1924begin
1925 inherited;
1926 FChanged := True;
1927 DoAutoSave;
1928end;
1929
1930procedure TfrmSurgery.popNoteMemoReplaceClick(Sender: TObject);
1931begin
1932 inherited;
1933 SendMessage(TRichEdit(popNoteMemo.PopupComponent).Handle, WM_VSCROLL, SB_TOP, 0);
1934 with dlgReplaceText do
1935 begin
1936 Position := Point(Application.MainForm.Left + pnlLeft.Width, Application.MainForm.Top);
1937 FindText := '';
1938 ReplaceText := '';
1939 Options := [frDown, frHideUpDown];
1940 Execute;
1941 end;
1942end;
1943
1944procedure TfrmSurgery.dlgReplaceTextFind(Sender: TObject);
1945begin
1946 inherited;
1947 dmodShared.FindRichEditText(dlgFindText, TRichEdit(popNoteMemo.PopupComponent));
1948end;
1949
1950procedure TfrmSurgery.dlgReplaceTextReplace(Sender: TObject);
1951begin
1952 inherited;
1953 dmodShared.ReplaceRichEditText(dlgReplaceText, TRichEdit(popNoteMemo.PopupComponent));
1954end;
1955
1956procedure TfrmSurgery.popNoteMemoSpellClick(Sender: TObject);
1957begin
1958 inherited;
1959 DoAutoSave(0);
1960 timAutoSave.Enabled := False;
1961 try
1962 SpellCheckForControl(memNewNote, Sender = popNoteMemoSpellOpenSource); //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
1963 finally
1964 FChanged := True;
1965 DoAutoSave(0);
1966 timAutoSave.Enabled := True;
1967 end;
1968end;
1969
1970procedure TfrmSurgery.popNoteMemoGrammarClick(Sender: TObject);
1971begin
1972 inherited;
1973 DoAutoSave(0);
1974 timAutoSave.Enabled := False;
1975 try
1976 GrammarCheckForControl(memNewNote);
1977 finally
1978 FChanged := True;
1979 DoAutoSave(0);
1980 timAutoSave.Enabled := True;
1981 end;
1982end;
1983
1984procedure TfrmSurgery.mnuViewDetailClick(Sender: TObject);
1985var
1986 x: string;
1987begin
1988 inherited;
1989 with tvSurgery do
1990 begin
1991 if Selected = nil then exit;
1992 if not (Selected.ImageIndex in [IMG_SURG_TOP_LEVEL, IMG_SURG_GROUP_SHUT, IMG_SURG_GROUP_OPEN,
1993 IMG_SURG_NON_OR_CASE_EMPTY, IMG_SURG_NON_OR_CASE_SHUT, IMG_SURG_NON_OR_CASE_OPEN,
1994 IMG_SURG_CASE_EMPTY, IMG_SURG_CASE_SHUT, IMG_SURG_CASE_OPEN]) then
1995 begin
1996 mnuViewDetail.Checked := not mnuViewDetail.Checked;
1997 if mnuViewDetail.Checked then
1998 begin
1999 x := TORTreeNode(Selected).StringData;
2000 StatusText('Retrieving selected surgery report details...');
2001 pnlRead.Visible := True;
2002 pnlWrite.Visible := False;
2003 Screen.Cursor := crHourGlass;
2004 LoadSurgReportDetail(memSurgery.Lines, StrToIntDef(Piece(x, U, 1), 0));
2005 Screen.Cursor := crDefault;
2006 StatusText('');
2007 memSurgery.SelStart := 0;
2008 memSurgery.Repaint;
2009 end
2010 else
2011 tvSurgeryChange(Self, Selected);
2012 end;
2013 end;
2014 SendMessage(memSurgery.Handle, WM_VSCROLL, SB_TOP, 0);
2015end;
2016
2017procedure TfrmSurgery.FormClose(Sender: TObject; var Action: TCloseAction);
2018var
2019 Saved: Boolean;
2020 IEN: Int64;
2021 ErrMsg: string;
2022 DeleteSts: TActionRec;
2023begin
2024 inherited;
2025 if frmFrame.TimedOut and (EditingIndex <> -1) then
2026 begin
2027 FSilent := True;
2028 if memNewNote.GetTextLen > 0 then SaveCurrentNote(Saved)
2029 else
2030 begin
2031 IEN := lstNotes.GetIEN(EditingIndex);
2032 if not LastSaveClean(IEN) then // means note hasn't been committed yet
2033 begin
2034 LockDocument(IEN, ErrMsg);
2035 if ErrMsg = '' then
2036 begin
2037 DeleteDocument(DeleteSts, IEN, '');
2038 UnlockDocument(IEN);
2039 end; {if ErrMsg}
2040 end; {if not LastSaveClean}
2041 end; {else}
2042 end; {if frmFrame}
2043end;
2044
2045procedure TfrmSurgery.mnuActIdentifyAddlSignersClick(Sender: TObject);
2046var
2047 Exclusions: TStrings;
2048 Saved, x, y: boolean;
2049 SignerList: TSignerList;
2050 ActionSts: TActionRec;
2051 SigAction: integer;
2052 SavedDocID: string;
2053 ARefDate: TFMDateTime;
2054begin
2055 inherited;
2056 if lstNotes.ItemIEN = 0 then exit;
2057 SavedDocID := lstNotes.ItemID;
2058 if lstNotes.ItemIndex = EditingIndex then
2059 begin
2060 SaveCurrentNote(Saved);
2061 if not Saved then Exit;
2062 LoadSurgeryCases;
2063 with tvSurgery do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2064 end;
2065 x := CanChangeCosigner(lstNotes.ItemIEN);
2066 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'IDENTIFY SIGNERS');
2067 y := ActionSts.Success;
2068 if x and not y then
2069 begin
2070 if InfoBox(ActionSts.Reason + CRLF + CRLF +
2071 'Would you like to change the cosigner?',
2072 TX_IN_AUTH, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES then
2073 SigAction := SG_COSIGNER
2074 else
2075 Exit;
2076 end
2077 else if y and not x then SigAction := SG_ADDITIONAL
2078 else if x and y then SigAction := SG_BOTH
2079 else
2080 begin
2081 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2082 Exit;
2083 end;
2084
2085 Exclusions := GetCurrentSigners(lstNotes.ItemIEN);
2086 ARefDate := StrToFloat(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
2087 SelectAdditionalSigners(Font.Size, lstNotes.ItemIEN, SigAction, Exclusions, SignerList, CT_NOTES, ARefDate);
2088 with SignerList do
2089 begin
2090 case SigAction of
2091 SG_ADDITIONAL: if Changed and (Signers <> nil) and (Signers.Count > 0) then
2092 UpdateAdditionalSigners(lstNotes.ItemIEN, Signers);
2093 SG_COSIGNER: if Changed then ChangeCosigner(lstNotes.ItemIEN, Cosigner);
2094 SG_BOTH: if Changed then
2095 begin
2096 if (Signers <> nil) and (Signers.Count > 0) then
2097 UpdateAdditionalSigners(lstNotes.ItemIEN, Signers);
2098 ChangeCosigner(lstNotes.ItemIEN, Cosigner);
2099 end;
2100 end;
2101 lstNotesClick(Self);
2102 end;
2103 UnlockDocument(lstNotes.ItemIEN);
2104end;
2105
2106procedure TfrmSurgery.popNoteMemoAddlSignClick(Sender: TObject);
2107begin
2108 inherited;
2109 mnuActIdentifyAddlSignersClick(Self);
2110end;
2111
2112procedure TfrmSurgery.ProcessNotifications;
2113var
2114 x: string;
2115 Saved: boolean;
2116 //tmpNode: TTreeNode;
2117 //AnObject: PCaseTreeObject;
2118 tmpList: TStringList;
2119begin
2120 if EditingIndex <> -1 then
2121 begin
2122 SaveCurrentNote(Saved);
2123 if not Saved then Exit;
2124 end;
2125 lblCases.Caption := Notifications.Text;
2126 tvSurgery.Caption := lblCases.Caption;
2127 EditingIndex := -1;
2128 lstNotes.Enabled := True ;
2129 pnlRead.BringToFront ;
2130 // show ALL unsigned/uncosigned for a patient, not just the alerted one
2131 // what about cosignature? How to get correct list? ORB FOLLOWUP TYPE = OR alerts only
2132 x := Notifications.AlertData;
2133 if StrToIntDef(Piece(x, U, 1), 0) = 0 then
2134 begin
2135 InfoBox(TX_NO_ALERT, TX_CAP_NO_ALERT, MB_OK);
2136 Exit;
2137 end;
2138 tmpList := TStringList.Create;
2139 try
2140 FCaseList.Clear;
2141 uChanging := True;
2142 tvSurgery.Items.BeginUpdate;
2143 lstNotes.Clear;
2144 KillCaseTreeObjects(tvSurgery);
2145 tvSurgery.Items.Clear;
2146 GetSingleCaseListItemWithDocs(tmpList, StrToIntDef(Piece(x, U, 1), 0));
2147 with FCurrentContext do CreateListItemsForCaseTree(FCaseList, tmpList, SR_ALL, GroupBy, TreeAscending);
2148 UpdateTreeView(FCaseList, tvSurgery);
2149 with tvSurgery do Selected := FindPieceNode(Piece(x, U, 1), 1, U, Items.GetFirstNode);
2150 (* lstNotes.Items.Add(x);
2151 AnObject := MakeCaseTreeObject('ALERT^Alerted Note^^^^^^^^^^^%^0');
2152 tmpNode := tvSurgery.Items.AddObjectFirst(tvSurgery.Items.GetFirstNode, AnObject.NodeText, AnObject);
2153 TORTreeNode(tmpNode).StringData := 'ALERT^Alerted Note^^^^^^^^^^^%^0';
2154 tmpNode.ImageIndex := IMG_SURG_TOP_LEVEL;
2155 AnObject := MakeCaseTreeObject(x);
2156 tmpNode := tvSurgery.Items.AddChildObjectFirst(tmpNode, AnObject.NodeText, AnObject);
2157 TORTreeNode(tmpNode).StringData := x;
2158 SetCaseTreeNodeImagesAndFormatting(TORTreeNode(tmpNode), FCurrentContext);
2159 tvSurgery.Selected := tmpNode;*)
2160 tvSurgery.Items.EndUpdate;
2161 uChanging := False;
2162 tvSurgeryChange(Self, tvSurgery.Selected);
2163 case Notifications.Followup of
2164 NF_SURGERY_UNSIGNED_NOTE: ; //Automatically deleted by sig action!!!
2165 end;
2166 if Copy(Piece(Notifications.RecordID, U, 2), 1, 6) = 'TIUADD' then Notifications.Delete;
2167 if Copy(Piece(Notifications.RecordID, U, 2), 1, 5) = 'TIUID' then Notifications.Delete;
2168 finally
2169 tmpList.Free;
2170 end;
2171end;
2172
2173procedure TfrmSurgery.mnuViewSaveAsDefaultClick(Sender: TObject);
2174begin
2175 inherited;
2176 if InfoBox('Replace current defaults?', 'Confirmation', MB_YESNO or MB_ICONQUESTION) = IDYES then
2177 begin
2178 SaveCurrentSurgCaseContext(FCurrentContext);
2179 FDefaultContext := FCurrentContext;
2180 lblCases.Caption := 'Default List';
2181 tvSurgery.Caption := lblCases.Caption;
2182 end;
2183end;
2184
2185procedure TfrmSurgery.mnuViewReturntoDefaultClick(Sender: TObject);
2186begin
2187 inherited;
2188 SetViewContext(FDefaultContext);
2189end;
2190
2191procedure TfrmSurgery.popNoteMemoTemplateClick(Sender: TObject);
2192begin
2193 inherited;
2194 EditTemplates(Self, TRUE, FEditCtrl.SelText);
2195end;
2196
2197procedure TfrmSurgery.popNoteListPopup(Sender: TObject);
2198begin
2199 inherited;
2200 N4.Visible := (popNoteList.PopupComponent is TORTreeView);
2201 popNoteListExpandAll.Visible := N4.Visible;
2202 popNoteListExpandSelected.Visible := N4.Visible;
2203 popNoteListCollapseAll.Visible := N4.Visible;
2204 popNoteListCollapseSelected.Visible := N4.Visible;
2205end;
2206
2207procedure TfrmSurgery.popNoteListExpandAllClick(Sender: TObject);
2208begin
2209 inherited;
2210 tvSurgery.FullExpand;
2211end;
2212
2213procedure TfrmSurgery.popNoteListCollapseAllClick(Sender: TObject);
2214begin
2215 inherited;
2216 tvSurgery.Selected := nil;
2217 memSurgery.Clear;
2218 tvSurgery.FullCollapse;
2219 tvSurgery.Selected := tvSurgery.TopItem;
2220end;
2221
2222procedure TfrmSurgery.popNoteListExpandSelectedClick(Sender: TObject);
2223begin
2224 inherited;
2225 if tvSurgery.Selected = nil then exit;
2226 with tvSurgery.Selected do if HasChildren then Expand(True);
2227end;
2228
2229procedure TfrmSurgery.popNoteListCollapseSelectedClick(Sender: TObject);
2230begin
2231 inherited;
2232 if tvSurgery.Selected = nil then exit;
2233 with tvSurgery.Selected do if HasChildren then Collapse(True);
2234end;
2235
2236procedure TfrmSurgery.mnuEditTemplatesClick(Sender: TObject);
2237begin
2238 inherited;
2239 EditTemplates(Self);
2240end;
2241
2242procedure TfrmSurgery.mnuNewTemplateClick(Sender: TObject);
2243begin
2244 inherited;
2245 EditTemplates(Self, TRUE);
2246end;
2247
2248procedure TfrmSurgery.mnuEditSharedTemplatesClick(Sender: TObject);
2249begin
2250 inherited;
2251 EditTemplates(Self, FALSE, '', TRUE);
2252end;
2253
2254procedure TfrmSurgery.mnuNewSharedTemplateClick(Sender: TObject);
2255begin
2256 inherited;
2257 EditTemplates(Self, TRUE, '', TRUE);
2258end;
2259
2260procedure TfrmSurgery.mnuOptionsClick(Sender: TObject);
2261begin
2262 inherited;
2263 mnuEditTemplates.Enabled := frmDrawers.CanEditTemplates;
2264 mnuNewTemplate.Enabled := frmDrawers.CanEditTemplates;
2265 mnuEditSharedTemplates.Enabled := frmDrawers.CanEditShared;
2266 mnuNewSharedTemplate.Enabled := frmDrawers.CanEditShared;
2267 mnuEditDialgFields.Enabled := CanEditTemplateFields;
2268end;
2269
2270procedure TfrmSurgery.SetEditingIndex(const Value: Integer);
2271begin
2272 FEditingIndex := Value;
2273 if(FEditingIndex < 0) then
2274 KillReminderDialog(Self);
2275 if(assigned(frmReminderTree)) then
2276 frmReminderTree.EnableActions;
2277end;
2278
2279(*function TfrmSurgery.CanFinishReminder: boolean;
2280begin
2281 Result := False;
2282 if(EditingIndex < 0) then
2283 Result := FALSE
2284 else
2285 Result := (lstNotes.ItemIndex = EditingIndex);
2286end;*)
2287
2288procedure TfrmSurgery.AssignRemForm;
2289begin
2290(* with RemForm do
2291 begin
2292 Form := Self;
2293 PCEObj := uPCEEdit;
2294 RightPanel := pnlRight;
2295 CanFinishProc := CanFinishReminder;
2296 DisplayPCEProc := DisplayPCE;
2297 Drawers := frmDrawers;
2298 NewNoteRE := memNewNote;
2299 NoteList := lstNotes;
2300 end;*)
2301end;
2302
2303procedure TfrmSurgery.mnuEditDialgFieldsClick(Sender: TObject);
2304begin
2305 inherited;
2306 EditDialogFields;
2307end;
2308
2309
2310procedure TfrmSurgery.tvSurgeryClick(Sender: TObject);
2311begin
2312 if tvSurgery.Selected = nil then exit;
2313 if (tvSurgery.Selected.ImageIndex in [IMG_SURG_TOP_LEVEL, IMG_SURG_GROUP_OPEN, IMG_SURG_GROUP_SHUT]) then
2314 memSurgery.Clear;
2315end;
2316
2317procedure TfrmSurgery.ShowPCEButtons(Editing: boolean);
2318begin
2319 FEditingNotePCEObj := Editing;
2320 if Editing or AnytimeEncounters then
2321 begin
2322 cmdPCE.Visible := TRUE;
2323 if Editing then
2324 begin
2325 cmdPCE.Enabled := CanEditPCE(uPCEEdit);
2326{ TODO -oRich V. -cSurgery/TIU : Uncomment if allow new notes from Surgery tab }
2327 //cmdNewNote.Visible := AnytimeEncounters;
2328 //cmdNewNote.Enabled := FALSE;
2329 end
2330 else
2331 begin
2332 cmdPCE.Enabled := (GetAskPCE(0) <> apDisable);
2333{ TODO -oRich V. -cSurgery/TIU : Uncomment if allow new notes from Surgery tab }
2334 //cmdNewNote.Visible := TRUE;
2335 //cmdNewNote.Enabled := TRUE;
2336 end;
2337 if cmdNewNote.Visible then
2338 cmdPCE.Top := cmdNewNote.Top-cmdPCE.Height;
2339 end
2340 else
2341 begin
2342 cmdPCE.Enabled := FALSE;
2343 cmdPCE.Visible := FALSE;
2344{ TODO -oRich V. -cSurgery/TIU : Uncomment if allow new notes from Surgery tab }
2345 //cmdNewNote.Visible := TRUE;
2346 //cmdNewNote.Enabled := TRUE;
2347 end;
2348 if cmdPCE.Visible then
2349 lblSpace1.Top := cmdPCE.Top - lblSpace1.Height
2350 else
2351 lblSpace1.Top := cmdNewNote.Top - lblSpace1.Height;
2352 popNoteMemoEncounter.Enabled := cmdPCE.Enabled;
2353 popNoteMemoEncounter.Visible := cmdPCE.Visible;
2354end;
2355
2356procedure TfrmSurgery.mnuIconLegendClick(Sender: TObject);
2357begin
2358 inherited;
2359 ShowIconLegend(ilSurgery);
2360end;
2361
2362procedure TfrmSurgery.tvSurgeryChange(Sender: TObject;
2363 Node: TTreeNode);
2364var
2365 x: string;
2366 IsTIUDocument: boolean;
2367 //MsgString, HasImages: string;
2368 //ShowReport: boolean;
2369begin
2370 if uChanging then Exit;
2371 //This gives the change a chance to occur when keyboarding, so that WindowEyes
2372 //doesn't use the old value.
2373 Application.ProcessMessages;
2374 //ShowReport := True;
2375 with tvSurgery do
2376 begin
2377 if Selected = nil then Exit;
2378 popNoteListExpandSelected.Enabled := Selected.HasChildren;
2379 popNoteListCollapseSelected.Enabled := Selected.HasChildren;
2380 RedrawSuspend(memSurgery.Handle);
2381 memSurgery.Clear;
2382 if not (Selected.ImageIndex in [IMG_SURG_TOP_LEVEL, IMG_SURG_GROUP_OPEN, IMG_SURG_GROUP_SHUT]) then
2383 begin
2384 x := TORTreeNode(Selected).StringData;
2385 memSurgery.Clear;
2386 StatusText('Retrieving selected surgery report...');
2387 Screen.Cursor := crHourGlass;
2388 pnlRead.Visible := True;
2389 pnlWrite.Visible := False;
2390 //UpdateReminderFinish;
2391 IsTIUDocument := PCaseTreeObject(Selected.Data)^.PkgRef <> '';
2392 EnableDisableMenus(IsTIUDocument);
2393 if not IsTIUDocument then
2394 begin
2395 lblTitle.Caption := MakeSurgeryCaseDisplayText(x);
2396 lblTitle.Hint := lblTitle.Caption;
2397 //LoadOpTop(memSurgery.Lines, StrToIntDef(Piece(x, U, 1), 0), PCaseTreeObject(Selected.Data)^.IsNonORProc, ShowReport);
2398 //--------------------------------------------------------------------------------------------------------
2399 // DON'T DO THIS UNTIL SURGERY API IS CHANGED - OTHERWISE WILL GIVE FALSE '0' COUNT FOR EVERY CASE (RV)
2400(* MsgString := 'SUR^' + Piece(x, U, 1);
2401 HasImages := BOOLCHAR[PCaseTreeObject(Selected.Data)^.ImageCount > 0];
2402 SetPiece(MsgString, U, 10, HasImages);
2403 NotifyOtherApps(NAE_REPORT, 'SUR^' + MsgString);*)
2404 //--------------------------------------------------------------------------------------------------------
2405 NotifyOtherApps(NAE_REPORT, 'SUR^' + Piece(x, U, 1));
2406 lstNotes.ItemIndex := -1;
2407 end
2408 else
2409 begin
2410 lstNotes.SelectByID(Piece(x, U, 1));
2411 lstNotesClick(Self);
2412 end;
2413 Screen.Cursor := crDefault;
2414 StatusText('');
2415 SendMessage(memSurgery.Handle, WM_VSCROLL, SB_TOP, 0);
2416 end
2417 else
2418 begin
2419 lblTitle.Caption := '';
2420 lblTitle.Hint := lblTitle.Caption;
2421 pnlWrite.Visible := False;
2422 pnlRead.Visible := True;
2423 //UpdateReminderFinish;
2424 ShowPCEControls(False);
2425 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]); //FALSE);
2426 ShowPCEButtons(FALSE);
2427 memSurgery.Clear;
2428 end;
2429 if(assigned(frmReminderTree)) then
2430 frmReminderTree.EnableActions;
2431 DisplayPCE;
2432 pnlRight.Refresh;
2433 memNewNote.Repaint;
2434 memSurgery.Repaint;
2435 SendMessage(tvSurgery.Handle, WM_HSCROLL, SB_THUMBTRACK, 0);
2436 RedrawActivate(memSurgery.Handle);
2437 end;
2438end;
2439
2440procedure TfrmSurgery.tvSurgeryExpanded(Sender: TObject;
2441 Node: TTreeNode);
2442begin
2443 with Node do
2444 begin
2445 if (ImageIndex in [IMG_SURG_GROUP_SHUT, IMG_SURG_CASE_SHUT, IMG_SURG_NON_OR_CASE_SHUT]) then
2446 ImageIndex := ImageIndex + 1;
2447 if (SelectedIndex in [IMG_SURG_GROUP_SHUT, IMG_SURG_CASE_SHUT, IMG_SURG_NON_OR_CASE_SHUT]) then
2448 SelectedIndex := SelectedIndex + 1;
2449 end;
2450 SendMessage(tvSurgery.Handle, WM_HSCROLL, SB_THUMBTRACK, 0);
2451end;
2452
2453procedure TfrmSurgery.tvSurgeryCollapsed(Sender: TObject;
2454 Node: TTreeNode);
2455begin
2456 with Node do
2457 begin
2458 if (ImageIndex in [IMG_SURG_GROUP_OPEN, IMG_SURG_CASE_OPEN, IMG_SURG_NON_OR_CASE_OPEN]) then
2459 ImageIndex := ImageIndex - 1;
2460 if (SelectedIndex in [IMG_SURG_GROUP_OPEN, IMG_SURG_CASE_OPEN, IMG_SURG_NON_OR_CASE_OPEN]) then
2461 SelectedIndex := SelectedIndex - 1;
2462 end;
2463end;
2464
2465procedure TfrmSurgery.LoadSurgeryCases;
2466var
2467 tmpList: TStringList;
2468 ANode: TORTreeNode;
2469begin
2470 tmpList := TStringList.Create;
2471 try
2472 FCaseList.Clear;
2473 uChanging := True;
2474 RedrawSuspend(memSurgery.Handle);
2475 tvSurgery.Items.BeginUpdate;
2476 KillCaseTreeObjects(tvSurgery);
2477 tvSurgery.Items.Clear;
2478 tvSurgery.Items.EndUpdate;
2479 lstNotes.Items.Clear;
2480 memSurgery.Clear;
2481 memSurgery.Invalidate;
2482 lblTitle.Caption := '';
2483 lblTitle.Hint := lblTitle.Caption;
2484 ShowPCEControls(FALSE);
2485 with FCurrentContext do
2486 begin
2487 GetSurgCaseList(tmpList, FMBeginDate, FMEndDate, SR_ALL, MaxDocs);
2488 CreateListItemsForCaseTree(FCaseList, tmpList, SR_ALL, GroupBy, TreeAscending);
2489 UpdateTreeView(FCaseList, tvSurgery);
2490 end;
2491 tmpList.Clear;
2492 FCaseList.Clear;
2493 with tvSurgery do
2494 begin
2495 uChanging := True;
2496 tvSurgery.Items.BeginUpdate;
2497 if FLastNoteID <> '' then
2498 Selected := FindPieceNode(FLastNoteID, 1, U, nil);
2499 if Selected = nil then
2500 begin
2501 if (uSurgeryContext.GroupBy <> '') then
2502 begin
2503 ANode := TORTreeNode(Items.GetFirstNode);
2504 while ANode <> nil do
2505 begin
2506 ANode.Expand(False);
2507 Selected := ANode;
2508 ANode := TORTreeNode(ANode.GetNextSibling);
2509 end;
2510 end
2511 else
2512 begin
2513 ANode := tvSurgery.FindPieceNode(IntToStr(SR_ALL), 1, U, nil);
2514 if ANode <> nil then Selected := ANode.getFirstChild;
2515 end;
2516 end;
2517 memSurgery.Clear;
2518 RemoveParentsWithNoChildren(tvSurgery, uSurgeryContext);
2519 tvSurgery.Items.EndUpdate;
2520 uChanging := False;
2521 lblCases.Caption := SetSurgTreeLabel(FCurrentContext);
2522 tvSurgery.Caption := lblCases.Caption;
2523 SendMessage(tvSurgery.Handle, WM_VSCROLL, SB_TOP, 0);
2524 if Selected <> nil then tvSurgeryChange(Self, Selected);
2525 end;
2526 finally
2527 RedrawActivate(memSurgery.Handle);
2528 tmpList.Free;
2529 end;
2530end;
2531
2532function TfrmSurgery.SetSurgTreeLabel(AContext: TSurgCaseContext): string;
2533var
2534 x: string;
2535
2536 function SetDateRangeText(AContext: TSurgCaseContext): string;
2537 var
2538 x1: string;
2539 begin
2540 with AContext do
2541 if BeginDate <> '' then
2542 begin
2543 x1 := 'from ' + UpperCase(BeginDate);
2544 if EndDate <> '' then x1 := x1 + ' to ' + UpperCase(EndDate)
2545 else x1 := x1 + ' to TODAY';
2546 end;
2547 Result := x1;
2548 end;
2549
2550begin
2551 with AContext do
2552 begin
2553 if MaxDocs > 0 then x := 'Last ' + IntToStr(MaxDocs) + ' ' else x := 'All ';
2554 case StrToIntDef(Status, 0) of
2555 SR_RECENT : x := x + 'Surgery Cases';
2556 SR_ALL : x := x + 'Surgery Cases';
2557 //SG_BY_SURGEON : x := x + 'Surgery Cases for ' + ExternalName(Surgeon, 200) + SetDateRangeText(AContext);
2558 SR_BY_DATE : x := x + 'Surgery Cases ' + SetDateRangeText(AContext);
2559 else
2560 x := 'Custom List';
2561 end;
2562 end;
2563 Result := x;
2564end;
2565
2566procedure TfrmSurgery.lstNotesClick(Sender: TObject);
2567{ loads the text for the selected note or displays the editing panel for the selected note }
2568var
2569 x: string;
2570begin
2571 inherited;
2572 with lstNotes do if ItemIndex = -1 then Exit
2573 else if ItemIndex = EditingIndex then
2574 begin
2575 pnlWrite.Visible := True;
2576 pnlRead.Visible := False;
2577 mnuViewDetail.Enabled := False;
2578 mnuActChange.Enabled := True;
2579 mnuActLoadBoiler.Enabled := True;
2580 //UpdateReminderFinish;
2581 end else
2582 begin
2583 StatusText('Retrieving selected surgery report...');
2584 Screen.Cursor := crHourGlass;
2585 pnlRead.Visible := True;
2586 pnlWrite.Visible := False;
2587 //UpdateReminderFinish;
2588 lblTitle.Caption := MakeSurgeryReportDisplayText(Items[ItemIndex]);
2589 lblTitle.Hint := lblTitle.Caption;
2590 LoadSurgReportText(memSurgery.Lines, ItemIEN);
2591 mnuViewDetail.Enabled := True;
2592 mnuViewDetail.Checked := False;
2593 mnuActChange.Enabled := False;
2594 mnuActLoadBoiler.Enabled := False;
2595 Screen.Cursor := crDefault;
2596 StatusText('');
2597 end;
2598 if(assigned(frmReminderTree)) then
2599 frmReminderTree.EnableActions;
2600 DisplayPCE;
2601 pnlRight.Refresh;
2602 memNewNote.Repaint;
2603 memSurgery.Repaint;
2604 x := 'TIU^' + lstNotes.ItemID;
2605 SetPiece(x, U, 10, Piece(lstNotes.Items[lstNotes.ItemIndex], U, 11));
2606 NotifyOtherApps(NAE_REPORT, x);
2607end;
2608
2609procedure TfrmSurgery.EnableDisableMenus(IsTIUDocument: boolean);
2610begin
2611{ TODO -oRich V. -cSurgery/TIU : Reset NewNoteMenu enabled if allow new notes from Surgery tab }
2612 mnuActNew.Enabled := False;
2613 mnuActAddend.Enabled := IsTIUDocument;
2614 mnuActAddIDEntry.Enabled := False;
2615 mnuActDetachFromIDParent.Enabled := False;
2616 mnuActEdit.Enabled := IsTIUDocument;
2617 mnuActDelete.Enabled := IsTIUDocument;
2618 mnuActSign.Enabled := IsTIUDocument;
2619 mnuActSignList.Enabled := IsTIUDocument;
2620 mnuActSave.Enabled := IsTIUDocument;
2621 mnuActIdentifyAddlSigners.Enabled := IsTIUDocument;
2622 mnuActChange.Enabled := IsTIUDocument;
2623 mnuActLoadBoiler.Enabled := IsTIUDocument;
2624 popNoteMemoSignList.Enabled := IsTIUDocument;
2625 popNoteMemoSign.Enabled := IsTIUDocument;
2626 popNoteMemoSave.Enabled := IsTIUDocument;
2627 popNoteMemoEdit.Enabled := IsTIUDocument;
2628 popNoteMemoDelete.Enabled := IsTIUDocument;
2629 popNoteMemoAddlSign.Enabled := IsTIUDocument;
2630 popNoteMemoAddend.Enabled := IsTIUDocument;
2631 mnuViewDetail.Enabled := IsTIUDocument;
2632 popNoteMemoPreview.Enabled := IsTIUDocument and Assigned(frmDrawers.tvTemplates.Selected);
2633 popNoteMemoInsTemplate.Enabled := IsTIUDocument and Assigned(frmDrawers.tvTemplates.Selected);
2634 if not IsTIUDocument then mnuViewDetail.Checked := False;
2635 frmFrame.mnuFilePrint.Enabled := IsTIUDocument;
2636end;
2637
2638procedure TfrmSurgery.memNewNoteKeyDown(Sender: TObject; var Key: Word;
2639 Shift: TShiftState);
2640begin
2641 inherited;
2642 if (Key = VK_TAB) then
2643 begin
2644 if ssShift in Shift then
2645 begin
2646 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
2647 Key := 0;
2648 end
2649 else if ssCtrl in Shift then
2650 begin
2651 FindNextControl(Sender as TWinControl, True, True, False).SetFocus; //next control
2652 Key := 0;
2653 end;
2654 end;
2655 if (key = VK_ESCAPE) then begin
2656 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
2657 key := 0;
2658 end;
2659end;
2660
2661procedure TfrmSurgery.sptHorzCanResize(Sender: TObject; var NewSize: Integer;
2662 var Accept: Boolean);
2663begin
2664 inherited;
2665 if pnlWrite.Visible then
2666 if NewSize > frmSurgery.ClientWidth - memNewNote.Constraints.MinWidth - sptHorz.Width then
2667 NewSize := frmSurgery.ClientWidth - memNewNote.Constraints.MinWidth - sptHorz.Width;
2668end;
2669
2670procedure TfrmSurgery.popNoteMemoPreviewClick(Sender: TObject);
2671begin
2672 frmDrawers.mnuPreviewTemplateClick(Sender);
2673end;
2674
2675procedure TfrmSurgery.popNoteMemoInsTemplateClick(Sender: TObject);
2676begin
2677 frmDrawers.mnuInsertTemplateClick(Sender);
2678end;
2679
2680procedure TfrmSurgery.ViewInfo(Sender: TObject);
2681begin
2682 inherited;
2683 frmFrame.ViewInfo(Sender);
2684end;
2685
2686procedure TfrmSurgery.mnuViewInformationClick(Sender: TObject);
2687begin
2688 inherited;
2689 mnuViewDemo.Enabled := frmFrame.pnlPatient.Enabled;
2690 mnuViewVisits.Enabled := frmFrame.pnlVisit.Enabled;
2691 mnuViewPrimaryCare.Enabled := frmFrame.pnlPrimaryCare.Enabled;
2692 mnuViewMyHealtheVet.Enabled := not (Copy(frmFrame.laMHV.Hint, 1, 2) = 'No');
2693 mnuInsurance.Enabled := not (Copy(frmFrame.laVAA2.Hint, 1, 2) = 'No');
2694 mnuViewFlags.Enabled := frmFrame.lblFlag.Enabled;
2695 mnuViewRemoteData.Enabled := frmFrame.lblCirn.Enabled;
2696 mnuViewReminders.Enabled := frmFrame.pnlReminders.Enabled;
2697 mnuViewPostings.Enabled := frmFrame.pnlPostings.Enabled;
2698end;
2699
2700initialization
2701 SpecifyFormIsNotADialog(TfrmSurgery);
2702 uPCEEdit := TPCEData.Create;
2703 uPCEShow := TPCEData.Create;
2704
2705finalization
2706 uPCEEdit.Free;
2707 uPCEShow.Free;
2708
2709end.
2710
Note: See TracBrowser for help on using the repository browser.