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

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

Dual sync of source code enabled: SVN + BZR

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