source: cprs/branches/tmg-cprs/CPRS-Chart/fNotes.pas@ 710

Last change on this file since 710 was 686, checked in by Kevin Toppenberg, 15 years ago

Fixed HTML Linked Template-Note Issue

File size: 190.3 KB
RevLine 
[541]1//kt -- Modified with SourceScanner on 7/19/2007, also 8/09
[453]2unit fNotes;
3{$O-}
4
5interface
6
7uses
8 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
9 fHSplit, StdCtrls, ExtCtrls, Menus, ComCtrls, ORCtrls, ORFn, uConst, ORDtTm,
10 uPCE, ORClasses, fDrawers, ImgList, rTIU, uTIU, uDocTree, fRptBox, fPrintList,
[541]11 MSHTML,TMGHTML2,ActiveX, //kt added this line 8/09 for HTML editing
12 fNoteST, ORNet, fNoteSTStop, OleCtrls, SHDocVw, DKLang, Buttons, ToolWin;
[453]13
14type
[541]15 TEditModes = (emNone,emText,emHTML); //kt 8/09
16 TViewModes = (vmEdit,vmView,vmText,vmHTML); //kt 8/09
17 TViewModeSet = Set of TViewModes; //kt 8/09
18const
19 vmHTML_MODE : array [false..true] of TViewModes = (vmText,vmHTML); //kt 8/09
20 emHTML_MODE : array [false..true] of TEditModes = (emText,emHTML); //kt 8/09
21
22type
[453]23 TfrmNotes = class(TfrmHSplit)
24 mnuNotes: TMainMenu;
25 mnuView: TMenuItem;
26 mnuViewChart: TMenuItem;
27 mnuChartReports: TMenuItem;
28 mnuChartLabs: TMenuItem;
29 mnuChartDCSumm: TMenuItem;
30 mnuChartCslts: TMenuItem;
31 mnuChartNotes: TMenuItem;
32 mnuChartOrders: TMenuItem;
33 mnuChartMeds: TMenuItem;
34 mnuChartProbs: TMenuItem;
35 mnuChartCover: TMenuItem;
36 Z1: TMenuItem;
37 mnuViewDetail: TMenuItem;
38 mnuAct: TMenuItem;
39 mnuActNew: TMenuItem;
40 Z2: TMenuItem;
41 mnuActSave: TMenuItem;
42 mnuActDelete: TMenuItem;
43 mnuActEdit: TMenuItem;
44 mnuActSign: TMenuItem;
45 mnuActAddend: TMenuItem;
46 lblNotes: TOROffsetLabel;
47 pnlRead: TPanel;
48 lblTitle: TOROffsetLabel;
49 memNote: TRichEdit;
50 pnlWrite: TPanel;
51 memNewNote: TRichEdit;
52 WebBrowser1: TWebBrowser; //kt added (and WebBrowser1 object in form file)
53 Z3: TMenuItem;
54 mnuViewAll: TMenuItem;
55 mnuViewByAuthor: TMenuItem;
56 mnuViewByDate: TMenuItem;
57 mnuViewUncosigned: TMenuItem;
58 mnuViewUnsigned: TMenuItem;
59 mnuActSignList: TMenuItem;
60 cmdNewNote: TORAlignButton;
61 cmdPCE: TORAlignButton;
62 lblSpace1: TLabel;
63 popNoteMemo: TPopupMenu;
64 popNoteMemoCut: TMenuItem;
65 popNoteMemoCopy: TMenuItem;
66 popNoteMemoPaste: TMenuItem;
67 Z10: TMenuItem;
68 popNoteMemoSignList: TMenuItem;
69 popNoteMemoDelete: TMenuItem;
70 popNoteMemoEdit: TMenuItem;
71 popNoteMemoSave: TMenuItem;
72 popNoteMemoSign: TMenuItem;
73 popNoteList: TPopupMenu;
74 popNoteListAll: TMenuItem;
75 popNoteListByAuthor: TMenuItem;
76 popNoteListByDate: TMenuItem;
77 popNoteListUncosigned: TMenuItem;
78 popNoteListUnsigned: TMenuItem;
79 sptVert: TSplitter;
80 memPCEShow: TRichEdit;
81 mnuActIdentifyAddlSigners: TMenuItem;
82 popNoteMemoAddlSign: TMenuItem;
83 Z11: TMenuItem;
84 popNoteMemoSpell: TMenuItem;
85 popNoteMemoGrammar: TMenuItem;
86 mnuViewCustom: TMenuItem;
87 N1: TMenuItem;
88 mnuViewSaveAsDefault: TMenuItem;
89 ReturntoDefault1: TMenuItem;
90 pnlDrawers: TPanel;
91 lstNotes: TORListBox;
92 splDrawers: TSplitter;
93 popNoteMemoTemplate: TMenuItem;
94 Z12: TMenuItem;
95 mnuOptions: TMenuItem;
96 mnuEditTemplates: TMenuItem;
97 mnuNewTemplate: TMenuItem;
98 N2: TMenuItem;
99 mnuEditSharedTemplates: TMenuItem;
100 mnuNewSharedTemplate: TMenuItem;
101 popNoteMemoAddend: TMenuItem;
102 pnlFields: TPanel;
103 lblNewTitle: TStaticText;
104 lblRefDate: TStaticText;
105 lblAuthor: TStaticText;
106 lblVisit: TStaticText;
107 lblCosigner: TStaticText;
108 cmdChange: TButton;
109 lblSubject: TStaticText;
110 txtSubject: TCaptionEdit;
111 timAutoSave: TTimer;
112 popNoteMemoPaste2: TMenuItem;
113 popNoteMemoReformat: TMenuItem;
114 Z4: TMenuItem;
115 mnuActChange: TMenuItem;
116 mnuActLoadBoiler: TMenuItem;
117 bvlNewTitle: TBevel;
118 popNoteMemoSaveContinue: TMenuItem;
119 N3: TMenuItem;
120 mnuEditDialgFields: TMenuItem;
121 tvNotes: TORTreeView;
122 lvNotes: TCaptionListView;
123 sptList: TSplitter;
124 N4: TMenuItem;
125 popNoteListExpandSelected: TMenuItem;
126 popNoteListExpandAll: TMenuItem;
127 popNoteListCollapseSelected: TMenuItem;
128 popNoteListCollapseAll: TMenuItem;
129 popNoteListCustom: TMenuItem;
130 mnuActDetachFromIDParent: TMenuItem;
131 N5: TMenuItem;
132 popNoteListDetachFromIDParent: TMenuItem;
133 popNoteListAddIDEntry: TMenuItem;
134 mnuActAddIDEntry: TMenuItem;
135 mnuIconLegend: TMenuItem;
136 N6: TMenuItem;
137 popNoteMemoFind: TMenuItem;
138 dlgFindText: TFindDialog;
139 dlgReplaceText: TReplaceDialog;
140 popNoteMemoReplace: TMenuItem;
141 N7: TMenuItem;
142 mnuChartSurgery: TMenuItem;
143 mnuActAttachtoIDParent: TMenuItem;
144 popNoteListAttachtoIDParent: TMenuItem;
145 N8: TMenuItem;
146 popNoteMemoPreview: TMenuItem;
147 popNoteMemoInsTemplate: TMenuItem;
148 popNoteMemoEncounter: TMenuItem;
149 mnuSearchForText: TMenuItem;
150 popSearchForText: TMenuItem;
151 mnuViewInformation: TMenuItem;
152 mnuViewDemo: TMenuItem;
153 mnuViewVisits: TMenuItem;
154 mnuViewPrimaryCare: TMenuItem;
155 mnuViewMyHealtheVet: TMenuItem;
156 mnuInsurance: TMenuItem;
157 mnuViewFlags: TMenuItem;
158 mnuViewReminders: TMenuItem;
159 mnuViewRemoteData: TMenuItem;
160 mnuViewPostings: TMenuItem;
[541]161 pnlHtmlViewer: TPanel; //kt 8/09
162 pnlTextWrite: TPanel; //kt 8/09
163 popNoteMemoHTMLFormat: TMenuItem; //kt 8/09
164 pnlHTMLWrite: TPanel; //kt 8/09
165 pnlHTMLEdit: TPanel; //kt 8/09
166 ToolBar: TToolBar; //kt 8/09
167 cbFontNames: TComboBox; //kt 8/09
168 cbFontSize: TComboBox; //kt 8/09
169 btnFonts: TSpeedButton; //kt 8/09
170 btnItalic: TSpeedButton; //kt 8/09
171 btnBold: TSpeedButton; //kt 8/09
172 btnUnderline: TSpeedButton; //kt 8/09
173 btnBullets: TSpeedButton; //kt 8/09
174 btnNumbers: TSpeedButton; //kt 8/09
175 btnLeftAlign: TSpeedButton; //kt 8/09
176 btnCenterAlign: TSpeedButton; //kt 8/09
177 btnRightAlign: TSpeedButton; //kt 8/09
178 btnMoreIndent: TSpeedButton; //kt 8/09
179 btnLessIndent: TSpeedButton; //kt 8/09
180 btnTextColor: TSpeedButton; //kt 8/09
181 btnBackColor: TSpeedButton; //kt 8/09
[453]182 procedure mnuChartTabClick(Sender: TObject);
183 procedure lstNotesClick(Sender: TObject);
184 procedure pnlRightResize(Sender: TObject);
185 procedure cmdNewNoteClick(Sender: TObject);
186 procedure mnuActNewClick(Sender: TObject);
187 procedure mnuActAddIDEntryClick(Sender: TObject);
188 procedure mnuActSaveClick(Sender: TObject);
189 procedure mnuViewClick(Sender: TObject);
190 procedure mnuActAddendClick(Sender: TObject);
191 procedure mnuActDetachFromIDParentClick(Sender: TObject);
192 procedure mnuActSignListClick(Sender: TObject);
193 procedure mnuActDeleteClick(Sender: TObject);
194 procedure mnuActEditClick(Sender: TObject);
195 procedure mnuActSignClick(Sender: TObject);
196 procedure cmdPCEClick(Sender: TObject);
197 procedure popNoteMemoCutClick(Sender: TObject);
198 procedure popNoteMemoCopyClick(Sender: TObject);
199 procedure popNoteMemoPasteClick(Sender: TObject);
200 procedure popNoteMemoPopup(Sender: TObject);
201 procedure pnlWriteResize(Sender: TObject);
202 procedure FormCreate(Sender: TObject);
203 procedure mnuViewDetailClick(Sender: TObject);
204 procedure FormClose(Sender: TObject; var Action: TCloseAction);
205 procedure mnuActIdentifyAddlSignersClick(Sender: TObject);
206 procedure popNoteMemoAddlSignClick(Sender: TObject);
207 procedure popNoteMemoSpellClick(Sender: TObject);
208 procedure popNoteMemoGrammarClick(Sender: TObject);
209 procedure mnuViewSaveAsDefaultClick(Sender: TObject);
210 procedure mnuViewReturntoDefaultClick(Sender: TObject);
211 procedure popNoteMemoTemplateClick(Sender: TObject);
212 procedure mnuEditTemplatesClick(Sender: TObject);
213 procedure mnuNewTemplateClick(Sender: TObject);
214 procedure mnuEditSharedTemplatesClick(Sender: TObject);
215 procedure mnuNewSharedTemplateClick(Sender: TObject);
216 procedure mnuOptionsClick(Sender: TObject);
217 procedure FormDestroy(Sender: TObject);
218 procedure cmdChangeClick(Sender: TObject);
219 procedure pnlFieldsResize(Sender: TObject);
220 procedure timAutoSaveTimer(Sender: TObject);
221 procedure memNewNoteChange(Sender: TObject);
222 procedure popNoteMemoReformatClick(Sender: TObject);
223 procedure mnuActChangeClick(Sender: TObject);
224 procedure mnuActLoadBoilerClick(Sender: TObject);
225 procedure popNoteMemoSaveContinueClick(Sender: TObject);
226 procedure mnuEditDialgFieldsClick(Sender: TObject);
227 procedure tvNotesChange(Sender: TObject; Node: TTreeNode);
228 procedure tvNotesClick(Sender: TObject);
229 procedure tvNotesCollapsed(Sender: TObject; Node: TTreeNode);
230 procedure tvNotesExpanded(Sender: TObject; Node: TTreeNode);
231 procedure tvNotesStartDrag(Sender: TObject;
232 var DragObject: TDragObject);
233 procedure tvNotesDragDrop(Sender, Source: TObject; X, Y: Integer);
234 procedure tvNotesDragOver(Sender, Source: TObject; X, Y: Integer;
235 State: TDragState; var Accept: Boolean);
236 procedure lvNotesColumnClick(Sender: TObject; Column: TListColumn);
237 procedure lvNotesCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
238 procedure lvNotesSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
239 procedure popNoteListExpandAllClick(Sender: TObject);
240 procedure popNoteListCollapseAllClick(Sender: TObject);
241 procedure popNoteListExpandSelectedClick(Sender: TObject);
242 procedure popNoteListCollapseSelectedClick(Sender: TObject);
243 procedure popNoteListPopup(Sender: TObject);
244 procedure lvNotesResize(Sender: TObject);
245 procedure mnuIconLegendClick(Sender: TObject);
246 procedure popNoteMemoFindClick(Sender: TObject);
247 procedure dlgFindTextFind(Sender: TObject);
248 procedure popNoteMemoReplaceClick(Sender: TObject);
249 procedure dlgReplaceTextReplace(Sender: TObject);
250 procedure dlgReplaceTextFind(Sender: TObject);
251 procedure mnuActAttachtoIDParentClick(Sender: TObject);
252 procedure memNewNoteKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
253 procedure sptHorzCanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean);
[541]254 //kt procedure WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); //kt added
[453]255 procedure popNoteMemoInsTemplateClick(Sender: TObject);
256 procedure popNoteMemoPreviewClick(Sender: TObject);
257 procedure tvNotesAddition(Sender: TObject; Node: TTreeNode);
258 procedure tvNotesDeletion(Sender: TObject; Node: TTreeNode);
259 procedure tvNotesExit(Sender: TObject);
260 procedure pnlReadExit(Sender: TObject);
261 procedure cmdNewNoteExit(Sender: TObject);
262 procedure FormHide(Sender: TObject);
263 procedure FormShow(Sender: TObject);
264 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
265 Y: Integer);
266 procedure memNewNoteKeyPress(Sender: TObject; var Key: Char);
267 procedure memNewNoteKeyUp(Sender: TObject; var Key: Word;
268 Shift: TShiftState);
269 procedure memPCEShowExit(Sender: TObject);
270 procedure cmdChangeExit(Sender: TObject);
271 procedure cmdPCEExit(Sender: TObject);
272 procedure ViewInfo(Sender: TObject);
273 procedure mnuViewInformationClick(Sender: TObject);
[541]274 procedure btnBackColorClick(Sender: TObject); //kt 8/09
275 procedure btnBoldClick(Sender: TObject); //kt 8/09
276 procedure btnBulletsClick(Sender: TObject); //kt 8/09
277 procedure btnCenterAlignClick(Sender: TObject); //kt 8/09
278 procedure btnFontsClick(Sender: TObject); //kt 8/09
279 procedure btnItalicClick(Sender: TObject); //kt 8/09
280 procedure btnLeftAlignClick(Sender: TObject); //kt 8/09
281 procedure btnLessIndentClick(Sender: TObject); //kt 8/09
282 procedure btnMoreIndentClick(Sender: TObject); //kt 8/09
283 procedure btnNumbersClick(Sender: TObject); //kt 8/09
284 procedure btnRightAlignClick(Sender: TObject); //kt 8/09
285 procedure btnTextColorClick(Sender: TObject); //kt 8/09
286 procedure btnUnderlineClick(Sender: TObject); //kt 8/09
287 procedure cbFontNamesChange(Sender: TObject); //kt 8/09
288 procedure cbFontSizeChange(Sender: TObject); //kt 8/09
289 procedure popNoteMemoHTMLFormatClick(Sender: TObject); //kt 8/09
[453]290 private
291 FNavigatingTab : Boolean; //Currently Using tab to navigate
292 FEditingIndex: Integer; // index of note being currently edited
293 FChanged: Boolean; // true if any text has changed in the note
294 FEditCtrl: TCustomEdit;
295 FSilent: Boolean;
296 FCurrentContext: TTIUContext;
297 FDefaultContext: TTIUContext;
298 FOrderID: string;
299 FImageFlag: TBitmap;
300 FEditNote: TEditNoteRec;
[541]301 FViewNote : TStringList; //kt 8/09
302 FWarmedUp : boolean; //kt 8/09
[453]303 FVerifyNoteTitle: Integer;
304 FDocList: TStringList;
305 FConfirmed: boolean;
306 FLastNoteID: string;
307 FNewIDChild: boolean;
308 FEditingNotePCEObj: boolean;
309 FDeleted: boolean;
310 FOldFramePnlPatientExit: TNotifyEvent;
311 FOldDrawerPnlTemplatesButtonExit: TNotifyEvent;
312 FOldDrawerPnlEncounterButtonExit: TNotifyEvent;
313 FOldDrawerEdtSearchExit: TNotifyEvent;
314 FMousing: TDateTime;
315 FStarting: boolean;
316 LastAuthor: Int64; //kt 6-1-05
317 LastAuthorName: string; //kt 6-1-05
[541]318 FHTMLEditMode : TEditModes; //kt 7/09 This is the mode of the note being edited (even if not actively displayed)
319 FViewMode : TViewModeSet; //kt 7/09 This is the status of the display
[453]320 procedure frmFramePnlPatientExit(Sender: TObject);
321 procedure frmDrawerPnlTemplatesButtonExit(Sender: TObject);
322 procedure frmDrawerPnlEncounterButtonExit(Sender: TObject);
323 procedure frmDrawerEdtSearchExit(Sender: TObject);
324 procedure ClearEditControls;
325 procedure DoAutoSave(Suppress: integer = 1);
326 function GetTitleText(AnIndex: Integer): string;
327 procedure InsertAddendum;
328 procedure InsertNewNote(IsIDChild: boolean; AnIDParent: integer);
329 function LacksRequiredForCreate: Boolean;
330 procedure LoadForEdit;
331 function LockConsultRequest(AConsult: Integer): Boolean;
332 function LockConsultRequestAndNote(AnIEN: Int64): Boolean;
333 procedure RemovePCEFromChanges(IEN: Int64; AVisitStr: string = '');
334 procedure SaveEditedNote(var Saved: Boolean);
335 procedure SaveCurrentNote(var Saved: Boolean);
336 procedure SetEditingIndex(const Value: Integer);
337 procedure SetSubjectVisible(ShouldShow: Boolean);
338 procedure ShowPCEControls(ShouldShow: Boolean);
339 function StartNewEdit(NewNoteType: integer): Boolean;
340 procedure UnlockConsultRequest(ANote: Int64; AConsult: Integer = 0);
341 procedure ProcessNotifications;
342 procedure SetViewContext(AContext: TTIUContext);
343 property EditingIndex: Integer read FEditingIndex write SetEditingIndex;
344 function GetDrawers: TFrmDrawers;
345 function CanFinishReminder: boolean;
346 procedure DisplayPCE;
347 function VerifyNoteTitle: Boolean;
348 // added for treeview
349 procedure LoadNotes;
350 procedure UpdateTreeView(DocList: TStringList; Tree: TORTreeView);
351 procedure EnableDisableIDNotes;
352 procedure ShowPCEButtons(Editing: boolean);
353 procedure DoAttachIDChild(AChild, AParent: TORTreeNode);
354 function SetNoteTreeLabel(AContext: TTIUContext): string;
355 procedure UpdateNoteAuthor(DocInfo: string);
[541]356 procedure SetHTMLEditMode(HTMLEditMode : boolean; Quiet : Boolean=false); //kt
357 procedure ToggleHTMLEditMode; //kt
358 procedure BroadcastImages(Note: TStrings); //kt
359 procedure ProperRepaint(Editing : Boolean); //kt
360 procedure SetEditorFocus; //kt
361 function EditorHasText : boolean; //kt
[453]362 public
[541]363 HtmlEditor : THtmlObj; //kt 8/09
364 HtmlViewer : THtmlObj; //kt 8/09
365 procedure SetDisplayToHTMLvsText(Mode :TViewModeSet; Lines : TStrings; ActivateOnly : boolean=False); //kt 8/09
[453]366 function ActiveEditOf(AnIEN: Int64; ARequest: integer): Boolean;
367 function AllowContextChange(var WhyNot: string): Boolean; override;
368 procedure ClearPtData; override;
369 procedure DisplayPage; override;
370 procedure RequestPrint; override;
371 procedure RequestMultiplePrint(AForm: TfrmPrintList);
372 procedure SetFontSize(NewFontSize: Integer); override;
373 procedure SaveSignItem(const ItemID, ESCode: string);
374 procedure AssignRemForm;
375 property OrderID: string read FOrderID;
[541]376 property ViewMode :TViewModeSet read FViewMode; //kt 8/09
[453]377 procedure LstNotesToPrint;
[541]378 constructor Create(AOwner: TComponent); override; //kt 8/09
379 destructor Destroy; override; //kt 8/09
[453]380 published
381 property Drawers: TFrmDrawers read GetDrawers; // Keep Drawers published
382 end;
383
384var
385 frmNotes: TfrmNotes;
386 SearchTextStopFlag: Boolean; // Text Search CQ: HDS00002856
387
388implementation
389
390{$R *.DFM}
391
392uses fFrame, fVisit, fEncnt, rCore, uCore, fNoteBA, fNoteBD, fSignItem, fEncounterFrame,
393 rPCE, Clipbrd, fNoteCslt, fNotePrt, rVitals, fAddlSigners, fNoteDR, fConsults, uSpell,
394 fTIUView, fTemplateEditor, uReminders, fReminderDialog, uOrders, rConsults, fReminderTree,
395 fNoteProps, fNotesBP, fTemplateFieldEditor, dShared, rTemplates,
396 FIconLegend, fPCEEdit, fNoteIDParents, rSurgery, uSurgery, uTemplates,
397 uAccessibleTreeView, uAccessibleTreeNode, fTemplateDialog, DateUtils,
398 StrUtils {//KT added 1-1-05},
[541]399 //fImages, {//kt added 9-20-05}
400 fOptionsNotes, //kt 8/09
[453]401 rHTMLTools; {//kt added 5-27-05 for IsHTMLDocument}
402
403const
404
405 NT_NEW_NOTE = -10; // Holder IEN for a new note
406 NT_ADDENDUM = -20; // Holder IEN for a new addendum
407
408 NT_ACT_NEW_NOTE = 2;
409 NT_ACT_ADDENDUM = 3;
410 NT_ACT_EDIT_NOTE = 4;
411 NT_ACT_ID_ENTRY = 5;
412
[541]413 VIEW_ACTIVATE_ONLY = true; //kt 8/09
414
[453]415//TX_NEED_VISIT = 'A visit is required before creating a new progress note.'; <-- original line. //kt 7/19/2007
416//TX_CREATE_ERR = 'Error Creating Note'; <-- original line. //kt 7/19/2007
417//TX_UPDATE_ERR = 'Error Updating Note'; <-- original line. //kt 7/19/2007
418//TX_NO_NOTE = 'No progress note is currently being edited'; <-- original line. //kt 7/19/2007
419//TX_SAVE_NOTE = 'Save Progress Note'; <-- original line. //kt 7/19/2007
420//TX_ADDEND_NO = 'Cannot make an addendum to a note that is being edited'; <-- original line. //kt 7/19/2007
421//TX_DEL_OK = CRLF + CRLF + 'Delete this progress note?'; <-- original line. //kt 7/19/2007
422//TX_DEL_ERR = 'Unable to Delete Note'; <-- original line. //kt 7/19/2007
423//TX_SIGN = 'Sign Note'; <-- original line. //kt 7/19/2007
424//TX_COSIGN = 'Cosign Note'; <-- original line. //kt 7/19/2007
425//TX_SIGN_ERR = 'Unable to Sign Note'; <-- original line. //kt 7/19/2007
426// TX_SCREQD = 'This progress note title requires the service connected questions to be '+
427// 'answered. The Encounter form will now be opened. Please answer all '+
428// 'service connected questions.';
429// TX_SCREQD_T = 'Response required for SC questions.';
430//TX_NONOTE = 'No progress note is currently selected.'; <-- original line. //kt 7/19/2007
431//TX_NONOTE_CAP = 'No Note Selected'; <-- original line. //kt 7/19/2007
432//TX_NOPRT_NEW = 'This progress note may not be printed until it is saved'; <-- original line. //kt 7/19/2007
433//TX_NOPRT_NEW_CAP = 'Save Progress Note'; <-- original line. //kt 7/19/2007
434//TX_NO_ALERT = 'There is insufficient information to process this alert.' + CRLF + <-- original line. //kt 7/19/2007
435// 'Either the alert has already been deleted, or it contained invalid data.' + CRLF + CRLF + <-- original line. //kt 7/19/2007
436// 'Click the NEXT button if you wish to continue processing more alerts.'; <-- original line. //kt 7/19/2007
437//TX_CAP_NO_ALERT = 'Unable to Process Alert'; <-- original line. //kt 7/19/2007
438//TX_ORDER_LOCKED = 'This record is locked by an action underway on the Consults tab'; <-- original line. //kt 7/19/2007
439//TC_ORDER_LOCKED = 'Unable to access record'; <-- original line. //kt 7/19/2007
440//TX_NO_ORD_CHG = 'The note is still associated with the previously selected request.' + CRLF + <-- original line. //kt 7/19/2007
441// 'Finish the pending action on the consults tab, then try again.'; <-- original line. //kt 7/19/2007
442//TC_NO_ORD_CHG = 'Locked Consult Request'; <-- original line. //kt 7/19/2007
443//TX_NEW_SAVE1 = 'You are currently editing:' + CRLF + CRLF; <-- original line. //kt 7/19/2007
444//TX_NEW_SAVE2 = CRLF + CRLF + 'Do you wish to save this note and begin a new one?'; <-- original line. //kt 7/19/2007
445//TX_NEW_SAVE3 = CRLF + CRLF + 'Do you wish to save this note and begin a new addendum?'; <-- original line. //kt 7/19/2007
446//TX_NEW_SAVE4 = CRLF + CRLF + 'Do you wish to save this note and edit the one selected?'; <-- original line. //kt 7/19/2007
447//TX_NEW_SAVE5 = CRLF + CRLF + 'Do you wish to save this note and begin a new Interdisciplinary entry?'; <-- original line. //kt 7/19/2007
448//TC_NEW_SAVE2 = 'Create New Note'; <-- original line. //kt 7/19/2007
449//TC_NEW_SAVE3 = 'Create New Addendum'; <-- original line. //kt 7/19/2007
450//TC_NEW_SAVE4 = 'Edit Different Note'; <-- original line. //kt 7/19/2007
451//TC_NEW_SAVE5 = 'Create New Interdisciplinary Entry'; <-- original line. //kt 7/19/2007
452//TX_EMPTY_NOTE = CRLF + CRLF + 'This note contains no text and will not be saved.' + CRLF + <-- original line. //kt 7/19/2007
453// 'Do you wish to delete this note?'; <-- original line. //kt 7/19/2007
454//TC_EMPTY_NOTE = 'Empty Note'; <-- original line. //kt 7/19/2007
455//TX_EMPTY_NOTE1 = 'This note contains no text and can not be signed.'; <-- original line. //kt 7/19/2007
456//TC_NO_LOCK = 'Unable to Lock Note'; <-- original line. //kt 7/19/2007
457//TX_ABSAVE = 'It appears the session terminated abnormally when this' + CRLF + <-- original line. //kt 7/19/2007
458// 'note was last edited. Some text may not have been saved.' + CRLF + CRLF + <-- original line. //kt 7/19/2007
459// 'Do you wish to continue and sign the note?'; <-- original line. //kt 7/19/2007
460//TC_ABSAVE = 'Possible Missing Text'; <-- original line. //kt 7/19/2007
461//TX_NO_BOIL = 'There is no boilerplate text associated with this title.'; <-- original line. //kt 7/19/2007
462//TC_NO_BOIL = 'Load Boilerplate Text'; <-- original line. //kt 7/19/2007
463//TX_BLR_CLEAR = 'Do you want to clear the previously loaded boilerplate text?'; <-- original line. //kt 7/19/2007
464//TC_BLR_CLEAR = 'Clear Previous Boilerplate Text'; <-- original line. //kt 7/19/2007
465//TX_DETACH_CNF = 'Confirm Detachment'; <-- original line. //kt 7/19/2007
466//TX_DETACH_FAILURE = 'Detach failed'; <-- original line. //kt 7/19/2007
467//TX_RETRACT_CAP = 'Retraction Notice'; <-- original line. //kt 7/19/2007
468//TX_RETRACT = 'This document will now be RETRACTED. As Such, it has been removed' +CRLF + <-- original line. //kt 7/19/2007
469// ' from public view, and from typical Releases of Information,' +CRLF + <-- original line. //kt 7/19/2007
470// ' but will remain indefinitely discoverable to HIMS.' +CRLF +CRLF; <-- original line. //kt 7/19/2007
471//TX_AUTH_SIGNED = 'Author has not signed, are you SURE you want to sign.' +CRLF; <-- original line. //kt 7/19/2007
472{
473type
474 //CQ8300
475 ClipboardData = record
476 Text: array[0..255] of char;
477 end;
478}
479
480
481var
482 TX_NEED_VISIT : string; //kt
483 TX_CREATE_ERR : string; //kt
484 TX_UPDATE_ERR : string; //kt
485 TX_NO_NOTE : string; //kt
486 TX_SAVE_NOTE : string; //kt
487 TX_ADDEND_NO : string; //kt
488 TX_DEL_OK : string; //kt
489 TX_DEL_ERR : string; //kt
490 TX_SIGN : string; //kt
491 TX_COSIGN : string; //kt
492 TX_SIGN_ERR : string; //kt
493 TX_NONOTE : string; //kt
494 TX_NONOTE_CAP : string; //kt
495 TX_NOPRT_NEW : string; //kt
496 TX_NOPRT_NEW_CAP : string; //kt
497 TX_NO_ALERT : string; //kt
498 TX_CAP_NO_ALERT : string; //kt
499 TX_ORDER_LOCKED : string; //kt
500 TC_ORDER_LOCKED : string; //kt
501 TX_NO_ORD_CHG : string; //kt
502 TC_NO_ORD_CHG : string; //kt
503 TX_NEW_SAVE1 : string; //kt
504 TX_NEW_SAVE2 : string; //kt
505 TX_NEW_SAVE3 : string; //kt
506 TX_NEW_SAVE4 : string; //kt
507 TX_NEW_SAVE5 : string; //kt
508 TC_NEW_SAVE2 : string; //kt
509 TC_NEW_SAVE3 : string; //kt
510 TC_NEW_SAVE4 : string; //kt
511 TC_NEW_SAVE5 : string; //kt
512 TX_EMPTY_NOTE : string; //kt
513 TC_EMPTY_NOTE : string; //kt
514 TX_EMPTY_NOTE1 : string; //kt
515 TC_NO_LOCK : string; //kt
516 TX_ABSAVE : string; //kt
517 TC_ABSAVE : string; //kt
518 TX_NO_BOIL : string; //kt
519 TC_NO_BOIL : string; //kt
520 TX_BLR_CLEAR : string; //kt
521 TC_BLR_CLEAR : string; //kt
522 TX_DETACH_CNF : string; //kt
523 TX_DETACH_FAILURE : string; //kt
524 TX_RETRACT_CAP : string; //kt
525 TX_RETRACT : string; //kt
526 TX_AUTH_SIGNED : string; //kt
527
528procedure SetupVars;
529//kt Added entire function to replace constant declarations 7/19/2007
530begin
531 TX_NEED_VISIT := DKLangConstW('fNotes_A_visit_is_required_before_creating_a_new_progress_notex');
532 TX_CREATE_ERR := DKLangConstW('fNotes_Error_Creating_Note');
533 TX_UPDATE_ERR := DKLangConstW('fNotes_Error_Updating_Note');
534 TX_NO_NOTE := DKLangConstW('fNotes_No_progress_note_is_currently_being_edited');
535 TX_SAVE_NOTE := DKLangConstW('fNotes_Save_Progress_Note');
536 TX_ADDEND_NO := DKLangConstW('fNotes_Cannot_make_an_addendum_to_a_note_that_is_being_edited');
537 TX_DEL_OK := CRLF + CRLF + DKLangConstW('fNotes_Delete_this_progress_notex');
538 TX_DEL_ERR := DKLangConstW('fNotes_Unable_to_Delete_Note');
539 TX_SIGN := DKLangConstW('fNotes_Sign_Note');
540 TX_COSIGN := DKLangConstW('fNotes_Cosign_Note');
541 TX_SIGN_ERR := DKLangConstW('fNotes_Unable_to_Sign_Note');
542 TX_NONOTE := DKLangConstW('fNotes_No_progress_note_is_currently_selectedx');
543 TX_NONOTE_CAP := DKLangConstW('fNotes_No_Note_Selected');
544 TX_NOPRT_NEW := DKLangConstW('fNotes_This_progress_note_may_not_be_printed_until_it_is_saved');
545 TX_NOPRT_NEW_CAP := DKLangConstW('fNotes_Save_Progress_Note');
546 TX_NO_ALERT := DKLangConstW('fNotes_There_is_insufficient_information_to_process_this_alertx') + CRLF +
547 DKLangConstW('fNotes_Either_the_alert_has_already_been_deletedx_or_it_contained_invalid_datax') + CRLF + CRLF +
548 DKLangConstW('fNotes_Click_the_NEXT_button_if_you_wish_to_continue_processing_more_alertsx');
549 TX_CAP_NO_ALERT := DKLangConstW('fNotes_Unable_to_Process_Alert');
550 TX_ORDER_LOCKED := DKLangConstW('fNotes_This_record_is_locked_by_an_action_underway_on_the_Consults_tab');
551 TC_ORDER_LOCKED := DKLangConstW('fNotes_Unable_to_access_record');
552 TX_NO_ORD_CHG := DKLangConstW('fNotes_The_note_is_still_associated_with_the_previously_selected_requestx') + CRLF +
553 DKLangConstW('fNotes_Finish_the_pending_action_on_the_consults_tabx_then_try_againx');
554 TC_NO_ORD_CHG := DKLangConstW('fNotes_Locked_Consult_Request');
555 TX_NEW_SAVE1 := DKLangConstW('fNotes_You_are_currently_editingx') + CRLF + CRLF;
556 TX_NEW_SAVE2 := CRLF + CRLF + DKLangConstW('fNotes_Do_you_wish_to_save_this_note_and_begin_a_new_onex');
557 TX_NEW_SAVE3 := CRLF + CRLF + DKLangConstW('fNotes_Do_you_wish_to_save_this_note_and_begin_a_new_addendumx');
558 TX_NEW_SAVE4 := CRLF + CRLF + DKLangConstW('fNotes_Do_you_wish_to_save_this_note_and_edit_the_one_selectedx');
559 TX_NEW_SAVE5 := CRLF + CRLF + DKLangConstW('fNotes_Do_you_wish_to_save_this_note_and_begin_a_new_Interdisciplinary_entryx');
560 TC_NEW_SAVE2 := DKLangConstW('fNotes_Create_New_Note');
561 TC_NEW_SAVE3 := DKLangConstW('fNotes_Create_New_Addendum');
562 TC_NEW_SAVE4 := DKLangConstW('fNotes_Edit_Different_Note');
563 TC_NEW_SAVE5 := DKLangConstW('fNotes_Create_New_Interdisciplinary_Entry');
564 TX_EMPTY_NOTE := CRLF + CRLF + DKLangConstW('fNotes_This_note_contains_no_text_and_will_not_be_savedx') + CRLF +
565 DKLangConstW('fNotes_Do_you_wish_to_delete_this_notex');
566 TC_EMPTY_NOTE := DKLangConstW('fNotes_Empty_Note');
567 TX_EMPTY_NOTE1 := DKLangConstW('fNotes_This_note_contains_no_text_and_can_not_be_signedx');
568 TC_NO_LOCK := DKLangConstW('fNotes_Unable_to_Lock_Note');
569 TX_ABSAVE := DKLangConstW('fNotes_It_appears_the_session_terminated_abnormally_when_this') + CRLF +
570 DKLangConstW('fNotes_note_was_last_editedx_Some_text_may_not_have_been_savedx') + CRLF + CRLF +
571 DKLangConstW('fNotes_Do_you_wish_to_continue_and_sign_the_notex');
572 TC_ABSAVE := DKLangConstW('fNotes_Possible_Missing_Text');
573 TX_NO_BOIL := DKLangConstW('fNotes_There_is_no_boilerplate_text_associated_with_this_titlex');
574 TC_NO_BOIL := DKLangConstW('fNotes_Load_Boilerplate_Text');
575 TX_BLR_CLEAR := DKLangConstW('fNotes_Do_you_want_to_clear_the_previously_loaded_boilerplate_textx');
576 TC_BLR_CLEAR := DKLangConstW('fNotes_Clear_Previous_Boilerplate_Text');
577 TX_DETACH_CNF := DKLangConstW('fNotes_Confirm_Detachment');
578 TX_DETACH_FAILURE := DKLangConstW('fNotes_Detach_failed');
579 TX_RETRACT_CAP := DKLangConstW('fNotes_Retraction_Notice');
580 TX_RETRACT := DKLangConstW('fNotes_This_document_will_now_be_RETRACTEDx__As_Suchx_it_has_been_removed') +CRLF +
581 DKLangConstW('fNotes_from_public_viewx_and_from_typical_Releases_of_Informationx') +CRLF +
582 DKLangConstW('fNotes_but_will_remain_indefinitely_discoverable_to_HIMSx') +CRLF +CRLF;
583 TX_AUTH_SIGNED := DKLangConstW('fNotes_Author_has_not_signedx_are_you_SURE_you_want_to_signx') +CRLF;
584end;
585
586var
587 uPCEShow, uPCEEdit: TPCEData;
588 ViewContext: Integer;
589 frmDrawers: TfrmDrawers;
590 uTIUContext: TTIUContext;
591 ColumnToSort: Integer;
592 ColumnSortForward: Boolean;
593 uChanging: Boolean;
594 uIDNotesActive: Boolean;
595
[541]596constructor TfrmNotes.Create(AOwner: TComponent);
597//kt Added function 8/09
598begin
599 inherited Create(AOwner);
600 FViewNote := TStringList.Create;
601end;
[453]602
[541]603destructor TfrmNotes.Destroy;
604//kt Added function 8/09
605begin
606 FViewNote.Free;
607 FEditNote.Lines.Free; //kt
608 inherited Destroy;
609end;
610
611
[453]612{ TPage common methods --------------------------------------------------------------------- }
613function TfrmNotes.AllowContextChange(var WhyNot: string): Boolean;
614begin
615 dlgFindText.CloseDialog;
616 Result := inherited AllowContextChange(WhyNot); // sets result = true
617 if Assigned(frmTemplateDialog) then
618 if Screen.ActiveForm = frmTemplateDialog then
619 //if (fsModal in frmTemplateDialog.FormState) then
620 case BOOLCHAR[frmFrame.CCOWContextChanging] of
621 '1': begin
622// WhyNot := 'A template in progress will be aborted. '; <-- original line. //kt 7/19/2007
623 WhyNot := DKLangConstW('fNotes_A_template_in_progress_will_be_abortedx'); //kt added 7/19/2007
624 Result := False;
625 end;
626 '0': begin
627// if WhyNot = 'COMMIT' then <-- original line. //kt 7/19/2007
628 if WhyNot = DKLangConstW('fNotes_COMMIT') then //kt added 7/19/2007
629 begin
630 FSilent := True;
631 frmTemplateDialog.Silent := True;
632 frmTemplateDialog.ModalResult := mrCancel;
633 end;
634 end;
635 end;
636 if Assigned(frmRemDlg) then
637 case BOOLCHAR[frmFrame.CCOWContextChanging] of
638 '1': begin
639// WhyNot := 'All current reminder processing information will be discarded. '; <-- original line. //kt 7/19/2007
640 WhyNot := DKLangConstW('fNotes_All_current_reminder_processing_information_will_be_discardedx'); //kt added 7/19/2007
641 Result := False;
642 end;
643 '0': begin
644 if WhyNot = 'COMMIT' then
645 begin
646 FSilent := True;
647 frmRemDlg.Silent := True;
648 frmRemDlg.btnCancelClick(Self);
649 end;
650 end;
651 end;
652 if EditingIndex <> -1 then
653 case BOOLCHAR[frmFrame.CCOWContextChanging] of
654 '1': begin
[541]655 if ((vmHTML in FViewMode) and (HTMLEditor.Text <> '')) //kt 8/09
656 or ((not (vmHTML in FViewMode)) and (memNewNote.GetTextLen > 0 )) then begin //kt
[453]657// WhyNot := WhyNot + 'A note in progress will be saved as unsigned. ' <-- original line. //kt 7/19/2007
658 WhyNot := WhyNot + DKLangConstW('fNotes_A_note_in_progress_will_be_saved_as_unsignedx') //kt added 7/19/2007
[541]659 end else begin //kt
[453]660// WhyNot := WhyNot + 'An empty note in progress will be deleted. '; <-- original line. //kt 7/19/2007
661 WhyNot := WhyNot + DKLangConstW('fNotes_An_empty_note_in_progress_will_be_deletedx'); //kt added 7/19/2007
[541]662 end; //kt
[453]663 Result := False;
664 end;
665 '0': begin
666// if WhyNot = 'COMMIT' then FSilent := True; <-- original line. //kt 7/19/2007
667 if WhyNot = DKLangConstW('fNotes_COMMIT') then FSilent := True; //kt added 7/19/2007
668 SaveCurrentNote(Result)
669 end;
670 end;
671 if Assigned(frmEncounterFrame) then
672 if Screen.ActiveForm = frmEncounterFrame then
673 //if (fsModal in frmEncounterFrame.FormState) then
674 case BOOLCHAR[frmFrame.CCOWContextChanging] of
675 '1': begin
676// WhyNot := WhyNot + 'Encounter information being edited will not be saved'; <-- original line. //kt 7/19/2007
677 WhyNot := WhyNot + DKLangConstW('fNotes_Encounter_information_being_edited_will_not_be_saved'); //kt added 7/19/2007
678 Result := False;
679 end;
680 '0': begin
681 if WhyNot = 'COMMIT' then
682 begin
683 FSilent := True;
684 frmEncounterFrame.Abort := False;
685 frmEncounterFrame.Cancel := True;
686 end;
687 end;
688 end;
689end;
690
691procedure TfrmNotes.LstNotesToPrint;
692var
693 AParentID: string;
694 SavedDocID: string;
695 Saved: boolean;
696begin
697 inherited;
698 if not uIDNotesActive then exit;
699 if lstNotes.ItemIEN = 0 then exit;
700 SavedDocID := lstNotes.ItemID;
701 if EditingIndex <> -1 then
702 begin
703 SaveCurrentNote(Saved);
704 if not Saved then Exit;
705 LoadNotes;
706 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
707 end;
708 if tvNotes.Selected = nil then exit;
709 AParentID := frmPrintList.SelectParentFromList(tvNotes,CT_NOTES);
710 if AParentID = '' then exit;
711 with tvNotes do Selected := FindPieceNode(AParentID, 1, U, Items.GetFirstNode);
712end;
713
714procedure TfrmNotes.ClearPtData;
715{ clear all controls that contain patient specific information }
716begin
717 inherited ClearPtData;
718 ClearEditControls;
719 uChanging := True;
720 tvNotes.Items.BeginUpdate;
721 KilldocTreeObjects(tvNotes);
722 tvNotes.Items.Clear;
723 tvNotes.Items.EndUpdate;
724 lvNotes.Items.Clear;
725 uChanging := False;
726 lstNotes.Clear;
727 memNote.Clear;
[541]728 HTMLViewer.Clear; //kt
729 HTMLEditor.Clear; //kt
730 FWarmedUp := false; //kt
731 SetDisplayToHTMLvsText([vmText,vmView],nil,VIEW_ACTIVATE_ONLY); //kt
[453]732 memPCEShow.Clear;
733 uPCEShow.Clear;
734 uPCEEdit.Clear;
735 frmDrawers.ResetTemplates;
736end;
737
738procedure TfrmNotes.DisplayPage;
739{ causes page to be visible and conditionally executes initialization code }
740begin
741 inherited DisplayPage;
742 frmFrame.ShowHideChartTabMenus(mnuViewChart);
743 frmFrame.mnuFilePrint.Tag := CT_NOTES;
744 frmFrame.mnuFilePrint.Enabled := True;
745 frmFrame.mnuFilePrintSetup.Enabled := True;
746 frmFrame.mnuFilePrintSelectedItems.Enabled := True;
747 if InitPage then
748 begin
749 EnableDisableIDNotes;
750 FDefaultContext := GetCurrentTIUContext;
751 FCurrentContext := FDefaultContext;
752 popNoteMemoSpell.Visible := SpellCheckAvailable;
753 popNoteMemoGrammar.Visible := popNoteMemoSpell.Visible;
754 Z11.Visible := popNoteMemoSpell.Visible;
755 timAutoSave.Interval := User.AutoSave * 1000; // convert seconds to milliseconds
756 SetEqualTabStops(memNewNote);
757 end;
758 // to indent the right margin need to set Paragraph.RightIndent for each paragraph?
759 if InitPatient and not (CallingContext = CC_NOTIFICATION) then
760 begin
761 SetViewContext(FDefaultContext);
762 end;
763 case CallingContext of
764 CC_INIT_PATIENT: if not InitPatient then
765 begin
766 SetViewContext(FDefaultContext);
767 end;
768 CC_NOTIFICATION: ProcessNotifications;
769 end;
770end;
771
772procedure TfrmNotes.RequestPrint;
773var
774 Saved: Boolean;
775begin
776 SetupVars; //kt added 7/19/2007 to replace constants with vars.
777 with lstNotes do
778 begin
779 if ItemIndex = EditingIndex then
780 //if ItemIEN < 0 then
781 begin
782 SaveCurrentNote(Saved);
783 if not Saved then Exit;
784 end;
785 if ItemIEN > 0 then PrintNote(ItemIEN, MakeNoteDisplayText(Items[ItemIndex])) else
786 begin
787 if ItemIEN = 0 then InfoBox(TX_NONOTE, TX_NONOTE_CAP, MB_OK);
788 if ItemIEN < 0 then InfoBox(TX_NOPRT_NEW, TX_NOPRT_NEW_CAP, MB_OK);
789 end;
790 end;
791end;
792
793{for printing multiple notes}
794procedure TfrmNotes.RequestMultiplePrint(AForm: TfrmPrintList);
795var
796 NoteIEN: int64;
797 i: integer;
798begin
799 SetupVars; //kt added 7/19/2007 to replace constants with vars.
800 with AForm.lbIDParents do
801 begin
802 for i := 0 to Items.Count - 1 do
803 begin
804 if Selected[i] then
805 begin
806 NoteIEN := StrToInt64def(Piece(TStringList(Items.Objects[i])[0],U,1),0);
807 if NoteIEN > 0 then PrintNote(NoteIEN, Items[i], TRUE) else
808 begin
809 if NoteIEN = 0 then InfoBox(TX_NONOTE, TX_NONOTE_CAP, MB_OK);
810 if NoteIEN < 0 then InfoBox(TX_NOPRT_NEW, TX_NOPRT_NEW_CAP, MB_OK);
811 end;
812 end; {if selected}
813 end; {for}
814 end; {with}
815end;
816
817procedure TfrmNotes.SetFontSize(NewFontSize: Integer);
818{ adjusts the font size of any controls that don't have ParentFont = True }
819begin
820 inherited SetFontSize(NewFontSize);
821 frmDrawers.Font.Size := NewFontSize;
822 SetEqualTabStops(memNewNote);
823end;
824
825procedure TfrmNotes.mnuChartTabClick(Sender: TObject);
826{ reroute to Chart Tab menu of the parent form: frmFrame }
827begin
828 inherited;
829 frmFrame.mnuChartTabClick(Sender);
830end;
831
832{ General procedures ----------------------------------------------------------------------- }
833
834procedure TfrmNotes.ClearEditControls;
835{ resets controls used for entering a new progress note }
836begin
837 // clear FEditNote (should FEditNote be an object with a clear method?)
838 with FEditNote do
839 begin
840 DocType := 0;
841 Title := 0;
842 TitleName := '';
843 DateTime := 0;
844 Author := 0;
845 AuthorName := '';
846 Cosigner := 0;
847 CosignerName := '';
848 Subject := '';
849 Location := 0;
850 LocationName := '';
851 PkgIEN := 0;
852 PkgPtr := '';
853 PkgRef := '';
854 NeedCPT := False;
855 Addend := 0;
856 {LastCosigner & LastCosignerName aren't cleared because they're used as default for next note.}
[541]857 //kt 8/09 Lines := nil;
858 if Assigned (Lines) then Lines.Clear; //kt 8/09
[453]859 PRF_IEN := 0;
860 ActionIEN := '';
861 end;
862 // clear the editing controls (also clear the new labels?)
863 txtSubject.Text := '';
864 if memNewNote <> nil then memNewNote.Clear; //CQ7012 Added test for nil
[541]865 HTMLEditor.Clear; //kt 8/09
866 HTMLViewer.Clear; //kt 8/09
867 FHTMLEditMode := emNone; //kt 8/09
[453]868 timAutoSave.Enabled := False;
869 // clear the PCE object for editing
870 uPCEEdit.Clear;
871 // set the tracking variables to initial state
872 EditingIndex := -1;
873 FChanged := False;
874end;
875
876procedure TfrmNotes.ShowPCEControls(ShouldShow: Boolean);
877begin
878 sptVert.Visible := ShouldShow;
879 memPCEShow.Visible := ShouldShow;
880 if(ShouldShow) then
881 sptVert.Top := memPCEShow.Top - sptVert.Height;
[541]882 if (vmHTML in FViewMode) then begin //kt 8/09
883 HTMLViewer.Invalidate; //kt 8/09
884 end else begin //kt 8/09
885 memNote.Invalidate;
886 end; //kt 8/09
[453]887end;
888
889procedure TfrmNotes.DisplayPCE;
890{ displays PCE information if appropriate & enables/disabled editing of PCE data }
891var
892 EnableList, ShowList: TDrawers;
893 VitalStr: TStringlist;
894 NoPCE: boolean;
895 ActionSts: TActionRec;
896 AnIEN: integer;
897begin
898 memPCEShow.Clear;
899 with lstNotes do if ItemIndex = EditingIndex then
900 begin
901 with uPCEEdit do
902 begin
903 AddStrData(memPCEShow.Lines);
904 NoPCE := (memPCEShow.Lines.Count = 0);
905 VitalStr := TStringList.create;
906 try
907 GetVitalsFromDate(VitalStr, uPCEEdit);
908 AddVitalData(VitalStr, memPCEShow.Lines);
909 finally
910 VitalStr.free;
911 end;
912 ShowPCEButtons(TRUE);
913 ShowPCEControls(cmdPCE.Enabled or (memPCEShow.Lines.Count > 0));
914 if(NoPCE and memPCEShow.Visible) then
915 memPCEShow.Lines.Insert(0, TX_NOPCE);
916 memPCEShow.SelStart := 0;
917
918 if(InteractiveRemindersActive) then
919 begin
920 if(GetReminderStatus = rsNone) then
921 EnableList := [odTemplates]
922 else
923 EnableList := [odTemplates, odReminders];
924 ShowList := [odTemplates, odReminders];
925 end
926 else
927 begin
928 EnableList := [odTemplates];
929 ShowList := [odTemplates];
930 end;
931 frmDrawers.DisplayDrawers(TRUE, EnableList, ShowList);
932 end;
933 end else
934 begin
935 ShowPCEButtons(FALSE);
936 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]);
937 AnIEN := lstNotes.ItemIEN;
938 ActOnDocument(ActionSts, AnIEN, 'VIEW');
939 if ActionSts.Success then
940 begin
941// StatusText('Retrieving encounter information...'); <-- original line. //kt 7/19/2007
942 StatusText(DKLangConstW('fNotes_Retrieving_encounter_informationxxx')); //kt added 7/19/2007
943 with uPCEShow do
944 begin
945 NoteDateTime := MakeFMDateTime(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
946 PCEForNote(AnIEN, uPCEEdit);
947 AddStrData(memPCEShow.Lines);
948 NoPCE := (memPCEShow.Lines.Count = 0);
949 VitalStr := TStringList.create;
950 try
951 GetVitalsFromNote(VitalStr, uPCEShow, AnIEN);
952 AddVitalData(VitalStr, memPCEShow.Lines);
953 finally
954 VitalStr.free;
955 end;
956 ShowPCEControls(memPCEShow.Lines.Count > 0);
957 if(NoPCE and memPCEShow.Visible) then
958 memPCEShow.Lines.Insert(0, TX_NOPCE);
959 memPCEShow.SelStart := 0;
960 end;
961 StatusText('');
962 end
963 else
964 ShowPCEControls(FALSE);
965 end; {if ItemIndex}
966end;
967
968{ supporting calls for writing notes }
969
970function TfrmNotes.GetTitleText(AnIndex: Integer): string;
971{ returns non-tabbed text for the title of a note given the ItemIndex in lstNotes }
972begin
973 with lstNotes do
974 Result := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(Items[AnIndex], U, 3))) +
975 ' ' + Piece(Items[AnIndex], U, 2) + ', ' + Piece(Items[AnIndex], U, 6) + ', ' +
976 Piece(Piece(Items[AnIndex], U, 5), ';', 2)
977end;
978
979function TfrmNotes.LacksRequiredForCreate: Boolean;
980{ determines if the fields required to create the note are present }
981var
982 CurTitle: Integer;
983begin
984 Result := False;
985 with FEditNote do
986 begin
987 if Title <= 0 then Result := True;
988 if Author <= 0 then Result := True;
989 if DateTime <= 0 then Result := True;
990 if IsConsultTitle(Title) and (PkgIEN = 0) then Result := True;
991 if IsSurgeryTitle(Title) and (PkgIEN = 0) then Result := True;
992 if IsPRFTitle(Title) and (PRF_IEN = 0) and (not DocType = TYP_ADDENDUM) then Result := True;
993 if (DocType = TYP_ADDENDUM) then
994 begin
995 if AskCosignerForDocument(Addend, Author) and (Cosigner <= 0) then Result := True;
996 end else
997 begin
998 if Title > 0 then CurTitle := Title else CurTitle := DocType;
999 if AskCosignerForTitle(CurTitle, Author, DateTime) and (Cosigner <= 0) then Result := True;
1000 end;
1001 end;
1002end;
1003
1004function TfrmNotes.VerifyNoteTitle: Boolean;
1005const
1006 VNT_UNKNOWN = 0;
1007 VNT_NO = 1;
1008 VNT_YES = 2;
1009var
1010 AParam: string;
1011begin
1012 if FVerifyNoteTitle = VNT_UNKNOWN then
1013 begin
1014 AParam := GetUserParam('ORWOR VERIFY NOTE TITLE');
1015 if AParam = '1' then FVerifyNoteTitle := VNT_YES else FVerifyNoteTitle := VNT_NO;
1016 end;
1017 Result := FVerifyNoteTitle = VNT_YES;
1018end;
1019
1020procedure TfrmNotes.SetSubjectVisible(ShouldShow: Boolean);
1021{ hide/show subject & resize panel accordingly - leave 6 pixel margin above memNewNote }
1022begin
1023 if ShouldShow then
1024 begin
1025 lblSubject.Visible := True;
1026 txtSubject.Visible := True;
1027 pnlFields.Height := txtSubject.Top + txtSubject.Height + 6;
1028 end else
1029 begin
1030 lblSubject.Visible := False;
1031 txtSubject.Visible := False;
1032 pnlFields.Height := lblVisit.Top + lblVisit.Height + 6;
1033 end;
1034end;
1035
1036{ consult request and note locking }
1037
1038function TfrmNotes.LockConsultRequest(AConsult: Integer): Boolean;
1039{ returns true if consult successfully locked }
1040begin
1041 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1042 // *** I'm not sure about the FOrderID field - if the user is editing one note and
1043 // deletes another, FOrderID will be for editing note, then delete note, then null
1044 Result := True;
1045 FOrderID := GetConsultOrderIEN(AConsult);
1046 if (FOrderID <> '') and (FOrderID = frmConsults.OrderID) then
1047 begin
1048 InfoBox(TX_ORDER_LOCKED, TC_ORDER_LOCKED, MB_OK);
1049 Result := False;
1050 Exit;
1051 end;
1052 if (FOrderId <> '') then
1053 if not OrderCanBeLocked(FOrderID) then Result := False;
1054 if not Result then FOrderID := '';
1055end;
1056
1057function TfrmNotes.LockConsultRequestAndNote(AnIEN: Int64): Boolean;
1058{ returns true if note and associated request successfully locked }
1059var
1060 AConsult: Integer;
1061 LockMsg, x: string;
1062begin
1063 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1064 Result := True;
1065 AConsult := 0;
1066 if frmConsults.ActiveEditOf(AnIEN) then
1067 begin
1068 InfoBox(TX_ORDER_LOCKED, TC_ORDER_LOCKED, MB_OK);
1069 Result := False;
1070 Exit;
1071 end;
1072 if Changes.Exist(CH_DOC, IntToStr(AnIEN)) then Exit; // already locked
1073 // try to lock the consult request first, if there is one
1074 if IsConsultTitle(TitleForNote(AnIEN)) then
1075 begin
1076 x := GetPackageRefForNote(lstNotes.ItemIEN);
1077 AConsult := StrToIntDef(Piece(x, ';', 1), 0);
1078 Result := LockConsultRequest(AConsult);
1079 end;
1080 // now try to lock the note
1081 if Result then
1082 begin
1083 LockDocument(AnIEN, LockMsg);
1084 if LockMsg <> '' then
1085 begin
1086 Result := False;
1087 // if can't lock the note, unlock the consult request that was just locked
1088 if AConsult > 0 then
1089 begin
1090 UnlockOrderIfAble(FOrderID);
1091 FOrderID := '';
1092 end;
1093 InfoBox(LockMsg, TC_NO_LOCK, MB_OK);
1094 end;
1095 end;
1096end;
1097
1098procedure TfrmNotes.UnlockConsultRequest(ANote: Int64; AConsult: Integer = 0);
1099(*var
1100 x: string;*)
1101begin
1102(* if (AConsult = 0) and IsConsultTitle(TitleForNote(ANote)) then
1103 begin
1104 x := GetPackageRefForNote(ANote);
1105 AConsult := StrToIntDef(Piece(x, ';', 1), 0);
1106 end;
1107 if AConsult = 0 then Exit;*)
1108 if AConsult = 0 then AConsult := GetConsultIENForNote(ANote);
1109 if AConsult <= 0 then exit;
1110 FOrderID := GetConsultOrderIEN(AConsult);
1111 UnlockOrderIfAble(FOrderID);
1112 FOrderID := '';
1113end;
1114
1115function TfrmNotes.ActiveEditOf(AnIEN: Int64; ARequest: integer): Boolean;
1116begin
1117 Result := False;
1118 if EditingIndex < 0 then Exit;
1119 if lstNotes.GetIEN(EditingIndex) = AnIEN then
1120 begin
1121 Result := True;
1122 Exit;
1123 end;
1124 with FEditNote do if (PkgIEN = ARequest) and (PkgPtr = PKG_CONSULTS) then Result := True;
1125end;
1126
1127{ create, edit & save notes }
1128
1129procedure TfrmNotes.InsertNewNote(IsIDChild: boolean; AnIDParent: integer);
1130{ creates the editing context for a new progress note & inserts stub into top of view list }
1131var
1132 EnableAutosave, HaveRequired: Boolean;
1133 CreatedNote: TCreatedDoc;
1134 TmpBoilerPlate: TStringList;
1135 tmpNode: TTreeNode;
1136 x, WhyNot, DocInfo: string;
1137 tempPos : integer; //kt 6-1-05
[541]1138 Mode : TViewModeSet; //kt 8/09
1139 BoilerplateIsHTML : boolean;//kt 8/09
[453]1140
1141begin
1142 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1143 if frmFrame.Timedout then Exit;
1144
1145 FNewIDChild := IsIDChild;
1146 EnableAutosave := FALSE;
1147 TmpBoilerPlate := nil;
1148 try
1149 ClearEditControls;
[541]1150 FEditNote.Lines.Free; //(done d/t full wipe-out on line below} //kt 8/09
[453]1151 FillChar(FEditNote, SizeOf(FEditNote), 0); //v15.7
[541]1152 FEditNote.Lines := TStringList.Create; //Freed in Destructor //kt 8/09
[453]1153 with FEditNote do
1154 begin
1155 DocType := TYP_PROGRESS_NOTE;
1156 IsNewNote := True;
1157 Title := DfltNoteTitle;
1158 TitleName := DfltNoteTitleName;
1159 if IsIDChild and (not CanTitleBeIDChild(Title, WhyNot)) then
1160 begin
1161 Title := 0;
1162 TitleName := '';
1163 end;
1164 if IsSurgeryTitle(Title) then // Don't want surgery title sneaking in unchallenged
1165 begin
1166 Title := 0;
1167 TitleName := '';
1168 end;
[541]1169 //DateTime := FMNow; //kt 6-1-05
1170 DateTime := Encounter.DateTime; //kt 6-1-05
[453]1171 //kt begin changes -------------- 6-1-05
1172 if LastAuthor<>0 then begin
1173 Author := LastAuthor;
1174 AuthorName := LastAuthorName;
1175 end else begin
1176 Author := User.DUZ;
1177 AuthorName := User.Name;
1178 end;
1179 //kt 6-1-05 Author := User.DUZ;
1180 //kt 6-1-05 AuthorName := User.Name;
1181 //kt end changes -------------- 6-1-05
1182 Location := Encounter.Location;
1183 LocationName := Encounter.LocationName;
1184 VisitDate := Encounter.DateTime;
1185 if IsIDChild then
1186 IDParent := AnIDParent
1187 else
1188 IDParent := 0;
1189 // Cosigner & PkgRef, if needed, will be set by fNoteProps
1190 end;
1191 // check to see if interaction necessary to get required fields
1192 GetUnresolvedConsultsInfo;
1193 if LacksRequiredForCreate or VerifyNoteTitle or uUnresolvedConsults.UnresolvedConsultsExist
1194 then HaveRequired := ExecuteNoteProperties(FEditNote, CT_NOTES, IsIDChild, FNewIDChild, '', 0)
1195 else HaveRequired := True;
1196 //kt begin addition 6-1-05 -----------------
1197 LastAuthor := FEditNote.Author;
1198 LastAuthorName := FEditNote.AuthorName;
1199 tempPos := Pos(' - ',LastAuthorName);
1200 if tempPos>0 then begin //trim off title, e.g. "Jones,John - Physician
1201 LastAuthorName:=UpperCase(Trim(MidStr(LastAuthorName,1,tempPos)));
1202 end;
1203 //kt end addition 6-1-05 -----------------
1204 // lock the consult request if there is a consult
1205 with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then HaveRequired := LockConsultRequest(PkgIEN);
1206 if HaveRequired then
1207 begin
1208 // set up uPCEEdit for entry of new note
1209 uPCEEdit.UseEncounter := True;
1210 uPCEEdit.NoteDateTime := FEditNote.DateTime;
1211 uPCEEdit.PCEForNote(USE_CURRENT_VISITSTR, uPCEShow);
1212 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
1213 // create the note
1214 PutNewNote(CreatedNote, FEditNote);
1215 uPCEEdit.NoteIEN := CreatedNote.IEN;
1216 if CreatedNote.IEN > 0 then LockDocument(CreatedNote.IEN, CreatedNote.ErrorText);
1217 if CreatedNote.ErrorText = '' then
1218 begin
1219 //x := $$RESOLVE^TIUSRVLO formatted string
1220 //7348^Note Title^3000913^NERD, YOURA (N0165)^1329;Rich Vertigan;VERTIGAN,RICH^8E REHAB MED^complete^Adm: 11/05/98;2981105.095547^ ;^^0^^^2
1221 with FEditNote do
1222 begin
1223 x := IntToStr(CreatedNote.IEN) + U + TitleName + U + FloatToStr(FEditNote.DateTime) + U +
1224 Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
1225 U + U + U + U + U + U + U;
1226 //Link Note to PRF Action
1227 if PRF_IEN <> 0 then
1228 if sCallV('TIU LINK TO FLAG', [CreatedNote.IEN,PRF_IEN,ActionIEN,Patient.DFN]) = '0' then
1229 ShowMessage('TIU LINK TO FLAG: FAILED');
1230 end;
1231
1232 lstNotes.Items.Insert(0, x);
1233 uChanging := True;
1234 tvNotes.Items.BeginUpdate;
1235 if IsIDChild then
1236 begin
1237 tmpNode := tvNotes.FindPieceNode(IntToStr(AnIDParent), 1, U, tvNotes.Items.GetFirstNode);
1238 tmpNode.ImageIndex := IMG_IDNOTE_OPEN;
1239 tmpNode.SelectedIndex := IMG_IDNOTE_OPEN;
1240 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
1241 tmpNode.ImageIndex := IMG_ID_CHILD;
1242 tmpNode.SelectedIndex := IMG_ID_CHILD;
1243 end
1244 else
1245 begin
1246// tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'New Note in Progress', <-- original line. //kt 7/19/2007
1247 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, DKLangConstW('fNotes_New_Note_in_Progress'), //kt added 7/19/2007
1248 MakeNoteTreeObject('NEW^New Note in Progress^^^^^^^^^^^%^0'));
1249 TORTreeNode(tmpNode).StringData := 'NEW^New Note in Progress^^^^^^^^^^^%^0';
1250 tmpNode.ImageIndex := IMG_TOP_LEVEL;
1251 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
1252 tmpNode.ImageIndex := IMG_SINGLE;
1253 tmpNode.SelectedIndex := IMG_SINGLE;
1254 end;
1255 tmpNode.StateIndex := IMG_NO_IMAGES;
1256 TORTreeNode(tmpNode).StringData := x;
1257 tvNotes.Selected := tmpNode;
1258 tvNotes.Items.EndUpdate;
1259 uChanging := False;
1260 Changes.Add(CH_DOC, IntToStr(CreatedNote.IEN), GetTitleText(0), '', CH_SIGN_YES);
1261 lstNotes.ItemIndex := 0;
1262 EditingIndex := 0;
1263 SetSubjectVisible(AskSubjectForNotes);
1264 if not assigned(TmpBoilerPlate) then
1265 TmpBoilerPlate := TStringList.Create;
1266 LoadBoilerPlate(TmpBoilerPlate, FEditNote.Title);
1267 FChanged := False;
1268 cmdChangeClick(Self); // will set captions, sign state for Changes
[541]1269 Mode := [vmEdit] + [vmHTML_MODE[fOptionsNotes.DefaultEditHTMLMode]]; //kt 8/09
1270 SetDisplayToHTMLvsText(Mode, nil, VIEW_ACTIVATE_ONLY); // kt 8/09
[453]1271 lstNotesClick(Self); // will make pnlWrite visible
1272 if timAutoSave.Interval <> 0 then EnableAutosave := TRUE;
[541]1273 //kt 6/3/09 original --> if txtSubject.Visible then txtSubject.SetFocus else memNewNote.SetFocus;
1274 if txtSubject.Visible then begin //kt 8/09
1275 txtSubject.SetFocus; //kt 8/09
1276 end else begin //kt 8/09
1277 SetEditorFocus; //kt memNewNote.SetFocus; //kt 8/09
1278 end; //kt 8/09
[453]1279 end else
1280 begin
1281 // if note creation failed or failed to get note lock (both unlikely), unlock consult
1282 with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then UnlockConsultRequest(0, PkgIEN);
1283 InfoBox(CreatedNote.ErrorText, TX_CREATE_ERR, MB_OK);
1284 HaveRequired := False;
1285 end; {if CreatedNote.IEN}
1286 end; {if HaveRequired}
1287 if not HaveRequired then
1288 begin
1289 ClearEditControls;
1290 ShowPCEButtons(False);
1291 end;
1292 finally
1293 if assigned(TmpBoilerPlate) then
1294 begin
1295 DocInfo := MakeXMLParamTIU(IntToStr(CreatedNote.IEN), FEditNote);
1296 ExecuteTemplateOrBoilerPlate(TmpBoilerPlate, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
[541]1297 //kt original --> memNewNote.Lines.Assign(TmpBoilerPlate);
1298 BoilerplateIsHTML := rHTMLTools.IsHTML(TmpBoilerPlate.Text); //kt 8/09
1299 FEditNote.Lines.Assign(TmpBoilerPlate); //kt 8/09
1300 if not ((vmHTML in FViewMode)) and BoilerplateIsHTML then begin //kt 8/09
1301 FViewMode := FViewMode - [vmText] + [vmHTML]; //kt 8/09
1302 end; //kt 8/09
1303 SetDisplayToHTMLvsText(FViewMode,FEditNote.Lines); //kt 8/09
1304 if (vmHTML in FViewMode) then begin //kt 8/09
1305 HtmlEditor.MoveCaretToEnd; //kt 8/09
1306 Application.ProcessMessages; //kt 8/09
1307 end; //kt 8/09
[453]1308 UpdateNoteAuthor(DocInfo);
1309 TmpBoilerPlate.Free;
1310 end;
1311 if EnableAutosave then // Don't enable autosave until after dialog fields have been resolved
1312 timAutoSave.Enabled := True;
1313 end;
1314 frmNotes.pnlWriteResize(Self);
1315end;
1316
[541]1317
1318procedure TfrmNotes.SetEditorFocus;
1319//kt added function 8/09
1320begin
1321 try
1322 if (vmHTML in FViewMode) then begin //kt 8/09
1323 HtmlEditor.SetFocus; //kt 8/09
1324 end else begin //kt 8/09
1325 memNewNote.SetFocus;
1326 end; //kt 8/09
1327 except
1328 on E: Exception do begin
1329 // ignore error. Info in E
1330 end;
1331 end;
1332end;
1333
1334
[453]1335procedure TfrmNotes.InsertAddendum;
1336{ sets up fields of pnlWrite to write an addendum for the selected note }
1337const
1338 AS_ADDENDUM = True;
1339 IS_ID_CHILD = False;
1340var
1341 HaveRequired: Boolean;
1342 CreatedNote: TCreatedDoc;
1343 tmpNode: TTreeNode;
1344 x: string;
1345begin
1346 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1347 ClearEditControls;
1348 with FEditNote do
1349 begin
1350 DocType := TYP_ADDENDUM;
1351 IsNewNote := False;
1352 Title := TitleForNote(lstNotes.ItemIEN);
1353 TitleName := Piece(lstNotes.Items[lstNotes.ItemIndex], U, 2);
1354 if Copy(TitleName,1,1) = '+' then TitleName := Copy(TitleName, 3, 199);
1355 DateTime := FMNow;
1356 Author := User.DUZ;
1357 AuthorName := User.Name;
1358 x := GetPackageRefForNote(lstNotes.ItemIEN);
1359 if Piece(x, U, 1) <> '-1' then
1360 begin
1361 PkgRef := GetPackageRefForNote(lstNotes.ItemIEN);
1362 PkgIEN := StrToIntDef(Piece(PkgRef, ';', 1), 0);
1363 PkgPtr := Piece(PkgRef, ';', 2);
1364 end;
1365 Addend := lstNotes.ItemIEN;
1366 //Lines := memNewNote.Lines;
1367 // Cosigner, if needed, will be set by fNoteProps
1368 // Location info will be set after the encounter is loaded
1369 end;
1370 // check to see if interaction necessary to get required fields
1371 if LacksRequiredForCreate
1372 then HaveRequired := ExecuteNoteProperties(FEditNote, CT_NOTES, IS_ID_CHILD, False, '', 0)
1373 else HaveRequired := True;
1374 // lock the consult request if there is a consult
1375 if HaveRequired then
1376 with FEditNote do
1377 if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then HaveRequired := LockConsultRequest(PkgIEN);
1378 if HaveRequired then
1379 begin
1380 uPCEEdit.NoteDateTime := FEditNote.DateTime;
1381 uPCEEdit.PCEForNote(FEditNote.Addend, uPCEShow);
1382 FEditNote.Location := uPCEEdit.Location;
1383 FEditNote.LocationName := ExternalName(uPCEEdit.Location, 44);
1384 FEditNote.VisitDate := uPCEEdit.DateTime;
1385 PutAddendum(CreatedNote, FEditNote, FEditNote.Addend);
1386 uPCEEdit.NoteIEN := CreatedNote.IEN;
1387 if CreatedNote.IEN > 0 then LockDocument(CreatedNote.IEN, CreatedNote.ErrorText);
1388 if CreatedNote.ErrorText = '' then
1389 begin
1390 with FEditNote do
1391 begin
1392 x := IntToStr(CreatedNote.IEN) + U + 'Addendum to ' + TitleName + U + FloatToStr(DateTime) + U +
1393 Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
1394 U + U + U + U + U + U + U;
1395 end;
1396
1397 lstNotes.Items.Insert(0, x);
1398 uChanging := True;
1399 tvNotes.Items.BeginUpdate;
1400// tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'New Addendum in Progress', <-- original line. //kt 7/19/2007
1401 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, DKLangConstW('fNotes_New_Addendum_in_Progress'), //kt added 7/19/2007
1402 MakeNoteTreeObject('ADDENDUM^New Addendum in Progress^^^^^^^^^^^%^0'));
1403 TORTreeNode(tmpNode).StringData := 'ADDENDUM^New Addendum in Progress^^^^^^^^^^^%^0';
1404 tmpNode.ImageIndex := IMG_TOP_LEVEL;
1405 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
1406 TORTreeNode(tmpNode).StringData := x;
1407
1408 tmpNode.ImageIndex := IMG_ADDENDUM;
1409 tmpNode.SelectedIndex := IMG_ADDENDUM;
1410 tvNotes.Selected := tmpNode;
1411 tvNotes.Items.EndUpdate;
1412 uChanging := False;
1413 Changes.Add(CH_DOC, IntToStr(CreatedNote.IEN), GetTitleText(0), '', CH_SIGN_YES);
1414 lstNotes.ItemIndex := 0;
1415 EditingIndex := 0;
1416 SetSubjectVisible(AskSubjectForNotes);
1417 cmdChangeClick(Self); // will set captions, sign state for Changes
1418 lstNotesClick(Self); // will make pnlWrite visible
1419 if timAutoSave.Interval <> 0 then timAutoSave.Enabled := True;
[541]1420 SetEditorFocus; //kt memNewNote.SetFocus; //kt 8/09
[453]1421 end else
1422 begin
1423 // if note creation failed or failed to get note lock (both unlikely), unlock consult
1424 with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then UnlockConsultRequest(0, PkgIEN);
1425 InfoBox(CreatedNote.ErrorText, TX_CREATE_ERR, MB_OK);
1426 HaveRequired := False;
1427 end; {if CreatedNote.IEN}
1428 end; {if HaveRequired}
1429 if not HaveRequired then ClearEditControls;
1430end;
1431
1432procedure TfrmNotes.LoadForEdit;
1433{ retrieves an existing note and places the data in the fields of pnlWrite }
1434var
1435 tmpNode: TTreeNode;
1436 x: string;
[541]1437 Mode : TViewModeSet; //kt
1438
[453]1439begin
1440 ClearEditControls;
1441 if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
1442 EditingIndex := lstNotes.ItemIndex;
1443 Changes.Add(CH_DOC, lstNotes.ItemID, GetTitleText(EditingIndex), '', CH_SIGN_YES);
1444 GetNoteForEdit(FEditNote, lstNotes.ItemIEN);
[541]1445 Mode := [vmEdit] + [vmHTML_MODE[IsHTML(FEditNote.Lines) or (vmHTML in FViewMode)]]; //kt 8/09
1446 SetDisplayToHTMLvsText(Mode,FEditNote.Lines); //kt 8/09
1447 //kt memNewNote.Lines.Assign(FEditNote.Lines); //kt 8/09
[453]1448 FChanged := False;
1449 if FEditNote.Title = TYP_ADDENDUM then
1450 begin
1451 FEditNote.DocType := TYP_ADDENDUM;
1452 FEditNote.TitleName := Piece(lstNotes.Items[lstNotes.ItemIndex], U, 2);
1453 if Copy(FEditNote.TitleName,1,1) = '+' then FEditNote.TitleName := Copy(FEditNote.TitleName, 3, 199);
1454// if CompareText(Copy(FEditNote.TitleName, 1, 8), 'Addendum') <> 0 <-- original line. //kt 7/19/2007
1455 if CompareText(Copy(FEditNote.TitleName, 1, 8), DKLangConstW('fNotes_Addendum')) <> 0 //kt added 7/19/2007
1456// then FEditNote.TitleName := FEditNote.TitleName + 'Addendum to '; <-- original line. //kt 7/19/2007
1457 then FEditNote.TitleName := FEditNote.TitleName + DKLangConstW('fNotes_Addendum_to'); //kt added 7/19/2007
1458 end;
1459
1460 uChanging := True;
1461 tvNotes.Items.BeginUpdate;
1462
1463 tmpNode := tvNotes.FindPieceNode('EDIT', 1, U, nil);
1464 if tmpNode = nil then
1465 begin
1466// tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'Note being edited', <-- original line. //kt 7/19/2007
1467 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, DKLangConstW('fNotes_Note_being_edited'), //kt added 7/19/2007
1468 MakeNoteTreeObject('EDIT^Note being edited^^^^^^^^^^^%^0'));
1469 TORTreeNode(tmpNode).StringData := 'EDIT^Note being edited^^^^^^^^^^^%^0';
1470 end
1471 else
1472 tmpNode.DeleteChildren;
1473 x := lstNotes.Items[lstNotes.ItemIndex];
1474 tmpNode.ImageIndex := IMG_TOP_LEVEL;
1475 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
1476 TORTreeNode(tmpNode).StringData := x;
1477//if CompareText(Copy(FEditNote.TitleName, 1, 8), 'Addendum') <> 0 then <-- original line. //kt 7/19/2007
1478 if CompareText(Copy(FEditNote.TitleName, 1, 8), DKLangConstW('fNotes_Addendum')) <> 0 then //kt added 7/19/2007
1479 tmpNode.ImageIndex := IMG_SINGLE
1480 else
1481 tmpNode.ImageIndex := IMG_ADDENDUM;
1482 tmpNode.SelectedIndex := tmpNode.ImageIndex;
1483 tvNotes.Selected := tmpNode;
1484 tvNotes.Items.EndUpdate;
1485 uChanging := False;
1486
1487 uPCEEdit.NoteDateTime := MakeFMDateTime(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
1488 uPCEEdit.PCEForNote(lstNotes.ItemIEN, uPCEShow);
1489 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
1490 txtSubject.Text := FEditNote.Subject;
1491 SetSubjectVisible(AskSubjectForNotes);
1492 cmdChangeClick(Self); // will set captions, sign state for Changes
1493 lstNotesClick(Self); // will make pnlWrite visible
1494 if timAutoSave.Interval <> 0 then timAutoSave.Enabled := True;
[541]1495 SetEditorFocus; //kt memNewNote.SetFocus; //kt 8/09
[453]1496end;
1497
1498procedure TfrmNotes.SaveEditedNote(var Saved: Boolean);
1499{ validates fields and sends the updated note to the server }
1500var
1501 UpdatedNote: TCreatedDoc;
1502 x: string;
[541]1503 EmptyNote : boolean; //kt
1504
[453]1505begin
1506 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1507 Saved := False;
[541]1508 if not (vmHTML in FViewMode) then begin //kt 8/09
1509 EmptyNote := (memNewNote.GetTextLen = 0) //kt 8/09
1510 or (not ContainsVisibleChar(memNewNote.Text)); //kt 8/09
1511 end else begin //kt 8/09
1512 EmptyNote := (HtmlEditor.GetTextLen = 0) //kt 8/09
1513 or (not ContainsVisibleChar(HtmlEditor.Text)); //kt 8/09
1514 end; //kt 8/09
1515 //kt 8/09 if (memNewNote.GetTextLen = 0) or (not ContainsVisibleChar(memNewNote.Text)) then
1516 //kt 8/09 begin
1517 if EmptyNote then begin
[453]1518 lstNotes.ItemIndex := EditingIndex;
1519 x := lstNotes.ItemID;
1520 uChanging := True;
1521 tvNotes.Selected := tvNotes.FindPieceNode(x, 1, U, tvNotes.Items.GetFirstNode);
1522 uChanging := False;
1523 tvNotesChange(Self, tvNotes.Selected);
1524 if FSilent or
1525 ((not FSilent) and
1526 (InfoBox(GetTitleText(EditingIndex) + TX_EMPTY_NOTE, TC_EMPTY_NOTE, MB_YESNO) = IDYES))
1527 then
1528 begin
1529 FConfirmed := True;
1530 mnuActDeleteClick(Self);
1531 Saved := True;
1532 FDeleted := True;
1533 end
1534 else
1535 FConfirmed := False;
1536 Exit;
1537 end;
1538 //ExpandTabsFilter(memNewNote.Lines, TAB_STOP_CHARS);
[541]1539 if FEditNote.Lines = nil then FEditNote.Lines := TStringList.Create; //kt
1540 //kt 8/09 FEditNote.Lines := memNewNote.Lines;
1541 if (vmHTML in FViewMode) then begin //kt 8/09
1542 SplitToArray(WrapHTML(HtmlEditor.HTMLText), FEditNote.Lines); //kt 8/09
1543 end else begin //kt 8/09
1544 FEditNote.Lines.Assign(memNewNote.Lines); //kt 8/09
1545 end; //kt 8/09
[453]1546 //FEditNote.Lines:= SetLinesTo74ForSave(memNewNote.Lines, Self);
1547 FEditNote.Subject := txtSubject.Text;
1548 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
1549 timAutoSave.Enabled := False;
1550 try
1551 PutEditedNote(UpdatedNote, FEditNote, lstNotes.GetIEN(EditingIndex));
1552 finally
1553 timAutoSave.Enabled := True;
1554 end;
1555 // there's no unlocking here since the note is still in Changes after a save
1556 if UpdatedNote.IEN > 0 then
1557 begin
1558 if lstNotes.ItemIndex = EditingIndex then
1559 begin
1560 EditingIndex := -1;
1561 lstNotesClick(Self);
1562 end;
1563 EditingIndex := -1; // make sure EditingIndex reset even if not viewing edited note
1564 Saved := True;
1565 FNewIDChild := False;
1566 FChanged := False;
[541]1567 HTMLEditor.KeyStruck := false; //kt
[453]1568 end else
1569 begin
1570 if not FSilent then
1571 InfoBox(TX_SAVE_ERROR1 + UpdatedNote.ErrorText + TX_SAVE_ERROR2, TC_SAVE_ERROR, MB_OK or MB_ICONWARNING);
1572 end;
1573end;
1574
1575procedure TfrmNotes.SaveCurrentNote(var Saved: Boolean);
1576{ called whenever a note should be saved - uses IEN to call appropriate save logic }
1577begin
1578 if EditingIndex < 0 then Exit;
1579 SaveEditedNote(Saved);
1580end;
1581
1582{ Form events ------------------------------------------------------------------------------ }
1583
1584procedure TfrmNotes.FormCreate(Sender: TObject);
1585var
1586 CacheDir : AnsiString; //kt 9-05
1587begin
1588 inherited;
[541]1589 //kt --- Begin Modification 9-2005, 8/09 -------------
[686]1590 fOptionsNotes.Loaded; //ported from version .15 1-27-10
[453]1591 CacheDir := ExtractFilePath(ParamStr(0))+ 'Cache'; //kt 9-05
[541]1592 if not DirectoryExists(CacheDir) then CreateDir(CacheDir);
1593 //kt HTMLfilename := CacheDir + '\html_note.html'; //kt 5-05
[453]1594 LastAuthor :=0; //kt 5-05
1595 LastAuthorName:=''; //kt 5-05
[541]1596 DesiredHTMLFontSize := 2; //Used later to downsize during printing.
1597 SetRegHTMLFontSize(DesiredHTMLFontSize); //0=SMALLEST ... 4=LARGEST
1598 //kt Note: On creation, THtmlObj will remember Application.OnMessage. But if
1599 // another object (say a prior THtmlObj) has become active and already
1600 // changed the handler, then there will be a problem. So probably best
1601 // to create them all at one. //kt
1602 HtmlViewer := THtmlObj.Create(pnlHTMLViewer,Application);
1603 HtmlEditor := THtmlObj.Create(pnlHTMLEdit,Application);
1604 TWinControl(HtmlViewer).Parent:=pnlHTMLViewer;
1605 TWinControl(HtmlViewer).Align:=alClient;
1606 HtmlEditor.PrevControl := cmdPCE;
1607 HtmlEditor.NextControl := cmdChange;
1608 //Note: A 'loaded' function will initialize the THtmlObj's, but it can't be
1609 // done until after this constructor is done, and this TfrmNotes has been
1610 // assigned a parent. So done elsewhere.
1611 HtmlViewer.PopupMenu := popNoteMemo;
1612 TWinControl(HtmlEditor).Parent:=pnlHTMLEdit;
1613 TWinControl(HtmlEditor).Align:=alClient;
1614 HtmlEditor.PopupMenu := popNoteMemo;
1615 cbFontNames.Items.Assign(Screen.Fonts);
1616 FViewMode := [vmView,vmText];
1617 FHTMLEditMode := emNone;
1618 HTMLViewer.BackgroundColor := ReadOnlyColor;
1619 //kt --- End Modification 9-2005, 8/09 ------
[453]1620 PageID := CT_NOTES;
1621 memNote.Color := ReadOnlyColor;
1622 memPCEShow.Color := ReadOnlyColor;
1623 lblNewTitle.Color := ReadOnlyColor;
1624 EditingIndex := -1;
1625 FEditNote.LastCosigner := 0;
1626 FEditNote.LastCosignerName := '';
1627 FLastNoteID := '';
1628 frmDrawers := TfrmDrawers.CreateDrawers(Self, pnlDrawers, [],[]);
1629 frmDrawers.Align := alBottom;
1630 frmDrawers.RichEditControl := memNewNote;
[541]1631 frmDrawers.HTMLEditControl := HtmlEditor; //kt 8/09
1632 frmDrawers.HTMLModeSwitcher := SetHTMLEditMode; //kt 8/09
[453]1633 frmDrawers.NewNoteButton := cmdNewNote;
1634 frmDrawers.Splitter := splDrawers;
1635 frmDrawers.DefTempPiece := 1;
1636 tvNotes.Images := dmodShared.imgNotes;
1637 tvNotes.StateImages := dmodShared.imgImages;
1638 lvNotes.StateImages := dmodShared.imgImages;
1639 lvNotes.SmallImages := dmodShared.imgNotes;
1640 FImageFlag := TBitmap.Create;
1641 FDocList := TStringList.Create;
1642 TAccessibleTreeView.WrapControl(tvNotes);
[541]1643 RestoreRegHTMLFontSize; //kt, elh 8/09
[453]1644end;
1645
1646procedure TfrmNotes.pnlRightResize(Sender: TObject);
1647{ memNote (TRichEdit) doesn't repaint appropriately unless it's parent panel is refreshed }
1648begin
1649 inherited;
1650 pnlRight.Refresh;
[541]1651 if (vmHTML in FViewMode) then begin //kt 8/09
1652 HTMLViewer.Repaint; //kt 8/09
1653 end else begin //kt 8/09
1654 memNote.Repaint
1655 end; //kt 8/09
[453]1656end;
1657
1658procedure TfrmNotes.pnlWriteResize(Sender: TObject);
1659const
1660 LEFT_MARGIN = 4;
1661begin
1662 inherited;
[541]1663 //kt NOTE: I don't know how to do the equivalent for HTML. Actually, I don't think it applies.
[453]1664 LimitEditWidth(memNewNote, MAX_PROGRESSNOTE_WIDTH - 1);
1665
1666 //CQ7012 Added test for nil
1667 if memNewNote <> nil then
1668 memNewNote.Constraints.MinWidth := TextWidthByFont(memNewNote.Font.Handle, StringOfChar('X', MAX_PROGRESSNOTE_WIDTH)) + (LEFT_MARGIN * 2) + ScrollBarWidth;
1669 //CQ7012 Added test for nil
1670 if (Self <> nil) and (pnlLeft <> nil) and (pnlWrite <> nil) and (sptHorz <> nil) then
1671 pnlLeft.Width := self.ClientWidth - pnlWrite.Width - sptHorz.Width;
1672end;
1673
1674{ Left panel (selector) events ------------------------------------------------------------- }
1675
1676procedure TfrmNotes.lstNotesClick(Sender: TObject);
1677{ loads the text for the selected note or displays the editing panel for the selected note }
1678var
[541]1679 Note : TStrings; //kt 6/09. Will be pointer to FViewNote, or FEditNote.Lines
1680 Editing : boolean; //kt 8/09
1681 Mode : TViewModeSet; //kt 8/09
1682 IsHTML : boolean; //kt 8/09
1683
[453]1684begin
1685 inherited;
[541]1686 //kt 8/09 with lstNotes do if ItemIndex = -1 then Exit
1687 //kt 8/09 else if ItemIndex = EditingIndex then
[453]1688
[541]1689 with lstNotes do begin //kt 8/09
1690 if ItemIndex = -1 then Exit; //kt 8/09
1691 Editing := (ItemIndex = EditingIndex); //kt 8/09
1692 if Editing then begin //kt 8/09
1693 if FEditNote.Lines = nil then FEditNote.Lines := TStringList.Create; //kt 8/09
1694 Note := FEditNote.Lines; //kt 8/09
1695 {pnlWrite.Visible := True; //kt 8/09
1696 pnlRead.Visible := False; } //kt done in SetHTMLorTextEditor //kt 8/09
1697 mnuViewDetail.Enabled := False;
1698 if (FEditNote.IDParent <> 0) and (not FNewIDChild) then
1699 mnuActChange.Enabled := False
1700 else
1701 mnuActChange.Enabled := True;
1702 mnuActLoadBoiler.Enabled := True;
1703 UpdateReminderFinish;
1704 Mode := [vmEdit] + [vmHTML_MODE[(FHTMLEditMode=emHTML)]]; //kt 8/09
1705 SetDisplayToHTMLvsText(Mode,FEditNote.Lines,VIEW_ACTIVATE_ONLY); //kt 8/09
1706 FWarmedUp := true; //kt 8/09
1707 end else begin
1708 // StatusText('Retrieving selected progress note...'); <-- original line. //kt 7/19/2007
1709 StatusText(DKLangConstW('fNotes_Retrieving_selected_progress_notexxx')); //kt added 7/19/2007
1710 Screen.Cursor := crAppStart; //kt changed from crHourGlass; 1/1/05
1711 //kt 8/09 pnlRead.Visible := True;
1712 //kt 8/09 pnlWrite.Visible := False;
1713 UpdateReminderFinish;
1714 lblTitle.Caption := Piece(Piece(Items[ItemIndex], U, 8), ';', 1) + #9 + Piece(Items[ItemIndex], U, 2) + ', ' +
1715 Piece(Items[ItemIndex], U, 6) + ', ' + Piece(Piece(Items[ItemIndex], U, 5), ';', 2) +
1716 ' (' + FormatFMDateTime('mmm dd,yy@hh:nn', MakeFMDateTime(Piece(Items[ItemIndex], U, 3)))
1717 + ')';
1718 lvNotes.Caption := lblTitle.Caption;
1719 //kt 8/09 LoadDocumentText(memNote.Lines, ItemIEN);
1720 LoadDocumentText(FViewNote, ItemIEN); //kt 8/09
1721 Note := FViewNote; //kt 8/09
1722 memNote.SelStart := 0;
1723 mnuViewDetail.Enabled := True;
1724 mnuViewDetail.Checked := False;
1725 mnuActChange.Enabled := False;
1726 mnuActLoadBoiler.Enabled := False;
1727 Screen.Cursor := crDefault;
1728 StatusText('');
1729 IsHTML := rHTMLTools.IsHTML(FViewNote); //kt 8/09
1730 Mode := [vmView] + [vmHTML_MODE[IsHTML]]; //kt 8/09
1731 SetDisplayToHTMLvsText(Mode,FViewNote); //kt 8/09
1732 if not FWarmedUp and IsHTML then begin //kt 8/09
1733 FWarmedUp := true; //kt 8/09
1734 //First HTML page won't display without this... //kt 8/09
1735 SetDisplayToHTMLvsText(Mode,FViewNote); //kt 8/09
1736 end; //kt 8/09
1737 end;
1738 end; //kt 8/09
[453]1739
[541]1740 if(assigned(frmReminderTree)) then frmReminderTree.EnableActions;
[453]1741 //DisplayPCE; //kt 5-31-05 (moved down below)
1742 pnlRight.Refresh;
[541]1743 ProperRepaint(Editing); //kt 8/09
1744 //kt 8/09 memNewNote.Repaint;
1745 //kt 8/09 memNote.Repaint;
[453]1746 NotifyOtherApps(NAE_REPORT, 'TIU^' + lstNotes.ItemID);
[541]1747 //kt RESTORE LATER... frmImages.NewNoteSelected(Editing); //kt 9/05
1748 DisplayPCE; //kt 5-31-05 (move down from above)
1749 BroadcastImages(Note); //kt 8/09
[453]1750
1751 //-----------------------------
[541]1752 //kt RESTORE LATER... frmImages.NewNoteSelected(lstNotes.ItemIndex=EditingIndex); //kt added 9-20-05
1753end;
1754
1755procedure TfrmNotes.ProperRepaint(Editing : Boolean);
1756//kt Added function 8/09
1757begin
1758 if Editing then begin
1759 if (vmHTML in FViewMode) then begin
1760 HtmlEditor.Repaint;
1761 end else begin
1762 memNewNote.Repaint;
1763 end;
1764 end else begin
1765 if (vmHTML in FViewMode) then begin
1766 HtmlViewer.Repaint;
1767 end else begin
1768 memNote.Repaint;
1769 end;
1770 end;
1771 Application.ProcessMessages;
1772end;
1773
1774procedure TfrmNotes.BroadcastImages(Note: TStrings);
1775//kt added function 8/09
1776var
1777 ImageList : TStringList;
1778 i : integer;
1779begin
[453]1780 ImageList := TStringList.Create;
[541]1781 if rHTMLTools.CheckForImageLink(Note, ImageList) then begin
[453]1782 for i:= 0 to ImageList.Count-1 do begin
1783 NotifyOtherApps(NAE_REPORT, 'IMAGE^' + ImageList.Strings[i]);
1784 end;
1785 end;
1786 ImageList.Free;
1787end;
1788
[541]1789function TfrmNotes.EditorHasText : boolean;
1790//kt added function 8/09
1791begin
1792 if (vmHTML in FViewMode) then begin
1793 Result := (HTMLViewer.Text <> '');
1794 end else begin
1795 Result := (memNote.Lines.Count > 0);
1796 end;
1797end;
1798
[453]1799procedure TfrmNotes.cmdNewNoteClick(Sender: TObject);
1800//{ maps 'New Note' button to the New Progress Note menu item } <-- original line. //kt 7/19/2007
1801{ maps DKLangConstW('fNotes_New_Note') button to the New Progress Note menu item } //kt added 7/19/2007
1802begin
1803 inherited;
1804 mnuActNewClick(Self);
1805end;
1806
1807procedure TfrmNotes.cmdPCEClick(Sender: TObject);
1808var
1809 Refresh: boolean;
1810 ActionSts: TActionRec;
1811 AnIEN: integer;
1812 PCEObj, tmpPCEEdit: TPCEData;
1813
1814 procedure UpdateEncounterInfo;
1815 begin
1816 if not FEditingNotePCEObj then
1817 begin
1818 PCEObj := nil;
1819 AnIEN := lstNotes.ItemIEN;
[541]1820 //kt 8/09 if (AnIEN <> 0) and (memNote.Lines.Count > 0) then
1821 if (AnIEN <> 0) and EditorHasText then //kt 8/09
[453]1822 begin
1823 ActOnDocument(ActionSts, AnIEN, 'VIEW');
1824 if ActionSts.Success then
1825 begin
1826 uPCEShow.CopyPCEData(uPCEEdit);
1827 PCEObj := uPCEEdit;
1828 end;
1829 end;
1830 Refresh := EditPCEData(PCEObj);
1831 end
1832 else
1833 begin
1834 UpdatePCE(uPCEEdit);
1835 Refresh := TRUE;
1836 end;
1837 if Refresh and (not frmFrame.Closing) then
1838 DisplayPCE;
1839 end;
1840
1841begin
1842 inherited;
1843 cmdPCE.Enabled := FALSE;
1844 if lstNotes.ItemIndex <> EditingIndex then
1845 // save uPCEEdit for note being edited, before updating current note's encounter, then restore (RV - TAM-0801-31056)
1846 begin
1847 tmpPCEEdit := TPCEData.Create;
1848 try
1849 uPCEEdit.CopyPCEData(tmpPCEEdit);
1850 UpdateEncounterInfo;
1851 tmpPCEEdit.CopyPCEData(uPCEEdit);
1852 finally
1853 tmpPCEEdit.Free;
1854 end;
1855 end
1856 else
1857 // no other note being edited, so just proceed as before.
1858 UpdateEncounterInfo;
1859 if cmdPCE <> nil then
1860 cmdPCE.Enabled := TRUE
1861end;
1862
1863{ Right panel (editor) events -------------------------------------------------------------- }
1864
1865procedure TfrmNotes.mnuActChangeClick(Sender: TObject);
1866begin
1867 inherited;
1868 if (FEditingIndex < 0) or (lstNotes.ItemIndex <> FEditingIndex) then Exit;
1869 cmdChangeClick(Sender);
1870end;
1871
1872procedure TfrmNotes.mnuActLoadBoilerClick(Sender: TObject);
1873var
1874 NoteEmpty: Boolean;
1875 BoilerText: TStringList;
1876 DocInfo: string;
1877
1878 procedure AssignBoilerText;
1879 begin
1880 ExecuteTemplateOrBoilerPlate(BoilerText, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
[541]1881 SetDisplayToHTMLvsText([vmHTML,vmEdit],BoilerText); //kt 8/09
1882 //kt 8/09 memNewNote.Lines.Assign(BoilerText);
[453]1883 UpdateNoteAuthor(DocInfo);
1884 FChanged := False;
1885 end;
1886
1887begin
1888 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1889 inherited;
1890 if (FEditingIndex < 0) or (lstNotes.ItemIndex <> FEditingIndex) then Exit;
1891 BoilerText := TStringList.Create;
1892 try
[541]1893 if (vmHTML in FViewMode) then begin //kt 8/09
1894 NoteEmpty := (HTMLEditor.Text = ''); //kt 8/09
1895 end else begin //kt 8/09
1896 NoteEmpty := memNewNote.Text = '';
1897 end; //kt 8/09
[453]1898 LoadBoilerPlate(BoilerText, FEditNote.Title);
1899 if (BoilerText.Text <> '') or
1900 assigned(GetLinkedTemplate(IntToStr(FEditNote.Title), ltTitle)) then
1901 begin
1902 DocInfo := MakeXMLParamTIU(IntToStr(lstNotes.ItemIEN), FEditNote);
1903 if NoteEmpty then AssignBoilerText else
1904 begin
1905 case QueryBoilerPlate(BoilerText) of
1906 0: { do nothing } ; // ignore
1907 1: begin
1908 ExecuteTemplateOrBoilerPlate(BoilerText, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
[541]1909 if (vmHTML in FViewMode) then begin //kt 8/09
1910 HTMLEditor.Text := HTMLEditor.Text + Text2HTML(BoilerText); //kt 8/09
1911 end else begin //kt 8/09
1912 memNewNote.Lines.AddStrings(BoilerText); // append
1913 end; //kt 8/09
[453]1914 UpdateNoteAuthor(DocInfo);
1915 end;
1916 2: AssignBoilerText; // replace
1917 end;
1918 end;
1919 end else
1920 begin
1921 if Sender = mnuActLoadBoiler
1922 then InfoBox(TX_NO_BOIL, TC_NO_BOIL, MB_OK)
1923 else
1924 begin
1925 if not NoteEmpty then
1926// if not FChanged and (InfoBox(TX_BLR_CLEAR, TC_BLR_CLEAR, MB_YESNO) = ID_YES)
[541]1927 if (InfoBox(TX_BLR_CLEAR, TC_BLR_CLEAR, MB_YESNO) = ID_YES) then begin
1928 if (vmHTML in FViewMode) then begin //kt 8/09
1929 HTMLEditor.Clear; //kt 8/09
1930 end else begin //kt 8/09
1931 memNewNote.Lines.Clear;
1932 end; //kt 8/09
1933 end;
[453]1934 end;
1935 end; {if BoilerText.Text <> ''}
1936 finally
1937 BoilerText.Free;
1938 end;
1939end;
1940
1941procedure TfrmNotes.cmdChangeClick(Sender: TObject);
1942var
1943 LastTitle, LastConsult: Integer;
1944 OKPressed, IsIDChild: Boolean;
1945 x: string;
1946 DisAssoText : String;
1947begin
1948 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1949 inherited;
1950 IsIDChild := uIDNotesActive and (FEditNote.IDParent > 0);
1951 LastTitle := FEditNote.Title;
1952 FEditNote.IsNewNote := False;
1953 DisAssoText := '';
1954 if (FEditNote.PkgPtr = PKG_CONSULTS) then
1955// DisAssoText := 'Consults'; <-- original line. //kt 7/19/2007
1956 DisAssoText := DKLangConstW('fNotes_Consults'); //kt added 7/19/2007
1957 if (FEditNote.PkgPtr = PKG_PRF) then
1958// DisAssoText := 'Patient Record Flags'; <-- original line. //kt 7/19/2007
1959 DisAssoText := DKLangConstW('fNotes_Patient_Record_Flags'); //kt added 7/19/2007
1960 if (DisAssoText <> '') and (Sender <> Self) then
1961// if InfoBox('If this title is changed, Any '+DisAssoText+' will be disassociated'+ <-- original line. //kt 7/19/2007
1962 if InfoBox(DKLangConstW('fNotes_If_this_title_is_changedx_Any')+' '+DisAssoText+DKLangConstW('fNotes_will_be_disassociated')+ //kt added 7/19/2007
1963// ' with this note', <-- original line. //kt 7/19/2007
1964 DKLangConstW('fNotes_with_this_note'), //kt added 7/19/2007
1965// 'Disassociate '+DisAssoText+'?',MB_OKCANCEL) = IDCANCEL then <-- original line. //kt 7/19/2007
1966 DKLangConstW('fNotes_Disassociate')+DisAssoText+'?',MB_OKCANCEL) = IDCANCEL then //kt added 7/19/2007
1967 exit;
1968 if FEditNote.PkgPtr = PKG_CONSULTS then LastConsult := FEditNote.PkgIEN else LastConsult := 0;;
1969 if Sender <> Self then OKPressed := ExecuteNoteProperties(FEditNote, CT_NOTES, IsIDChild, FNewIDChild, '', 0)
1970 else OKPressed := True;
1971 if not OKPressed then Exit;
1972 // update display fields & uPCEEdit
1973 lblNewTitle.Caption := ' ' + FEditNote.TitleName + ' ';
1974//if (FEditNote.Addend > 0) and (CompareText(Copy(lblNewTitle.Caption, 2, 8), 'Addendum') <> 0) <-- original line. //kt 7/19/2007
1975 if (FEditNote.Addend > 0) and (CompareText(Copy(lblNewTitle.Caption, 2, 8), DKLangConstW('fNotes_Addendum')) <> 0) //kt added 7/19/2007
1976// then lblNewTitle.Caption := ' Addendum to:' + lblNewTitle.Caption; <-- original line. //kt 7/19/2007
1977 then lblNewTitle.Caption := DKLangConstW('fNotes_Addendum_tox') + lblNewTitle.Caption; //kt added 7/19/2007
1978 with lblNewTitle do bvlNewTitle.SetBounds(Left - 1, Top - 1, Width + 2, Height + 2);
1979 lblRefDate.Caption := FormatFMDateTime('mmm dd,yyyy@hh:nn', FEditNote.DateTime);
1980 lblAuthor.Caption := FEditNote.AuthorName;
1981 if uPCEEdit.Inpatient then x := 'Adm: ' else x := 'Vst: ';
1982 x := x + FormatFMDateTime('mm/dd/yy', FEditNote.VisitDate) + ' ' + FEditNote.LocationName;
1983 lblVisit.Caption := x;
1984 if Length(FEditNote.CosignerName) > 0
1985// then lblCosigner.Caption := 'Expected Cosigner: ' + FEditNote.CosignerName <-- original line. //kt 7/19/2007
1986 then lblCosigner.Caption := DKLangConstW('fNotes_Expected_Cosignerx') + FEditNote.CosignerName //kt added 7/19/2007
1987 else lblCosigner.Caption := '';
1988 uPCEEdit.NoteTitle := FEditNote.Title;
1989 // modify signature requirements if author or cosigner changed
1990 if (User.DUZ <> FEditNote.Author) and (User.DUZ <> FEditNote.Cosigner)
1991 then Changes.ReplaceSignState(CH_DOC, lstNotes.ItemID, CH_SIGN_NA)
1992 else Changes.ReplaceSignState(CH_DOC, lstNotes.ItemID, CH_SIGN_YES);
1993 x := lstNotes.Items[EditingIndex];
1994 SetPiece(x, U, 2, lblNewTitle.Caption);
1995 SetPiece(x, U, 3, FloatToStr(FEditNote.DateTime));
1996 tvNotes.Selected.Text := MakeNoteDisplayText(x);
1997 TORTreeNode(tvNotes.Selected).StringData := x;
1998 lstNotes.Items[EditingIndex] := x;
1999 Changes.ReplaceText(CH_DOC, lstNotes.ItemID, GetTitleText(EditingIndex));
2000 with FEditNote do
2001 begin
2002 if (PkgPtr = PKG_CONSULTS) and (LastConsult <> PkgIEN) then
2003 begin
2004 // try to lock the new consult, reset to previous if unable
2005 if (PkgIEN > 0) and not LockConsultRequest(PkgIEN) then
2006 begin
2007 Infobox(TX_NO_ORD_CHG, TC_NO_ORD_CHG, MB_OK);
2008 PkgIEN := LastConsult;
2009 end else
2010 begin
2011 // unlock the previous consult
2012 if LastConsult > 0 then UnlockOrderIfAble(GetConsultOrderIEN(LastConsult));
2013 if PkgIEN = 0 then FOrderID := '';
2014 end;
2015 end;
2016 //Link Note to PRF Action
2017 if PRF_IEN <> 0 then
2018 if sCallV('TIU LINK TO FLAG', [lstNotes.ItemIEN,PRF_IEN,ActionIEN,Patient.DFN]) = '0' then
2019 ShowMessage('TIU LINK TO FLAG: FAILED');
2020 end;
2021
2022 if LastTitle <> FEditNote.Title then mnuActLoadBoilerClick(Self);
2023end;
2024
2025procedure TfrmNotes.memNewNoteChange(Sender: TObject);
2026begin
2027 inherited;
[541]2028 //kt 8/09 NOTE: the equivalent functionality for HTML is HTMLEditor.Keystruck. Don't have to set here.
[453]2029 FChanged := True;
2030end;
2031
2032procedure TfrmNotes.pnlFieldsResize(Sender: TObject);
2033{ center the reference date on the panel }
2034begin
2035 inherited;
2036 lblRefDate.Left := (pnlFields.Width - lblRefDate.Width) div 2;
2037 if lblRefDate.Left < (lblNewTitle.Left + lblNewTitle.Width + 6)
2038 then lblRefDate.Left := (lblNewTitle.Left + lblNewTitle.Width);
2039end;
2040
2041procedure TfrmNotes.DoAutoSave(Suppress: integer = 1);
2042var
2043 ErrMsg: string;
[541]2044 Changed : boolean; //kt 8/09
[453]2045begin
[541]2046 Changed := false; //kt 8/09
2047 if (vmHTML in FViewMode) then begin //kt 8/09
2048 Changed := HTMLEditor.KeyStruck; //kt 8/09
2049 end else begin //kt 8/09
2050 Changed := FChanged; //kt 8/09
2051 end; //kt 8/09
2052 //kt 8/09 if (EditingIndex > -1) and FChanged then
2053 if (EditingIndex > -1) and Changed then //kt 8/09
[453]2054 begin
2055// StatusText('Autosaving note...'); <-- original line. //kt 7/19/2007
2056 StatusText(DKLangConstW('fNotes_Autosaving_notexxx')); //kt added 7/19/2007
2057 //PutTextOnly(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex));
2058 timAutoSave.Enabled := False;
2059 try
[541]2060 if (vmHTML in FViewMode) then begin //kt
2061 rHTMLTools.SplitToArray (HTMLEditor.HTMLText, FEditNote.Lines); //kt
2062 SetText(ErrMsg, FEditNote.Lines, lstNotes.GetIEN(EditingIndex),Suppress);//kt
2063 end else begin //kt
[453]2064 SetText(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex), Suppress);
[541]2065 end; //kt
[453]2066 finally
2067 timAutoSave.Enabled := True;
2068 end;
2069 FChanged := False;
[541]2070 HTMLEditor.KeyStruck := false; //kt
[453]2071 StatusText('');
2072 end;
2073 if ErrMsg <> '' then
2074 InfoBox(TX_SAVE_ERROR1 + ErrMsg + TX_SAVE_ERROR2, TC_SAVE_ERROR, MB_OK or MB_ICONWARNING);
2075 //Assert(ErrMsg = '', 'AutoSave: ' + ErrMsg);
2076end;
2077
2078procedure TfrmNotes.timAutoSaveTimer(Sender: TObject);
2079begin
2080 inherited;
2081 DoAutoSave;
2082end;
2083
2084{ View menu events ------------------------------------------------------------------------- }
2085
2086procedure TfrmNotes.mnuViewClick(Sender: TObject);
2087{ changes the list of notes available for viewing }
2088var
2089 AuthCtxt: TAuthorContext;
2090 SearchCtxt: TSearchContext; // Text Search CQ: HDS00002856
2091 DateRange: TNoteDateRange;
2092 Saved: Boolean;
2093begin
2094 inherited;
2095 // save note at EditingIndex?
2096 if EditingIndex <> -1 then
2097 begin
2098 SaveCurrentNote(Saved);
2099 if not Saved then Exit;
2100 end;
2101 FLastNoteID := lstNotes.ItemID;
2102 mnuViewDetail.Checked := False;
2103//StatusText('Retrieving progress note list...'); <-- original line. //kt 7/19/2007
2104 StatusText(DKLangConstW('fNotes_Retrieving_progress_note_listxxx')); //kt added 7/19/2007
2105 if Sender is TMenuItem then ViewContext := TMenuItem(Sender).Tag
2106 else if FCurrentContext.Status <> '' then ViewContext := NC_CUSTOM
2107 else ViewContext := NC_RECENT;
2108 case ViewContext of
2109 NC_RECENT: begin
2110 FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
2111// lblNotes.Caption := 'Last ' + IntToStr(ReturnMaxNotes) + ' Notes'; <-- original line. //kt 7/19/2007
2112 lblNotes.Caption := DKLangConstW('fNotes_Last') + IntToStr(ReturnMaxNotes) + DKLangConstW('fNotes_Notes'); //kt added 7/19/2007
2113 FCurrentContext.Status := IntToStr(ViewContext);
2114 FCurrentContext.MaxDocs := ReturnMaxNotes;
2115 LoadNotes;
2116 end;
2117 NC_ALL: begin
2118 FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
2119// lblNotes.Caption := 'All Signed Notes'; <-- original line. //kt 7/19/2007
2120 lblNotes.Caption := DKLangConstW('fNotes_All_Signed_Notes'); //kt added 7/19/2007
2121 FCurrentContext.Status := IntToStr(ViewContext);
2122 LoadNotes;
2123 end;
2124 NC_UNSIGNED: begin
2125 FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
2126// lblNotes.Caption := 'Unsigned Notes'; <-- original line. //kt 7/19/2007
2127 lblNotes.Caption := DKLangConstW('fNotes_Unsigned_Notes'); //kt added 7/19/2007
2128 FCurrentContext.Status := IntToStr(ViewContext);
2129 LoadNotes;
2130 end;
2131 // Text Search CQ: HDS00002856 --------------------
2132 NC_SEARCHTEXT: begin;
2133 SearchTextStopFlag := False;
2134 SelectSearchText(Font.Size, FCurrentContext.SearchString, SearchCtxt );
2135 with SearchCtxt do if Changed then
2136 begin
2137 //FCurrentContext.Status := IntToStr(ViewContext);
2138 frmSearchStop.Show;
2139// lblNotes.Caption := 'Search: '+ SearchString; <-- original line. //kt 7/19/2007
2140 lblNotes.Caption := DKLangConstW('fNotes_Searchx')+ SearchString; //kt added 7/19/2007
2141 frmSearchStop.lblSearchStatus.Caption := lblNotes.Caption;
2142 FCurrentContext.SearchString := SearchString;
2143 LoadNotes;
2144 end;
2145 // Only do LoadNotes if something changed
2146 end;
2147 // Text Search CQ: HDS00002856 --------------------
2148 NC_UNCOSIGNED: begin
2149 FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
2150// lblNotes.Caption := 'Uncosigned Notes'; <-- original line. //kt 7/19/2007
2151 lblNotes.Caption := DKLangConstW('fNotes_Uncosigned_Notes'); //kt added 7/19/2007
2152 FCurrentContext.Status := IntToStr(ViewContext);
2153 LoadNotes;
2154 end;
2155 NC_BY_AUTHOR: begin
2156 SelectAuthor(Font.Size, FCurrentContext, AuthCtxt);
2157 with AuthCtxt do if Changed then
2158 begin
2159 FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
2160// lblNotes.Caption := AuthorName + ': Signed Notes'; <-- original line. //kt 7/19/2007
2161 lblNotes.Caption := AuthorName + DKLangConstW('fNotes_x_Signed_Notes'); //kt added 7/19/2007
2162 FCurrentContext.Status := IntToStr(NC_BY_AUTHOR);
2163 FCurrentContext.Author := Author;
2164 FCurrentContext.TreeAscending := Ascending;
2165 LoadNotes;
2166 end;
2167 end;
2168 NC_BY_DATE: begin
2169 SelectNoteDateRange(Font.Size, FCurrentContext, DateRange);
2170 with DateRange do if Changed then
2171 begin
2172 FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
2173 lblNotes.Caption := FormatFMDateTime('mmm dd,yy', FMBeginDate) + ' to ' +
2174 FormatFMDateTime('mmm dd,yy', FMEndDate) + ': Signed Notes';
2175 FCurrentContext.BeginDate := BeginDate;
2176 FCurrentContext.EndDate := EndDate;
2177 FCurrentContext.FMBeginDate := FMBeginDate;
2178 FCurrentContext.FMEndDate := FMEndDate;
2179 FCurrentContext.TreeAscending := Ascending;
2180 FCurrentContext.Status := IntToStr(NC_BY_DATE);
2181 LoadNotes;
2182 end;
2183 end;
2184 NC_CUSTOM: begin
2185 if Sender is TMenuItem then
2186 begin
2187 SelectTIUView(Font.Size, True, FCurrentContext, uTIUContext);
2188 //lblNotes.Caption := 'Custom List';
2189 end;
2190 with uTIUContext do if Changed then
2191 begin
2192 //if not (Sender is TMenuItem) then lblNotes.Caption := 'Default List';
2193 //if MaxDocs = 0 then MaxDocs := ReturnMaxNotes;
2194 FCurrentContext.BeginDate := BeginDate;
2195 FCurrentContext.EndDate := EndDate;
2196 FCurrentContext.FMBeginDate := FMBeginDate;
2197 FCurrentContext.FMEndDate := FMEndDate;
2198 FCurrentContext.Status := Status;
2199 FCurrentContext.Author := Author;
2200 FCurrentContext.MaxDocs := MaxDocs;
2201 FCurrentContext.ShowSubject := ShowSubject;
2202 // NEW PREFERENCES:
2203 FCurrentContext.SortBy := SortBy;
2204 FCurrentContext.ListAscending := ListAscending;
2205 FCurrentContext.GroupBy := GroupBy;
2206 FCurrentContext.TreeAscending := TreeAscending;
2207 FCurrentContext.SearchField := SearchField;
2208 FCurrentContext.Keyword := Keyword;
2209 FCurrentContext.Filtered := Filtered;
2210 LoadNotes;
2211 end;
2212 end;
2213 end; {case}
2214 lblNotes.Caption := SetNoteTreeLabel(FCurrentContext);
2215 // Text Search CQ: HDS00002856 --------------------
2216 If FCurrentContext.SearchString <> '' then
2217// lblNotes.Caption := lblNotes.Caption+', containing "'+FCurrentContext.SearchString+'"'; <-- original line. //kt 7/19/2007
2218 lblNotes.Caption := lblNotes.Caption+DKLangConstW('fNotes_x_containing_x')+FCurrentContext.SearchString+'"'; //kt added 7/19/2007
2219 If SearchTextStopFlag=True then begin;
2220// lblNotes.Caption := 'Search for "'+FCurrentContext.SearchString+'" was stopped!'; <-- original line. //kt 7/19/2007
2221 lblNotes.Caption := DKLangConstW('fNotes_Search_for_x')+FCurrentContext.SearchString+DKLangConstW('fNotes_x_was_stoppedx'); //kt added 7/19/2007
2222 end;
2223 frmSearchStop.Hide;
2224 // Text Search CQ: HDS00002856 --------------------
2225 lblNotes.hint := lblNotes.Caption;
2226 tvNotes.Caption := lblNotes.Caption;
2227 StatusText('');
2228end;
2229
2230{ Action menu events ----------------------------------------------------------------------- }
2231
2232function TfrmNotes.StartNewEdit(NewNoteType: integer): Boolean;
2233{ if currently editing a note, returns TRUE if the user wants to start a new one }
2234var
2235 Saved: Boolean;
2236 Msg, CapMsg: string;
2237begin
2238 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2239 FStarting := False;
2240 Result := True;
2241 cmdNewNote.Enabled := False;
2242 if EditingIndex > -1 then
2243 begin
2244 FStarting := True;
2245 case NewNoteType of
2246 NT_ACT_ADDENDUM: begin
2247 Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE3;
2248 CapMsg := TC_NEW_SAVE3;
2249 end;
2250 NT_ACT_EDIT_NOTE: begin
2251 Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE4;
2252 CapMsg := TC_NEW_SAVE4;
2253 end;
2254 NT_ACT_ID_ENTRY: begin
2255 Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE5;
2256 CapMsg := TC_NEW_SAVE5;
2257 end;
2258 else
2259 begin
2260 Msg := TX_NEW_SAVE1 + MakeNoteDisplayText(lstNotes.Items[EditingIndex]) + TX_NEW_SAVE2;
2261 CapMsg := TC_NEW_SAVE2;
2262 end;
2263 end;
2264 if InfoBox(Msg, CapMsg, MB_YESNO) = IDNO then
2265 begin
2266 Result := False;
2267 FStarting := False;
2268 end
2269 else
2270 begin
2271 SaveCurrentNote(Saved);
2272 if not Saved then Result := False else LoadNotes;
2273 FStarting := False;
2274 end;
2275 end;
2276 cmdNewNote.Enabled := (Result = False) and (FStarting = False);
2277end;
2278
2279procedure TfrmNotes.mnuActNewClick(Sender: TObject);
2280const
2281 IS_ID_CHILD = False;
2282{ switches to current new note or creates a new note if none is being edited already }
2283begin
2284 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2285 inherited;
2286 if not StartNewEdit(NT_ACT_NEW_NOTE) then Exit;
2287 //LoadNotes;
2288 // make sure a visit (time & location) is available before creating the note
2289 if Encounter.NeedVisit then
2290 begin
2291 UpdateVisit(Font.Size, DfltTIULocation);
2292 frmFrame.DisplayEncounterText;
2293 end;
2294 if Encounter.NeedVisit then
2295 begin
2296 InfoBox(TX_NEED_VISIT, TX_NO_VISIT, MB_OK or MB_ICONWARNING);
2297 ShowPCEButtons(False);
2298 Exit;
2299 end;
2300 InsertNewNote(IS_ID_CHILD, 0);
2301end;
2302
2303procedure TfrmNotes.mnuActAddIDEntryClick(Sender: TObject);
2304const
2305 IS_ID_CHILD = True;
2306var
2307 AnIDParent: integer;
2308{ switches to current new note or creates a new note if none is being edited already }
2309begin
2310 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2311 inherited;
2312 AnIDParent := lstNotes.ItemIEN;
2313 if not StartNewEdit(NT_ACT_ID_ENTRY) then Exit;
2314 //LoadNotes;
2315 with tvNotes do Selected := FindPieceNode(IntToStr(AnIDParent), U, Items.GetFirstNode);
2316 // make sure a visit (time & location) is available before creating the note
2317 if Encounter.NeedVisit then
2318 begin
2319 UpdateVisit(Font.Size, DfltTIULocation);
2320 frmFrame.DisplayEncounterText;
2321 end;
2322 if Encounter.NeedVisit then
2323 begin
2324 InfoBox(TX_NEED_VISIT, TX_NO_VISIT, MB_OK or MB_ICONWARNING);
2325 Exit;
2326 end;
2327 InsertNewNote(IS_ID_CHILD, AnIDParent);
2328end;
2329
2330procedure TfrmNotes.mnuActAddendClick(Sender: TObject);
2331{ make an addendum to an existing note }
2332var
2333 ActionSts: TActionRec;
2334 ANoteID: string;
2335begin
2336 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2337 inherited;
2338 if lstNotes.ItemIEN <= 0 then Exit;
2339 ANoteID := lstNotes.ItemID;
2340 if not StartNewEdit(NT_ACT_ADDENDUM) then Exit;
2341 //LoadNotes;
2342 with tvNotes do Selected := FindPieceNode(ANoteID, 1, U, Items.GetFirstNode);
2343 if lstNotes.ItemIndex = EditingIndex then
2344 begin
2345 InfoBox(TX_ADDEND_NO, TX_ADDEND_MK, MB_OK);
2346 Exit;
2347 end;
2348 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'MAKE ADDENDUM');
2349 if not ActionSts.Success then
2350 begin
2351 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2352 Exit;
2353 end;
2354 with lstNotes do if TitleForNote(lstNotes.ItemIEN) = TYP_ADDENDUM then
2355 begin
2356 InfoBox(TX_ADDEND_AD, TX_ADDEND_MK, MB_OK);
2357 Exit;
2358 end;
2359 InsertAddendum;
2360end;
2361
2362procedure TfrmNotes.mnuActDetachFromIDParentClick(Sender: TObject);
2363var
2364 DocID, WhyNot: string;
2365 Saved: boolean;
2366 SavedDocID: string;
2367begin
2368 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2369 if lstNotes.ItemIEN = 0 then exit;
2370 SavedDocID := lstNotes.ItemID;
2371 if EditingIndex <> -1 then
2372 begin
2373 SaveCurrentNote(Saved);
2374 if not Saved then Exit;
2375 LoadNotes;
2376 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2377 end;
2378 if not CanBeAttached(PDocTreeObject(tvNotes.Selected.Data)^.DocID, WhyNot) then
2379 begin
2380 WhyNot := StringReplace(WhyNot, 'ATTACH', 'DETACH', [rfIgnoreCase]);
2381 WhyNot := StringReplace(WhyNot, 'to an ID', 'from an ID', [rfIgnoreCase]);
2382 InfoBox(WhyNot, TX_DETACH_FAILURE, MB_OK);
2383 Exit;
2384 end;
2385 if (InfoBox('DETACH: ' + tvNotes.Selected.Text + CRLF + CRLF +
2386 ' FROM: ' + tvNotes.Selected.Parent.Text + CRLF + CRLF +
2387// 'Are you sure?', TX_DETACH_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) <-- original line. //kt 7/19/2007
2388 DKLangConstW('fNotes_Are_you_surex'), TX_DETACH_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) //kt added 7/19/2007
2389 then Exit;
2390 DocID := PDocTreeObject(tvNotes.Selected.Data)^.DocID;
2391 SavedDocID := PDocTreeObject(tvNotes.Selected.Parent.Data)^.DocID;
2392 if DetachEntryFromParent(DocID, WhyNot) then
2393 begin
2394 LoadNotes;
2395 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2396 if tvNotes.Selected <> nil then tvNotes.Selected.Expand(False);
2397 end
2398 else
2399 begin
2400 WhyNot := StringReplace(WhyNot, 'ATTACH', 'DETACH', [rfIgnoreCase]);
2401 WhyNot := StringReplace(WhyNot, 'to an ID', 'from an ID', [rfIgnoreCase]);
2402 InfoBox(WhyNot, TX_DETACH_FAILURE, MB_OK);
2403 end;
2404end;
2405
2406procedure TfrmNotes.mnuActSignListClick(Sender: TObject);
2407{ add the note to the Encounter object, see mnuActSignClick - copied}
2408const
2409 SIG_COSIGN = 'COSIGNATURE';
2410 SIG_SIGN = 'SIGNATURE';
2411var
2412 ActionType, SignTitle: string;
2413 ActionSts: TActionRec;
2414begin
2415 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2416 inherited;
2417 if lstNotes.ItemIEN = 0 then Exit;
2418 if lstNotes.ItemIndex = EditingIndex then Exit; // already in signature list
2419 if not NoteHasText(lstNotes.ItemIEN) then
2420 begin
2421 InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
2422 Exit;
2423 end;
2424 if not LastSaveClean(lstNotes.ItemIEN) and
2425 (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES) then Exit;
2426 if CosignDocument(lstNotes.ItemIEN) then
2427 begin
2428 SignTitle := TX_COSIGN;
2429 ActionType := SIG_COSIGN;
2430 end else
2431 begin
2432 SignTitle := TX_SIGN;
2433 ActionType := SIG_SIGN;
2434 end;
2435 ActOnDocument(ActionSts, lstNotes.ItemIEN, ActionType);
2436 if not ActionSts.Success then
2437 begin
2438 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2439 Exit;
2440 end;
2441 LockConsultRequestAndNote(lstNotes.ItemIEN);
2442 with lstNotes do Changes.Add(CH_DOC, ItemID, GetTitleText(ItemIndex), '', CH_SIGN_YES);
2443end;
2444
2445procedure TfrmNotes.RemovePCEFromChanges(IEN: Int64; AVisitStr: string = '');
2446begin
2447 if IEN = NT_ADDENDUM then Exit; // no PCE information entered for an addendum
2448 // do we need to call DeletePCE(AVisitStr), as was done with NT_NEW_NOTE (ien=-10)???
2449 if AVisitStr = '' then AVisitStr := VisitStrForNote(IEN);
2450 Changes.Remove(CH_PCE, 'V' + AVisitStr);
2451 Changes.Remove(CH_PCE, 'P' + AVisitStr);
2452 Changes.Remove(CH_PCE, 'D' + AVisitStr);
2453 Changes.Remove(CH_PCE, 'I' + AVisitStr);
2454 Changes.Remove(CH_PCE, 'S' + AVisitStr);
2455 Changes.Remove(CH_PCE, 'A' + AVisitStr);
2456 Changes.Remove(CH_PCE, 'H' + AVisitStr);
2457 Changes.Remove(CH_PCE, 'E' + AVisitStr);
2458 Changes.Remove(CH_PCE, 'T' + AVisitStr);
2459end;
2460
2461procedure TfrmNotes.mnuActDeleteClick(Sender: TObject);
2462{ delete the selected progress note & remove from the Encounter object if necessary }
2463var
2464 DeleteSts, ActionSts: TActionRec;
2465 SaveConsult, SavedDocIEN: Integer;
2466 ReasonForDelete, AVisitStr, SavedDocID, x: string;
2467 Saved: boolean;
2468begin
2469 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2470 inherited;
2471 if lstNotes.ItemIEN = 0 then Exit;
2472 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'DELETE RECORD');
2473 if ShowMsgOn(not ActionSts.Success, ActionSts.Reason, TX_IN_AUTH) then Exit;
2474 ReasonForDelete := SelectDeleteReason(lstNotes.ItemIEN);
2475 if ReasonForDelete = DR_CANCEL then Exit;
2476 // suppress prompt for deletion when called from SaveEditedNote (Sender = Self)
2477 if (Sender <> Self) and (InfoBox(MakeNoteDisplayText(lstNotes.Items[lstNotes.ItemIndex]) + TX_DEL_OK,
2478 TX_DEL_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) then Exit;
2479 // do the appropriate locking
2480 if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
2481 // retraction notification message
2482 if JustifyDocumentDelete(lstNotes.ItemIEN) then
2483 InfoBox(TX_RETRACT, TX_RETRACT_CAP, MB_OK);
2484 SavedDocID := lstNotes.ItemID;
2485 SavedDocIEN := lstNotes.ItemIEN;
2486 if (EditingIndex > -1) and (not FConfirmed) and (lstNotes.ItemIndex <> EditingIndex) and (memNewNote.GetTextLen > 0) then
2487 begin
2488 SaveCurrentNote(Saved);
2489 if not Saved then Exit;
2490 end;
2491 EditingIndex := -1;
2492 FConfirmed := False;
2493 (* if Saved then
2494 begin
2495 EditingIndex := -1;
2496 mnuViewClick(Self);
2497 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2498 end;*)
2499 // remove the note
2500 DeleteSts.Success := True;
2501 x := GetPackageRefForNote(SavedDocIEN);
2502 SaveConsult := StrToIntDef(Piece(x, ';', 1), 0);
2503 AVisitStr := VisitStrForNote(SavedDocIEN);
2504 RemovePCEFromChanges(SavedDocIEN, AVisitStr);
2505 if (SavedDocIEN > 0) and (lstNotes.ItemIEN = SavedDocIEN) then DeleteDocument(DeleteSts, SavedDocIEN, ReasonForDelete);
2506 if not Changes.Exist(CH_DOC, SavedDocID) then UnlockDocument(SavedDocIEN);
2507 Changes.Remove(CH_DOC, SavedDocID); // this will unlock the document if in Changes
2508 UnlockConsultRequest(0, SaveConsult); // note has been deleted, so 1st param = 0
2509 // reset the display now that the note is gone
2510 if DeleteSts.Success then
2511 begin
2512 DeletePCE(AVisitStr); // removes PCE data if this was the only note pointing to it
2513 ClearEditControls;
2514 //ClearPtData; WRONG - fixed in v15.10 - RV
2515 LoadNotes;
2516(* with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2517 if tvNotes.Selected <> nil then tvNotesChange(Self, tvNotes.Selected) else
2518 begin*)
[541]2519 FHTMLEditMode := emNone; //kt 8/09
[453]2520 pnlWrite.Visible := False;
2521 pnlRead.Visible := True;
2522 UpdateReminderFinish;
2523 ShowPCEControls(False);
2524 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]); //FALSE);
2525 ShowPCEButtons(FALSE);
2526 //end; {if ItemIndex}
2527 end {if DeleteSts}
2528 else InfoBox(DeleteSts.Reason, TX_DEL_ERR, MB_OK or MB_ICONWARNING);
2529end;
2530
2531procedure TfrmNotes.mnuActEditClick(Sender: TObject);
2532{ load the selected progress note for editing }
2533var
2534 ActionSts: TActionRec;
2535 ANoteID: string;
2536begin
2537 inherited;
2538 if lstNotes.ItemIndex = EditingIndex then Exit;
2539 ANoteID := lstNotes.ItemID;
2540 if not StartNewEdit(NT_ACT_EDIT_NOTE) then Exit;
2541 //LoadNotes;
2542 with tvNotes do Selected := FindPieceNode(ANoteID, 1, U, Items.GetFirstNode);
2543 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'EDIT RECORD');
2544 if not ActionSts.Success then
2545 begin
2546 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2547 Exit;
2548 end;
2549 LoadForEdit;
2550end;
2551
2552procedure TfrmNotes.mnuActSaveClick(Sender: TObject);
2553{ saves the note that is currently being edited }
2554var
2555 Saved: Boolean;
2556 SavedDocID: string;
2557begin
2558 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2559 inherited;
2560 if EditingIndex > -1 then
2561 begin
2562 SavedDocID := Piece(lstNotes.Items[EditingIndex], U, 1);
2563 FLastNoteID := SavedDocID;
2564 SaveCurrentNote(Saved);
2565 if Saved and (EditingIndex < 0) and (not FDeleted) then
2566 //if Saved then
2567 begin
2568 LoadNotes;
2569 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2570 end;
2571 end
2572 else InfoBox(TX_NO_NOTE, TX_SAVE_NOTE, MB_OK or MB_ICONWARNING);
2573end;
2574
2575procedure TfrmNotes.mnuActSignClick(Sender: TObject);
2576{ sign the currently selected note, save first if necessary }
2577const
2578 SIG_COSIGN = 'COSIGNATURE';
2579 SIG_SIGN = 'SIGNATURE';
2580var
2581 Saved, NoteUnlocked: Boolean;
2582 ActionType, ESCode, SignTitle: string;
2583 ActionSts, SignSts: TActionRec;
2584 OK: boolean;
2585 SavedDocID, tmpItem: string;
2586 EditingID: string; //v22.12 - RV
2587 tmpNode: TTreeNode;
2588begin
2589 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2590 inherited;
2591(* if lstNotes.ItemIndex = EditingIndex then //v22.12 - RV
2592 begin //v22.12 - RV
2593 SaveCurrentNote(Saved); //v22.12 - RV
2594 if (not Saved) or FDeleted then Exit; //v22.12 - RV
2595 end //v22.12 - RV
2596 else if EditingIndex > -1 then //v22.12 - RV
2597 tmpItem := lstNotes.Items[EditingIndex]; //v22.12 - RV
2598 SavedDocID := lstNotes.ItemID;*) //v22.12 - RV
2599 SavedDocID := lstNotes.ItemID; //v22.12 - RV
2600 FLastNoteID := SavedDocID; //v22.12 - RV
2601 if lstNotes.ItemIndex = EditingIndex then //v22.12 - RV
2602 begin //v22.12 - RV
2603 SaveCurrentNote(Saved); //v22.12 - RV
2604 if (not Saved) or FDeleted then Exit; //v22.12 - RV
2605 end //v22.12 - RV
2606 else if EditingIndex > -1 then //v22.12 - RV
2607 begin //v22.12 - RV
2608 tmpItem := lstNotes.Items[EditingIndex]; //v22.12 - RV
2609 EditingID := Piece(tmpItem, U, 1); //v22.12 - RV
2610 end; //v22.12 - RV
2611 if not NoteHasText(lstNotes.ItemIEN) then
2612 begin
2613 InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
2614 Exit;
2615 end;
2616 if not LastSaveClean(lstNotes.ItemIEN) and
2617 (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES) then Exit;
2618 if CosignDocument(lstNotes.ItemIEN) then
2619 begin
2620 SignTitle := TX_COSIGN;
2621 ActionType := SIG_COSIGN;
2622 end else
2623 begin
2624 SignTitle := TX_SIGN;
2625 ActionType := SIG_SIGN;
2626 end;
2627 if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
2628 // no exits after things are locked
2629 NoteUnlocked := False;
2630 ActOnDocument(ActionSts, lstNotes.ItemIEN, ActionType);
2631 if ActionSts.Success then
2632 begin
2633 OK := IsOK2Sign(uPCEShow, lstNotes.ItemIEN);
2634 if frmFrame.Closing then exit;
2635 if(uPCEShow.Updated) then
2636 begin
2637 uPCEShow.CopyPCEData(uPCEEdit);
2638 uPCEShow.Updated := FALSE;
2639 lstNotesClick(Self);
2640 end;
2641 if not AuthorSignedDocument(lstNotes.ItemIEN) then
2642 begin
2643 if (InfoBox(TX_AUTH_SIGNED +
2644 GetTitleText(lstNotes.ItemIndex),TX_SIGN ,MB_YESNO)= ID_NO) then exit;
2645 end;
2646 if(OK) then
2647 begin
2648 with lstNotes do SignatureForItem(Font.Size, MakeNoteDisplayText(Items[ItemIndex]), SignTitle, ESCode);
2649 if Length(ESCode) > 0 then
2650 begin
2651 SignDocument(SignSts, lstNotes.ItemIEN, ESCode);
2652 RemovePCEFromChanges(lstNotes.ItemIEN);
2653 NoteUnlocked := Changes.Exist(CH_DOC, lstNotes.ItemID);
2654 Changes.Remove(CH_DOC, lstNotes.ItemID); // this will unlock if in Changes
2655 if SignSts.Success then
2656 begin
2657 SendMessage(frmConsults.Handle, UM_NEWORDER, ORDER_SIGN, 0); {*REV*}
2658 lstNotesClick(Self);
2659 end
2660 else InfoBox(SignSts.Reason, TX_SIGN_ERR, MB_OK);
2661 end {if Length(ESCode)}
2662 else
2663 NoteUnlocked := Changes.Exist(CH_DOC, lstNotes.ItemID);
2664 end;
2665 end
2666 else InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2667 if not NoteUnlocked then UnlockDocument(lstNotes.ItemIEN);
2668 UnlockConsultRequest(lstNotes.ItemIEN);
2669 //SetViewContext(FCurrentContext); //v22.12 - RV
2670 LoadNotes; //v22.12 - RV
2671 //if EditingIndex > -1 then //v22.12 - RV
2672 if (EditingID <> '') then //v22.12 - RV
2673 begin
2674 lstNotes.Items.Insert(0, tmpItem);
2675// tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'Note being edited', <-- original line. //kt 7/19/2007
2676 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, DKLangConstW('fNotes_Note_being_edited'), //kt added 7/19/2007
2677 MakeNoteTreeObject('EDIT^Note being edited^^^^^^^^^^^%^0'));
2678 TORTreeNode(tmpNode).StringData := 'EDIT^Note being edited^^^^^^^^^^^%^0';
2679 tmpNode.ImageIndex := IMG_TOP_LEVEL;
2680 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(tmpItem), MakeNoteTreeObject(tmpItem));
2681 TORTreeNode(tmpNode).StringData := tmpItem;
2682 SetTreeNodeImagesAndFormatting(TORTreeNode(tmpNode), FCurrentContext, CT_NOTES);
2683 EditingIndex := lstNotes.SelectByID(EditingID); //v22.12 - RV
2684 end;
2685 //with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode); //v22.12 - RV
2686 with tvNotes do //v22.12 - RV
2687 begin //v22.12 - RV
2688 Selected := FindPieceNode(FLastNoteID, U, Items.GetFirstNode); //v22.12 - RV
2689 if Selected <> nil then
2690 tvNotesChange(Self, Selected) //v22.12 - RV
2691 else
2692 tvNotes.Selected := tvNotes.Items[0]; //first Node in treeview
2693 end; //v22.12 - RV
2694end;
2695
2696procedure TfrmNotes.SaveSignItem(const ItemID, ESCode: string);
2697{ saves and optionally signs a progress note or addendum }
2698const
2699 SIG_COSIGN = 'COSIGNATURE';
2700 SIG_SIGN = 'SIGNATURE';
2701var
2702 AnIndex, IEN, i: Integer;
2703 Saved, ContinueSign: Boolean; {*RAB* 8/26/99}
2704 ActionSts, SignSts: TActionRec;
2705 APCEObject: TPCEData;
2706 OK: boolean;
2707 ActionType, SignTitle: string;
2708begin
2709 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2710 AnIndex := -1;
2711 IEN := StrToIntDef(ItemID, 0);
2712 if IEN = 0 then Exit;
2713 if frmFrame.TimedOut and (EditingIndex <> -1) then FSilent := True;
2714 with lstNotes do for i := 0 to Items.Count - 1 do if lstNotes.GetIEN(i) = IEN then
2715 begin
2716 AnIndex := i;
2717 break;
2718 end;
2719 if (AnIndex > -1) and (AnIndex = EditingIndex) then
2720 begin
2721 SaveCurrentNote(Saved);
2722 if not Saved then Exit;
2723 if FDeleted then
2724 begin
2725 FDeleted := False;
2726 Exit;
2727 end;
2728 AnIndex := lstNotes.SelectByIEN(IEN);
2729 //IEN := lstNotes.GetIEN(AnIndex); // saving will change IEN
2730 end;
2731 if Length(ESCode) > 0 then
2732 begin
2733 if CosignDocument(IEN) then
2734 begin
2735 SignTitle := TX_COSIGN;
2736 ActionType := SIG_COSIGN;
2737 end else
2738 begin
2739 SignTitle := TX_SIGN;
2740 ActionType := SIG_SIGN;
2741 end;
2742 ActOnDocument(ActionSts, IEN, ActionType);
2743 if not ActionSts.Success then
2744 begin
2745 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2746 ContinueSign := False;
2747 end
2748 else if not NoteHasText(IEN) then
2749 begin
2750 InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
2751 ContinueSign := False;
2752 end
2753 else if not LastSaveClean(IEN) and
2754 (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES)
2755 then ContinueSign := False
2756 else ContinueSign := True;
2757 if ContinueSign then
2758 begin
2759 if (AnIndex >= 0) and (AnIndex = lstNotes.ItemIndex) then
2760 APCEObject := uPCEShow
2761 else
2762 APCEObject := nil;
2763 OK := IsOK2Sign(APCEObject, IEN);
2764 if frmFrame.Closing then exit;
2765 if(assigned(APCEObject)) and (uPCEShow.Updated) then
2766 begin
2767 uPCEShow.CopyPCEData(uPCEEdit);
2768 uPCEShow.Updated := FALSE;
2769 lstNotesClick(Self);
2770 end
2771 else
2772 uPCEEdit.Clear;
2773 if(OK) then
2774 begin
2775 //if ((not FSilent) and IsSurgeryTitle(TitleForNote(IEN))) then DisplayOpTop(IEN);
2776 SignDocument(SignSts, IEN, ESCode);
2777 if not SignSts.Success then InfoBox(SignSts.Reason, TX_SIGN_ERR, MB_OK);
2778 end; {if OK}
2779 end; {if ContinueSign}
2780 end; {if Length(ESCode)}
2781
2782 UnlockConsultRequest(IEN);
2783 if (AnIndex = lstNotes.ItemIndex) and (not frmFrame.ContextChanging) then
2784 begin
2785 LoadNotes;
2786 with tvNotes do Selected := FindPieceNode(IntToStr(IEN), U, Items.GetFirstNode);
2787 end;
2788end;
2789
2790procedure TfrmNotes.popNoteMemoPopup(Sender: TObject);
[541]2791const FORMAT_MODE : array[false..true] of string = ('fNotes_Formatted_Text','fNotes_Plain_Text'); //kt 8/09
[453]2792begin
2793 inherited;
2794 if PopupComponent(Sender, popNoteMemo) is TCustomEdit
2795 then FEditCtrl := TCustomEdit(PopupComponent(Sender, popNoteMemo))
2796 else FEditCtrl := nil;
2797 if FEditCtrl <> nil then
2798 begin
2799 popNoteMemoCut.Enabled := FEditCtrl.SelLength > 0;
2800 popNoteMemoCopy.Enabled := popNoteMemoCut.Enabled;
2801 popNoteMemoPaste.Enabled := (not TORExposedCustomEdit(FEditCtrl).ReadOnly) and
2802 Clipboard.HasFormat(CF_TEXT);
2803 popNoteMemoTemplate.Enabled := frmDrawers.CanEditTemplates and popNoteMemoCut.Enabled;
2804 popNoteMemoFind.Enabled := FEditCtrl.GetTextLen > 0;
2805 end else
2806 begin
[541]2807 popNoteMemoHTMLFormat.Enabled := False; //kt 8/09
[453]2808 popNoteMemoCut.Enabled := False;
2809 popNoteMemoCopy.Enabled := False;
2810 popNoteMemoPaste.Enabled := False;
2811 popNoteMemoTemplate.Enabled := False;
2812 end;
[541]2813 popNoteMemoHTMLFormat.Caption := DKLangConstW('fNotes_Change_Edit_Mode_To') + ' ' + //kt 8/09
2814 DKLangConstW(FORMAT_MODE[(vmHTML in FViewMode)]); //kt 8/09
2815 popNoteMemoHTMLFormat.Enabled := pnlWrite.Visible; //kt 8/09
[453]2816 if pnlWrite.Visible then
2817 begin
[541]2818 //kt 8/09 popNoteMemoSpell.Enabled := True;
2819 //kt 8/09 popNoteMemoGrammar.Enabled := True;
2820 //kt 8/09 popNoteMemoReformat.Enabled := True;
2821 popNoteMemoSpell.Enabled := not pnlHTMLWrite.Visible; //kt 8/09
2822 popNoteMemoGrammar.Enabled := not pnlHTMLWrite.Visible; //kt 8/09
2823 popNoteMemoReformat.Enabled := not pnlHTMLWrite.Visible; //kt 8/09
[453]2824 popNoteMemoReplace.Enabled := (FEditCtrl.GetTextLen > 0);
2825 popNoteMemoPreview.Enabled := (frmDrawers.TheOpenDrawer = odTemplates) and Assigned(frmDrawers.tvTemplates.Selected);
2826 popNoteMemoInsTemplate.Enabled := (frmDrawers.TheOpenDrawer = odTemplates) and Assigned(frmDrawers.tvTemplates.Selected);
2827 end else
2828 begin
2829 popNoteMemoSpell.Enabled := False;
2830 popNoteMemoGrammar.Enabled := False;
2831 popNoteMemoReformat.Enabled := False;
2832 popNoteMemoReplace.Enabled := False;
2833 popNoteMemoPreview.Enabled := False;
2834 popNoteMemoInsTemplate.Enabled := False;
2835 end;
2836end;
2837
[541]2838(*//kt 8/09 NOTICE:
2839 On the form, popNoteMenu was edited to add a new item as below
2840 popNoteMemoHTMLFormat : TMenuItem
2841 Captions: ~ Edit as Formatted Text
2842 OnClick -- popNoteMemoHTMLFormatClick
2843*)
2844
2845procedure TfrmNotes.popNoteMemoHTMLFormatClick(Sender: TObject);
2846//kt added function 8/09
2847begin
2848 inherited;
2849 ToggleHTMLEditMode;
2850end;
2851
[453]2852procedure TfrmNotes.popNoteMemoCutClick(Sender: TObject);
2853begin
2854 inherited;
2855 FEditCtrl.CutToClipboard;
2856end;
2857
2858procedure TfrmNotes.popNoteMemoCopyClick(Sender: TObject);
2859begin
2860 inherited;
2861 FEditCtrl.CopyToClipboard;
2862end;
2863
2864procedure TfrmNotes.popNoteMemoPasteClick(Sender: TObject);
2865begin
2866 inherited;
2867 FEditCtrl.SelText := Clipboard.AsText; {*KCM*}
2868 frmNotes.pnlWriteResize(Self);
2869 //FEditCtrl.PasteFromClipboard; // use AsText to prevent formatting
2870end;
2871
2872procedure TfrmNotes.popNoteMemoReformatClick(Sender: TObject);
2873begin
2874 inherited;
2875 if Screen.ActiveControl <> memNewNote then Exit;
2876 ReformatMemoParagraph(memNewNote);
2877end;
2878
2879procedure TfrmNotes.popNoteMemoSaveContinueClick(Sender: TObject);
2880begin
2881 inherited;
2882 FChanged := True;
2883 DoAutoSave;
2884end;
2885
2886procedure TfrmNotes.popNoteMemoFindClick(Sender: TObject);
2887//var
2888 //hData: THandle; //CQ8300
2889 //pData: ^ClipboardData; //CQ8300
2890begin
2891 inherited;
2892 SendMessage(TRichEdit(popNoteMemo.PopupComponent).Handle, WM_VSCROLL, SB_TOP, 0);
2893 with dlgFindText do
2894 begin
2895 Position := Point(Application.MainForm.Left + pnlLeft.Width, Application.MainForm.Top);
2896 FindText := '';
2897 Options := [frDown, frHideUpDown];
2898{
2899 //CQ8300
2900 OpenClipboard(dlgFindText.Handle);
2901 hData := GetClipboardData(CF_TEXT);
2902 pData := GlobalLock(hData);
2903 FindText := pData^.Text;
2904 GlobalUnlock(hData);
2905 CloseClipboard;
2906 //end CQ8300
2907}
2908 Execute;
2909 end;
2910end;
2911
2912procedure TfrmNotes.dlgFindTextFind(Sender: TObject);
2913begin
2914 dmodShared.FindRichEditText(dlgFindText, TRichEdit(popNoteMemo.PopupComponent));
2915end;
2916
2917procedure TfrmNotes.popNoteMemoReplaceClick(Sender: TObject);
2918begin
2919 inherited;
2920 SendMessage(TRichEdit(popNoteMemo.PopupComponent).Handle, WM_VSCROLL, SB_TOP, 0);
2921 with dlgReplaceText do
2922 begin
2923 Position := Point(Application.MainForm.Left + pnlLeft.Width, Application.MainForm.Top);
2924 FindText := '';
2925 ReplaceText := '';
2926 Options := [frDown, frHideUpDown];
2927 Execute;
2928 end;
2929end;
2930
2931procedure TfrmNotes.dlgReplaceTextFind(Sender: TObject);
2932begin
2933 inherited;
2934 dmodShared.FindRichEditText(dlgFindText, TRichEdit(popNoteMemo.PopupComponent));
2935end;
2936
2937procedure TfrmNotes.dlgReplaceTextReplace(Sender: TObject);
2938begin
2939 inherited;
2940 dmodShared.ReplaceRichEditText(dlgReplaceText, TRichEdit(popNoteMemo.PopupComponent));
2941end;
2942
2943procedure TfrmNotes.popNoteMemoSpellClick(Sender: TObject);
2944begin
2945 inherited;
2946 DoAutoSave(0);
2947 timAutoSave.Enabled := False;
2948 try
2949 SpellCheckForControl(memNewNote);
2950 finally
2951 FChanged := True;
2952 DoAutoSave(0);
2953 timAutoSave.Enabled := True;
2954 end;
2955end;
2956
2957procedure TfrmNotes.popNoteMemoGrammarClick(Sender: TObject);
2958begin
2959 inherited;
2960 DoAutoSave(0);
2961 timAutoSave.Enabled := False;
2962 try
2963 GrammarCheckForControl(memNewNote);
2964 finally
2965 FChanged := True;
2966 DoAutoSave(0);
2967 timAutoSave.Enabled := True;
2968 end;
2969end;
2970
2971procedure TfrmNotes.mnuViewDetailClick(Sender: TObject);
2972begin
2973 inherited;
2974 if lstNotes.ItemIEN <= 0 then Exit;
2975 mnuViewDetail.Checked := not mnuViewDetail.Checked;
2976 if mnuViewDetail.Checked then
2977 begin
2978// StatusText('Retrieving progress note details...'); <-- original line. //kt 7/19/2007
2979 StatusText(DKLangConstW('fNotes_Retrieving_progress_note_detailsxxx')); //kt added 7/19/2007
2980 Screen.Cursor := crAppStart; //kt, was crHourGlass;
[541]2981 //kt LoadDetailText(memNote.Lines, lstNotes.ItemIEN);
2982 LoadDetailText(FViewNote, lstNotes.ItemIEN); //kt 8/09
2983 SetDisplayToHTMLvsText(FViewMode,FViewNote); //kt 8/09
[453]2984 Screen.Cursor := crDefault;
2985 StatusText('');
2986 memNote.SelStart := 0;
[541]2987 if not (vmHTML in FViewMode) then //kt 8/09
2988 memNote.Repaint;
[453]2989 end
2990 else
2991 lstNotesClick(Self);
[541]2992 if (vmHTML in FViewMode) then begin //kt 8/09
2993 SendMessage(HTMLViewer.Handle, WM_VSCROLL, SB_TOP, 0); //kt 8/09
2994 end else begin //kt 8/09
2995 SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
2996 end; //kt 8/09
[453]2997end;
2998
2999procedure TfrmNotes.FormClose(Sender: TObject; var Action: TCloseAction);
3000var
3001 Saved: Boolean;
3002 IEN: Int64;
3003 ErrMsg: string;
3004 DeleteSts: TActionRec;
3005begin
3006 inherited;
3007 if frmFrame.TimedOut and (EditingIndex <> -1) then
3008 begin
3009 FSilent := True;
[541]3010 //kt 8/09 if memNewNote.GetTextLen > 0 then SaveCurrentNote(Saved)
3011 if EditorHasText then SaveCurrentNote(Saved) //kt 8/09
[453]3012 else
3013 begin
3014 IEN := lstNotes.GetIEN(EditingIndex);
3015 if not LastSaveClean(IEN) then // means note hasn't been committed yet
3016 begin
3017 LockDocument(IEN, ErrMsg);
3018 if ErrMsg = '' then
3019 begin
3020 DeleteDocument(DeleteSts, IEN, '');
3021 UnlockDocument(IEN);
3022 end; {if ErrMsg}
3023 end; {if not LastSaveClean}
3024 end; {else}
3025 end; {if frmFrame}
3026end;
3027
3028procedure TfrmNotes.mnuActIdentifyAddlSignersClick(Sender: TObject);
3029var
3030 Exclusions: TStrings;
3031 Saved, x, y: boolean;
3032 SignerList: TSignerList;
3033 ActionSts: TActionRec;
3034 SigAction: integer;
3035 SavedDocID: string;
3036 ARefDate: TFMDateTime;
3037begin
3038 inherited;
3039 if lstNotes.ItemIEN = 0 then exit;
3040 SavedDocID := lstNotes.ItemID;
3041 if lstNotes.ItemIndex = EditingIndex then
3042 begin
3043 SaveCurrentNote(Saved);
3044 if not Saved then Exit;
3045 LoadNotes;
3046 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
3047 end;
3048 x := CanChangeCosigner(lstNotes.ItemIEN);
3049 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'IDENTIFY SIGNERS');
3050 y := ActionSts.Success;
3051 if x and not y then
3052 begin
3053 if InfoBox(ActionSts.Reason + CRLF + CRLF +
3054// 'Would you like to change the cosigner?', <-- original line. //kt 7/19/2007
3055 DKLangConstW('fNotes_Would_you_like_to_change_the_cosignerx'), //kt added 7/19/2007
3056 TX_IN_AUTH, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES then
3057 SigAction := SG_COSIGNER
3058 else
3059 Exit;
3060 end
3061 else if y and not x then SigAction := SG_ADDITIONAL
3062 else if x and y then SigAction := SG_BOTH
3063 else
3064 begin
3065 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
3066 Exit;
3067 end;
3068
3069 if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
3070 Exclusions := GetCurrentSigners(lstNotes.ItemIEN);
3071 ARefDate := StrToFloat(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
3072 SelectAdditionalSigners(Font.Size, lstNotes.ItemIEN, SigAction, Exclusions, SignerList, CT_NOTES, ARefDate);
3073 with SignerList do
3074 begin
3075 case SigAction of
3076 SG_ADDITIONAL: if Changed and (Signers <> nil) and (Signers.Count > 0) then
3077 UpdateAdditionalSigners(lstNotes.ItemIEN, Signers);
3078 SG_COSIGNER: if Changed then ChangeCosigner(lstNotes.ItemIEN, Cosigner);
3079 SG_BOTH: if Changed then
3080 begin
3081 if (Signers <> nil) and (Signers.Count > 0) then
3082 UpdateAdditionalSigners(lstNotes.ItemIEN, Signers);
3083 ChangeCosigner(lstNotes.ItemIEN, Cosigner);
3084 end;
3085 end;
3086 lstNotesClick(Self);
3087 end;
3088 UnlockDocument(lstNotes.ItemIEN);
3089 UnlockConsultRequest(lstNotes.ItemIEN);
3090end;
3091
3092procedure TfrmNotes.popNoteMemoAddlSignClick(Sender: TObject);
3093begin
3094 inherited;
3095 mnuActIdentifyAddlSignersClick(Self);
3096end;
3097
3098procedure TfrmNotes.ProcessNotifications;
3099var
3100 x: string;
3101 Saved: boolean;
3102 tmpNode: TTreeNode;
3103 AnObject: PDocTreeObject;
3104begin
3105 SetupVars; //kt added 7/19/2007 to replace constants with vars.
3106 if EditingIndex <> -1 then
3107 begin
3108 SaveCurrentNote(Saved);
3109 if not Saved then Exit;
3110 end;
3111 lblNotes.Caption := Notifications.Text;
3112 tvNotes.Caption := Notifications.Text;
3113 EditingIndex := -1;
3114 lstNotes.Enabled := True ;
3115 pnlRead.BringToFront ;
3116 // show ALL unsigned/uncosigned for a patient, not just the alerted one
3117 // what about cosignature? How to get correct list? ORB FOLLOWUP TYPE = OR alerts only
3118 x := Notifications.AlertData;
3119 if StrToIntDef(Piece(x, U, 1), 0) = 0 then
3120 begin
3121 InfoBox(TX_NO_ALERT, TX_CAP_NO_ALERT, MB_OK);
3122 Exit;
3123 end;
3124 uChanging := True;
3125 tvNotes.Items.BeginUpdate;
3126 lstNotes.Clear;
3127 KillDocTreeObjects(tvNotes);
3128 tvNotes.Items.Clear;
3129 lstNotes.Items.Add(x);
3130 AnObject := MakeNoteTreeObject('ALERT^Alerted Note^^^^^^^^^^^%^0');
3131 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, AnObject.NodeText, AnObject);
3132 TORTreeNode(tmpNode).StringData := 'ALERT^Alerted Note^^^^^^^^^^^%^0';
3133 tmpNode.ImageIndex := IMG_TOP_LEVEL;
3134 AnObject := MakeNoteTreeObject(x);
3135 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, AnObject.NodeText, AnObject);
3136 TORTreeNode(tmpNode).StringData := x;
3137 SetTreeNodeImagesAndFormatting(TORTreeNode(tmpNode), FCurrentContext, CT_NOTES);
3138 tvNotes.Selected := tmpNode;
3139 tvNotes.Items.EndUpdate;
3140 uChanging := False;
3141 tvNotesChange(Self, tvNotes.Selected);
3142 case Notifications.Followup of
3143 NF_NOTES_UNSIGNED_NOTE: ; //Automatically deleted by sig action!!!
3144 end;
3145 if Copy(Piece(Notifications.RecordID, U, 2), 1, 6) = 'TIUADD' then Notifications.Delete;
3146 if Copy(Piece(Notifications.RecordID, U, 2), 1, 5) = 'TIUID' then Notifications.Delete;
3147end;
3148
3149procedure TfrmNotes.SetViewContext(AContext: TTIUContext);
3150var
3151 Saved: boolean;
3152begin
3153 if EditingIndex <> -1 then
3154 begin
3155 SaveCurrentNote(Saved);
3156 if not Saved then Exit;
3157 end;
3158 FCurrentContext := AContext;
3159 EditingIndex := -1;
3160 tvNotes.Enabled := True ;
3161 pnlRead.BringToFront ;
3162 if FCurrentContext.Status <> '' then with uTIUContext do
3163 begin
3164 BeginDate := FCurrentContext.BeginDate;
3165 EndDate := FCurrentContext.EndDate;
3166 FMBeginDate := FCurrentContext.FMBeginDate;
3167 FMEndDate := FCurrentContext.FMEndDate;
3168 Status := FCurrentContext.Status;
3169 Author := FCurrentContext.Author;
3170 MaxDocs := FCurrentContext.MaxDocs;
3171 ShowSubject := FCurrentContext.ShowSubject;
3172 GroupBy := FCurrentContext.GroupBy;
3173 SortBy := FCurrentContext.SortBy;
3174 ListAscending := FCurrentContext.ListAscending;
3175 TreeAscending := FCurrentContext.TreeAscending;
3176 Keyword := FCurrentContext.Keyword;
3177 SearchField := FCurrentContext.SearchField;
3178 Filtered := FCurrentContext.Filtered;
3179 Changed := True;
3180 mnuViewClick(Self);
3181 end
3182 else
3183 begin
3184 ViewContext := NC_RECENT ;
3185 mnuViewClick(Self);
3186 end;
3187end;
3188
3189procedure TfrmNotes.mnuViewSaveAsDefaultClick(Sender: TObject);
3190//const
3191//TX_NO_MAX = 'You have not specified a maximum number of notes to be returned.' + CRLF + <-- original line. //kt 7/19/2007
3192// 'If you save this preference, the result will be that ALL notes for every' + CRLF + <-- original line. //kt 7/19/2007
3193// 'patient will be saved as your default view.' + CRLF + CRLF + <-- original line. //kt 7/19/2007
3194// 'For patients with large numbers of notes, this could result in some lengthy' + CRLF + <-- original line. //kt 7/19/2007
3195// 'delays in loading the list of notes.' + CRLF + CRLF + <-- original line. //kt 7/19/2007
3196// 'Are you sure you mean to do this?'; <-- original line. //kt 7/19/2007
3197//TX_REPLACE = 'Replace current defaults?'; <-- original line. //kt 7/19/2007
3198var
3199 TX_NO_MAX : string; //kt
3200 TX_REPLACE : string; //kt
3201
3202begin
3203 inherited;
3204 TX_NO_MAX := DKLangConstW('fNotes_You_have_not_specified_a_maximum_number_of_notes_to_be_returnedx') + CRLF + //kt added 7/19/2007
3205 DKLangConstW('fNotes_If_you_save_this_preferencex_the_result_will_be_that_ALL_notes_for_every') + CRLF + //kt added 7/19/2007
3206 DKLangConstW('fNotes_patient_will_be_saved_as_your_default_viewx') + CRLF + CRLF + //kt added 7/19/2007
3207 DKLangConstW('fNotes_For_patients_with_large_numbers_of_notesx_this_could_result_in_some_lengthy') + CRLF + //kt added 7/19/2007
3208 DKLangConstW('fNotes_delays_in_loading_the_list_of_notesx') + CRLF + CRLF + //kt added 7/19/2007
3209 DKLangConstW('fNotes_Are_you_sure_you_mean_to_do_thisx'); //kt added 7/19/2007
3210 TX_REPLACE := DKLangConstW('fNotes_Replace_current_defaultsx'); //kt added 7/19/2007
3211 if FCurrentContext.MaxDocs = 0 then
3212 if InfoBox(TX_NO_MAX,'Warning', MB_YESNO or MB_ICONWARNING) = IDNO then
3213 begin
3214 mnuViewClick(mnuViewCustom);
3215 Exit;
3216 end;
3217 if InfoBox(TX_REPLACE,'Confirmation', MB_YESNO or MB_ICONQUESTION) = IDYES then
3218 begin
3219 SaveCurrentTIUContext(FCurrentContext);
3220 FDefaultContext := FCurrentContext;
3221 //lblNotes.Caption := 'Default List';
3222 end;
3223end;
3224
3225procedure TfrmNotes.mnuViewReturntoDefaultClick(Sender: TObject);
3226begin
3227 inherited;
3228 SetViewContext(FDefaultContext);
3229end;
3230
3231procedure TfrmNotes.popNoteMemoTemplateClick(Sender: TObject);
3232begin
3233 inherited;
3234 EditTemplates(Self, TRUE, FEditCtrl.SelText);
3235end;
3236
3237procedure TfrmNotes.popNoteListPopup(Sender: TObject);
3238begin
3239 inherited;
3240 N4.Visible := (popNoteList.PopupComponent is TORTreeView);
3241 popNoteListExpandAll.Visible := N4.Visible;
3242 popNoteListExpandSelected.Visible := N4.Visible;
3243 popNoteListCollapseAll.Visible := N4.Visible;
3244 popNoteListCollapseSelected.Visible := N4.Visible;
3245end;
3246
3247procedure TfrmNotes.popNoteListExpandAllClick(Sender: TObject);
3248begin
3249 inherited;
3250 tvNotes.FullExpand;
3251end;
3252
3253procedure TfrmNotes.popNoteListCollapseAllClick(Sender: TObject);
3254begin
3255 inherited;
3256 tvNotes.Selected := nil;
3257 lvNotes.Items.Clear;
3258 memNote.Clear;
[541]3259 HTMLViewer.Clear; //kt 8/09
[453]3260 tvNotes.FullCollapse;
3261 tvNotes.Selected := tvNotes.TopItem;
3262end;
3263
3264procedure TfrmNotes.popNoteListExpandSelectedClick(Sender: TObject);
3265begin
3266 inherited;
3267 if tvNotes.Selected = nil then exit;
3268 with tvNotes.Selected do if HasChildren then Expand(True);
3269end;
3270
3271procedure TfrmNotes.popNoteListCollapseSelectedClick(Sender: TObject);
3272begin
3273 inherited;
3274 if tvNotes.Selected = nil then exit;
3275 with tvNotes.Selected do if HasChildren then Collapse(True);
3276end;
3277
3278procedure TfrmNotes.mnuEditTemplatesClick(Sender: TObject);
3279begin
3280 inherited;
3281 EditTemplates(Self);
3282end;
3283
3284procedure TfrmNotes.mnuNewTemplateClick(Sender: TObject);
3285begin
3286 inherited;
3287 EditTemplates(Self, TRUE);
3288end;
3289
3290procedure TfrmNotes.mnuEditSharedTemplatesClick(Sender: TObject);
3291begin
3292 inherited;
3293 EditTemplates(Self, FALSE, '', TRUE);
3294end;
3295
3296procedure TfrmNotes.mnuNewSharedTemplateClick(Sender: TObject);
3297begin
3298 inherited;
3299 EditTemplates(Self, TRUE, '', TRUE);
3300end;
3301
3302procedure TfrmNotes.mnuOptionsClick(Sender: TObject);
3303begin
3304 inherited;
3305 mnuEditTemplates.Enabled := frmDrawers.CanEditTemplates;
3306 mnuNewTemplate.Enabled := frmDrawers.CanEditTemplates;
3307 mnuEditSharedTemplates.Enabled := frmDrawers.CanEditShared;
3308 mnuNewSharedTemplate.Enabled := frmDrawers.CanEditShared;
3309 mnuEditDialgFields.Enabled := CanEditTemplateFields;
3310end;
3311
3312procedure TfrmNotes.SetEditingIndex(const Value: Integer);
3313begin
3314 FEditingIndex := Value;
3315 if(FEditingIndex < 0) then
3316 KillReminderDialog(Self);
3317 if(assigned(frmReminderTree)) then
3318 frmReminderTree.EnableActions;
3319end;
3320
3321function TfrmNotes.CanFinishReminder: boolean;
3322begin
3323 if(EditingIndex < 0) then
3324 Result := FALSE
3325 else
3326 Result := (lstNotes.ItemIndex = EditingIndex);
3327end;
3328
3329procedure TfrmNotes.FormDestroy(Sender: TObject);
3330begin
3331 //kt note: The Images tab will delete all files in .\Cache, which
3332 // might include HTMLfilename. No harm if already deleted.
[541]3333 //kt 8/09 DeleteFile(HTMLfilename); //kt added 5-2-05
[453]3334 TAccessibleTreeView.UnwrapControl(tvNotes);
3335 FDocList.Free;
3336 FImageFlag.Free;
3337 KillDocTreeObjects(tvNotes);
[541]3338 HtmlEditor.Free; //kt 6/7/09
3339 HtmlViewer.Free; //kt 6/7/09
[453]3340 inherited;
3341end;
3342
3343function TfrmNotes.GetDrawers: TFrmDrawers;
3344begin
3345 Result := frmDrawers;
3346end;
3347
3348procedure TfrmNotes.AssignRemForm;
3349begin
[541]3350 //kt 8/09 ReminderDialog interaction has not yet been debugged with HTML formatted text.
[453]3351 with RemForm do
3352 begin
3353 Form := Self;
3354 PCEObj := uPCEEdit;
3355 RightPanel := pnlRight;
3356 CanFinishProc := CanFinishReminder;
3357 DisplayPCEProc := DisplayPCE;
3358 Drawers := frmDrawers;
3359 NewNoteRE := memNewNote;
[541]3360 NewNoteHTMLE := HTMLEditor; //kt
[453]3361 NoteList := lstNotes;
3362 end;
3363end;
3364
3365procedure TfrmNotes.mnuEditDialgFieldsClick(Sender: TObject);
3366begin
3367 inherited;
3368 EditDialogFields;
3369end;
3370
3371//=================== Added for sort/search enhancements ======================
3372procedure TfrmNotes.LoadNotes;
3373const
3374 INVALID_ID = -1;
3375 INFO_ID = 1;
3376var
3377 tmpList: TStringList;
3378 ANode: TORTreeNode;
3379 x,xx,noteId: integer; // Text Search CQ: HDS00002856
3380 Dest: TStrings; // Text Search CQ: HDS00002856
3381 KeepFlag: Boolean; // Text Search CQ: HDS00002856
3382 NoteCount, NoteMatches: integer; // Text Search CQ: HDS00002856
3383begin
3384 tmpList := TStringList.Create;
3385 try
3386 FDocList.Clear;
3387 uChanging := True;
3388 RedrawSuspend(memNote.Handle);
[541]3389 RedrawSuspend(HTMLViewer.Handle); //kt 8/09
[453]3390 RedrawSuspend(lvNotes.Handle);
3391 tvNotes.Items.BeginUpdate;
3392 lstNotes.Items.Clear;
3393 KillDocTreeObjects(tvNotes);
3394 tvNotes.Items.Clear;
3395 tvNotes.Items.EndUpdate;
3396 lvNotes.Items.Clear;
3397 memNote.Clear;
[541]3398 HTMLViewer.Clear; //kt 8/09
[453]3399 memNote.Invalidate;
3400 lblTitle.Caption := '';
3401 lvNotes.Caption := '';
3402 with FCurrentContext do
3403 begin
3404 if Status <> IntToStr(NC_UNSIGNED) then
3405 begin
3406 ListNotesForTree(tmpList, NC_UNSIGNED, 0, 0, 0, 0, TreeAscending);
3407 if tmpList.Count > 0 then
3408 begin
3409 CreateListItemsforDocumentTree(FDocList, tmpList, NC_UNSIGNED, GroupBy, TreeAscending, CT_NOTES);
3410 UpdateTreeView(FDocList, tvNotes);
3411 end;
3412 tmpList.Clear;
3413 FDocList.Clear;
3414 end;
3415 if Status <> IntToStr(NC_UNCOSIGNED) then
3416 begin
3417 ListNotesForTree(tmpList, NC_UNCOSIGNED, 0, 0, 0, 0, TreeAscending);
3418 if tmpList.Count > 0 then
3419 begin
3420 CreateListItemsforDocumentTree(FDocList, tmpList, NC_UNCOSIGNED, GroupBy, TreeAscending, CT_NOTES);
3421 UpdateTreeView(FDocList, tvNotes);
3422 end;
3423 tmpList.Clear;
3424 FDocList.Clear;
3425 end;
3426 ListNotesForTree(tmpList, StrToIntDef(Status, 0), FMBeginDate, FMEndDate, Author, MaxDocs, TreeAscending);
3427 CreateListItemsforDocumentTree(FDocList, tmpList, StrToIntDef(Status, 0), GroupBy, TreeAscending, CT_NOTES);
3428
3429 // Text Search CQ: HDS00002856 ---------------------------------------
3430 if FCurrentContext.SearchString<>'' then // Text Search CQ: HDS00002856
3431 begin
3432 NoteMatches := 0;
3433 Dest:=TStringList.Create;
3434 NoteCount:=FDocList.Count-1;
3435 if FDocList.Count>0 then
3436 for x := FDocList.Count-1 downto 1 do begin; // Don't do 0, because it's informational
3437 KeepFlag:=False;
3438// lblNotes.Caption:='Scanning '+IntToStr(NoteCount-x+1)+' of '+IntToStr(NoteCount)+', '+IntToStr(NoteMatches); <-- original line. //kt 7/19/2007
3439 lblNotes.Caption:=DKLangConstW('fNotes_Scanning')+' '+IntToStr(NoteCount-x+1)+DKLangConstW('fNotes_of')+IntToStr(NoteCount)+', '+IntToStr(NoteMatches); //kt added 7/19/2007
3440 If NoteMatches=1 then lblNotes.Caption:=lblNotes.Caption+' match' else
3441 lblNotes.Caption:=lblNotes.Caption+' matches';
3442 frmSearchStop.lblSearchStatus.Caption := lblNotes.Caption;
3443 frmSearchStop.lblSearchStatus.Repaint;
3444 lblNotes.Repaint;
3445 // Free up some ticks so they can click the "Stop" button
3446 application.processmessages;
3447 application.processmessages;
3448 application.processmessages;
3449 If SearchTextStopFlag = False then begin
3450 noteId := StrToIntDef(Piece(FDocList.Strings[x],'^',1),-1);
3451 if (noteId = INVALID_ID) or (noteId = INFO_ID) then
3452 Continue;
3453 CallV('TIU GET RECORD TEXT', [Piece(FDocList.Strings[x],'^',1)]);
3454 Dest.Assign(RPCBrokerV.Results);
3455 If Dest.Count > 0 then
3456 for xx := 0 to Dest.Count-1 do
3457 begin
3458 //Dest.Strings[xx] := StringReplace(Dest.Strings[xx],'#13',' ',[rfReplaceAll, rfIgnoreCase]);
3459 if Pos(Uppercase(FCurrentContext.SearchString),Uppercase(Dest.Strings[xx]))>0 then
3460 keepflag:=true;
3461 end;
3462 If KeepFlag=False then begin;
3463 if FDocList.Count >= x then
3464 FDocList.Delete(x);
3465 if (tmpList.Count >= x) and (x > 0) then
3466 tmpList.Delete(x-1);
3467 end else
3468 Inc(NoteMatches);
3469 end;
3470 end;
3471 Dest.Free;
3472 end;
3473 // Text Search CQ: HDS00002856 ---------------------------------------
3474
3475 UpdateTreeView(FDocList, tvNotes);
3476 end;
3477 with tvNotes do
3478 begin
3479 uChanging := True;
3480 tvNotes.Items.BeginUpdate;
3481 RemoveParentsWithNoChildren(tvNotes, FCurrentContext); // moved here in v15.9 (RV)
3482 if FLastNoteID <> '' then
3483 Selected := FindPieceNode(FLastNoteID, 1, U, nil);
3484 if Selected = nil then
3485 begin
3486 if (FCurrentContext.GroupBy <> '') or (FCurrentContext.Filtered) then
3487 begin
3488 ANode := TORTreeNode(Items.GetFirstNode);
3489 while ANode <> nil do
3490 begin
3491 ANode.Expand(False);
3492 Selected := ANode;
3493 ANode := TORTreeNode(ANode.GetNextSibling);
3494 end;
3495 end
3496 else
3497 begin
3498 ANode := tvNotes.FindPieceNode(FCurrentContext.Status, 1, U, nil);
3499 if ANode <> nil then ANode.Expand(False);
3500 ANode := tvNotes.FindPieceNode(IntToStr(NC_UNSIGNED), 1, U, nil);
3501 if ANode = nil then
3502 ANode := tvNotes.FindPieceNode(IntToStr(NC_UNCOSIGNED), 1, U, nil);
3503 if ANode = nil then
3504 ANode := tvNotes.FindPieceNode(FCurrentContext.Status, 1, U, nil);
3505 if ANode <> nil then
3506 begin
3507 if ANode.getFirstChild <> nil then
3508 Selected := ANode.getFirstChild
3509 else
3510 Selected := ANode;
3511 end;
3512 end;
3513 end;
3514 memNote.Clear;
[541]3515 HTMLViewer.Clear; //kt 8/09
[453]3516 with lvNotes do
3517 begin
3518 Selected := nil;
3519 if FCurrentContext.SortBy <> '' then
3520 ColumnToSort := Pos(FCurrentContext.SortBy, 'RDSAL') - 1;
3521 if not FCurrentContext.ShowSubject then
3522 begin
3523 Columns[1].Width := 2 * (Width div 5);
3524 Columns[2].Width := 0;
3525 end
3526 else
3527 begin
3528 Columns[1].Width := Width div 5;
3529 Columns[2].Width := Columns[1].Width;
3530 end;
3531 end;
3532 //RemoveParentsWithNoChildren(tvNotes, FCurrentContext); // moved FROM here in v15.9 (RV)
3533 tvNotes.Items.EndUpdate;
3534 uChanging := False;
3535 SendMessage(tvNotes.Handle, WM_VSCROLL, SB_TOP, 0);
3536 if Selected <> nil then tvNotesChange(Self, Selected);
3537 end;
3538 finally
[541]3539 //kt NOTE: Is this enough??
3540 if (vmHTML in FViewMode) then begin //kt 8/09
3541 RedrawActivate(HtmlViewer.Handle); //kt 8/09
3542 end else begin //kt 8/09
3543 RedrawActivate(memNote.Handle);
3544 end; //kt 8/09
[453]3545 RedrawActivate(lvNotes.Handle);
3546 tmpList.Free;
3547 end;
3548end;
3549
3550procedure TfrmNotes.UpdateTreeView(DocList: TStringList; Tree: TORTreeView);
3551begin
3552 with Tree do
3553 begin
3554 uChanging := True;
3555 Items.BeginUpdate;
3556 lstNotes.Items.AddStrings(DocList);
3557 BuildDocumentTree(DocList, '0', Tree, nil, FCurrentContext, CT_NOTES);
3558 Items.EndUpdate;
3559 uChanging := False;
3560 end;
3561end;
3562
3563procedure TfrmNotes.tvNotesChange(Sender: TObject; Node: TTreeNode);
3564var
3565 x, MySearch, MyNodeID: string;
3566 i: integer;
3567 WhyNot: string;
[541]3568 Mode : TViewModeSet; //kt 8/09
[453]3569begin
3570 if uChanging then Exit;
3571 //This gives the change a chance to occur when keyboarding, so that WindowEyes
3572 //doesn't use the old value.
3573 Application.ProcessMessages;
3574 with tvNotes do
3575 begin
3576 memNote.Clear;
[541]3577 HTMLViewer.Clear; //kt 8/09
[453]3578 if Selected = nil then Exit;
3579 if uIDNotesActive then
3580 begin
3581 mnuActDetachFromIDParent.Enabled := (Selected.ImageIndex in [IMG_ID_CHILD, IMG_ID_CHILD_ADD]);
3582 popNoteListDetachFromIDParent.Enabled := mnuActDetachFromIDParent.Enabled;
3583 if (Selected.ImageIndex in [IMG_SINGLE, IMG_PARENT, IMG_ID_CHILD, IMG_ID_CHILD_ADD]) then
3584 mnuActAttachtoIDParent.Enabled := CanBeAttached(PDocTreeObject(Selected.Data)^.DocID, WhyNot)
3585 else
3586 mnuActAttachtoIDParent.Enabled := False;
3587 popNoteListAttachtoIDParent.Enabled := mnuActAttachtoIDParent.Enabled;
3588 if (Selected.ImageIndex in [IMG_SINGLE, IMG_PARENT,
3589 IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT,
3590 IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT]) then
3591 mnuActAddIDEntry.Enabled := CanReceiveAttachment(PDocTreeObject(Selected.Data)^.DocID, WhyNot)
3592 else
3593 mnuActAddIDEntry.Enabled := False;
3594 popNoteListAddIDEntry.Enabled := mnuActAddIDEntry.Enabled
3595 end;
3596 RedrawSuspend(lvNotes.Handle);
3597 RedrawSuspend(memNote.Handle);
[541]3598 RedrawSuspend(HTMLViewer.Handle); //kt 8/09
[453]3599 popNoteListExpandSelected.Enabled := Selected.HasChildren;
3600 popNoteListCollapseSelected.Enabled := Selected.HasChildren;
3601 x := TORTreeNode(Selected).StringData;
3602 if (Selected.ImageIndex in [IMG_TOP_LEVEL, IMG_GROUP_OPEN, IMG_GROUP_SHUT]) then
3603 begin
3604 lvNotes.Visible := True;
3605 lvNotes.Items.Clear;
3606 lvNotes.Height := (2 * lvNotes.Parent.Height) div 5;
3607 with lblTitle do
3608 begin
3609 Caption := Trim(Selected.Text);
3610 if (FCurrentContext.SearchField <> '') and (FCurrentContext.Filtered) then
3611 begin
3612 case FCurrentContext.SearchField[1] of
3613 'T': MySearch := 'TITLE';
3614 'S': MySearch := 'SUBJECT';
3615 'B': MySearch := 'TITLE or SUBJECT';
3616 end;
3617// Caption := Caption + ' where ' + MySearch + ' contains "' + UpperCase(FCurrentContext.Keyword) + '"'; <-- original line. //kt 7/19/2007
3618 Caption := Caption + DKLangConstW('fNotes_where') + MySearch + DKLangConstW('fNotes_contains_x') + UpperCase(FCurrentContext.Keyword) + '"'; //kt added 7/19/2007
3619 end;
3620 lvNotes.Caption := Caption;
3621 end;
3622
3623 if Selected.ImageIndex = IMG_TOP_LEVEL then
3624 MyNodeID := Piece(TORTreeNode(Selected).StringData, U, 1)
3625 else if Selected.Parent.ImageIndex = IMG_TOP_LEVEL then
3626 MyNodeID := Piece(TORTreeNode(Selected.Parent).StringData, U, 1)
3627 else if Selected.Parent.Parent.ImageIndex = IMG_TOP_LEVEL then
3628 MyNodeID := Piece(TORTreeNode(Selected.Parent.Parent).StringData, U, 1);
3629
3630 uChanging := True;
3631 TraverseTree(tvNotes, lvNotes, Selected.GetFirstChild, MyNodeID, FCurrentContext);
3632 with lvNotes do
3633 begin
3634 for i := 0 to Columns.Count - 1 do
3635 Columns[i].ImageIndex := IMG_NONE;
3636 ColumnSortForward := FCurrentContext.ListAscending;
3637 if ColumnToSort = 5 then ColumnToSort := 0;
3638 if ColumnSortForward then
3639 Columns[ColumnToSort].ImageIndex := IMG_ASCENDING
3640 else
3641 Columns[ColumnToSort].ImageIndex := IMG_DESCENDING;
3642 if ColumnToSort = 0 then ColumnToSort := 5;
3643 AlphaSort;
3644 Columns[5].Width := 0;
3645 Columns[6].Width := 0;
3646 end;
3647 uChanging := False;
3648 with lvNotes do
3649 if Items.Count > 0 then
3650 begin
3651 Selected := Items[0];
3652 lvNotesSelectItem(Self, Selected, True);
3653 end
3654 else
3655 begin
3656 Selected := nil;
3657 lstNotes.ItemIndex := -1;
3658 memPCEShow.Clear;
3659 ShowPCEControls(False);
3660 end;
[541]3661 //kt 8/09
3662 //kt NOTE: At this point the list has changed. But what is the new note-to-view's format?
3663 // We can't just use FViewMode. Because that just states what mode was used on the last note.
3664 Mode := [vmView] + [vmHTML_MODE[vmHTML in FViewMode]]; //kt 8/09
3665 SetDisplayToHTMLvsText(Mode,nil,VIEW_ACTIVATE_ONLY); //kt 8/09
3666 //kt 8/09 pnlWrite.Visible := False;
3667 //kt 8/09 pnlRead.Visible := True;
[453]3668 // uncommented next 4 lines in v17.5 (RV)
3669 //-----------------------------
3670 UpdateReminderFinish;
3671 ShowPCEControls(False);
3672 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]); //FALSE);
3673 ShowPCEButtons(FALSE);
3674 //-----------------------------
3675 //memNote.Clear;
3676 end
3677 else if StrToIntDef(Piece(x, U, 1), 0) > 0 then
3678 begin
3679 memNote.Clear;
[541]3680 HTMLViewer.Clear; //kt 8/09
[453]3681 lvNotes.Visible := False;
3682 lstNotes.SelectByID(Piece(x, U, 1));
3683 lstNotesClick(Self);
[541]3684 if (vmHTML in FViewMode) then begin //kt 8/09
3685 SendMessage(HTMLViewer.Handle, WM_VSCROLL, SB_TOP, 0); //kt 8/09
3686 end else begin //kt 8/09
3687 SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
3688 end; //kt 8/09
[453]3689 end;
3690 SendMessage(tvNotes.Handle, WM_HSCROLL, SB_THUMBTRACK, 0);
3691 RedrawActivate(lvNotes.Handle);
[541]3692 if (vmHTML in FViewMode) then begin //kt 8/09
3693 RedrawActivate(HtmlViewer.Handle); //kt 8/09
3694 end else begin //kt 8/09
3695 RedrawActivate(memNote.Handle);
3696 end; //kt 8/09
[453]3697 end;
3698end;
3699
3700procedure TfrmNotes.tvNotesCollapsed(Sender: TObject; Node: TTreeNode);
3701begin
3702 with Node do
3703 begin
3704 if (ImageIndex in [IMG_GROUP_OPEN, IMG_IDNOTE_OPEN, IMG_IDPAR_ADDENDA_OPEN]) then
3705 ImageIndex := ImageIndex - 1;
3706 if (SelectedIndex in [IMG_GROUP_OPEN, IMG_IDNOTE_OPEN, IMG_IDPAR_ADDENDA_OPEN]) then
3707 SelectedIndex := SelectedIndex - 1;
3708 end;
3709end;
3710
3711procedure TfrmNotes.tvNotesExpanded(Sender: TObject; Node: TTreeNode);
3712
3713 function SortByTitle(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall;
3714 begin
3715 { Within an ID parent node, sorts in ascending order by title
3716 BUT - addenda to parent document are always at the top of the sort, in date order}
3717 if (Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum') and
3718 (Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum') then
3719 begin
3720 Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
3721 PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
3722 end
3723 else if Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := -1
3724 else if Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := 1
3725 else
3726 begin
3727 if Data = 0 then
3728 Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocTitle),
3729 PChar(PDocTreeObject(Node2.Data)^.DocTitle))
3730 else
3731 Result := -AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocTitle),
3732 PChar(PDocTreeObject(Node2.Data)^.DocTitle));
3733 end
3734 end;
3735
3736 function SortByDate(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall;
3737 begin
3738 { Within an ID parent node, sorts in ascending order by document date
3739 BUT - addenda to parent document are always at the top of the sort, in date order}
3740 if (Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum') and
3741 (Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum') then
3742 begin
3743 Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
3744 PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
3745 end
3746 else if Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := -1
3747 else if Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := 1
3748 else
3749 begin
3750 if Data = 0 then
3751 Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
3752 PChar(PDocTreeObject(Node2.Data)^.DocFMDate))
3753 else
3754 Result := -AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
3755 PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
3756 end;
3757 end;
3758
3759begin
3760 with Node do
3761 begin
3762 if Assigned(Data) then
3763 if (Pos('<', PDocTreeObject(Data)^.DocHasChildren) > 0) then
3764 begin
3765 if (PDocTreeObject(Node.Data)^.OrderByTitle) then
3766 CustomSort(@SortByTitle, 0)
3767 else
3768 CustomSort(@SortByDate, 0);
3769 end;
3770 if (ImageIndex in [IMG_GROUP_SHUT, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_SHUT]) then
3771 ImageIndex := ImageIndex + 1;
3772 if (SelectedIndex in [IMG_GROUP_SHUT, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_SHUT]) then
3773 SelectedIndex := SelectedIndex + 1;
3774 end;
3775end;
3776
3777procedure TfrmNotes.tvNotesClick(Sender: TObject);
3778begin
3779(* if tvNotes.Selected = nil then exit;
3780 if (tvNotes.Selected.ImageIndex in [IMG_TOP_LEVEL, IMG_GROUP_OPEN, IMG_GROUP_SHUT]) then
3781 begin
3782 uChanging := True;
3783 lvNotes.Selected := nil;
3784 uChanging := False;
3785 memNote.Clear;
3786 end;*)
3787end;
3788
3789procedure TfrmNotes.tvNotesDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
3790var
3791 AnItem: TORTreeNode;
3792begin
3793 Accept := False;
3794 if not uIDNotesActive then exit;
3795 AnItem := TORTreeNode(tvNotes.GetNodeAt(X, Y));
3796 if (AnItem = nil) or (AnItem.ImageIndex in [IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) then Exit;
3797 with tvNotes.Selected do
3798 if (ImageIndex in [IMG_SINGLE, IMG_PARENT, IMG_ID_CHILD, IMG_ID_CHILD_ADD]) then
3799 Accept := (AnItem.ImageIndex in [IMG_SINGLE, IMG_PARENT,
3800 IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT,
3801 IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT])
3802 else if (ImageIndex in [IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT]) then
3803 Accept := (AnItem.ImageIndex in [IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL])
3804 else if (ImageIndex in [IMG_ADDENDUM, IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) then
3805 Accept := False;
3806end;
3807
3808procedure TfrmNotes.tvNotesDragDrop(Sender, Source: TObject; X, Y: Integer);
3809var
3810 HT: THitTests;
3811 Saved: boolean;
3812 ADestNode: TORTreeNode;
3813begin
3814 if not uIDNotesActive then
3815 begin
3816 CancelDrag;
3817 exit;
3818 end;
3819 if tvNotes.Selected = nil then exit;
3820 if EditingIndex <> -1 then
3821 begin
3822 SaveCurrentNote(Saved);
3823 if not Saved then Exit;
3824 end;
3825 HT := tvNotes.GetHitTestInfoAt(X, Y);
3826 ADestNode := TORTreeNode(tvNotes.GetNodeAt(X, Y));
3827 DoAttachIDChild(TORTreeNode(tvNotes.Selected), ADestNode);
3828end;
3829
3830procedure TfrmNotes.tvNotesStartDrag(Sender: TObject; var DragObject: TDragObject);
3831//const
3832//TX_CAP_NO_DRAG = 'Item cannot be moved'; <-- original line. //kt 7/19/2007
3833//TX_NO_EDIT_DRAG = 'Items can not be dragged while a note is being edited.'; <-- original line. //kt 7/19/2007
3834var
3835 WhyNot: string;
3836 //Saved: boolean;
3837 TX_CAP_NO_DRAG : string; //kt
3838 TX_NO_EDIT_DRAG : string; //kt
3839begin
3840 TX_CAP_NO_DRAG := DKLangConstW('fNotes_Item_cannot_be_moved'); //kt added 7/19/2007
3841 TX_NO_EDIT_DRAG := DKLangConstW('fNotes_Items_can_not_be_dragged_while_a_note_is_being_editedx'); //kt added 7/19/2007
3842 if EditingIndex <> -1 then
3843 begin
3844 InfoBox(TX_NO_EDIT_DRAG, TX_CAP_NO_DRAG, MB_ICONERROR or MB_OK);
3845 CancelDrag;
3846 Exit;
3847 end;
3848 if (tvNotes.Selected.ImageIndex in [IMG_ADDENDUM, IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) or
3849 (not uIDNotesActive) or
3850 (lstNotes.ItemIEN = 0) then
3851 begin
3852 CancelDrag;
3853 Exit;
3854 end;
3855(* if EditingIndex <> -1 then
3856 begin
3857 SaveCurrentNote(Saved);
3858 if not Saved then Exit;
3859 end;*)
3860 if not CanBeAttached(PDocTreeObject(tvNotes.Selected.Data)^.DocID, WhyNot) then
3861 begin
3862 InfoBox(WhyNot, TX_CAP_NO_DRAG, MB_OK);
3863 CancelDrag;
3864 end;
3865end;
3866
3867//===================== Listview events =================================
3868
3869procedure TfrmNotes.lvNotesColumnClick(Sender: TObject; Column: TListColumn);
3870var
3871 i, ClickedColumn: Integer;
3872begin
3873 if Column.Index = 0 then ClickedColumn := 5 else ClickedColumn := Column.Index;
3874 if ClickedColumn = ColumnToSort then
3875 ColumnSortForward := not ColumnSortForward
3876 else
3877 ColumnSortForward := True;
3878 for i := 0 to lvNotes.Columns.Count - 1 do
3879 lvNotes.Columns[i].ImageIndex := IMG_NONE;
3880 if ColumnSortForward then lvNotes.Columns[Column.Index].ImageIndex := IMG_ASCENDING
3881 else lvNotes.Columns[Column.Index].ImageIndex := IMG_DESCENDING;
3882 ColumnToSort := ClickedColumn;
3883 case ColumnToSort of
3884 5: FCurrentContext.SortBy := 'R';
3885 1: FCurrentContext.SortBy := 'D';
3886 2: FCurrentContext.SortBy := 'S';
3887 3: FCurrentContext.SortBy := 'A';
3888 4: FCurrentContext.SortBy := 'L';
3889 else
3890 FCurrentContext.SortBy := 'R';
3891 end;
3892 FCurrentContext.ListAscending := ColumnSortForward;
3893 (Sender as TCustomListView).AlphaSort;
3894 //with lvNotes do if Selected <> nil then Scroll(0, Selected.Top - TopItem.Top);
3895end;
3896
3897procedure TfrmNotes.lvNotesCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
3898var
3899 ix: Integer;
3900begin
3901 if ColumnToSort = 0 then
3902 Compare := CompareText(Item1.Caption,Item2.Caption)
3903 else begin
3904 ix := ColumnToSort - 1;
3905 Compare := CompareText(Item1.SubItems[ix],Item2.SubItems[ix]);
3906 end;
3907 if not ColumnSortForward then Compare := -Compare;
3908end;
3909
3910procedure TfrmNotes.lvNotesSelectItem(Sender: TObject; Item: TListItem;
3911 Selected: Boolean);
3912begin
3913 if uChanging or (not Selected) then Exit;
3914 with lvNotes do
3915 begin
3916// StatusText('Retrieving selected progress note...'); <-- original line. //kt 7/19/2007
3917 StatusText(DKLangConstW('fNotes_Retrieving_selected_progress_notexxx')); //kt added 7/19/2007
3918 lstNotes.SelectByID(Item.SubItems[5]);
3919 lstNotesClick(Self);
[541]3920 if (vmHTML in FViewMode) then begin //kt 8/09
3921 SendMessage(HTMLViewer.Handle, WM_VSCROLL, SB_TOP, 0); //kt 8/09
3922 end else begin //kt 8/09
3923 SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
3924 end; //kt 8/09
[453]3925 end;
3926end;
3927
3928procedure TfrmNotes.lvNotesResize(Sender: TObject);
3929begin
3930 inherited;
3931 with lvNotes do
3932 begin
3933 if not FCurrentContext.ShowSubject then
3934 begin
3935 Columns[1].Width := 2 * (Width div 5);
3936 Columns[2].Width := 0;
3937 end
3938 else
3939 begin
3940 Columns[1].Width := Width div 5;
3941 Columns[2].Width := Columns[1].Width;
3942 end;
3943 end;
3944end;
3945
3946procedure TfrmNotes.EnableDisableIDNotes;
3947begin
3948 uIDNotesActive := IDNotesInstalled;
3949 mnuActDetachFromIDParent.Visible := uIDNotesActive;
3950 popNoteListDetachFromIDParent.Visible := uIDNotesActive;
3951 mnuActAddIDEntry.Visible := uIDNotesActive;
3952 popNoteListAddIDEntry.Visible := uIDNotesActive;
3953 mnuActAttachtoIDParent.Visible := uIDNotesActive;
3954 popNoteListAttachtoIDParent.Visible := uIDNotesActive;
3955 if uIDNotesActive then
3956 tvNotes.DragMode := dmAutomatic
3957 else
3958 tvNotes.DragMode := dmManual;
3959end;
3960
3961procedure TfrmNotes.ShowPCEButtons(Editing: boolean);
3962begin
3963 if frmFrame.Timedout then Exit;
3964
3965 FEditingNotePCEObj := Editing;
3966 if Editing or AnytimeEncounters then
3967 begin
3968 cmdPCE.Visible := TRUE;
3969 if Editing then
3970 begin
3971 cmdPCE.Enabled := CanEditPCE(uPCEEdit);
3972 cmdNewNote.Visible := AnytimeEncounters;
3973 cmdNewNote.Enabled := FALSE;
3974 end
3975 else
3976 begin
3977 cmdPCE.Enabled := (GetAskPCE(0) <> apDisable);
3978 cmdNewNote.Visible := TRUE;
3979 cmdNewNote.Enabled := (FStarting = False); //TRUE;
3980 end;
3981 if cmdNewNote.Visible then
3982 cmdPCE.Top := cmdNewNote.Top-cmdPCE.Height;
3983 end
3984 else
3985 begin
3986 cmdPCE.Enabled := FALSE;
3987 cmdPCE.Visible := FALSE;
3988 cmdNewNote.Visible := TRUE;
3989 cmdNewNote.Enabled := (FStarting = False); //TRUE;
3990 end;
3991 if cmdPCE.Visible then
3992 lblSpace1.Top := cmdPCE.Top - lblSpace1.Height
3993 else
3994 lblSpace1.Top := cmdNewNote.Top - lblSpace1.Height;
3995 popNoteMemoEncounter.Enabled := cmdPCE.Enabled;
3996 popNoteMemoEncounter.Visible := cmdPCE.Visible;
3997end;
3998
3999procedure TfrmNotes.mnuIconLegendClick(Sender: TObject);
4000begin
4001 inherited;
4002 ShowIconLegend(ilNotes);
4003end;
4004
4005procedure TfrmNotes.mnuActAttachtoIDParentClick(Sender: TObject);
4006var
4007 AChildNode: TORTreeNode;
4008 AParentID: string;
4009 SavedDocID: string;
4010 Saved: boolean;
4011begin
4012 inherited;
4013 if not uIDNotesActive then exit;
4014 if lstNotes.ItemIEN = 0 then exit;
4015 SavedDocID := lstNotes.ItemID;
4016 if EditingIndex <> -1 then
4017 begin
4018 SaveCurrentNote(Saved);
4019 if not Saved then Exit;
4020 LoadNotes;
4021 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
4022 end;
4023 if tvNotes.Selected = nil then exit;
4024 AChildNode := TORTreeNode(tvNotes.Selected);
4025 AParentID := SelectParentNodeFromList(tvNotes);
4026 if AParentID = '' then exit;
4027 with tvNotes do Selected := FindPieceNode(AParentID, 1, U, Items.GetFirstNode);
4028 DoAttachIDChild(AChildNode, TORTreeNode(tvNotes.Selected));
4029end;
4030
4031procedure TfrmNotes.DoAttachIDChild(AChild, AParent: TORTreeNode);
4032//const
4033//TX_ATTACH_CNF = 'Confirm Attachment'; <-- original line. //kt 7/19/2007
4034//TX_ATTACH_FAILURE = 'Attachment failed'; <-- original line. //kt 7/19/2007
4035var
4036 ErrMsg, WhyNot: string;
4037 SavedDocID: string;
4038 TX_ATTACH_CNF : string; //kt
4039 TX_ATTACH_FAILURE : string; //kt
4040begin
4041 SetupVars; //kt added 7/19/2007 to replace constants with vars.
4042 TX_ATTACH_CNF := DKLangConstW('fNotes_Confirm_Attachment'); //kt added 7/19/2007
4043 TX_ATTACH_FAILURE := DKLangConstW('fNotes_Attachment_failed'); //kt added 7/19/2007
4044 if (AChild = nil) or (AParent = nil) then exit;
4045 ErrMsg := '';
4046 if not CanBeAttached(PDocTreeObject(AChild.Data)^.DocID, WhyNot) then
4047 ErrMsg := ErrMsg + WhyNot + CRLF + CRLF;
4048 if not CanReceiveAttachment(PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
4049 ErrMsg := ErrMsg + WhyNot;
4050 if ErrMsg <> '' then
4051 begin
4052 InfoBox(ErrMsg, TX_ATTACH_FAILURE, MB_OK);
4053 Exit;
4054 end
4055 else
4056 begin
4057 WhyNot := '';
4058 if (InfoBox('ATTACH: ' + AChild.Text + CRLF + CRLF +
4059 ' TO: ' + AParent.Text + CRLF + CRLF +
4060// 'Are you sure?', TX_ATTACH_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) <-- original line. //kt 7/19/2007
4061 DKLangConstW('fNotes_Are_you_surex'), TX_ATTACH_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) //kt added 7/19/2007
4062 then Exit;
4063 SavedDocID := PDocTreeObject(AParent.Data)^.DocID;
4064 end;
4065 if AChild.ImageIndex in [IMG_ID_CHILD, IMG_ID_CHILD_ADD] then
4066 begin
4067 if DetachEntryFromParent(PDocTreeObject(AChild.Data)^.DocID, WhyNot) then
4068 begin
4069 if AttachEntryToParent(PDocTreeObject(AChild.Data)^.DocID, PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
4070 begin
4071 LoadNotes;
4072 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
4073 if tvNotes.Selected <> nil then tvNotes.Selected.Expand(False);
4074 end
4075 else
4076 InfoBox(WhyNot, TX_ATTACH_FAILURE, MB_OK);
4077 end
4078 else
4079 begin
4080 WhyNot := StringReplace(WhyNot, 'ATTACH', 'DETACH', [rfIgnoreCase]);
4081 WhyNot := StringReplace(WhyNot, 'to an ID', 'from an ID', [rfIgnoreCase]);
4082 InfoBox(WhyNot, TX_DETACH_FAILURE, MB_OK);
4083 Exit;
4084 end;
4085 end
4086 else
4087 begin
4088 if AttachEntryToParent(PDocTreeObject(AChild.Data)^.DocID, PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
4089 begin
4090 LoadNotes;
4091 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
4092 if tvNotes.Selected <> nil then tvNotes.Selected.Expand(False);
4093 end
4094 else
4095 InfoBox(WhyNot, TX_ATTACH_FAILURE, MB_OK);
4096 end;
4097end;
4098
4099function TfrmNotes.SetNoteTreeLabel(AContext: TTIUContext): string;
4100var
4101 x: string;
4102
4103 function SetDateRangeText(AContext: TTIUContext): string;
4104 var
4105 x1: string;
4106 begin
4107 with AContext do
4108 if BeginDate <> '' then
4109 begin
4110 x1 := ' from ' + UpperCase(BeginDate);
4111// if EndDate <> '' then x1 := x1 + ' to ' + UpperCase(EndDate) <-- original line. //kt 7/19/2007
4112 if EndDate <> '' then x1 := x1 + DKLangConstW('fNotes_to') + UpperCase(EndDate) //kt added 7/19/2007
4113 else x1 := x1 + ' to TODAY';
4114 end;
4115 Result := x1;
4116 end;
4117
4118begin
4119 with AContext do
4120 begin
4121// if MaxDocs > 0 then x := 'Last ' + IntToStr(MaxDocs) + ' ' else x := 'All '; <-- original line. //kt 7/19/2007
4122 if MaxDocs > 0 then x := DKLangConstW('fNotes_Last') + IntToStr(MaxDocs) + ' ' else x := DKLangConstW('fNotes_All'); //kt added 7/19/2007
4123 case StrToIntDef(Status, 0) of
4124// NC_ALL : x := x + 'Signed Notes'; <-- original line. //kt 7/19/2007
4125 NC_ALL : x := x + DKLangConstW('fNotes_Signed_Notes'); //kt added 7/19/2007
4126 NC_UNSIGNED : begin
4127// x := x + 'Unsigned Notes for '; <-- original line. //kt 7/19/2007
4128 x := x + DKLangConstW('fNotes_Unsigned_Notes_for'); //kt added 7/19/2007
4129 if Author > 0 then x := x + ExternalName(Author, 200)
4130 else x := x + User.Name;
4131 x := x + SetDateRangeText(AContext);
4132 end;
4133 NC_UNCOSIGNED : begin
4134// x := x + 'Uncosigned Notes for '; <-- original line. //kt 7/19/2007
4135 x := x + DKLangConstW('fNotes_Uncosigned_Notes_for'); //kt added 7/19/2007
4136 if Author > 0 then x := x + ExternalName(Author, 200)
4137 else x := x + User.Name;
4138 x := x + SetDateRangeText(AContext);
4139 end;
4140// NC_BY_AUTHOR : x := x + 'Signed Notes for ' + ExternalName(Author, 200) + SetDateRangeText(AContext); <-- original line. //kt 7/19/2007
4141 NC_BY_AUTHOR : x := x + DKLangConstW('fNotes_Signed_Notes_for') + ExternalName(Author, 200) + SetDateRangeText(AContext); //kt added 7/19/2007
4142// NC_BY_DATE : x := x + 'Signed Notes ' + SetDateRangeText(AContext); <-- original line. //kt 7/19/2007
4143 NC_BY_DATE : x := x + DKLangConstW('fNotes_Signed_Notes') + SetDateRangeText(AContext); //kt added 7/19/2007
4144 else
4145// x := 'Custom List'; <-- original line. //kt 7/19/2007
4146 x := DKLangConstW('fNotes_Custom_List'); //kt added 7/19/2007
4147 end;
4148 end;
4149 Result := x;
4150end;
4151
4152procedure TfrmNotes.memNewNoteKeyDown(Sender: TObject; var Key: Word;
4153 Shift: TShiftState);
4154begin
4155 inherited;
4156 FNavigatingTab := (Key = VK_TAB) and ([ssShift,ssCtrl] * Shift <> []);
4157 if FNavigatingTab then
4158 Key := 0;
4159end;
4160
4161procedure TfrmNotes.UpdateNoteAuthor(DocInfo: string);
4162//const
4163//TX_INVALID_AUTHOR1 = 'The author returned by the template ('; <-- original line. //kt 7/19/2007
4164//TX_INVALID_AUTHOR2 = ') is not valid.' + #13#10 + 'The note''s author will remain as '; <-- original line. //kt 7/19/2007
4165//TC_INVALID_AUTHOR = 'Invalid Author'; <-- original line. //kt 7/19/2007
4166//TX_COSIGNER_REQD = ' requires a cosigner for this note.'; <-- original line. //kt 7/19/2007
4167//TC_COSIGNER_REQD = 'Cosigner Required'; <-- original line. //kt 7/19/2007
4168var
4169 NewAuth, NewAuthName, AuthNameCheck, x: string;
4170 ADummySender: TObject;
4171 TX_INVALID_AUTHOR1 : string; //kt
4172 TX_INVALID_AUTHOR2 : string; //kt
4173 TC_INVALID_AUTHOR : string; //kt
4174 TX_COSIGNER_REQD : string; //kt
4175 TC_COSIGNER_REQD : string; //kt
4176begin
4177 TX_INVALID_AUTHOR1 := DKLangConstW('fNotes_The_author_returned_by_the_template_x'); //kt added 7/19/2007
4178 TX_INVALID_AUTHOR2 := DKLangConstW('fNotes_x_is_not_validx') + #13#10 + DKLangConstW('fNotes_The_notexxs_author_will_remain_as'); //kt added 7/19/2007
4179 TC_INVALID_AUTHOR := DKLangConstW('fNotes_Invalid_Author'); //kt added 7/19/2007
4180 TX_COSIGNER_REQD := DKLangConstW('fNotes_requires_a_cosigner_for_this_notex'); //kt added 7/19/2007
4181 TC_COSIGNER_REQD := DKLangConstW('fNotes_Cosigner_Required'); //kt added 7/19/2007
4182 SetupVars; //kt added 7/19/2007 to replace constants with vars.
4183 if DocInfo = '' then Exit;
4184 NewAuth := GetXMLParamReturnValueTIU(DocInfo, 'AUTHOR_IEN');
4185 if NewAuth = '' then Exit;
4186 AuthNameCheck := ExternalName(StrToInt64Def(NewAuth, 0), 200);
4187 if AuthNameCheck = '' then
4188 begin
4189 NewAuthName := GetXMLParamReturnValueTIU(DocInfo, 'AUTHOR_NAME');
4190 InfoBox(TX_INVALID_AUTHOR1 + UpperCase(NewAuthName) + TX_INVALID_AUTHOR2 + UpperCase(FEditNote.AuthorName),
4191 TC_INVALID_AUTHOR, MB_OK and MB_ICONERROR);
4192 Exit;
4193 end;
4194 with FEditNote do if StrToInt64Def(NewAuth, 0) <> Author then
4195 begin
4196 Author := StrToInt64Def(NewAuth, 0);
4197 AuthorName := AuthNameCheck;
4198 x := lstNotes.Items[EditingIndex];
4199 SetPiece(x, U, 5, NewAuth + ';' + AuthNameCheck);
4200 lstNotes.Items[EditingIndex] := x;
4201 if AskCosignerForTitle(Title, Author, DateTime) then
4202 begin
4203 InfoBox(UpperCase(AuthNameCheck) + TX_COSIGNER_REQD, TC_COSIGNER_REQD, MB_OK);
4204 //Cosigner := 0; CosignerName := ''; // not sure about this yet
4205 ADummySender := TObject.Create;
4206 try
4207 cmdChangeClick(ADummySender);
4208 finally
4209 FreeAndNil(ADummySender);
4210 end;
4211 end
4212 else cmdChangeClick(Self);
4213 end;
4214end;
4215
4216procedure TfrmNotes.sptHorzCanResize(Sender: TObject; var NewSize: Integer;
4217 var Accept: Boolean);
4218begin
4219 inherited;
4220 if pnlWrite.Visible then
4221 if NewSize > frmNotes.ClientWidth - memNewNote.Constraints.MinWidth - sptHorz.Width then
4222 NewSize := frmNotes.ClientWidth - memNewNote.Constraints.MinWidth - sptHorz.Width;
4223end;
4224
[541]4225(*
[453]4226//kt 5-2-05 added following function (initially copied from fReports.pas)
4227procedure TfrmNotes.WebBrowser1DocumentComplete(Sender: TObject;
4228 const pDisp: IDispatch; var URL: OleVariant);
4229var
4230 WebDoc: IHtmlDocument2;
4231 v: variant;
4232begin
4233 {
4234 inherited;
4235 if uHTMLDoc = '' then Exit;
4236 if not(uReportType = 'H') then Exit; //this can be removed if & when browser replaces memtext control
4237 if not Assigned(WebBrowser1.Document) then Exit;
4238 WebDoc := WebBrowser1.Document as IHtmlDocument2;
4239 v := VarArrayCreate([0, 0], varVariant);
4240 v[0] := uHTMLDoc;
4241 WebDoc.write(PSafeArray(TVarData(v).VArray));
4242 WebDoc.close;
4243 //uHTMLDoc := '';
4244 }
4245end;
[541]4246*)
[453]4247
4248procedure TfrmNotes.popNoteMemoInsTemplateClick(Sender: TObject);
4249begin
4250 frmDrawers.mnuInsertTemplateClick(Sender);
4251end;
4252
4253procedure TfrmNotes.popNoteMemoPreviewClick(Sender: TObject);
4254begin
4255 frmDrawers.mnuPreviewTemplateClick(Sender);
4256end;
4257
4258procedure TfrmNotes.tvNotesAddition(Sender: TObject; Node: TTreeNode);
4259begin
4260 inherited;
4261 TAccessibleTreeNode.WrapControl(Node as TORTreeNode);
4262end;
4263
4264procedure TfrmNotes.tvNotesDeletion(Sender: TObject; Node: TTreeNode);
4265begin
4266 TAccessibleTreeNode.UnwrapControl(Node as TORTreeNode);
4267 inherited;
4268end;
4269
4270{Tab Order tricks. Need to change
4271 tvNotes
4272
4273 frmDrawers.pnlTemplateButton
4274 frmDrawers.pnlEncounterButton
4275 cmdNewNote
4276 cmdPCE
4277
4278 lvNotes
4279 memNote
4280
4281to
4282 tvNotes
4283
4284 lvNotes
4285 memNote
4286
4287 frmDrawers.pnlTemplateButton
4288 frmDrawers.pnlEncounterButton
4289 cmdNewNote
4290 cmdPCE
4291}
4292
4293procedure TfrmNotes.tvNotesExit(Sender: TObject);
4294begin
4295 if IncSecond(FMousing,1) < Now then
4296 begin
4297 if (Screen.ActiveControl = frmDrawers.pnlTemplatesButton) or
4298 (Screen.ActiveControl = frmDrawers.pnlEncounterButton) or
4299 (Screen.ActiveControl = cmdNewNote) or
4300 (Screen.ActiveControl = cmdPCE) then
4301 FindNextControl( cmdPCE, True, True, False).SetFocus;
4302 end;
4303 FMousing := 0;
4304end;
4305
4306procedure TfrmNotes.pnlReadExit(Sender: TObject);
4307begin
4308 inherited;
4309 if IncSecond(FMousing,1) < Now then
4310 begin
4311 if (Screen.ActiveControl = frmFrame.pnlPatient) then
4312 FindNextControl( tvNotes, True, True, False).SetFocus
4313 else
4314 if (Screen.ActiveControl = frmDrawers.pnlTemplatesButton) or
4315 (Screen.ActiveControl = frmDrawers.pnlEncounterButton) or
4316 (Screen.ActiveControl = cmdNewNote) or
4317 (Screen.ActiveControl = cmdPCE) then
4318 FindNextControl( frmDrawers.pnlTemplatesButton, False, True, False).SetFocus;
4319 end;
4320 FMousing := 0;
4321end;
4322
4323procedure TfrmNotes.cmdNewNoteExit(Sender: TObject);
4324begin
4325 inherited;
4326 if IncSecond(FMousing,1) < Now then
4327 begin
4328 if (Screen.ActiveControl = lvNotes) or
4329 (Screen.ActiveControl = memNote) then
4330 frmFrame.pnlPatient.SetFocus
4331 else
4332 if (Screen.ActiveControl = tvNotes) then
4333 FindNextControl( frmFrame.pnlPatient, False, True, False).SetFocus;
4334 end;
4335 FMousing := 0;
4336end;
4337
4338procedure TfrmNotes.frmFramePnlPatientExit(Sender: TObject);
4339begin
4340 FOldFramePnlPatientExit(Sender);
4341 if IncSecond(FMousing,1) < Now then
4342 begin
4343 if (Screen.ActiveControl = lvNotes) or
4344 (Screen.ActiveControl = memNote) then
4345 FindNextControl( lvNotes, False, True, False).SetFocus;
4346 end;
4347 FMousing := 0;
4348end;
4349
4350procedure TfrmNotes.FormHide(Sender: TObject);
4351begin
4352 inherited;
4353 frmFrame.pnlPatient.OnExit := FOldFramePnlPatientExit;
4354 frmDrawers.pnlTemplatesButton.OnExit := FOldDrawerPnlTemplatesButtonExit;
4355 frmDrawers.pnlEncounterButton.OnExit := FOldDrawerPnlEncounterButtonExit;
4356 frmDrawers.edtSearch.OnExit := FOldDrawerEdtSearchExit;
4357end;
4358
4359procedure TfrmNotes.FormShow(Sender: TObject);
4360begin
4361 inherited;
4362 FOldFramePnlPatientExit := frmFrame.pnlPatient.OnExit;
4363 frmFrame.pnlPatient.OnExit := frmFramePnlPatientExit;
4364 FOldDrawerPnlTemplatesButtonExit := frmDrawers.pnlTemplatesButton.OnExit;
4365 frmDrawers.pnlTemplatesButton.OnExit := frmDrawerPnlTemplatesButtonExit;
4366 FOldDrawerPnlEncounterButtonExit := frmDrawers.pnlEncounterButton.OnExit;
4367 frmDrawers.pnlEncounterButton.OnExit := frmDrawerPnlEncounterButtonExit;
4368 FOldDrawerEdtSearchExit := frmDrawers.edtSearch.OnExit;
4369 frmDrawers.edtSearch.OnExit := frmDrawerEdtSearchExit;
4370end;
4371
4372procedure TfrmNotes.frmDrawerEdtSearchExit(Sender: TObject);
4373begin
4374 FOldDrawerEdtSearchExit(Sender);
4375 cmdNewNoteExit(Sender);
4376end;
4377
4378procedure TfrmNotes.frmDrawerPnlTemplatesButtonExit(Sender: TObject);
4379begin
4380 FOldDrawerPnlTemplatesButtonExit(Sender);
4381 if Boolean(Hi(GetKeyState(VK_TAB))) and (memNewNote.CanFocus) and
4382 Boolean(Hi(GetKeyState(VK_SHIFT))) then
4383 memNewNote.SetFocus
4384 else
4385 cmdNewNoteExit(Sender);
4386end;
4387
4388procedure TfrmNotes.frmDrawerPnlEncounterButtonExit(Sender: TObject);
4389begin
4390 FOldDrawerPnlEncounterButtonExit(Sender);
4391 cmdNewNoteExit(Sender);
4392end;
4393
4394procedure TfrmNotes.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
4395 Y: Integer);
4396begin
4397 inherited;
4398 FMousing := Now;
4399end;
4400
[541]4401procedure TfrmNotes.SetHTMLEditMode(HTMLEditMode : boolean; Quiet : boolean);
4402//kt added function 7/09
4403var Mode : TViewModeSet; //kt
4404const HTML_MODE_S : Array[false..true] of string[16] = ('PLAIN','FORMATTED');
4405begin
4406 if FEditNote.Lines = nil then FEditNote.Lines := TStringList.Create; //kt
4407 if HTMLEditMode then begin
4408 if (FViewMode = [vmHTML,vmEdit]) then exit; //no change needed.
4409 FEditNote.Lines.Assign(memNewNote.Lines);
4410 end else begin
4411 if (FViewMode = [vmText,vmEdit]) then exit; //no change needed.
4412 if HtmlEditor.GetTextLen > 0 then begin
4413 if MessageDlg('Do you want to convert this note to PLAIN TEXT?'+#10#13+
4414 '(May cause loss of formatting information.)',mtWarning, mbOKCancel,0) <> mrOK then begin
4415 exit;
4416 end;
4417 end;
4418 FEditNote.Lines.Text := HTMLEditor.Text;
4419 end;
4420 Mode := [vmEdit] + [vmHTML_MODE[HTMLEditMode]]; //kt
4421 SetDisplayToHTMLvsText(Mode,FEditNote.Lines);
4422 if not Quiet then begin
4423 if MessageDlg('Start new notes in '+HTML_MODE_S[HTMLEditMode]+' TEXT by default?',mtConfirmation,[mbYES,mbNO],0) = mrYES then begin
4424 fOptionsNotes.SetDefaultEditHTMLMode(HTMLEditMode);
4425 end;
4426 end;
4427end;
4428
4429procedure TfrmNotes.ToggleHTMLEditMode;
4430//kt added function 6/09
4431var NewHTMLMode: boolean;
4432begin
4433 if not (vmEdit in FViewMode) then exit; //quit if not in edit mode
4434 NewHTMLMode := not (vmHTML in FViewMode);
4435 SetHTMLEditMode(NewHTMLMode);
4436end;
4437
4438
4439procedure TfrmNotes.SetDisplayToHTMLvsText(Mode : TViewModeSet;
4440 Lines : TStrings;
4441 ActivateOnly : boolean {default=False});
4442//kt added function 7/09
4443//If ActivateOnly=True, then the visibility is set, but the control is not filled with text.
4444
4445type
4446 TPanelVisibilityMode = (pvmReadMode, pvmWriteMode); //kt
4447
4448 procedure SetPanelVisibility(Mode: TPanelVisibilityMode; HTMLMode : boolean);
4449
4450 procedure SetpnlReadVisibility(Visible : boolean; HTMLMode : boolean);
4451 begin
4452 pnlRead.Visible := Visible;
4453 if Visible then begin
4454 memNote.Visible := not HTMLMode;
4455 memNote.TabStop := not HTMLMode;
4456 pnlHTMLViewer.Visible := HTMLMode;
4457 HTMLViewer.Visible := HTMLMode;
4458 if HTMLMode then begin
4459 HtmlViewer.BringToFront;
4460 end else begin
4461 MemNote.BringToFront;
4462 end;
4463 end else begin
4464 memNote.Visible := false;
4465 memNote.TabStop := false;
4466 pnlHTMLViewer.Visible := false;
4467 HTMLViewer.Visible := false;
4468 end;
4469 end; {SetDisplayToHTMLvsText.SetPanelVisibility.SetpnlReadVisibility}
4470
4471 procedure SetpnlWriteVisibility(Visible : boolean; HTMLMode : boolean);
4472 begin
4473 pnlWrite.Visible := Visible;
4474 if Visible then begin
4475 pnlHTMLWrite.Visible := HTMLMode;
4476 pnlHTMLEdit.Visible := HTMLMode;
4477 HTMLEditor.Visible := HTMLMode;
4478 pnlTextWrite.Visible := not HTMLMode;
4479 MemNewNote.Visible := not HTMLMode;
4480 if HTMLMode then begin
4481 HTMLEditor.BringToFront;
4482 end else begin
4483 MemNewNote.BringToFront;
4484 end;
4485 end else begin
4486 pnlHTMLWrite.Visible := false;
4487 pnlHTMLEdit.Visible := false;
4488 HTMLEditor.Visible := false;
4489 pnlTextWrite.Visible := false;
4490 memNewNote.Visible := false;
4491 end;
4492 end; {SetDisplayToHTMLvsText.SetPanelVisibility.SetpnlWriteVisibility}
4493
4494 begin {SetDisplayToHTMLvsText.SetPanelVisibility}
4495 SetpnlReadVisibility ((Mode=pvmReadMode), HTMLMode);
4496 SetpnlWriteVisibility((Mode=pvmWriteMode),HTMLMode);
4497 Application.ProcessMessages;
4498 end; {SetDisplayToHTMLvsText.SetPanelVisibility}
4499
4500 procedure SetHTMLorTextEditor(HTMLEditMode : boolean;
4501 Lines : TStrings;
4502 ActivateOnly : boolean {default=False});
4503 procedure ActivateHtmlEditor(Lines : TStrings);
4504 var HTMLText : string;
4505 begin
4506 HtmlEditor.Editable := true;
4507 if ActivateOnly=false then begin
4508 if Lines <> nil then begin
4509 if rHTMLTools.IsHTML(Lines) then begin
4510 HTMLText := Lines.Text;
4511 end else begin
4512 HTMLText := Text2HTML(Lines);
4513 if HTMLText='' then HTMLText := ' ';
4514 end;
4515 end else HTMLText := ' ';
4516 HtmlEditor.HTMLText := HTMLText;
4517 HTMLEditor.KeyStruck := false;
4518 end;
4519 end; {SetDisplayToHTMLvsText.SetHTMLorTextEditor.ActivateHtmlEditor}
4520
4521 procedure ActiveMemoEditor(Lines : TStrings);
4522 begin
4523 if ActivateOnly=false then begin
4524 memNewNote.Lines.Assign(Lines); //kt new
4525 end;
4526 //kt HtmlEditor.Active := false; //stop intercepting OnMessages
4527 HtmlEditor.Clear;
4528 end; {SetDisplayToHTMLvsText.SetHTMLorTextEditor.ActiveMemoEditor}
4529
4530 begin {SetDisplayToHTMLvsText.SetHTMLorTextEditor}
4531 FHTMLEditMode := emHTML_MODE[HTMLEditMode];
4532 FViewMode := [vmEdit] + [vmHTML_MODE[HTMLEditMode]];
4533 SetPanelVisibility(pvmWriteMode,HTMLEditMode);
4534 pnlRight.Repaint; //kt TEMP
4535 if HTMLEditMode then begin
4536 ActivateHtmlEditor(Lines);
4537 end else begin
4538 ActiveMemoEditor(Lines);
4539 end;
4540 pnlRight.Repaint; //kt TEMP
4541 end; {SetDisplayToHTMLvsText.SetHTMLorTextEditor}
4542
4543 procedure SetHTMLorTextViewer(HTMLViewMode : boolean;
4544 Lines : TStrings;
4545 ActivateOnly : boolean); //kt
4546 //Set forms such that either HTML Viewer is visible, or standard edit window.
4547 procedure ActivateHtmlViewer(Lines : TStrings);
4548 begin
4549 with frmNotes do begin
4550 //ScanForSubs(MemNote.Lines);
4551 pnlHtmlViewer.Visible := true;
4552 //memNote.Visible := false;
4553 //memNote.TabStop := false;
4554 HtmlViewer.BringToFront;
4555 if ActivateOnly=False then begin
4556 FixHTML(Lines);
4557 HtmlViewer.HTMLText := Lines.Text;
4558 end;
4559 HtmlViewer.Editable := false;
4560 HtmlViewer.BackgroundColor := clCream;
4561 HtmlViewer.TabStop := true;
4562 RedrawActivate(HtmlViewer.Handle);
4563 end;
4564 end; {SetDisplayToHTMLvsText.SetHTMLorTextViewer.ActivateHtmlViewer}
4565
4566 procedure ActivateMemoViewer(Lines : TStrings);
4567 begin
4568 with frmNotes do begin
4569 pnlHtmlViewer.Visible := false;
4570 HtmlViewer.Clear;
4571 //HtmlEditor.Clear; //don't this here. Only clear in ClearEditControls...
4572 HtmlViewer.TabStop := false;
4573 if ActivateOnly=False then memNote.Lines.Assign(Lines); //new
4574 memNote.Visible := true;
4575 memNote.TabStop := true;
4576 memNote.BringToFront;
4577 RedrawActivate(memNote.Handle);
4578 end;
4579 end; {SetDisplayToHTMLvsText.SetHTMLorTextViewer.ActivateMemoViewer}
4580
4581 begin {SetHTMLorTextViewer}
4582 FViewMode := [vmView] + [vmHTML_MODE[HTMLViewMode]];
4583 SetPanelVisibility(pvmReadMode,HTMLviewMode);
4584 //pnlRight.Repaint; //kt TEMP
4585 if HTMLViewMode then begin
4586 ActivateHtmlViewer(Lines);
4587 end else begin
4588 ActivateMemoViewer(Lines);
4589 HtmlViewer.Clear;
4590 end;
4591 pnlRight.Repaint; //kt TEMP
4592 end; {SetDisplayToHTMLvsText.SetHTMLorTextViewer}
4593
4594begin {SetDisplayToHTMLvsText}
4595 if vmEdit in Mode then begin
4596 SetHTMLorTextEditor((vmHTML in Mode),Lines,ActivateOnly);
4597 end else begin
4598 SetHTMLorTextViewer((vmHTML in Mode),Lines,ActivateOnly);
4599 end;
4600end; {SetDisplayToHTMLvsText}
4601
4602procedure TfrmNotes.btnBoldClick(Sender: TObject);
4603//kt added function
4604begin
4605 inherited;
4606 HtmlEditor.ToggleBold;
4607end;
4608
4609procedure TfrmNotes.btnItalicClick(Sender: TObject);
4610//kt added function
4611begin
4612 inherited;
4613 HtmlEditor.ToggleItalic;
4614end;
4615
4616procedure TfrmNotes.btnLessIndentClick(Sender: TObject);
4617//kt added function
4618begin
4619 inherited;
4620 HtmlEditor.Outdent;
4621end;
4622
4623procedure TfrmNotes.btnMoreIndentClick(Sender: TObject);
4624//kt added function
4625begin
4626 inherited;
4627 HtmlEditor.Indent;
4628end;
4629
4630procedure TfrmNotes.btnRightAlignClick(Sender: TObject);
4631//kt added function
4632begin
4633 inherited;
4634 HtmlEditor.AlignRight;
4635end;
4636
4637procedure TfrmNotes.btnCenterAlignClick(Sender: TObject);
4638//kt added function
4639begin
4640 inherited;
4641 HtmlEditor.AlignCenter;
4642end;
4643
4644procedure TfrmNotes.btnLeftAlignClick(Sender: TObject);
4645//kt added function
4646begin
4647 inherited;
4648 HtmlEditor.AlignLeft;
4649end;
4650
4651procedure TfrmNotes.btnNumbersClick(Sender: TObject);
4652//kt added function
4653begin
4654 inherited;
4655 HtmlEditor.ToggleNumbering;
4656end;
4657
4658procedure TfrmNotes.btnBulletsClick(Sender: TObject);
4659//kt added function
4660begin
4661 inherited;
4662 HtmlEditor.ToggleBullet;
4663end;
4664
4665procedure TfrmNotes.btnUnderlineClick(Sender: TObject);
4666//kt added function
4667begin
4668 inherited;
4669 HtmlEditor.ToggleUnderline;
4670end;
4671
4672procedure TfrmNotes.btnTextColorClick(Sender: TObject);
4673//kt added function
4674begin
4675 inherited;
4676 HtmlEditor.TextForeColorDialog;
4677end;
4678
4679procedure TfrmNotes.btnBackColorClick(Sender: TObject);
4680//kt added function
4681begin
4682 inherited;
4683 HtmlEditor.TextBackColorDialog;
4684end;
4685
4686procedure TfrmNotes.btnFontsClick(Sender: TObject);
4687//kt added function
4688begin
4689 inherited;
4690 HtmlEditor.FontDialog;
4691end;
4692
4693procedure TfrmNotes.cbFontSizeChange(Sender: TObject);
4694//kt added function
4695const
4696 FontSizes : array [0..6] of byte = (8,10,12,14,18,24,36);
4697begin
4698 inherited;
4699 //HtmlEditor.FontSize := StrToInt(cbFontSize.Text);
4700 HtmlEditor.FontSize := FontSizes[cbFontSize.ItemIndex];
4701end;
4702
4703procedure TfrmNotes.cbFontNamesChange(Sender: TObject);
4704//kt added function
4705var i : integer;
4706 FontName : string;
4707const
4708 TEXT_BAR = '---------------';
4709begin
4710 inherited;
4711 if cbFontNames.Text[1]='<' then exit;
4712 FontName := cbFontNames.Text;
4713 HtmlEditor.FontName := FontName;
4714 i := cbFontNames.Items.IndexOf(TEXT_BAR);
4715 if i < 1 then cbFontNames.Items.Insert(0,TEXT_BAR);
4716 if i > 5 then cbFontNames.Items.Delete(5);
4717 if cbFontNames.Items.IndexOf(FontName)> i then begin
4718 cbFontNames.Items.Insert(0,FontName);
4719 end;
4720end;
4721
4722(*
[453]4723//kt made this entire temp function
4724procedure TfrmNotes.WebBrowser1CommandStateChange(Sender: TObject;
4725 Command: Integer; Enable: WordBool);
4726
4727 var
4728 s,ts: String;
4729 Buff : array[0..255] of char;
4730 pBuff : pChar;
4731
4732begin
4733 inherited;
4734 pBuff := @Buff;
4735 case Command of
4736// CSC_UPDATECOMMANDS: ts := '<Some property>'; <-- original line. //kt 7/19/2007
4737// CSC_UPDATECOMMANDS: ts := DKLangConstW('fNotes_xSome_propertyx'); //kt added 7/19/2007
4738 -1: ts := DKLangConstW('fNotes_xSome_propertyx'); //kt changed 9/7/07
4739 CSC_NAVIGATEFORWARD: ts := ''; //'<Navigate Forward>';
4740 CSC_NAVIGATEBACK: ts := ''; //'<Nagivate Backwards>';
4741 else ts := '??';
4742 end; {case}
4743 if ts<>'' then begin
4744// s := 'Browser Status change: ' + ts + '; Enabled= ' + BoolToStr(Enable); <-- original line. //kt 7/19/2007
4745 s := DKLangConstW('fNotes_Browser_Status_changex')+' ' + ts + DKLangConstW('fNotes_x_Enabledx') + BoolToStr(Enable); //kt added 7/19/2007
4746 //Application.MessageBox(StrPCopy(pBuff,s),'Note');
4747 end;
4748end;
[541]4749*)
[453]4750
4751procedure TfrmNotes.memNewNoteKeyPress(Sender: TObject; var Key: Char);
4752begin
4753 inherited;
4754 if FNavigatingTab then
4755 Key := #0; //Disable shift-tab processinend;
4756end;
4757
4758procedure TfrmNotes.memNewNoteKeyUp(Sender: TObject; var Key: Word;
4759 Shift: TShiftState);
4760begin
4761 inherited;
4762 if FNavigatingTab then
4763 begin
4764 if ssShift in Shift then
4765 FindNextControl(Sender as TWinControl, False, True, False).SetFocus //previous control
4766 else if ssCtrl in Shift then
4767 if frmDrawers.pnlTemplatesButton.CanFocus then
4768 frmDrawers.pnlTemplatesButton.SetFocus
4769 else
4770 FindNextControl(Sender as TWinControl, True, True, False).SetFocus; //next control
4771 FNavigatingTab := False;
4772 end;
4773 if (key = VK_ESCAPE) then begin
4774 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
4775 key := 0;
4776 end;
4777end;
4778
4779procedure TfrmNotes.memPCEShowExit(Sender: TObject);
4780begin
4781 inherited;
4782 //Fix the Tab Order Make Drawers Buttons Accessible
4783 if Boolean(Hi(GetKeyState(VK_TAB))) then
4784 if Boolean(Hi(GetKeyState(VK_SHIFT))) then
4785 cmdPCE.SetFocus
4786 else
4787 frmFrame.pnlPatient.SetFocus;
4788end;
4789
4790procedure TfrmNotes.cmdChangeExit(Sender: TObject);
4791begin
4792 inherited;
4793 //Fix the Tab Order Make Drawers Buttons Accessible
4794 if Boolean(Hi(GetKeyState(VK_TAB))) and
4795 Boolean(Hi(GetKeyState(VK_SHIFT))) then
4796 tvNotes.SetFocus;
4797end;
4798
4799procedure TfrmNotes.cmdPCEExit(Sender: TObject);
4800begin
4801 inherited;
4802 //Fix the Tab Order Make Drawers Buttons Accessible
4803 if Boolean(Hi(GetKeyState(VK_TAB))) and
4804 Not Boolean(Hi(GetKeyState(VK_SHIFT))) then
4805 if memPCEShow.Visible then //CQ7120
4806 memPCEShow.SetFocus; //CQ7120
4807end;
4808
4809procedure TfrmNotes.ViewInfo(Sender: TObject);
4810begin
4811 inherited;
4812 frmFrame.ViewInfo(Sender);
4813end;
4814
4815procedure TfrmNotes.mnuViewInformationClick(Sender: TObject);
4816begin
4817 inherited;
4818 mnuViewDemo.Enabled := frmFrame.pnlPatient.Enabled;
4819 mnuViewVisits.Enabled := frmFrame.pnlVisit.Enabled;
4820 mnuViewPrimaryCare.Enabled := frmFrame.pnlPrimaryCare.Enabled;
4821 mnuViewMyHealtheVet.Enabled := not (Copy(frmFrame.laMHV.Hint, 1, 2) = 'No');
4822 mnuInsurance.Enabled := not (Copy(frmFrame.laVAA2.Hint, 1, 2) = 'No');
4823 mnuViewFlags.Enabled := frmFrame.lblFlag.Enabled;
4824 mnuViewRemoteData.Enabled := frmFrame.lblCirn.Enabled;
4825 mnuViewReminders.Enabled := frmFrame.pnlReminders.Enabled;
4826 mnuViewPostings.Enabled := frmFrame.pnlPostings.Enabled;
4827end;
4828
4829initialization
4830 uPCEEdit := TPCEData.Create;
4831 uPCEShow := TPCEData.Create;
4832
4833finalization
4834 if (uPCEEdit <> nil) then uPCEEdit.Free; //CQ7012 Added test for nil
4835 if (uPCEShow <> nil) then uPCEShow.Free; //CQ7012 Added test for nil
4836
4837end.
4838
Note: See TracBrowser for help on using the repository browser.