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

Last change on this file since 620 was 456, checked in by Kevin Toppenberg, 16 years ago

Initial Upload of Official WV CPRS 1.0.26.76

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