source: cprs/trunk/CPRS-Chart/fSurgery.pas@ 1138

Last change on this file since 1138 was 830, checked in by Kevin Toppenberg, 14 years ago

Upgrading to version 27

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