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

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

Fixed crash on non-login

File size: 193.0 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 4/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// WhyNot := WhyNot + 'A note in progress will be saved as unsigned. ' <-- original line. //kt 7/19/2007
670 WhyNot := WhyNot + DKLangConstW('fNotes_A_note_in_progress_will_be_saved_as_unsignedx') //kt added 7/19/2007
671 end else begin //kt
672// WhyNot := WhyNot + 'An empty note in progress will be deleted. '; <-- original line. //kt 7/19/2007
673 WhyNot := WhyNot + DKLangConstW('fNotes_An_empty_note_in_progress_will_be_deletedx'); //kt added 7/19/2007
674 end; //kt
675 Result := False;
676 end;
677 '0': begin
678// if WhyNot = 'COMMIT' then FSilent := True; <-- original line. //kt 7/19/2007
679 if WhyNot = DKLangConstW('fNotes_COMMIT') then FSilent := True; //kt added 7/19/2007
680 SaveCurrentNote(Result)
681 end;
682 end;
683 if Assigned(frmEncounterFrame) then
684 if Screen.ActiveForm = frmEncounterFrame then
685 //if (fsModal in frmEncounterFrame.FormState) then
686 case BOOLCHAR[frmFrame.CCOWContextChanging] of
687 '1': begin
688// WhyNot := WhyNot + 'Encounter information being edited will not be saved'; <-- original line. //kt 7/19/2007
689 WhyNot := WhyNot + DKLangConstW('fNotes_Encounter_information_being_edited_will_not_be_saved'); //kt added 7/19/2007
690 Result := False;
691 end;
692 '0': begin
693 if WhyNot = 'COMMIT' then
694 begin
695 FSilent := True;
696 frmEncounterFrame.Abort := False;
697 frmEncounterFrame.Cancel := True;
698 end;
699 end;
700 end;
701end;
702
703procedure TfrmNotes.LstNotesToPrint;
704var
705 AParentID: string;
706 SavedDocID: string;
707 Saved: boolean;
708begin
709 inherited;
710 if not uIDNotesActive then exit;
711 if lstNotes.ItemIEN = 0 then exit;
712 SavedDocID := lstNotes.ItemID;
713 if EditingIndex <> -1 then
714 begin
715 SaveCurrentNote(Saved);
716 if not Saved then Exit;
717 LoadNotes;
718 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
719 end;
720 if tvNotes.Selected = nil then exit;
721 AParentID := frmPrintList.SelectParentFromList(tvNotes,CT_NOTES);
722 if AParentID = '' then exit;
723 with tvNotes do Selected := FindPieceNode(AParentID, 1, U, Items.GetFirstNode);
724end;
725
726procedure TfrmNotes.ClearPtData;
727{ clear all controls that contain patient specific information }
728begin
729 inherited ClearPtData;
730 ClearEditControls;
731 uChanging := True;
732 tvNotes.Items.BeginUpdate;
733 KilldocTreeObjects(tvNotes);
734 tvNotes.Items.Clear;
735 tvNotes.Items.EndUpdate;
736 lvNotes.Items.Clear;
737 uChanging := False;
738 lstNotes.Clear;
739 memNote.Clear;
740 HTMLViewer.Clear; //kt
741 HTMLEditor.Clear; //kt
742 FWarmedUp := false; //kt
743 SetDisplayToHTMLvsText([vmText,vmView],nil,VIEW_ACTIVATE_ONLY); //kt
744 memPCEShow.Clear;
745 uPCEShow.Clear;
746 uPCEEdit.Clear;
747 frmDrawers.ResetTemplates;
748end;
749
750procedure TfrmNotes.DisplayPage;
751{ causes page to be visible and conditionally executes initialization code }
752begin
753 inherited DisplayPage;
754 frmFrame.ShowHideChartTabMenus(mnuViewChart);
755 frmFrame.mnuFilePrint.Tag := CT_NOTES;
756 frmFrame.mnuFilePrint.Enabled := True;
757 frmFrame.mnuFilePrintSetup.Enabled := True;
758 frmFrame.mnuFilePrintSelectedItems.Enabled := True;
759 if InitPage then
760 begin
761 EnableDisableIDNotes;
762 FDefaultContext := GetCurrentTIUContext;
763 FCurrentContext := FDefaultContext;
764 popNoteMemoSpell.Visible := SpellCheckAvailable;
765 popNoteMemoGrammar.Visible := popNoteMemoSpell.Visible;
766 Z11.Visible := popNoteMemoSpell.Visible;
767 timAutoSave.Interval := User.AutoSave * 1000; // convert seconds to milliseconds
768 SetEqualTabStops(memNewNote);
769 end;
770 // to indent the right margin need to set Paragraph.RightIndent for each paragraph?
771 if InitPatient and not (CallingContext = CC_NOTIFICATION) then
772 begin
773 SetViewContext(FDefaultContext);
774 end;
775 case CallingContext of
776 CC_INIT_PATIENT: if not InitPatient then
777 begin
778 SetViewContext(FDefaultContext);
779 end;
780 CC_NOTIFICATION: ProcessNotifications;
781 end;
782end;
783
784procedure TfrmNotes.RequestPrint;
785var
786 Saved: Boolean;
787begin
788 SetupVars; //kt added 7/19/2007 to replace constants with vars.
789 with lstNotes do
790 begin
791 if ItemIndex = EditingIndex then
792 //if ItemIEN < 0 then
793 begin
794 SaveCurrentNote(Saved);
795 if not Saved then Exit;
796 end;
797 if ItemIEN > 0 then PrintNote(ItemIEN, MakeNoteDisplayText(Items[ItemIndex])) else
798 begin
799 if ItemIEN = 0 then InfoBox(TX_NONOTE, TX_NONOTE_CAP, MB_OK);
800 if ItemIEN < 0 then InfoBox(TX_NOPRT_NEW, TX_NOPRT_NEW_CAP, MB_OK);
801 end;
802 end;
803end;
804
805{for printing multiple notes}
806procedure TfrmNotes.RequestMultiplePrint(AForm: TfrmPrintList);
807var
808 NoteIEN: int64;
809 i: integer;
810begin
811 SetupVars; //kt added 7/19/2007 to replace constants with vars.
812 with AForm.lbIDParents do
813 begin
814 for i := 0 to Items.Count - 1 do
815 begin
816 if Selected[i] then
817 begin
818 NoteIEN := StrToInt64def(Piece(TStringList(Items.Objects[i])[0],U,1),0);
819 if NoteIEN > 0 then PrintNote(NoteIEN, Items[i], TRUE) else
820 begin
821 if NoteIEN = 0 then InfoBox(TX_NONOTE, TX_NONOTE_CAP, MB_OK);
822 if NoteIEN < 0 then InfoBox(TX_NOPRT_NEW, TX_NOPRT_NEW_CAP, MB_OK);
823 end;
824 end; {if selected}
825 end; {for}
826 end; {with}
827end;
828
829procedure TfrmNotes.SetFontSize(NewFontSize: Integer);
830{ adjusts the font size of any controls that don't have ParentFont = True }
831begin
832 inherited SetFontSize(NewFontSize);
833 frmDrawers.Font.Size := NewFontSize;
834 SetEqualTabStops(memNewNote);
835end;
836
837procedure TfrmNotes.mnuChartTabClick(Sender: TObject);
838{ reroute to Chart Tab menu of the parent form: frmFrame }
839begin
840 inherited;
841 frmFrame.mnuChartTabClick(Sender);
842end;
843
844{ General procedures ----------------------------------------------------------------------- }
845
846procedure TfrmNotes.ClearEditControls;
847{ resets controls used for entering a new progress note }
848begin
849 // clear FEditNote (should FEditNote be an object with a clear method?)
850 with FEditNote do
851 begin
852 DocType := 0;
853 Title := 0;
854 TitleName := '';
855 DateTime := 0;
856 Author := 0;
857 AuthorName := '';
858 Cosigner := 0;
859 CosignerName := '';
860 Subject := '';
861 Location := 0;
862 LocationName := '';
863 PkgIEN := 0;
864 PkgPtr := '';
865 PkgRef := '';
866 NeedCPT := False;
867 Addend := 0;
868 {LastCosigner & LastCosignerName aren't cleared because they're used as default for next note.}
869 //kt 8/09 Lines := nil;
870 if Assigned (Lines) then Lines.Clear; //kt 8/09
871 PRF_IEN := 0;
872 ActionIEN := '';
873 end;
874 // clear the editing controls (also clear the new labels?)
875 txtSubject.Text := '';
876 if memNewNote <> nil then memNewNote.Clear; //CQ7012 Added test for nil
877 HTMLEditor.Clear; //kt 8/09
878 HTMLViewer.Clear; //kt 8/09
879 FHTMLEditMode := emNone; //kt 8/09
880 timAutoSave.Enabled := False;
881 // clear the PCE object for editing
882 uPCEEdit.Clear;
883 // set the tracking variables to initial state
884 EditingIndex := -1;
885 FChanged := False;
886end;
887
888procedure TfrmNotes.ShowPCEControls(ShouldShow: Boolean);
889begin
890 sptVert.Visible := ShouldShow;
891 memPCEShow.Visible := ShouldShow;
892 if(ShouldShow) then
893 sptVert.Top := memPCEShow.Top - sptVert.Height;
894 if (vmHTML in FViewMode) then begin //kt 8/09
895 HTMLViewer.Invalidate; //kt 8/09
896 end else begin //kt 8/09
897 memNote.Invalidate;
898 end; //kt 8/09
899end;
900
901procedure TfrmNotes.DisplayPCE;
902{ displays PCE information if appropriate & enables/disabled editing of PCE data }
903var
904 EnableList, ShowList: TDrawers;
905 VitalStr: TStringlist;
906 NoPCE: boolean;
907 ActionSts: TActionRec;
908 AnIEN: integer;
909begin
910 memPCEShow.Clear;
911 with lstNotes do if ItemIndex = EditingIndex then
912 begin
913 with uPCEEdit do
914 begin
915 AddStrData(memPCEShow.Lines);
916 NoPCE := (memPCEShow.Lines.Count = 0);
917 VitalStr := TStringList.create;
918 try
919 GetVitalsFromDate(VitalStr, uPCEEdit);
920 AddVitalData(VitalStr, memPCEShow.Lines);
921 finally
922 VitalStr.free;
923 end;
924 ShowPCEButtons(TRUE);
925 ShowPCEControls(cmdPCE.Enabled or (memPCEShow.Lines.Count > 0));
926 if(NoPCE and memPCEShow.Visible) then
927 memPCEShow.Lines.Insert(0, TX_NOPCE);
928 memPCEShow.SelStart := 0;
929
930 if(InteractiveRemindersActive) then
931 begin
932 if(GetReminderStatus = rsNone) then
933 EnableList := [odTemplates]
934 else
935 EnableList := [odTemplates, odReminders];
936 ShowList := [odTemplates, odReminders];
937 end
938 else
939 begin
940 EnableList := [odTemplates];
941 ShowList := [odTemplates];
942 end;
943 frmDrawers.DisplayDrawers(TRUE, EnableList, ShowList);
944 end;
945 end else
946 begin
947 ShowPCEButtons(FALSE);
948 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]);
949 AnIEN := lstNotes.ItemIEN;
950 ActOnDocument(ActionSts, AnIEN, 'VIEW');
951 if ActionSts.Success then
952 begin
953// StatusText('Retrieving encounter information...'); <-- original line. //kt 7/19/2007
954 StatusText(DKLangConstW('fNotes_Retrieving_encounter_informationxxx')); //kt added 7/19/2007
955 with uPCEShow do
956 begin
957 NoteDateTime := MakeFMDateTime(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
958 PCEForNote(AnIEN, uPCEEdit);
959 AddStrData(memPCEShow.Lines);
960 NoPCE := (memPCEShow.Lines.Count = 0);
961 VitalStr := TStringList.create;
962 try
963 GetVitalsFromNote(VitalStr, uPCEShow, AnIEN);
964 AddVitalData(VitalStr, memPCEShow.Lines);
965 finally
966 VitalStr.free;
967 end;
968 ShowPCEControls(memPCEShow.Lines.Count > 0);
969 if(NoPCE and memPCEShow.Visible) then
970 memPCEShow.Lines.Insert(0, TX_NOPCE);
971 memPCEShow.SelStart := 0;
972 end;
973 StatusText('');
974 end
975 else
976 ShowPCEControls(FALSE);
977 end; {if ItemIndex}
978end;
979
980{ supporting calls for writing notes }
981
982function TfrmNotes.GetTitleText(AnIndex: Integer): string;
983{ returns non-tabbed text for the title of a note given the ItemIndex in lstNotes }
984begin
985 with lstNotes do
986 Result := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(Items[AnIndex], U, 3))) +
987 ' ' + Piece(Items[AnIndex], U, 2) + ', ' + Piece(Items[AnIndex], U, 6) + ', ' +
988 Piece(Piece(Items[AnIndex], U, 5), ';', 2)
989end;
990
991function TfrmNotes.LacksRequiredForCreate: Boolean;
992{ determines if the fields required to create the note are present }
993var
994 CurTitle: Integer;
995begin
996 Result := False;
997 with FEditNote do
998 begin
999 if Title <= 0 then Result := True;
1000 if Author <= 0 then Result := True;
1001 if DateTime <= 0 then Result := True;
1002 if IsConsultTitle(Title) and (PkgIEN = 0) then Result := True;
1003 if IsSurgeryTitle(Title) and (PkgIEN = 0) then Result := True;
1004 if IsPRFTitle(Title) and (PRF_IEN = 0) and (not DocType = TYP_ADDENDUM) then Result := True;
1005 if (DocType = TYP_ADDENDUM) then
1006 begin
1007 if AskCosignerForDocument(Addend, Author) and (Cosigner <= 0) then Result := True;
1008 end else
1009 begin
1010 if Title > 0 then CurTitle := Title else CurTitle := DocType;
1011 if AskCosignerForTitle(CurTitle, Author, DateTime) and (Cosigner <= 0) then Result := True;
1012 end;
1013 end;
1014end;
1015
1016function TfrmNotes.VerifyNoteTitle: Boolean;
1017const
1018 VNT_UNKNOWN = 0;
1019 VNT_NO = 1;
1020 VNT_YES = 2;
1021var
1022 AParam: string;
1023begin
1024 if FVerifyNoteTitle = VNT_UNKNOWN then
1025 begin
1026 AParam := GetUserParam('ORWOR VERIFY NOTE TITLE');
1027 if AParam = '1' then FVerifyNoteTitle := VNT_YES else FVerifyNoteTitle := VNT_NO;
1028 end;
1029 Result := FVerifyNoteTitle = VNT_YES;
1030end;
1031
1032procedure TfrmNotes.SetSubjectVisible(ShouldShow: Boolean);
1033{ hide/show subject & resize panel accordingly - leave 6 pixel margin above memNewNote }
1034begin
1035 if ShouldShow then
1036 begin
1037 lblSubject.Visible := True;
1038 txtSubject.Visible := True;
1039 pnlFields.Height := txtSubject.Top + txtSubject.Height + 6;
1040 end else
1041 begin
1042 lblSubject.Visible := False;
1043 txtSubject.Visible := False;
1044 pnlFields.Height := lblVisit.Top + lblVisit.Height + 6;
1045 end;
1046end;
1047
1048{ consult request and note locking }
1049
1050function TfrmNotes.LockConsultRequest(AConsult: Integer): Boolean;
1051{ returns true if consult successfully locked }
1052begin
1053 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1054 // *** I'm not sure about the FOrderID field - if the user is editing one note and
1055 // deletes another, FOrderID will be for editing note, then delete note, then null
1056 Result := True;
1057 FOrderID := GetConsultOrderIEN(AConsult);
1058 if (FOrderID <> '') and (FOrderID = frmConsults.OrderID) then
1059 begin
1060 InfoBox(TX_ORDER_LOCKED, TC_ORDER_LOCKED, MB_OK);
1061 Result := False;
1062 Exit;
1063 end;
1064 if (FOrderId <> '') then
1065 if not OrderCanBeLocked(FOrderID) then Result := False;
1066 if not Result then FOrderID := '';
1067end;
1068
1069function TfrmNotes.LockConsultRequestAndNote(AnIEN: Int64): Boolean;
1070{ returns true if note and associated request successfully locked }
1071var
1072 AConsult: Integer;
1073 LockMsg, x: string;
1074begin
1075 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1076 Result := True;
1077 AConsult := 0;
1078 if frmConsults.ActiveEditOf(AnIEN) then
1079 begin
1080 InfoBox(TX_ORDER_LOCKED, TC_ORDER_LOCKED, MB_OK);
1081 Result := False;
1082 Exit;
1083 end;
1084 if Changes.Exist(CH_DOC, IntToStr(AnIEN)) then Exit; // already locked
1085 // try to lock the consult request first, if there is one
1086 if IsConsultTitle(TitleForNote(AnIEN)) then
1087 begin
1088 x := GetPackageRefForNote(lstNotes.ItemIEN);
1089 AConsult := StrToIntDef(Piece(x, ';', 1), 0);
1090 Result := LockConsultRequest(AConsult);
1091 end;
1092 // now try to lock the note
1093 if Result then
1094 begin
1095 LockDocument(AnIEN, LockMsg);
1096 if LockMsg <> '' then
1097 begin
1098 Result := False;
1099 // if can't lock the note, unlock the consult request that was just locked
1100 if AConsult > 0 then
1101 begin
1102 UnlockOrderIfAble(FOrderID);
1103 FOrderID := '';
1104 end;
1105 InfoBox(LockMsg, TC_NO_LOCK, MB_OK);
1106 end;
1107 end;
1108end;
1109
1110procedure TfrmNotes.UnlockConsultRequest(ANote: Int64; AConsult: Integer = 0);
1111(*var
1112 x: string;*)
1113begin
1114(* if (AConsult = 0) and IsConsultTitle(TitleForNote(ANote)) then
1115 begin
1116 x := GetPackageRefForNote(ANote);
1117 AConsult := StrToIntDef(Piece(x, ';', 1), 0);
1118 end;
1119 if AConsult = 0 then Exit;*)
1120 if AConsult = 0 then AConsult := GetConsultIENForNote(ANote);
1121 if AConsult <= 0 then exit;
1122 FOrderID := GetConsultOrderIEN(AConsult);
1123 UnlockOrderIfAble(FOrderID);
1124 FOrderID := '';
1125end;
1126
1127function TfrmNotes.ActiveEditOf(AnIEN: Int64; ARequest: integer): Boolean;
1128begin
1129 Result := False;
1130 if EditingIndex < 0 then Exit;
1131 if lstNotes.GetIEN(EditingIndex) = AnIEN then
1132 begin
1133 Result := True;
1134 Exit;
1135 end;
1136 with FEditNote do if (PkgIEN = ARequest) and (PkgPtr = PKG_CONSULTS) then Result := True;
1137end;
1138
1139{ create, edit & save notes }
1140
1141procedure TfrmNotes.InsertNewNote(IsIDChild: boolean; AnIDParent: integer);
1142{ creates the editing context for a new progress note & inserts stub into top of view list }
1143var
1144 EnableAutosave, HaveRequired: Boolean;
1145 CreatedNote: TCreatedDoc;
1146 TmpBoilerPlate: TStringList;
1147 tmpNode: TTreeNode;
1148 x, WhyNot, DocInfo: string;
1149 tempPos : integer; //kt 6-1-05
1150 Mode : TViewModeSet; //kt 8/09
1151 BoilerplateIsHTML : boolean;//kt 8/09
1152
1153begin
1154 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1155 if frmFrame.Timedout then Exit;
1156
1157 FNewIDChild := IsIDChild;
1158 EnableAutosave := FALSE;
1159 TmpBoilerPlate := nil;
1160 try
1161 ClearEditControls;
1162 FEditNote.Lines.Free; //(done d/t full wipe-out on line below} //kt 8/09
1163 FillChar(FEditNote, SizeOf(FEditNote), 0); //v15.7
1164 FEditNote.Lines := TStringList.Create; //Freed in Destructor //kt 8/09
1165 with FEditNote do
1166 begin
1167 DocType := TYP_PROGRESS_NOTE;
1168 IsNewNote := True;
1169 Title := DfltNoteTitle;
1170 TitleName := DfltNoteTitleName;
1171 if IsIDChild and (not CanTitleBeIDChild(Title, WhyNot)) then
1172 begin
1173 Title := 0;
1174 TitleName := '';
1175 end;
1176 if IsSurgeryTitle(Title) then // Don't want surgery title sneaking in unchallenged
1177 begin
1178 Title := 0;
1179 TitleName := '';
1180 end;
1181 //DateTime := FMNow; //kt 6-1-05
1182 DateTime := Encounter.DateTime; //kt 6-1-05
1183 //kt begin changes -------------- 6-1-05
1184 if LastAuthor<>0 then begin
1185 Author := LastAuthor;
1186 AuthorName := LastAuthorName;
1187 end else begin
1188 Author := User.DUZ;
1189 AuthorName := User.Name;
1190 end;
1191 //kt 6-1-05 Author := User.DUZ;
1192 //kt 6-1-05 AuthorName := User.Name;
1193 //kt end changes -------------- 6-1-05
1194 Location := Encounter.Location;
1195 LocationName := Encounter.LocationName;
1196 VisitDate := Encounter.DateTime;
1197 if IsIDChild then
1198 IDParent := AnIDParent
1199 else
1200 IDParent := 0;
1201 // Cosigner & PkgRef, if needed, will be set by fNoteProps
1202 end;
1203 // check to see if interaction necessary to get required fields
1204 GetUnresolvedConsultsInfo;
1205 if LacksRequiredForCreate or VerifyNoteTitle or uUnresolvedConsults.UnresolvedConsultsExist
1206 then HaveRequired := ExecuteNoteProperties(FEditNote, CT_NOTES, IsIDChild, FNewIDChild, '', 0)
1207 else HaveRequired := True;
1208 //kt begin addition 6-1-05 -----------------
1209 LastAuthor := FEditNote.Author;
1210 LastAuthorName := FEditNote.AuthorName;
1211 tempPos := Pos(' - ',LastAuthorName);
1212 if tempPos>0 then begin //trim off title, e.g. "Jones,John - Physician
1213 LastAuthorName:=UpperCase(Trim(MidStr(LastAuthorName,1,tempPos)));
1214 end;
1215 //kt end addition 6-1-05 -----------------
1216 // lock the consult request if there is a consult
1217 with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then HaveRequired := LockConsultRequest(PkgIEN);
1218 if HaveRequired then
1219 begin
1220 // set up uPCEEdit for entry of new note
1221 uPCEEdit.UseEncounter := True;
1222 uPCEEdit.NoteDateTime := FEditNote.DateTime;
1223 uPCEEdit.PCEForNote(USE_CURRENT_VISITSTR, uPCEShow);
1224 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
1225 // create the note
1226 PutNewNote(CreatedNote, FEditNote);
1227 uPCEEdit.NoteIEN := CreatedNote.IEN;
1228 if CreatedNote.IEN > 0 then LockDocument(CreatedNote.IEN, CreatedNote.ErrorText);
1229 if CreatedNote.ErrorText = '' then
1230 begin
1231 //x := $$RESOLVE^TIUSRVLO formatted string
1232 //7348^Note Title^3000913^NERD, YOURA (N0165)^1329;Rich Vertigan;VERTIGAN,RICH^8E REHAB MED^complete^Adm: 11/05/98;2981105.095547^ ;^^0^^^2
1233 with FEditNote do
1234 begin
1235 x := IntToStr(CreatedNote.IEN) + U + TitleName + U + FloatToStr(FEditNote.DateTime) + U +
1236 Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
1237 U + U + U + U + U + U + U;
1238 //Link Note to PRF Action
1239 if PRF_IEN <> 0 then
1240 if sCallV('TIU LINK TO FLAG', [CreatedNote.IEN,PRF_IEN,ActionIEN,Patient.DFN]) = '0' then
1241 ShowMessage('TIU LINK TO FLAG: FAILED');
1242 end;
1243
1244 lstNotes.Items.Insert(0, x);
1245 uChanging := True;
1246 tvNotes.Items.BeginUpdate;
1247 if IsIDChild then
1248 begin
1249 tmpNode := tvNotes.FindPieceNode(IntToStr(AnIDParent), 1, U, tvNotes.Items.GetFirstNode);
1250 tmpNode.ImageIndex := IMG_IDNOTE_OPEN;
1251 tmpNode.SelectedIndex := IMG_IDNOTE_OPEN;
1252 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
1253 tmpNode.ImageIndex := IMG_ID_CHILD;
1254 tmpNode.SelectedIndex := IMG_ID_CHILD;
1255 end
1256 else
1257 begin
1258// tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'New Note in Progress', <-- original line. //kt 7/19/2007
1259 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, DKLangConstW('fNotes_New_Note_in_Progress'), //kt added 7/19/2007
1260 MakeNoteTreeObject('NEW^New Note in Progress^^^^^^^^^^^%^0'));
1261 TORTreeNode(tmpNode).StringData := 'NEW^New Note in Progress^^^^^^^^^^^%^0';
1262 tmpNode.ImageIndex := IMG_TOP_LEVEL;
1263 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
1264 tmpNode.ImageIndex := IMG_SINGLE;
1265 tmpNode.SelectedIndex := IMG_SINGLE;
1266 end;
1267 tmpNode.StateIndex := IMG_NO_IMAGES;
1268 TORTreeNode(tmpNode).StringData := x;
1269 tvNotes.Selected := tmpNode;
1270 tvNotes.Items.EndUpdate;
1271 uChanging := False;
1272 Changes.Add(CH_DOC, IntToStr(CreatedNote.IEN), GetTitleText(0), '', CH_SIGN_YES);
1273 lstNotes.ItemIndex := 0;
1274 EditingIndex := 0;
1275 SetSubjectVisible(AskSubjectForNotes);
1276 if not assigned(TmpBoilerPlate) then
1277 TmpBoilerPlate := TStringList.Create;
1278 LoadBoilerPlate(TmpBoilerPlate, FEditNote.Title);
1279 FChanged := False;
1280 cmdChangeClick(Self); // will set captions, sign state for Changes
1281 Mode := [vmEdit] + [vmHTML_MODE[fOptionsNotes.DefaultEditHTMLMode]]; //kt 8/09
1282 SetDisplayToHTMLvsText(Mode, nil, VIEW_ACTIVATE_ONLY); // kt 8/09
1283 lstNotesClick(Self); // will make pnlWrite visible
1284 if timAutoSave.Interval <> 0 then EnableAutosave := TRUE;
1285 //kt 6/3/09 original --> if txtSubject.Visible then txtSubject.SetFocus else memNewNote.SetFocus;
1286 if txtSubject.Visible then begin //kt 8/09
1287 txtSubject.SetFocus; //kt 8/09
1288 end else begin //kt 8/09
1289 SetEditorFocus; //kt memNewNote.SetFocus; //kt 8/09
1290 end; //kt 8/09
1291 end else
1292 begin
1293 // if note creation failed or failed to get note lock (both unlikely), unlock consult
1294 with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then UnlockConsultRequest(0, PkgIEN);
1295 InfoBox(CreatedNote.ErrorText, TX_CREATE_ERR, MB_OK);
1296 HaveRequired := False;
1297 end; {if CreatedNote.IEN}
1298 end; {if HaveRequired}
1299 if not HaveRequired then
1300 begin
1301 ClearEditControls;
1302 ShowPCEButtons(False);
1303 end;
1304 finally
1305 if assigned(TmpBoilerPlate) then
1306 begin
1307 DocInfo := MakeXMLParamTIU(IntToStr(CreatedNote.IEN), FEditNote);
1308 ExecuteTemplateOrBoilerPlate(TmpBoilerPlate, FEditNote.Title, ltTitle, Self, 'Title: ' + FEditNote.TitleName, DocInfo);
1309 //kt original --> memNewNote.Lines.Assign(TmpBoilerPlate);
1310 BoilerplateIsHTML := rHTMLTools.IsHTML(TmpBoilerPlate.Text); //kt 8/09
1311 FEditNote.Lines.Assign(TmpBoilerPlate); //kt 8/09
1312 if not ((vmHTML in FViewMode)) and BoilerplateIsHTML then begin //kt 8/09
1313 FViewMode := FViewMode - [vmText] + [vmHTML]; //kt 8/09
1314 end; //kt 8/09
1315 SetDisplayToHTMLvsText(FViewMode,FEditNote.Lines); //kt 8/09
1316 if (vmHTML in FViewMode) then begin //kt 8/09
1317 HtmlEditor.MoveCaretToEnd; //kt 8/09
1318 Application.ProcessMessages; //kt 8/09
1319 end; //kt 8/09
1320 UpdateNoteAuthor(DocInfo);
1321 TmpBoilerPlate.Free;
1322 end;
1323 if EnableAutosave then // Don't enable autosave until after dialog fields have been resolved
1324 timAutoSave.Enabled := True;
1325 end;
1326 frmNotes.pnlWriteResize(Self);
1327end;
1328
1329
1330procedure TfrmNotes.SetEditorFocus;
1331//kt added function 8/09
1332begin
1333 try
1334 if (vmHTML in FViewMode) then begin //kt 8/09
1335 HtmlEditor.SetFocus; //kt 8/09
1336 end else begin //kt 8/09
1337 memNewNote.SetFocus;
1338 end; //kt 8/09
1339 except
1340 on E: Exception do begin
1341 // ignore error. Info in E
1342 end;
1343 end;
1344end;
1345
1346
1347procedure TfrmNotes.InsertAddendum;
1348{ sets up fields of pnlWrite to write an addendum for the selected note }
1349const
1350 AS_ADDENDUM = True;
1351 IS_ID_CHILD = False;
1352var
1353 HaveRequired: Boolean;
1354 CreatedNote: TCreatedDoc;
1355 tmpNode: TTreeNode;
1356 x: string;
1357begin
1358 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1359 ClearEditControls;
1360 with FEditNote do
1361 begin
1362 DocType := TYP_ADDENDUM;
1363 IsNewNote := False;
1364 Title := TitleForNote(lstNotes.ItemIEN);
1365 TitleName := Piece(lstNotes.Items[lstNotes.ItemIndex], U, 2);
1366 if Copy(TitleName,1,1) = '+' then TitleName := Copy(TitleName, 3, 199);
1367 DateTime := FMNow;
1368 Author := User.DUZ;
1369 AuthorName := User.Name;
1370 x := GetPackageRefForNote(lstNotes.ItemIEN);
1371 if Piece(x, U, 1) <> '-1' then
1372 begin
1373 PkgRef := GetPackageRefForNote(lstNotes.ItemIEN);
1374 PkgIEN := StrToIntDef(Piece(PkgRef, ';', 1), 0);
1375 PkgPtr := Piece(PkgRef, ';', 2);
1376 end;
1377 Addend := lstNotes.ItemIEN;
1378 //Lines := memNewNote.Lines;
1379 // Cosigner, if needed, will be set by fNoteProps
1380 // Location info will be set after the encounter is loaded
1381 end;
1382 // check to see if interaction necessary to get required fields
1383 if LacksRequiredForCreate
1384 then HaveRequired := ExecuteNoteProperties(FEditNote, CT_NOTES, IS_ID_CHILD, False, '', 0)
1385 else HaveRequired := True;
1386 // lock the consult request if there is a consult
1387 if HaveRequired then
1388 with FEditNote do
1389 if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then HaveRequired := LockConsultRequest(PkgIEN);
1390 if HaveRequired then
1391 begin
1392 uPCEEdit.NoteDateTime := FEditNote.DateTime;
1393 uPCEEdit.PCEForNote(FEditNote.Addend, uPCEShow);
1394 FEditNote.Location := uPCEEdit.Location;
1395 FEditNote.LocationName := ExternalName(uPCEEdit.Location, 44);
1396 FEditNote.VisitDate := uPCEEdit.DateTime;
1397 PutAddendum(CreatedNote, FEditNote, FEditNote.Addend);
1398 uPCEEdit.NoteIEN := CreatedNote.IEN;
1399 if CreatedNote.IEN > 0 then LockDocument(CreatedNote.IEN, CreatedNote.ErrorText);
1400 if CreatedNote.ErrorText = '' then
1401 begin
1402 with FEditNote do
1403 begin
1404 x := IntToStr(CreatedNote.IEN) + U + 'Addendum to ' + TitleName + U + FloatToStr(DateTime) + U +
1405 Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
1406 U + U + U + U + U + U + U;
1407 end;
1408
1409 lstNotes.Items.Insert(0, x);
1410 uChanging := True;
1411 tvNotes.Items.BeginUpdate;
1412// tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'New Addendum in Progress', <-- original line. //kt 7/19/2007
1413 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, DKLangConstW('fNotes_New_Addendum_in_Progress'), //kt added 7/19/2007
1414 MakeNoteTreeObject('ADDENDUM^New Addendum in Progress^^^^^^^^^^^%^0'));
1415 TORTreeNode(tmpNode).StringData := 'ADDENDUM^New Addendum in Progress^^^^^^^^^^^%^0';
1416 tmpNode.ImageIndex := IMG_TOP_LEVEL;
1417 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
1418 TORTreeNode(tmpNode).StringData := x;
1419
1420 tmpNode.ImageIndex := IMG_ADDENDUM;
1421 tmpNode.SelectedIndex := IMG_ADDENDUM;
1422 tvNotes.Selected := tmpNode;
1423 tvNotes.Items.EndUpdate;
1424 uChanging := False;
1425 Changes.Add(CH_DOC, IntToStr(CreatedNote.IEN), GetTitleText(0), '', CH_SIGN_YES);
1426 lstNotes.ItemIndex := 0;
1427 EditingIndex := 0;
1428 SetSubjectVisible(AskSubjectForNotes);
1429 cmdChangeClick(Self); // will set captions, sign state for Changes
1430 lstNotesClick(Self); // will make pnlWrite visible
1431 if timAutoSave.Interval <> 0 then timAutoSave.Enabled := True;
1432 SetEditorFocus; //kt memNewNote.SetFocus; //kt 8/09
1433 end else
1434 begin
1435 // if note creation failed or failed to get note lock (both unlikely), unlock consult
1436 with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then UnlockConsultRequest(0, PkgIEN);
1437 InfoBox(CreatedNote.ErrorText, TX_CREATE_ERR, MB_OK);
1438 HaveRequired := False;
1439 end; {if CreatedNote.IEN}
1440 end; {if HaveRequired}
1441 if not HaveRequired then ClearEditControls;
1442end;
1443
1444procedure TfrmNotes.LoadForEdit;
1445{ retrieves an existing note and places the data in the fields of pnlWrite }
1446var
1447 tmpNode: TTreeNode;
1448 x: string;
1449 Mode : TViewModeSet; //kt
1450
1451begin
1452 ClearEditControls;
1453 if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
1454 EditingIndex := lstNotes.ItemIndex;
1455 Changes.Add(CH_DOC, lstNotes.ItemID, GetTitleText(EditingIndex), '', CH_SIGN_YES);
1456 GetNoteForEdit(FEditNote, lstNotes.ItemIEN);
1457 Mode := [vmEdit] + [vmHTML_MODE[IsHTML(FEditNote.Lines) or (vmHTML in FViewMode)]]; //kt 8/09
1458 SetDisplayToHTMLvsText(Mode,FEditNote.Lines); //kt 8/09
1459 //kt memNewNote.Lines.Assign(FEditNote.Lines); //kt 8/09
1460 FChanged := False;
1461 if FEditNote.Title = TYP_ADDENDUM then
1462 begin
1463 FEditNote.DocType := TYP_ADDENDUM;
1464 FEditNote.TitleName := Piece(lstNotes.Items[lstNotes.ItemIndex], U, 2);
1465 if Copy(FEditNote.TitleName,1,1) = '+' then FEditNote.TitleName := Copy(FEditNote.TitleName, 3, 199);
1466// if CompareText(Copy(FEditNote.TitleName, 1, 8), 'Addendum') <> 0 <-- original line. //kt 7/19/2007
1467 if CompareText(Copy(FEditNote.TitleName, 1, 8), DKLangConstW('fNotes_Addendum')) <> 0 //kt added 7/19/2007
1468// then FEditNote.TitleName := FEditNote.TitleName + 'Addendum to '; <-- original line. //kt 7/19/2007
1469 then FEditNote.TitleName := FEditNote.TitleName + DKLangConstW('fNotes_Addendum_to'); //kt added 7/19/2007
1470 end;
1471
1472 uChanging := True;
1473 tvNotes.Items.BeginUpdate;
1474
1475 tmpNode := tvNotes.FindPieceNode('EDIT', 1, U, nil);
1476 if tmpNode = nil then
1477 begin
1478// tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'Note being edited', <-- original line. //kt 7/19/2007
1479 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, DKLangConstW('fNotes_Note_being_edited'), //kt added 7/19/2007
1480 MakeNoteTreeObject('EDIT^Note being edited^^^^^^^^^^^%^0'));
1481 TORTreeNode(tmpNode).StringData := 'EDIT^Note being edited^^^^^^^^^^^%^0';
1482 end
1483 else
1484 tmpNode.DeleteChildren;
1485 x := lstNotes.Items[lstNotes.ItemIndex];
1486 tmpNode.ImageIndex := IMG_TOP_LEVEL;
1487 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(x), MakeNoteTreeObject(x));
1488 TORTreeNode(tmpNode).StringData := x;
1489//if CompareText(Copy(FEditNote.TitleName, 1, 8), 'Addendum') <> 0 then <-- original line. //kt 7/19/2007
1490 if CompareText(Copy(FEditNote.TitleName, 1, 8), DKLangConstW('fNotes_Addendum')) <> 0 then //kt added 7/19/2007
1491 tmpNode.ImageIndex := IMG_SINGLE
1492 else
1493 tmpNode.ImageIndex := IMG_ADDENDUM;
1494 tmpNode.SelectedIndex := tmpNode.ImageIndex;
1495 tvNotes.Selected := tmpNode;
1496 tvNotes.Items.EndUpdate;
1497 uChanging := False;
1498
1499 uPCEEdit.NoteDateTime := MakeFMDateTime(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
1500 uPCEEdit.PCEForNote(lstNotes.ItemIEN, uPCEShow);
1501 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
1502 txtSubject.Text := FEditNote.Subject;
1503 SetSubjectVisible(AskSubjectForNotes);
1504 cmdChangeClick(Self); // will set captions, sign state for Changes
1505 lstNotesClick(Self); // will make pnlWrite visible
1506 if timAutoSave.Interval <> 0 then timAutoSave.Enabled := True;
1507 SetEditorFocus; //kt memNewNote.SetFocus; //kt 8/09
1508end;
1509
1510procedure TfrmNotes.SaveEditedNote(var Saved: Boolean);
1511{ validates fields and sends the updated note to the server }
1512var
1513 UpdatedNote: TCreatedDoc;
1514 x: string;
1515 EmptyNote : boolean; //kt
1516
1517begin
1518 SetupVars; //kt added 7/19/2007 to replace constants with vars.
1519 Saved := False;
1520 if not (vmHTML in FViewMode) then begin //kt 8/09
1521 EmptyNote := (memNewNote.GetTextLen = 0) //kt 8/09
1522 or (not ContainsVisibleChar(memNewNote.Text)); //kt 8/09
1523 end else begin //kt 8/09
1524 EmptyNote := (HtmlEditor.GetTextLen = 0) //kt 8/09
1525 or (not ContainsVisibleChar(HtmlEditor.Text)); //kt 8/09
1526 end; //kt 8/09
1527 //kt 8/09 if (memNewNote.GetTextLen = 0) or (not ContainsVisibleChar(memNewNote.Text)) then
1528 //kt 8/09 begin
1529 if EmptyNote then begin
1530 lstNotes.ItemIndex := EditingIndex;
1531 x := lstNotes.ItemID;
1532 uChanging := True;
1533 tvNotes.Selected := tvNotes.FindPieceNode(x, 1, U, tvNotes.Items.GetFirstNode);
1534 uChanging := False;
1535 tvNotesChange(Self, tvNotes.Selected);
1536 if FSilent or
1537 ((not FSilent) and
1538 (InfoBox(GetTitleText(EditingIndex) + TX_EMPTY_NOTE, TC_EMPTY_NOTE, MB_YESNO) = IDYES))
1539 then
1540 begin
1541 FConfirmed := True;
1542 mnuActDeleteClick(Self);
1543 Saved := True;
1544 FDeleted := True;
1545 end
1546 else
1547 FConfirmed := False;
1548 Exit;
1549 end;
1550 //ExpandTabsFilter(memNewNote.Lines, TAB_STOP_CHARS);
1551 if FEditNote.Lines = nil then FEditNote.Lines := TStringList.Create; //kt
1552 //kt 8/09 FEditNote.Lines := memNewNote.Lines;
1553 if (vmHTML in FViewMode) then begin //kt 8/09
1554 SplitToArray(WrapHTML(HtmlEditor.HTMLText), FEditNote.Lines); //kt 8/09
1555 rHTMLTools.InsertSubs(FEditNote.Lines); //kt 4/21/10
1556 end else begin //kt 8/09
1557 FEditNote.Lines.Assign(memNewNote.Lines); //kt 8/09
1558 end; //kt 8/09
1559 //FEditNote.Lines:= SetLinesTo74ForSave(memNewNote.Lines, Self);
1560 FEditNote.Subject := txtSubject.Text;
1561 FEditNote.NeedCPT := uPCEEdit.CPTRequired;
1562 timAutoSave.Enabled := False;
1563 try
1564 PutEditedNote(UpdatedNote, FEditNote, lstNotes.GetIEN(EditingIndex));
1565 finally
1566 timAutoSave.Enabled := True;
1567 end;
1568 // there's no unlocking here since the note is still in Changes after a save
1569 if UpdatedNote.IEN > 0 then
1570 begin
1571 if lstNotes.ItemIndex = EditingIndex then
1572 begin
1573 EditingIndex := -1;
1574 lstNotesClick(Self);
1575 end;
1576 EditingIndex := -1; // make sure EditingIndex reset even if not viewing edited note
1577 Saved := True;
1578 FNewIDChild := False;
1579 FChanged := False;
1580 HTMLEditor.KeyStruck := false; //kt
1581 end else
1582 begin
1583 if not FSilent then
1584 InfoBox(TX_SAVE_ERROR1 + UpdatedNote.ErrorText + TX_SAVE_ERROR2, TC_SAVE_ERROR, MB_OK or MB_ICONWARNING);
1585 end;
1586end;
1587
1588procedure TfrmNotes.SaveCurrentNote(var Saved: Boolean);
1589{ called whenever a note should be saved - uses IEN to call appropriate save logic }
1590begin
1591 if EditingIndex < 0 then Exit;
1592 SaveEditedNote(Saved);
1593end;
1594
1595{ Form events ------------------------------------------------------------------------------ }
1596
1597procedure TfrmNotes.FormCreate(Sender: TObject);
1598var
1599 CacheDir : AnsiString; //kt 9-05
1600begin
1601 inherited;
1602 //kt --- Begin Modification 9-2005, 8/09 -------------
1603 fOptionsNotes.Loaded; //ported from version .15 1-27-10
1604 CacheDir := ExtractFilePath(ParamStr(0))+ 'Cache'; //kt 9-05
1605 if not DirectoryExists(CacheDir) then CreateDir(CacheDir);
1606 //kt HTMLfilename := CacheDir + '\html_note.html'; //kt 5-05
1607 LastAuthor :=0; //kt 5-05
1608 LastAuthorName:=''; //kt 5-05
1609 DesiredHTMLFontSize := 2; //Used later to downsize during printing.
1610 SetRegHTMLFontSize(DesiredHTMLFontSize); //0=SMALLEST ... 4=LARGEST
1611 //kt Note: On creation, THtmlObj will remember Application.OnMessage. But if
1612 // another object (say a prior THtmlObj) has become active and already
1613 // changed the handler, then there will be a problem. So probably best
1614 // to create them all at once. //kt
1615 HtmlViewer := THtmlObj.Create(pnlHTMLViewer,Application);
1616 HtmlEditor := THtmlObj.Create(pnlHTMLEdit,Application);
1617 TWinControl(HtmlViewer).Parent:=pnlHTMLViewer;
1618 TWinControl(HtmlViewer).Align:=alClient;
1619 HtmlEditor.PrevControl := cmdPCE;
1620 HtmlEditor.NextControl := cmdChange;
1621 //Note: A 'loaded' function will initialize the THtmlObj's, but it can't be
1622 // done until after this constructor is done, and this TfrmNotes has been
1623 // assigned a parent. So done elsewhere.
1624 HtmlViewer.PopupMenu := popNoteMemo;
1625 TWinControl(HtmlEditor).Parent:=pnlHTMLEdit;
1626 TWinControl(HtmlEditor).Align:=alClient;
1627 HtmlEditor.PopupMenu := popNoteMemo;
1628 cbFontNames.Items.Assign(Screen.Fonts);
1629 FViewMode := [vmView,vmText];
1630 FHTMLEditMode := emNone;
1631 HTMLViewer.BackgroundColor := ReadOnlyColor;
1632 //kt --- End Modification 9-2005, 8/09 ------
1633 PageID := CT_NOTES;
1634 memNote.Color := ReadOnlyColor;
1635 memPCEShow.Color := ReadOnlyColor;
1636 lblNewTitle.Color := ReadOnlyColor;
1637 EditingIndex := -1;
1638 FEditNote.LastCosigner := 0;
1639 FEditNote.LastCosignerName := '';
1640 FLastNoteID := '';
1641 frmDrawers := TfrmDrawers.CreateDrawers(Self, pnlDrawers, [],[]);
1642 frmDrawers.Align := alBottom;
1643 frmDrawers.RichEditControl := memNewNote;
1644 frmDrawers.HTMLEditControl := HtmlEditor; //kt 8/09
1645 frmDrawers.HTMLModeSwitcher := SetHTMLEditMode; //kt 8/09
1646 frmDrawers.NewNoteButton := cmdNewNote;
1647 frmDrawers.Splitter := splDrawers;
1648 frmDrawers.DefTempPiece := 1;
1649 tvNotes.Images := dmodShared.imgNotes;
1650 tvNotes.StateImages := dmodShared.imgImages;
1651 lvNotes.StateImages := dmodShared.imgImages;
1652 lvNotes.SmallImages := dmodShared.imgNotes;
1653 FImageFlag := TBitmap.Create;
1654 FDocList := TStringList.Create;
1655 TAccessibleTreeView.WrapControl(tvNotes);
1656 RestoreRegHTMLFontSize; //kt, elh 8/09
1657end;
1658
1659procedure TfrmNotes.pnlRightResize(Sender: TObject);
1660{ memNote (TRichEdit) doesn't repaint appropriately unless it's parent panel is refreshed }
1661begin
1662 inherited;
1663 pnlRight.Refresh;
1664 if (vmHTML in FViewMode) then begin //kt 8/09
1665 HTMLViewer.Repaint; //kt 8/09
1666 end else begin //kt 8/09
1667 memNote.Repaint
1668 end; //kt 8/09
1669end;
1670
1671procedure TfrmNotes.pnlWriteResize(Sender: TObject);
1672const
1673 LEFT_MARGIN = 4;
1674begin
1675 inherited;
1676 //kt NOTE: I don't know how to do the equivalent for HTML. Actually, I don't think it applies.
1677 LimitEditWidth(memNewNote, MAX_PROGRESSNOTE_WIDTH - 1);
1678
1679 //CQ7012 Added test for nil
1680 if memNewNote <> nil then
1681 memNewNote.Constraints.MinWidth := TextWidthByFont(memNewNote.Font.Handle, StringOfChar('X', MAX_PROGRESSNOTE_WIDTH)) + (LEFT_MARGIN * 2) + ScrollBarWidth;
1682 //CQ7012 Added test for nil
1683 if (Self <> nil) and (pnlLeft <> nil) and (pnlWrite <> nil) and (sptHorz <> nil) then
1684 pnlLeft.Width := self.ClientWidth - pnlWrite.Width - sptHorz.Width;
1685end;
1686
1687{ Left panel (selector) events ------------------------------------------------------------- }
1688
1689procedure TfrmNotes.lstNotesClick(Sender: TObject);
1690{ loads the text for the selected note or displays the editing panel for the selected note }
1691var
1692 Note : TStrings; //kt 6/09. Will be pointer to FViewNote, or FEditNote.Lines
1693 Editing : boolean; //kt 8/09
1694 Mode : TViewModeSet; //kt 8/09
1695 IsHTML : boolean; //kt 8/09
1696
1697begin
1698 inherited;
1699 //kt 8/09 with lstNotes do if ItemIndex = -1 then Exit
1700 //kt 8/09 else if ItemIndex = EditingIndex then
1701
1702 with lstNotes do begin //kt 8/09
1703 if ItemIndex = -1 then Exit; //kt 8/09
1704 Editing := (ItemIndex = EditingIndex); //kt 8/09
1705 if Editing then begin //kt 8/09
1706 if FEditNote.Lines = nil then FEditNote.Lines := TStringList.Create; //kt 8/09
1707 Note := FEditNote.Lines; //kt 8/09
1708 mnuViewDetail.Enabled := False;
1709 if (FEditNote.IDParent <> 0) and (not FNewIDChild) then
1710 mnuActChange.Enabled := False
1711 else
1712 mnuActChange.Enabled := True;
1713 mnuActLoadBoiler.Enabled := True;
1714 UpdateReminderFinish;
1715 Mode := [vmEdit] + [vmHTML_MODE[(FHTMLEditMode=emHTML)]]; //kt 8/09
1716 SetDisplayToHTMLvsText(Mode,FEditNote.Lines,VIEW_ACTIVATE_ONLY); //kt 8/09
1717 FWarmedUp := true; //kt 8/09
1718 end else begin
1719 // StatusText('Retrieving selected progress note...'); <-- original line. //kt 7/19/2007
1720 StatusText(DKLangConstW('fNotes_Retrieving_selected_progress_notexxx')); //kt added 7/19/2007
1721 Screen.Cursor := crAppStart; //kt changed from crHourGlass; 1/1/05
1722 //kt 8/09 pnlRead.Visible := True;
1723 //kt 8/09 pnlWrite.Visible := False;
1724 UpdateReminderFinish;
1725 lblTitle.Caption := Piece(Piece(Items[ItemIndex], U, 8), ';', 1) + #9 + Piece(Items[ItemIndex], U, 2) + ', ' +
1726 Piece(Items[ItemIndex], U, 6) + ', ' + Piece(Piece(Items[ItemIndex], U, 5), ';', 2) +
1727 ' (' + FormatFMDateTime('mmm dd,yy@hh:nn', MakeFMDateTime(Piece(Items[ItemIndex], U, 3)))
1728 + ')';
1729 lvNotes.Caption := lblTitle.Caption;
1730 //kt 8/09 LoadDocumentText(memNote.Lines, ItemIEN);
1731 LoadDocumentText(FViewNote, ItemIEN); //kt 8/09
1732 Note := FViewNote; //kt 8/09
1733 memNote.SelStart := 0;
1734 mnuViewDetail.Enabled := True;
1735 mnuViewDetail.Checked := False;
1736 mnuActChange.Enabled := False;
1737 mnuActLoadBoiler.Enabled := False;
1738 Screen.Cursor := crDefault;
1739 StatusText('');
1740 IsHTML := rHTMLTools.IsHTML(FViewNote); //kt 8/09
1741 Mode := [vmView] + [vmHTML_MODE[IsHTML]]; //kt 8/09
1742 SetDisplayToHTMLvsText(Mode,FViewNote); //kt 8/09
1743 if not FWarmedUp and IsHTML then begin //kt 8/09
1744 FWarmedUp := true; //kt 8/09
1745 //First HTML page won't display without this... //kt 8/09
1746 SetDisplayToHTMLvsText(Mode,FViewNote); //kt 8/09
1747 end; //kt 8/09
1748 end;
1749 end; //kt 8/09
1750
1751 if(assigned(frmReminderTree)) then frmReminderTree.EnableActions;
1752 //DisplayPCE; //kt 5-31-05 (moved down below)
1753 pnlRight.Refresh;
1754 ProperRepaint(Editing); //kt 8/09
1755 //kt 8/09 memNewNote.Repaint;
1756 //kt 8/09 memNote.Repaint;
1757 NotifyOtherApps(NAE_REPORT, 'TIU^' + lstNotes.ItemID);
1758 frmImages.NewNoteSelected(Editing); //kt 9/05
1759 DisplayPCE; //kt 5-31-05 (move down from above)
1760 BroadcastImages(Note); //kt 8/09
1761
1762 //-----------------------------
1763 //kt RESTORE LATER... frmImages.NewNoteSelected(lstNotes.ItemIndex=EditingIndex); //kt added 9-20-05
1764end;
1765
1766procedure TfrmNotes.ProperRepaint(Editing : Boolean);
1767//kt Added function 8/09
1768begin
1769 if Editing then begin
1770 if (vmHTML in FViewMode) then begin
1771 HtmlEditor.Repaint;
1772 end else begin
1773 memNewNote.Repaint;
1774 end;
1775 end else begin
1776 if (vmHTML in FViewMode) then begin
1777 HtmlViewer.Repaint;
1778 end else begin
1779 memNote.Repaint;
1780 end;
1781 end;
1782 Application.ProcessMessages;
1783end;
1784
1785procedure TfrmNotes.BroadcastImages(Note: TStrings);
1786//kt added function 8/09
1787var
1788 ImageList : TStringList;
1789 i : integer;
1790begin
1791 ImageList := TStringList.Create;
1792 if rHTMLTools.CheckForImageLink(Note, ImageList) then begin
1793 for i:= 0 to ImageList.Count-1 do begin
1794 NotifyOtherApps(NAE_REPORT, 'IMAGE^' + ImageList.Strings[i]);
1795 end;
1796 end;
1797 ImageList.Free;
1798end;
1799
1800function TfrmNotes.EditorHasText : boolean;
1801//kt added function 8/09
1802begin
1803 if (vmHTML in FViewMode) then begin
1804 Result := (HTMLViewer.Text <> '');
1805 end else begin
1806 Result := (memNote.Lines.Count > 0);
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;
2479begin
2480 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2481 inherited;
2482 if lstNotes.ItemIEN = 0 then Exit;
2483 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'DELETE RECORD');
2484 if ShowMsgOn(not ActionSts.Success, ActionSts.Reason, TX_IN_AUTH) then Exit;
2485 ReasonForDelete := SelectDeleteReason(lstNotes.ItemIEN);
2486 if ReasonForDelete = DR_CANCEL then Exit;
2487 // suppress prompt for deletion when called from SaveEditedNote (Sender = Self)
2488 if (Sender <> Self) and (InfoBox(MakeNoteDisplayText(lstNotes.Items[lstNotes.ItemIndex]) + TX_DEL_OK,
2489 TX_DEL_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) then Exit;
2490 // do the appropriate locking
2491 if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
2492 // retraction notification message
2493 if JustifyDocumentDelete(lstNotes.ItemIEN) then
2494 InfoBox(TX_RETRACT, TX_RETRACT_CAP, MB_OK);
2495 SavedDocID := lstNotes.ItemID;
2496 SavedDocIEN := lstNotes.ItemIEN;
2497 if (EditingIndex > -1) and (not FConfirmed) and (lstNotes.ItemIndex <> EditingIndex) and (memNewNote.GetTextLen > 0) then
2498 begin
2499 SaveCurrentNote(Saved);
2500 if not Saved then Exit;
2501 end;
2502 EditingIndex := -1;
2503 FConfirmed := False;
2504 (* if Saved then
2505 begin
2506 EditingIndex := -1;
2507 mnuViewClick(Self);
2508 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2509 end;*)
2510 // remove the note
2511 DeleteSts.Success := True;
2512 x := GetPackageRefForNote(SavedDocIEN);
2513 SaveConsult := StrToIntDef(Piece(x, ';', 1), 0);
2514 AVisitStr := VisitStrForNote(SavedDocIEN);
2515 RemovePCEFromChanges(SavedDocIEN, AVisitStr);
2516 if (SavedDocIEN > 0) and (lstNotes.ItemIEN = SavedDocIEN) then DeleteDocument(DeleteSts, SavedDocIEN, ReasonForDelete);
2517 if not Changes.Exist(CH_DOC, SavedDocID) then UnlockDocument(SavedDocIEN);
2518 Changes.Remove(CH_DOC, SavedDocID); // this will unlock the document if in Changes
2519 UnlockConsultRequest(0, SaveConsult); // note has been deleted, so 1st param = 0
2520 // reset the display now that the note is gone
2521 if DeleteSts.Success then
2522 begin
2523 DeletePCE(AVisitStr); // removes PCE data if this was the only note pointing to it
2524 ClearEditControls;
2525 //ClearPtData; WRONG - fixed in v15.10 - RV
2526 LoadNotes;
2527(* with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2528 if tvNotes.Selected <> nil then tvNotesChange(Self, tvNotes.Selected) else
2529 begin*)
2530 FHTMLEditMode := emNone; //kt 8/09
2531 pnlWrite.Visible := False;
2532 pnlRead.Visible := True;
2533 UpdateReminderFinish;
2534 ShowPCEControls(False);
2535 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]); //FALSE);
2536 ShowPCEButtons(FALSE);
2537 //end; {if ItemIndex}
2538 end {if DeleteSts}
2539 else InfoBox(DeleteSts.Reason, TX_DEL_ERR, MB_OK or MB_ICONWARNING);
2540end;
2541
2542procedure TfrmNotes.mnuActEditClick(Sender: TObject);
2543{ load the selected progress note for editing }
2544var
2545 ActionSts: TActionRec;
2546 ANoteID: string;
2547begin
2548 inherited;
2549 if lstNotes.ItemIndex = EditingIndex then Exit;
2550 ANoteID := lstNotes.ItemID;
2551 if not StartNewEdit(NT_ACT_EDIT_NOTE) then Exit;
2552 //LoadNotes;
2553 with tvNotes do Selected := FindPieceNode(ANoteID, 1, U, Items.GetFirstNode);
2554 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'EDIT RECORD');
2555 if not ActionSts.Success then
2556 begin
2557 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2558 Exit;
2559 end;
2560 LoadForEdit;
2561end;
2562
2563procedure TfrmNotes.mnuActSaveClick(Sender: TObject);
2564{ saves the note that is currently being edited }
2565var
2566 Saved: Boolean;
2567 SavedDocID: string;
2568begin
2569 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2570 inherited;
2571 if EditingIndex > -1 then
2572 begin
2573 SavedDocID := Piece(lstNotes.Items[EditingIndex], U, 1);
2574 FLastNoteID := SavedDocID;
2575 SaveCurrentNote(Saved);
2576 if Saved and (EditingIndex < 0) and (not FDeleted) then
2577 //if Saved then
2578 begin
2579 LoadNotes;
2580 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
2581 end;
2582 end
2583 else InfoBox(TX_NO_NOTE, TX_SAVE_NOTE, MB_OK or MB_ICONWARNING);
2584end;
2585
2586procedure TfrmNotes.mnuActSignClick(Sender: TObject);
2587{ sign the currently selected note, save first if necessary }
2588const
2589 SIG_COSIGN = 'COSIGNATURE';
2590 SIG_SIGN = 'SIGNATURE';
2591var
2592 Saved, NoteUnlocked: Boolean;
2593 ActionType, ESCode, SignTitle: string;
2594 ActionSts, SignSts: TActionRec;
2595 OK: boolean;
2596 SavedDocID, tmpItem: string;
2597 EditingID: string; //v22.12 - RV
2598 tmpNode: TTreeNode;
2599begin
2600 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2601 inherited;
2602(* if lstNotes.ItemIndex = EditingIndex then //v22.12 - RV
2603 begin //v22.12 - RV
2604 SaveCurrentNote(Saved); //v22.12 - RV
2605 if (not Saved) or FDeleted then Exit; //v22.12 - RV
2606 end //v22.12 - RV
2607 else if EditingIndex > -1 then //v22.12 - RV
2608 tmpItem := lstNotes.Items[EditingIndex]; //v22.12 - RV
2609 SavedDocID := lstNotes.ItemID;*) //v22.12 - RV
2610 SavedDocID := lstNotes.ItemID; //v22.12 - RV
2611 FLastNoteID := SavedDocID; //v22.12 - RV
2612 if lstNotes.ItemIndex = EditingIndex then //v22.12 - RV
2613 begin //v22.12 - RV
2614 SaveCurrentNote(Saved); //v22.12 - RV
2615 if (not Saved) or FDeleted then Exit; //v22.12 - RV
2616 end //v22.12 - RV
2617 else if EditingIndex > -1 then //v22.12 - RV
2618 begin //v22.12 - RV
2619 tmpItem := lstNotes.Items[EditingIndex]; //v22.12 - RV
2620 EditingID := Piece(tmpItem, U, 1); //v22.12 - RV
2621 end; //v22.12 - RV
2622 if not NoteHasText(lstNotes.ItemIEN) then
2623 begin
2624 InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
2625 Exit;
2626 end;
2627 if not LastSaveClean(lstNotes.ItemIEN) and
2628 (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES) then Exit;
2629 if CosignDocument(lstNotes.ItemIEN) then
2630 begin
2631 SignTitle := TX_COSIGN;
2632 ActionType := SIG_COSIGN;
2633 end else
2634 begin
2635 SignTitle := TX_SIGN;
2636 ActionType := SIG_SIGN;
2637 end;
2638 if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
2639 // no exits after things are locked
2640 NoteUnlocked := False;
2641 ActOnDocument(ActionSts, lstNotes.ItemIEN, ActionType);
2642 if ActionSts.Success then
2643 begin
2644 OK := IsOK2Sign(uPCEShow, lstNotes.ItemIEN);
2645 if frmFrame.Closing then exit;
2646 if(uPCEShow.Updated) then
2647 begin
2648 uPCEShow.CopyPCEData(uPCEEdit);
2649 uPCEShow.Updated := FALSE;
2650 lstNotesClick(Self);
2651 end;
2652 if not AuthorSignedDocument(lstNotes.ItemIEN) then
2653 begin
2654 if (InfoBox(TX_AUTH_SIGNED +
2655 GetTitleText(lstNotes.ItemIndex),TX_SIGN ,MB_YESNO)= ID_NO) then exit;
2656 end;
2657 if(OK) then
2658 begin
2659 with lstNotes do SignatureForItem(Font.Size, MakeNoteDisplayText(Items[ItemIndex]), SignTitle, ESCode);
2660 if Length(ESCode) > 0 then
2661 begin
2662 SignDocument(SignSts, lstNotes.ItemIEN, ESCode);
2663 RemovePCEFromChanges(lstNotes.ItemIEN);
2664 NoteUnlocked := Changes.Exist(CH_DOC, lstNotes.ItemID);
2665 Changes.Remove(CH_DOC, lstNotes.ItemID); // this will unlock if in Changes
2666 if SignSts.Success then
2667 begin
2668 SendMessage(frmConsults.Handle, UM_NEWORDER, ORDER_SIGN, 0); {*REV*}
2669 lstNotesClick(Self);
2670 end
2671 else InfoBox(SignSts.Reason, TX_SIGN_ERR, MB_OK);
2672 end {if Length(ESCode)}
2673 else
2674 NoteUnlocked := Changes.Exist(CH_DOC, lstNotes.ItemID);
2675 end;
2676 end
2677 else InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2678 if not NoteUnlocked then UnlockDocument(lstNotes.ItemIEN);
2679 UnlockConsultRequest(lstNotes.ItemIEN);
2680 //SetViewContext(FCurrentContext); //v22.12 - RV
2681 LoadNotes; //v22.12 - RV
2682 //if EditingIndex > -1 then //v22.12 - RV
2683 if (EditingID <> '') then //v22.12 - RV
2684 begin
2685 lstNotes.Items.Insert(0, tmpItem);
2686// tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, 'Note being edited', <-- original line. //kt 7/19/2007
2687 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, DKLangConstW('fNotes_Note_being_edited'), //kt added 7/19/2007
2688 MakeNoteTreeObject('EDIT^Note being edited^^^^^^^^^^^%^0'));
2689 TORTreeNode(tmpNode).StringData := 'EDIT^Note being edited^^^^^^^^^^^%^0';
2690 tmpNode.ImageIndex := IMG_TOP_LEVEL;
2691 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, MakeNoteDisplayText(tmpItem), MakeNoteTreeObject(tmpItem));
2692 TORTreeNode(tmpNode).StringData := tmpItem;
2693 SetTreeNodeImagesAndFormatting(TORTreeNode(tmpNode), FCurrentContext, CT_NOTES);
2694 EditingIndex := lstNotes.SelectByID(EditingID); //v22.12 - RV
2695 end;
2696 //with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode); //v22.12 - RV
2697 with tvNotes do //v22.12 - RV
2698 begin //v22.12 - RV
2699 Selected := FindPieceNode(FLastNoteID, U, Items.GetFirstNode); //v22.12 - RV
2700 if Selected <> nil then
2701 tvNotesChange(Self, Selected) //v22.12 - RV
2702 else
2703 tvNotes.Selected := tvNotes.Items[0]; //first Node in treeview
2704 end; //v22.12 - RV
2705end;
2706
2707procedure TfrmNotes.SaveSignItem(const ItemID, ESCode: string);
2708{ saves and optionally signs a progress note or addendum }
2709const
2710 SIG_COSIGN = 'COSIGNATURE';
2711 SIG_SIGN = 'SIGNATURE';
2712var
2713 AnIndex, IEN, i: Integer;
2714 Saved, ContinueSign: Boolean; {*RAB* 8/26/99}
2715 ActionSts, SignSts: TActionRec;
2716 APCEObject: TPCEData;
2717 OK: boolean;
2718 ActionType, SignTitle: string;
2719begin
2720 SetupVars; //kt added 7/19/2007 to replace constants with vars.
2721 AnIndex := -1;
2722 IEN := StrToIntDef(ItemID, 0);
2723 if IEN = 0 then Exit;
2724 if frmFrame.TimedOut and (EditingIndex <> -1) then FSilent := True;
2725 with lstNotes do for i := 0 to Items.Count - 1 do if lstNotes.GetIEN(i) = IEN then
2726 begin
2727 AnIndex := i;
2728 break;
2729 end;
2730 if (AnIndex > -1) and (AnIndex = EditingIndex) then
2731 begin
2732 SaveCurrentNote(Saved);
2733 if not Saved then Exit;
2734 if FDeleted then
2735 begin
2736 FDeleted := False;
2737 Exit;
2738 end;
2739 AnIndex := lstNotes.SelectByIEN(IEN);
2740 //IEN := lstNotes.GetIEN(AnIndex); // saving will change IEN
2741 end;
2742 if Length(ESCode) > 0 then
2743 begin
2744 if CosignDocument(IEN) then
2745 begin
2746 SignTitle := TX_COSIGN;
2747 ActionType := SIG_COSIGN;
2748 end else
2749 begin
2750 SignTitle := TX_SIGN;
2751 ActionType := SIG_SIGN;
2752 end;
2753 ActOnDocument(ActionSts, IEN, ActionType);
2754 if not ActionSts.Success then
2755 begin
2756 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
2757 ContinueSign := False;
2758 end
2759 else if not NoteHasText(IEN) then
2760 begin
2761 InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
2762 ContinueSign := False;
2763 end
2764 else if not LastSaveClean(IEN) and
2765 (InfoBox(TX_ABSAVE, TC_ABSAVE, MB_YESNO or MB_DEFBUTTON2 or MB_ICONWARNING) <> IDYES)
2766 then ContinueSign := False
2767 else ContinueSign := True;
2768 if ContinueSign then
2769 begin
2770 if (AnIndex >= 0) and (AnIndex = lstNotes.ItemIndex) then
2771 APCEObject := uPCEShow
2772 else
2773 APCEObject := nil;
2774 OK := IsOK2Sign(APCEObject, IEN);
2775 if frmFrame.Closing then exit;
2776 if(assigned(APCEObject)) and (uPCEShow.Updated) then
2777 begin
2778 uPCEShow.CopyPCEData(uPCEEdit);
2779 uPCEShow.Updated := FALSE;
2780 lstNotesClick(Self);
2781 end
2782 else
2783 uPCEEdit.Clear;
2784 if(OK) then
2785 begin
2786 //if ((not FSilent) and IsSurgeryTitle(TitleForNote(IEN))) then DisplayOpTop(IEN);
2787 SignDocument(SignSts, IEN, ESCode);
2788 if not SignSts.Success then InfoBox(SignSts.Reason, TX_SIGN_ERR, MB_OK);
2789 end; {if OK}
2790 end; {if ContinueSign}
2791 end; {if Length(ESCode)}
2792
2793 UnlockConsultRequest(IEN);
2794 if (AnIndex = lstNotes.ItemIndex) and (not frmFrame.ContextChanging) then
2795 begin
2796 LoadNotes;
2797 with tvNotes do Selected := FindPieceNode(IntToStr(IEN), U, Items.GetFirstNode);
2798 end;
2799end;
2800
2801procedure TfrmNotes.popNoteMemoPopup(Sender: TObject);
2802const FORMAT_MODE : array[false..true] of string = ('fNotes_Formatted_Text','fNotes_Plain_Text'); //kt 8/09
2803begin
2804 inherited;
2805 if PopupComponent(Sender, popNoteMemo) is TCustomEdit
2806 then FEditCtrl := TCustomEdit(PopupComponent(Sender, popNoteMemo))
2807 else FEditCtrl := nil;
2808 if FEditCtrl <> nil then
2809 begin
2810 popNoteMemoCut.Enabled := FEditCtrl.SelLength > 0;
2811 popNoteMemoCopy.Enabled := popNoteMemoCut.Enabled;
2812 popNoteMemoPaste.Enabled := (not TORExposedCustomEdit(FEditCtrl).ReadOnly) and
2813 Clipboard.HasFormat(CF_TEXT);
2814 popNoteMemoTemplate.Enabled := frmDrawers.CanEditTemplates and popNoteMemoCut.Enabled;
2815 popNoteMemoFind.Enabled := FEditCtrl.GetTextLen > 0;
2816 end else
2817 begin
2818 popNoteMemoHTMLFormat.Enabled := False; //kt 8/09
2819 popNoteMemoCut.Enabled := False;
2820 popNoteMemoCopy.Enabled := False;
2821 popNoteMemoPaste.Enabled := False;
2822 popNoteMemoTemplate.Enabled := False;
2823 end;
2824 popNoteMemoHTMLFormat.Caption := DKLangConstW('fNotes_Change_Edit_Mode_To') + ' ' + //kt 8/09
2825 DKLangConstW(FORMAT_MODE[(vmHTML in FViewMode)]); //kt 8/09
2826 popNoteMemoHTMLFormat.Enabled := pnlWrite.Visible; //kt 8/09
2827 if pnlWrite.Visible then
2828 begin
2829 //kt 8/09 popNoteMemoSpell.Enabled := True;
2830 //kt 8/09 popNoteMemoGrammar.Enabled := True;
2831 //kt 8/09 popNoteMemoReformat.Enabled := True;
2832 popNoteMemoSpell.Enabled := not pnlHTMLWrite.Visible; //kt 8/09
2833 popNoteMemoGrammar.Enabled := not pnlHTMLWrite.Visible; //kt 8/09
2834 popNoteMemoReformat.Enabled := not pnlHTMLWrite.Visible; //kt 8/09
2835 popNoteMemoReplace.Enabled := (FEditCtrl.GetTextLen > 0);
2836 popNoteMemoPreview.Enabled := (frmDrawers.TheOpenDrawer = odTemplates) and Assigned(frmDrawers.tvTemplates.Selected);
2837 popNoteMemoInsTemplate.Enabled := (frmDrawers.TheOpenDrawer = odTemplates) and Assigned(frmDrawers.tvTemplates.Selected);
2838 end else
2839 begin
2840 popNoteMemoSpell.Enabled := False;
2841 popNoteMemoGrammar.Enabled := False;
2842 popNoteMemoReformat.Enabled := False;
2843 popNoteMemoReplace.Enabled := False;
2844 popNoteMemoPreview.Enabled := False;
2845 popNoteMemoInsTemplate.Enabled := False;
2846 end;
2847end;
2848
2849(*//kt 8/09 NOTICE:
2850 On the form, popNoteMenu was edited to add a new item as below
2851 popNoteMemoHTMLFormat : TMenuItem
2852 Captions: ~ Edit as Formatted Text
2853 OnClick -- popNoteMemoHTMLFormatClick
2854*)
2855
2856procedure TfrmNotes.popNoteMemoHTMLFormatClick(Sender: TObject);
2857//kt added function 8/09
2858begin
2859 inherited;
2860 ToggleHTMLEditMode;
2861end;
2862
2863procedure TfrmNotes.popNoteMemoCutClick(Sender: TObject);
2864begin
2865 inherited;
2866 FEditCtrl.CutToClipboard;
2867end;
2868
2869procedure TfrmNotes.popNoteMemoCopyClick(Sender: TObject);
2870begin
2871 inherited;
2872 FEditCtrl.CopyToClipboard;
2873end;
2874
2875procedure TfrmNotes.popNoteMemoPasteClick(Sender: TObject);
2876begin
2877 inherited;
2878 FEditCtrl.SelText := Clipboard.AsText; {*KCM*}
2879 frmNotes.pnlWriteResize(Self);
2880 //FEditCtrl.PasteFromClipboard; // use AsText to prevent formatting
2881end;
2882
2883procedure TfrmNotes.popNoteMemoReformatClick(Sender: TObject);
2884begin
2885 inherited;
2886 if Screen.ActiveControl <> memNewNote then Exit;
2887 ReformatMemoParagraph(memNewNote);
2888end;
2889
2890procedure TfrmNotes.popNoteMemoSaveContinueClick(Sender: TObject);
2891begin
2892 inherited;
2893 FChanged := True;
2894 DoAutoSave;
2895end;
2896
2897procedure TfrmNotes.popNoteMemoFindClick(Sender: TObject);
2898//var
2899 //hData: THandle; //CQ8300
2900 //pData: ^ClipboardData; //CQ8300
2901begin
2902 inherited;
2903 SendMessage(TRichEdit(popNoteMemo.PopupComponent).Handle, WM_VSCROLL, SB_TOP, 0);
2904 with dlgFindText do
2905 begin
2906 Position := Point(Application.MainForm.Left + pnlLeft.Width, Application.MainForm.Top);
2907 FindText := '';
2908 Options := [frDown, frHideUpDown];
2909{
2910 //CQ8300
2911 OpenClipboard(dlgFindText.Handle);
2912 hData := GetClipboardData(CF_TEXT);
2913 pData := GlobalLock(hData);
2914 FindText := pData^.Text;
2915 GlobalUnlock(hData);
2916 CloseClipboard;
2917 //end CQ8300
2918}
2919 Execute;
2920 end;
2921end;
2922
2923procedure TfrmNotes.dlgFindTextFind(Sender: TObject);
2924begin
2925 dmodShared.FindRichEditText(dlgFindText, TRichEdit(popNoteMemo.PopupComponent));
2926end;
2927
2928procedure TfrmNotes.popNoteMemoReplaceClick(Sender: TObject);
2929begin
2930 inherited;
2931 SendMessage(TRichEdit(popNoteMemo.PopupComponent).Handle, WM_VSCROLL, SB_TOP, 0);
2932 with dlgReplaceText do
2933 begin
2934 Position := Point(Application.MainForm.Left + pnlLeft.Width, Application.MainForm.Top);
2935 FindText := '';
2936 ReplaceText := '';
2937 Options := [frDown, frHideUpDown];
2938 Execute;
2939 end;
2940end;
2941
2942procedure TfrmNotes.dlgReplaceTextFind(Sender: TObject);
2943begin
2944 inherited;
2945 dmodShared.FindRichEditText(dlgFindText, TRichEdit(popNoteMemo.PopupComponent));
2946end;
2947
2948procedure TfrmNotes.dlgReplaceTextReplace(Sender: TObject);
2949begin
2950 inherited;
2951 dmodShared.ReplaceRichEditText(dlgReplaceText, TRichEdit(popNoteMemo.PopupComponent));
2952end;
2953
2954procedure TfrmNotes.popNoteMemoSpellClick(Sender: TObject);
2955begin
2956 inherited;
2957 DoAutoSave(0);
2958 timAutoSave.Enabled := False;
2959 try
2960 SpellCheckForControl(memNewNote);
2961 finally
2962 FChanged := True;
2963 DoAutoSave(0);
2964 timAutoSave.Enabled := True;
2965 end;
2966end;
2967
2968procedure TfrmNotes.popNoteMemoGrammarClick(Sender: TObject);
2969begin
2970 inherited;
2971 DoAutoSave(0);
2972 timAutoSave.Enabled := False;
2973 try
2974 GrammarCheckForControl(memNewNote);
2975 finally
2976 FChanged := True;
2977 DoAutoSave(0);
2978 timAutoSave.Enabled := True;
2979 end;
2980end;
2981
2982procedure TfrmNotes.mnuViewDetailClick(Sender: TObject);
2983begin
2984 inherited;
2985 if lstNotes.ItemIEN <= 0 then Exit;
2986 mnuViewDetail.Checked := not mnuViewDetail.Checked;
2987 if mnuViewDetail.Checked then
2988 begin
2989// StatusText('Retrieving progress note details...'); <-- original line. //kt 7/19/2007
2990 StatusText(DKLangConstW('fNotes_Retrieving_progress_note_detailsxxx')); //kt added 7/19/2007
2991 Screen.Cursor := crAppStart; //kt, was crHourGlass;
2992 //kt LoadDetailText(memNote.Lines, lstNotes.ItemIEN);
2993 LoadDetailText(FViewNote, lstNotes.ItemIEN); //kt 8/09
2994 SetDisplayToHTMLvsText(FViewMode,FViewNote); //kt 8/09
2995 Screen.Cursor := crDefault;
2996 StatusText('');
2997 memNote.SelStart := 0;
2998 if not (vmHTML in FViewMode) then //kt 8/09
2999 memNote.Repaint;
3000 end
3001 else
3002 lstNotesClick(Self);
3003 if (vmHTML in FViewMode) then begin //kt 8/09
3004 SendMessage(HTMLViewer.Handle, WM_VSCROLL, SB_TOP, 0); //kt 8/09
3005 end else begin //kt 8/09
3006 SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
3007 end; //kt 8/09
3008end;
3009
3010procedure TfrmNotes.FormClose(Sender: TObject; var Action: TCloseAction);
3011var
3012 Saved: Boolean;
3013 IEN: Int64;
3014 ErrMsg: string;
3015 DeleteSts: TActionRec;
3016begin
3017 inherited;
3018 if frmFrame.TimedOut and (EditingIndex <> -1) then
3019 begin
3020 FSilent := True;
3021 //kt 8/09 if memNewNote.GetTextLen > 0 then SaveCurrentNote(Saved)
3022 if EditorHasText then SaveCurrentNote(Saved) //kt 8/09
3023 else
3024 begin
3025 IEN := lstNotes.GetIEN(EditingIndex);
3026 if not LastSaveClean(IEN) then // means note hasn't been committed yet
3027 begin
3028 LockDocument(IEN, ErrMsg);
3029 if ErrMsg = '' then
3030 begin
3031 DeleteDocument(DeleteSts, IEN, '');
3032 UnlockDocument(IEN);
3033 end; {if ErrMsg}
3034 end; {if not LastSaveClean}
3035 end; {else}
3036 end; {if frmFrame}
3037end;
3038
3039procedure TfrmNotes.mnuActIdentifyAddlSignersClick(Sender: TObject);
3040var
3041 Exclusions: TStrings;
3042 Saved, x, y: boolean;
3043 SignerList: TSignerList;
3044 ActionSts: TActionRec;
3045 SigAction: integer;
3046 SavedDocID: string;
3047 ARefDate: TFMDateTime;
3048begin
3049 inherited;
3050 if lstNotes.ItemIEN = 0 then exit;
3051 SavedDocID := lstNotes.ItemID;
3052 if lstNotes.ItemIndex = EditingIndex then
3053 begin
3054 SaveCurrentNote(Saved);
3055 if not Saved then Exit;
3056 LoadNotes;
3057 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
3058 end;
3059 x := CanChangeCosigner(lstNotes.ItemIEN);
3060 ActOnDocument(ActionSts, lstNotes.ItemIEN, 'IDENTIFY SIGNERS');
3061 y := ActionSts.Success;
3062 if x and not y then
3063 begin
3064 if InfoBox(ActionSts.Reason + CRLF + CRLF +
3065// 'Would you like to change the cosigner?', <-- original line. //kt 7/19/2007
3066 DKLangConstW('fNotes_Would_you_like_to_change_the_cosignerx'), //kt added 7/19/2007
3067 TX_IN_AUTH, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = ID_YES then
3068 SigAction := SG_COSIGNER
3069 else
3070 Exit;
3071 end
3072 else if y and not x then SigAction := SG_ADDITIONAL
3073 else if x and y then SigAction := SG_BOTH
3074 else
3075 begin
3076 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
3077 Exit;
3078 end;
3079
3080 if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
3081 Exclusions := GetCurrentSigners(lstNotes.ItemIEN);
3082 ARefDate := StrToFloat(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
3083 SelectAdditionalSigners(Font.Size, lstNotes.ItemIEN, SigAction, Exclusions, SignerList, CT_NOTES, ARefDate);
3084 with SignerList do
3085 begin
3086 case SigAction of
3087 SG_ADDITIONAL: if Changed and (Signers <> nil) and (Signers.Count > 0) then
3088 UpdateAdditionalSigners(lstNotes.ItemIEN, Signers);
3089 SG_COSIGNER: if Changed then ChangeCosigner(lstNotes.ItemIEN, Cosigner);
3090 SG_BOTH: if Changed then
3091 begin
3092 if (Signers <> nil) and (Signers.Count > 0) then
3093 UpdateAdditionalSigners(lstNotes.ItemIEN, Signers);
3094 ChangeCosigner(lstNotes.ItemIEN, Cosigner);
3095 end;
3096 end;
3097 lstNotesClick(Self);
3098 end;
3099 UnlockDocument(lstNotes.ItemIEN);
3100 UnlockConsultRequest(lstNotes.ItemIEN);
3101end;
3102
3103procedure TfrmNotes.popNoteMemoAddlSignClick(Sender: TObject);
3104begin
3105 inherited;
3106 mnuActIdentifyAddlSignersClick(Self);
3107end;
3108
3109procedure TfrmNotes.ProcessNotifications;
3110var
3111 x: string;
3112 Saved: boolean;
3113 tmpNode: TTreeNode;
3114 AnObject: PDocTreeObject;
3115begin
3116 SetupVars; //kt added 7/19/2007 to replace constants with vars.
3117 if EditingIndex <> -1 then
3118 begin
3119 SaveCurrentNote(Saved);
3120 if not Saved then Exit;
3121 end;
3122 lblNotes.Caption := Notifications.Text;
3123 tvNotes.Caption := Notifications.Text;
3124 EditingIndex := -1;
3125 lstNotes.Enabled := True ;
3126 pnlRead.BringToFront ;
3127 // show ALL unsigned/uncosigned for a patient, not just the alerted one
3128 // what about cosignature? How to get correct list? ORB FOLLOWUP TYPE = OR alerts only
3129 x := Notifications.AlertData;
3130 if StrToIntDef(Piece(x, U, 1), 0) = 0 then
3131 begin
3132 InfoBox(TX_NO_ALERT, TX_CAP_NO_ALERT, MB_OK);
3133 Exit;
3134 end;
3135 uChanging := True;
3136 tvNotes.Items.BeginUpdate;
3137 lstNotes.Clear;
3138 KillDocTreeObjects(tvNotes);
3139 tvNotes.Items.Clear;
3140 lstNotes.Items.Add(x);
3141 AnObject := MakeNoteTreeObject('ALERT^Alerted Note^^^^^^^^^^^%^0');
3142 tmpNode := tvNotes.Items.AddObjectFirst(tvNotes.Items.GetFirstNode, AnObject.NodeText, AnObject);
3143 TORTreeNode(tmpNode).StringData := 'ALERT^Alerted Note^^^^^^^^^^^%^0';
3144 tmpNode.ImageIndex := IMG_TOP_LEVEL;
3145 AnObject := MakeNoteTreeObject(x);
3146 tmpNode := tvNotes.Items.AddChildObjectFirst(tmpNode, AnObject.NodeText, AnObject);
3147 TORTreeNode(tmpNode).StringData := x;
3148 SetTreeNodeImagesAndFormatting(TORTreeNode(tmpNode), FCurrentContext, CT_NOTES);
3149 tvNotes.Selected := tmpNode;
3150 tvNotes.Items.EndUpdate;
3151 uChanging := False;
3152 tvNotesChange(Self, tvNotes.Selected);
3153 case Notifications.Followup of
3154 NF_NOTES_UNSIGNED_NOTE: ; //Automatically deleted by sig action!!!
3155 end;
3156 if Copy(Piece(Notifications.RecordID, U, 2), 1, 6) = 'TIUADD' then Notifications.Delete;
3157 if Copy(Piece(Notifications.RecordID, U, 2), 1, 5) = 'TIUID' then Notifications.Delete;
3158end;
3159
3160procedure TfrmNotes.SetViewContext(AContext: TTIUContext);
3161var
3162 Saved: boolean;
3163begin
3164 if EditingIndex <> -1 then
3165 begin
3166 SaveCurrentNote(Saved);
3167 if not Saved then Exit;
3168 end;
3169 FCurrentContext := AContext;
3170 EditingIndex := -1;
3171 tvNotes.Enabled := True ;
3172 pnlRead.BringToFront ;
3173 if FCurrentContext.Status <> '' then with uTIUContext do
3174 begin
3175 BeginDate := FCurrentContext.BeginDate;
3176 EndDate := FCurrentContext.EndDate;
3177 FMBeginDate := FCurrentContext.FMBeginDate;
3178 FMEndDate := FCurrentContext.FMEndDate;
3179 Status := FCurrentContext.Status;
3180 Author := FCurrentContext.Author;
3181 MaxDocs := FCurrentContext.MaxDocs;
3182 ShowSubject := FCurrentContext.ShowSubject;
3183 GroupBy := FCurrentContext.GroupBy;
3184 SortBy := FCurrentContext.SortBy;
3185 ListAscending := FCurrentContext.ListAscending;
3186 TreeAscending := FCurrentContext.TreeAscending;
3187 Keyword := FCurrentContext.Keyword;
3188 SearchField := FCurrentContext.SearchField;
3189 Filtered := FCurrentContext.Filtered;
3190 Changed := True;
3191 mnuViewClick(Self);
3192 end
3193 else
3194 begin
3195 ViewContext := NC_RECENT ;
3196 mnuViewClick(Self);
3197 end;
3198end;
3199
3200procedure TfrmNotes.mnuViewSaveAsDefaultClick(Sender: TObject);
3201//const
3202//TX_NO_MAX = 'You have not specified a maximum number of notes to be returned.' + CRLF + <-- original line. //kt 7/19/2007
3203// 'If you save this preference, the result will be that ALL notes for every' + CRLF + <-- original line. //kt 7/19/2007
3204// 'patient will be saved as your default view.' + CRLF + CRLF + <-- original line. //kt 7/19/2007
3205// 'For patients with large numbers of notes, this could result in some lengthy' + CRLF + <-- original line. //kt 7/19/2007
3206// 'delays in loading the list of notes.' + CRLF + CRLF + <-- original line. //kt 7/19/2007
3207// 'Are you sure you mean to do this?'; <-- original line. //kt 7/19/2007
3208//TX_REPLACE = 'Replace current defaults?'; <-- original line. //kt 7/19/2007
3209var
3210 TX_NO_MAX : string; //kt
3211 TX_REPLACE : string; //kt
3212
3213begin
3214 inherited;
3215 TX_NO_MAX := DKLangConstW('fNotes_You_have_not_specified_a_maximum_number_of_notes_to_be_returnedx') + CRLF + //kt added 7/19/2007
3216 DKLangConstW('fNotes_If_you_save_this_preferencex_the_result_will_be_that_ALL_notes_for_every') + CRLF + //kt added 7/19/2007
3217 DKLangConstW('fNotes_patient_will_be_saved_as_your_default_viewx') + CRLF + CRLF + //kt added 7/19/2007
3218 DKLangConstW('fNotes_For_patients_with_large_numbers_of_notesx_this_could_result_in_some_lengthy') + CRLF + //kt added 7/19/2007
3219 DKLangConstW('fNotes_delays_in_loading_the_list_of_notesx') + CRLF + CRLF + //kt added 7/19/2007
3220 DKLangConstW('fNotes_Are_you_sure_you_mean_to_do_thisx'); //kt added 7/19/2007
3221 TX_REPLACE := DKLangConstW('fNotes_Replace_current_defaultsx'); //kt added 7/19/2007
3222 if FCurrentContext.MaxDocs = 0 then
3223 if InfoBox(TX_NO_MAX,'Warning', MB_YESNO or MB_ICONWARNING) = IDNO then
3224 begin
3225 mnuViewClick(mnuViewCustom);
3226 Exit;
3227 end;
3228 if InfoBox(TX_REPLACE,'Confirmation', MB_YESNO or MB_ICONQUESTION) = IDYES then
3229 begin
3230 SaveCurrentTIUContext(FCurrentContext);
3231 FDefaultContext := FCurrentContext;
3232 //lblNotes.Caption := 'Default List';
3233 end;
3234end;
3235
3236procedure TfrmNotes.mnuViewReturntoDefaultClick(Sender: TObject);
3237begin
3238 inherited;
3239 SetViewContext(FDefaultContext);
3240end;
3241
3242procedure TfrmNotes.popNoteMemoTemplateClick(Sender: TObject);
3243begin
3244 inherited;
3245 EditTemplates(Self, TRUE, FEditCtrl.SelText);
3246end;
3247
3248procedure TfrmNotes.popNoteListPopup(Sender: TObject);
3249begin
3250 inherited;
3251 N4.Visible := (popNoteList.PopupComponent is TORTreeView);
3252 popNoteListExpandAll.Visible := N4.Visible;
3253 popNoteListExpandSelected.Visible := N4.Visible;
3254 popNoteListCollapseAll.Visible := N4.Visible;
3255 popNoteListCollapseSelected.Visible := N4.Visible;
3256end;
3257
3258procedure TfrmNotes.popNoteListExpandAllClick(Sender: TObject);
3259begin
3260 inherited;
3261 tvNotes.FullExpand;
3262end;
3263
3264procedure TfrmNotes.popNoteListCollapseAllClick(Sender: TObject);
3265begin
3266 inherited;
3267 tvNotes.Selected := nil;
3268 lvNotes.Items.Clear;
3269 memNote.Clear;
3270 HTMLViewer.Clear; //kt 8/09
3271 tvNotes.FullCollapse;
3272 tvNotes.Selected := tvNotes.TopItem;
3273end;
3274
3275procedure TfrmNotes.popNoteListExpandSelectedClick(Sender: TObject);
3276begin
3277 inherited;
3278 if tvNotes.Selected = nil then exit;
3279 with tvNotes.Selected do if HasChildren then Expand(True);
3280end;
3281
3282procedure TfrmNotes.popNoteListCollapseSelectedClick(Sender: TObject);
3283begin
3284 inherited;
3285 if tvNotes.Selected = nil then exit;
3286 with tvNotes.Selected do if HasChildren then Collapse(True);
3287end;
3288
3289procedure TfrmNotes.mnuEditTemplatesClick(Sender: TObject);
3290begin
3291 inherited;
3292 EditTemplates(Self);
3293end;
3294
3295procedure TfrmNotes.mnuNewTemplateClick(Sender: TObject);
3296begin
3297 inherited;
3298 EditTemplates(Self, TRUE);
3299end;
3300
3301procedure TfrmNotes.mnuEditSharedTemplatesClick(Sender: TObject);
3302begin
3303 inherited;
3304 EditTemplates(Self, FALSE, '', TRUE);
3305end;
3306
3307procedure TfrmNotes.mnuNewSharedTemplateClick(Sender: TObject);
3308begin
3309 inherited;
3310 EditTemplates(Self, TRUE, '', TRUE);
3311end;
3312
3313procedure TfrmNotes.mnuOptionsClick(Sender: TObject);
3314begin
3315 inherited;
3316 mnuEditTemplates.Enabled := frmDrawers.CanEditTemplates;
3317 mnuNewTemplate.Enabled := frmDrawers.CanEditTemplates;
3318 mnuEditSharedTemplates.Enabled := frmDrawers.CanEditShared;
3319 mnuNewSharedTemplate.Enabled := frmDrawers.CanEditShared;
3320 mnuEditDialgFields.Enabled := CanEditTemplateFields;
3321end;
3322
3323procedure TfrmNotes.SetEditingIndex(const Value: Integer);
3324begin
3325 FEditingIndex := Value;
3326 if(FEditingIndex < 0) then
3327 KillReminderDialog(Self);
3328 if(assigned(frmReminderTree)) then
3329 frmReminderTree.EnableActions;
3330end;
3331
3332function TfrmNotes.CanFinishReminder: boolean;
3333begin
3334 if(EditingIndex < 0) then
3335 Result := FALSE
3336 else
3337 Result := (lstNotes.ItemIndex = EditingIndex);
3338end;
3339
3340procedure TfrmNotes.FormDestroy(Sender: TObject);
3341begin
3342 //kt note: The Images tab will delete all files in .\Cache, which
3343 // might include HTMLfilename. No harm if already deleted.
3344 //kt 8/09 DeleteFile(HTMLfilename); //kt added 5-2-05
3345 TAccessibleTreeView.UnwrapControl(tvNotes);
3346 FDocList.Free;
3347 FImageFlag.Free;
3348 KillDocTreeObjects(tvNotes);
3349 HtmlEditor.Free; //kt 6/7/09
3350 HtmlViewer.Free; //kt 6/7/09
3351 inherited;
3352end;
3353
3354function TfrmNotes.GetDrawers: TFrmDrawers;
3355begin
3356 Result := frmDrawers;
3357end;
3358
3359procedure TfrmNotes.AssignRemForm;
3360begin
3361 //kt 8/09 ReminderDialog interaction has not yet been debugged with HTML formatted text.
3362 with RemForm do
3363 begin
3364 Form := Self;
3365 PCEObj := uPCEEdit;
3366 RightPanel := pnlRight;
3367 CanFinishProc := CanFinishReminder;
3368 DisplayPCEProc := DisplayPCE;
3369 Drawers := frmDrawers;
3370 NewNoteRE := memNewNote;
3371 NewNoteHTMLE := HTMLEditor; //kt
3372 NoteList := lstNotes;
3373 end;
3374end;
3375
3376procedure TfrmNotes.mnuEditDialgFieldsClick(Sender: TObject);
3377begin
3378 inherited;
3379 EditDialogFields;
3380end;
3381
3382//=================== Added for sort/search enhancements ======================
3383procedure TfrmNotes.LoadNotes;
3384const
3385 INVALID_ID = -1;
3386 INFO_ID = 1;
3387var
3388 tmpList: TStringList;
3389 ANode: TORTreeNode;
3390 x,xx,noteId: integer; // Text Search CQ: HDS00002856
3391 Dest: TStrings; // Text Search CQ: HDS00002856
3392 KeepFlag: Boolean; // Text Search CQ: HDS00002856
3393 NoteCount, NoteMatches: integer; // Text Search CQ: HDS00002856
3394begin
3395 tmpList := TStringList.Create;
3396 try
3397 FDocList.Clear;
3398 uChanging := True;
3399 RedrawSuspend(memNote.Handle);
3400 RedrawSuspend(HTMLViewer.Handle); //kt 8/09
3401 RedrawSuspend(lvNotes.Handle);
3402 tvNotes.Items.BeginUpdate;
3403 lstNotes.Items.Clear;
3404 KillDocTreeObjects(tvNotes);
3405 tvNotes.Items.Clear;
3406 tvNotes.Items.EndUpdate;
3407 lvNotes.Items.Clear;
3408 memNote.Clear;
3409 HTMLViewer.Clear; //kt 8/09
3410 memNote.Invalidate;
3411 lblTitle.Caption := '';
3412 lvNotes.Caption := '';
3413 with FCurrentContext do
3414 begin
3415 if Status <> IntToStr(NC_UNSIGNED) then
3416 begin
3417 ListNotesForTree(tmpList, NC_UNSIGNED, 0, 0, 0, 0, TreeAscending);
3418 if tmpList.Count > 0 then
3419 begin
3420 CreateListItemsforDocumentTree(FDocList, tmpList, NC_UNSIGNED, GroupBy, TreeAscending, CT_NOTES);
3421 UpdateTreeView(FDocList, tvNotes);
3422 end;
3423 tmpList.Clear;
3424 FDocList.Clear;
3425 end;
3426 if Status <> IntToStr(NC_UNCOSIGNED) then
3427 begin
3428 ListNotesForTree(tmpList, NC_UNCOSIGNED, 0, 0, 0, 0, TreeAscending);
3429 if tmpList.Count > 0 then
3430 begin
3431 CreateListItemsforDocumentTree(FDocList, tmpList, NC_UNCOSIGNED, GroupBy, TreeAscending, CT_NOTES);
3432 UpdateTreeView(FDocList, tvNotes);
3433 end;
3434 tmpList.Clear;
3435 FDocList.Clear;
3436 end;
3437 ListNotesForTree(tmpList, StrToIntDef(Status, 0), FMBeginDate, FMEndDate, Author, MaxDocs, TreeAscending);
3438 CreateListItemsforDocumentTree(FDocList, tmpList, StrToIntDef(Status, 0), GroupBy, TreeAscending, CT_NOTES);
3439
3440 // Text Search CQ: HDS00002856 ---------------------------------------
3441 if FCurrentContext.SearchString<>'' then // Text Search CQ: HDS00002856
3442 begin
3443 NoteMatches := 0;
3444 Dest:=TStringList.Create;
3445 NoteCount:=FDocList.Count-1;
3446 if FDocList.Count>0 then
3447 for x := FDocList.Count-1 downto 1 do begin; // Don't do 0, because it's informational
3448 KeepFlag:=False;
3449// lblNotes.Caption:='Scanning '+IntToStr(NoteCount-x+1)+' of '+IntToStr(NoteCount)+', '+IntToStr(NoteMatches); <-- original line. //kt 7/19/2007
3450 lblNotes.Caption:=DKLangConstW('fNotes_Scanning')+' '+IntToStr(NoteCount-x+1)+DKLangConstW('fNotes_of')+IntToStr(NoteCount)+', '+IntToStr(NoteMatches); //kt added 7/19/2007
3451 If NoteMatches=1 then lblNotes.Caption:=lblNotes.Caption+' match' else
3452 lblNotes.Caption:=lblNotes.Caption+' matches';
3453 frmSearchStop.lblSearchStatus.Caption := lblNotes.Caption;
3454 frmSearchStop.lblSearchStatus.Repaint;
3455 lblNotes.Repaint;
3456 // Free up some ticks so they can click the "Stop" button
3457 application.processmessages;
3458 application.processmessages;
3459 application.processmessages;
3460 If SearchTextStopFlag = False then begin
3461 noteId := StrToIntDef(Piece(FDocList.Strings[x],'^',1),-1);
3462 if (noteId = INVALID_ID) or (noteId = INFO_ID) then
3463 Continue;
3464 CallV('TIU GET RECORD TEXT', [Piece(FDocList.Strings[x],'^',1)]);
3465 Dest.Assign(RPCBrokerV.Results);
3466 If Dest.Count > 0 then
3467 for xx := 0 to Dest.Count-1 do
3468 begin
3469 //Dest.Strings[xx] := StringReplace(Dest.Strings[xx],'#13',' ',[rfReplaceAll, rfIgnoreCase]);
3470 if Pos(Uppercase(FCurrentContext.SearchString),Uppercase(Dest.Strings[xx]))>0 then
3471 keepflag:=true;
3472 end;
3473 If KeepFlag=False then begin;
3474 if FDocList.Count >= x then
3475 FDocList.Delete(x);
3476 if (tmpList.Count >= x) and (x > 0) then
3477 tmpList.Delete(x-1);
3478 end else
3479 Inc(NoteMatches);
3480 end;
3481 end;
3482 Dest.Free;
3483 end;
3484 // Text Search CQ: HDS00002856 ---------------------------------------
3485
3486 UpdateTreeView(FDocList, tvNotes);
3487 end;
3488 with tvNotes do
3489 begin
3490 uChanging := True;
3491 tvNotes.Items.BeginUpdate;
3492 RemoveParentsWithNoChildren(tvNotes, FCurrentContext); // moved here in v15.9 (RV)
3493 if FLastNoteID <> '' then
3494 Selected := FindPieceNode(FLastNoteID, 1, U, nil);
3495 if Selected = nil then
3496 begin
3497 if (FCurrentContext.GroupBy <> '') or (FCurrentContext.Filtered) then
3498 begin
3499 ANode := TORTreeNode(Items.GetFirstNode);
3500 while ANode <> nil do
3501 begin
3502 ANode.Expand(False);
3503 Selected := ANode;
3504 ANode := TORTreeNode(ANode.GetNextSibling);
3505 end;
3506 end
3507 else
3508 begin
3509 ANode := tvNotes.FindPieceNode(FCurrentContext.Status, 1, U, nil);
3510 if ANode <> nil then ANode.Expand(False);
3511 ANode := tvNotes.FindPieceNode(IntToStr(NC_UNSIGNED), 1, U, nil);
3512 if ANode = nil then
3513 ANode := tvNotes.FindPieceNode(IntToStr(NC_UNCOSIGNED), 1, U, nil);
3514 if ANode = nil then
3515 ANode := tvNotes.FindPieceNode(FCurrentContext.Status, 1, U, nil);
3516 if ANode <> nil then
3517 begin
3518 if ANode.getFirstChild <> nil then
3519 Selected := ANode.getFirstChild
3520 else
3521 Selected := ANode;
3522 end;
3523 end;
3524 end;
3525 memNote.Clear;
3526 HTMLViewer.Clear; //kt 8/09
3527 with lvNotes do
3528 begin
3529 Selected := nil;
3530 if FCurrentContext.SortBy <> '' then
3531 ColumnToSort := Pos(FCurrentContext.SortBy, 'RDSAL') - 1;
3532 if not FCurrentContext.ShowSubject then
3533 begin
3534 Columns[1].Width := 2 * (Width div 5);
3535 Columns[2].Width := 0;
3536 end
3537 else
3538 begin
3539 Columns[1].Width := Width div 5;
3540 Columns[2].Width := Columns[1].Width;
3541 end;
3542 end;
3543 //RemoveParentsWithNoChildren(tvNotes, FCurrentContext); // moved FROM here in v15.9 (RV)
3544 tvNotes.Items.EndUpdate;
3545 uChanging := False;
3546 SendMessage(tvNotes.Handle, WM_VSCROLL, SB_TOP, 0);
3547 if Selected <> nil then tvNotesChange(Self, Selected);
3548 end;
3549 finally
3550 //kt NOTE: Is this enough??
3551 if (vmHTML in FViewMode) then begin //kt 8/09
3552 RedrawActivate(HtmlViewer.Handle); //kt 8/09
3553 end else begin //kt 8/09
3554 RedrawActivate(memNote.Handle);
3555 end; //kt 8/09
3556 RedrawActivate(lvNotes.Handle);
3557 tmpList.Free;
3558 end;
3559end;
3560
3561procedure TfrmNotes.UpdateTreeView(DocList: TStringList; Tree: TORTreeView);
3562begin
3563 with Tree do
3564 begin
3565 uChanging := True;
3566 Items.BeginUpdate;
3567 lstNotes.Items.AddStrings(DocList);
3568 BuildDocumentTree(DocList, '0', Tree, nil, FCurrentContext, CT_NOTES);
3569 Items.EndUpdate;
3570 uChanging := False;
3571 end;
3572end;
3573
3574procedure TfrmNotes.tvNotesChange(Sender: TObject; Node: TTreeNode);
3575var
3576 x, MySearch, MyNodeID: string;
3577 i: integer;
3578 WhyNot: string;
3579 Mode : TViewModeSet; //kt 8/09
3580begin
3581 if uChanging then Exit;
3582 //This gives the change a chance to occur when keyboarding, so that WindowEyes
3583 //doesn't use the old value.
3584 Application.ProcessMessages;
3585 with tvNotes do
3586 begin
3587 memNote.Clear;
3588 HTMLViewer.Clear; //kt 8/09
3589 if Selected = nil then Exit;
3590 if uIDNotesActive then
3591 begin
3592 mnuActDetachFromIDParent.Enabled := (Selected.ImageIndex in [IMG_ID_CHILD, IMG_ID_CHILD_ADD]);
3593 popNoteListDetachFromIDParent.Enabled := mnuActDetachFromIDParent.Enabled;
3594 if (Selected.ImageIndex in [IMG_SINGLE, IMG_PARENT, IMG_ID_CHILD, IMG_ID_CHILD_ADD]) then
3595 mnuActAttachtoIDParent.Enabled := CanBeAttached(PDocTreeObject(Selected.Data)^.DocID, WhyNot)
3596 else
3597 mnuActAttachtoIDParent.Enabled := False;
3598 popNoteListAttachtoIDParent.Enabled := mnuActAttachtoIDParent.Enabled;
3599 if (Selected.ImageIndex in [IMG_SINGLE, IMG_PARENT,
3600 IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT,
3601 IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT]) then
3602 mnuActAddIDEntry.Enabled := CanReceiveAttachment(PDocTreeObject(Selected.Data)^.DocID, WhyNot)
3603 else
3604 mnuActAddIDEntry.Enabled := False;
3605 popNoteListAddIDEntry.Enabled := mnuActAddIDEntry.Enabled
3606 end;
3607 RedrawSuspend(lvNotes.Handle);
3608 RedrawSuspend(memNote.Handle);
3609 RedrawSuspend(HTMLViewer.Handle); //kt 8/09
3610 popNoteListExpandSelected.Enabled := Selected.HasChildren;
3611 popNoteListCollapseSelected.Enabled := Selected.HasChildren;
3612 x := TORTreeNode(Selected).StringData;
3613 if (Selected.ImageIndex in [IMG_TOP_LEVEL, IMG_GROUP_OPEN, IMG_GROUP_SHUT]) then
3614 begin
3615 lvNotes.Visible := True;
3616 lvNotes.Items.Clear;
3617 lvNotes.Height := (2 * lvNotes.Parent.Height) div 5;
3618 with lblTitle do
3619 begin
3620 Caption := Trim(Selected.Text);
3621 if (FCurrentContext.SearchField <> '') and (FCurrentContext.Filtered) then
3622 begin
3623 case FCurrentContext.SearchField[1] of
3624 'T': MySearch := 'TITLE';
3625 'S': MySearch := 'SUBJECT';
3626 'B': MySearch := 'TITLE or SUBJECT';
3627 end;
3628// Caption := Caption + ' where ' + MySearch + ' contains "' + UpperCase(FCurrentContext.Keyword) + '"'; <-- original line. //kt 7/19/2007
3629 Caption := Caption + DKLangConstW('fNotes_where') + MySearch + DKLangConstW('fNotes_contains_x') + UpperCase(FCurrentContext.Keyword) + '"'; //kt added 7/19/2007
3630 end;
3631 lvNotes.Caption := Caption;
3632 end;
3633
3634 if Selected.ImageIndex = IMG_TOP_LEVEL then
3635 MyNodeID := Piece(TORTreeNode(Selected).StringData, U, 1)
3636 else if Selected.Parent.ImageIndex = IMG_TOP_LEVEL then
3637 MyNodeID := Piece(TORTreeNode(Selected.Parent).StringData, U, 1)
3638 else if Selected.Parent.Parent.ImageIndex = IMG_TOP_LEVEL then
3639 MyNodeID := Piece(TORTreeNode(Selected.Parent.Parent).StringData, U, 1);
3640
3641 uChanging := True;
3642 TraverseTree(tvNotes, lvNotes, Selected.GetFirstChild, MyNodeID, FCurrentContext);
3643 with lvNotes do
3644 begin
3645 for i := 0 to Columns.Count - 1 do
3646 Columns[i].ImageIndex := IMG_NONE;
3647 ColumnSortForward := FCurrentContext.ListAscending;
3648 if ColumnToSort = 5 then ColumnToSort := 0;
3649 if ColumnSortForward then
3650 Columns[ColumnToSort].ImageIndex := IMG_ASCENDING
3651 else
3652 Columns[ColumnToSort].ImageIndex := IMG_DESCENDING;
3653 if ColumnToSort = 0 then ColumnToSort := 5;
3654 AlphaSort;
3655 Columns[5].Width := 0;
3656 Columns[6].Width := 0;
3657 end;
3658 uChanging := False;
3659 with lvNotes do
3660 if Items.Count > 0 then
3661 begin
3662 Selected := Items[0];
3663 lvNotesSelectItem(Self, Selected, True);
3664 end
3665 else
3666 begin
3667 Selected := nil;
3668 lstNotes.ItemIndex := -1;
3669 memPCEShow.Clear;
3670 ShowPCEControls(False);
3671 end;
3672 //kt 8/09
3673 //kt NOTE: At this point the list has changed. But what is the new note-to-view's format?
3674 // We can't just use FViewMode. Because that just states what mode was used on the last note.
3675 Mode := [vmView] + [vmHTML_MODE[vmHTML in FViewMode]]; //kt 8/09
3676 SetDisplayToHTMLvsText(Mode,nil,VIEW_ACTIVATE_ONLY); //kt 8/09
3677 //kt 8/09 pnlWrite.Visible := False;
3678 //kt 8/09 pnlRead.Visible := True;
3679 // uncommented next 4 lines in v17.5 (RV)
3680 //-----------------------------
3681 UpdateReminderFinish;
3682 ShowPCEControls(False);
3683 frmDrawers.DisplayDrawers(TRUE, [odTemplates], [odTemplates]); //FALSE);
3684 ShowPCEButtons(FALSE);
3685 //-----------------------------
3686 //memNote.Clear;
3687 end
3688 else if StrToIntDef(Piece(x, U, 1), 0) > 0 then
3689 begin
3690 memNote.Clear;
3691 HTMLViewer.Clear; //kt 8/09
3692 lvNotes.Visible := False;
3693 lstNotes.SelectByID(Piece(x, U, 1));
3694 lstNotesClick(Self);
3695 if (vmHTML in FViewMode) then begin //kt 8/09
3696 SendMessage(HTMLViewer.Handle, WM_VSCROLL, SB_TOP, 0); //kt 8/09
3697 end else begin //kt 8/09
3698 SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
3699 end; //kt 8/09
3700 end;
3701 SendMessage(tvNotes.Handle, WM_HSCROLL, SB_THUMBTRACK, 0);
3702 RedrawActivate(lvNotes.Handle);
3703 if (vmHTML in FViewMode) then begin //kt 8/09
3704 RedrawActivate(HtmlViewer.Handle); //kt 8/09
3705 end else begin //kt 8/09
3706 RedrawActivate(memNote.Handle);
3707 end; //kt 8/09
3708 end;
3709end;
3710
3711procedure TfrmNotes.tvNotesCollapsed(Sender: TObject; Node: TTreeNode);
3712begin
3713 with Node do
3714 begin
3715 if (ImageIndex in [IMG_GROUP_OPEN, IMG_IDNOTE_OPEN, IMG_IDPAR_ADDENDA_OPEN]) then
3716 ImageIndex := ImageIndex - 1;
3717 if (SelectedIndex in [IMG_GROUP_OPEN, IMG_IDNOTE_OPEN, IMG_IDPAR_ADDENDA_OPEN]) then
3718 SelectedIndex := SelectedIndex - 1;
3719 end;
3720end;
3721
3722procedure TfrmNotes.tvNotesExpanded(Sender: TObject; Node: TTreeNode);
3723
3724 function SortByTitle(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall;
3725 begin
3726 { Within an ID parent node, sorts in ascending order by title
3727 BUT - addenda to parent document are always at the top of the sort, in date order}
3728 if (Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum') and
3729 (Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum') then
3730 begin
3731 Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
3732 PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
3733 end
3734 else if Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := -1
3735 else if Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := 1
3736 else
3737 begin
3738 if Data = 0 then
3739 Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocTitle),
3740 PChar(PDocTreeObject(Node2.Data)^.DocTitle))
3741 else
3742 Result := -AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocTitle),
3743 PChar(PDocTreeObject(Node2.Data)^.DocTitle));
3744 end
3745 end;
3746
3747 function SortByDate(Node1, Node2: TTreeNode; Data: Longint): Integer; stdcall;
3748 begin
3749 { Within an ID parent node, sorts in ascending order by document date
3750 BUT - addenda to parent document are always at the top of the sort, in date order}
3751 if (Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum') and
3752 (Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum') then
3753 begin
3754 Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
3755 PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
3756 end
3757 else if Copy(PDocTreeObject(Node1.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := -1
3758 else if Copy(PDocTreeObject(Node2.Data)^.DocTitle, 1, 8) = 'Addendum' then Result := 1
3759 else
3760 begin
3761 if Data = 0 then
3762 Result := AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
3763 PChar(PDocTreeObject(Node2.Data)^.DocFMDate))
3764 else
3765 Result := -AnsiStrIComp(PChar(PDocTreeObject(Node1.Data)^.DocFMDate),
3766 PChar(PDocTreeObject(Node2.Data)^.DocFMDate));
3767 end;
3768 end;
3769
3770begin
3771 with Node do
3772 begin
3773 if Assigned(Data) then
3774 if (Pos('<', PDocTreeObject(Data)^.DocHasChildren) > 0) then
3775 begin
3776 if (PDocTreeObject(Node.Data)^.OrderByTitle) then
3777 CustomSort(@SortByTitle, 0)
3778 else
3779 CustomSort(@SortByDate, 0);
3780 end;
3781 if (ImageIndex in [IMG_GROUP_SHUT, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_SHUT]) then
3782 ImageIndex := ImageIndex + 1;
3783 if (SelectedIndex in [IMG_GROUP_SHUT, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_SHUT]) then
3784 SelectedIndex := SelectedIndex + 1;
3785 end;
3786end;
3787
3788procedure TfrmNotes.tvNotesClick(Sender: TObject);
3789begin
3790(* if tvNotes.Selected = nil then exit;
3791 if (tvNotes.Selected.ImageIndex in [IMG_TOP_LEVEL, IMG_GROUP_OPEN, IMG_GROUP_SHUT]) then
3792 begin
3793 uChanging := True;
3794 lvNotes.Selected := nil;
3795 uChanging := False;
3796 memNote.Clear;
3797 end;*)
3798end;
3799
3800procedure TfrmNotes.tvNotesDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
3801var
3802 AnItem: TORTreeNode;
3803begin
3804 Accept := False;
3805 if not uIDNotesActive then exit;
3806 AnItem := TORTreeNode(tvNotes.GetNodeAt(X, Y));
3807 if (AnItem = nil) or (AnItem.ImageIndex in [IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) then Exit;
3808 with tvNotes.Selected do
3809 if (ImageIndex in [IMG_SINGLE, IMG_PARENT, IMG_ID_CHILD, IMG_ID_CHILD_ADD]) then
3810 Accept := (AnItem.ImageIndex in [IMG_SINGLE, IMG_PARENT,
3811 IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT,
3812 IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT])
3813 else if (ImageIndex in [IMG_IDNOTE_OPEN, IMG_IDNOTE_SHUT, IMG_IDPAR_ADDENDA_OPEN, IMG_IDPAR_ADDENDA_SHUT]) then
3814 Accept := (AnItem.ImageIndex in [IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL])
3815 else if (ImageIndex in [IMG_ADDENDUM, IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) then
3816 Accept := False;
3817end;
3818
3819procedure TfrmNotes.tvNotesDragDrop(Sender, Source: TObject; X, Y: Integer);
3820var
3821 HT: THitTests;
3822 Saved: boolean;
3823 ADestNode: TORTreeNode;
3824begin
3825 if not uIDNotesActive then
3826 begin
3827 CancelDrag;
3828 exit;
3829 end;
3830 if tvNotes.Selected = nil then exit;
3831 if EditingIndex <> -1 then
3832 begin
3833 SaveCurrentNote(Saved);
3834 if not Saved then Exit;
3835 end;
3836 HT := tvNotes.GetHitTestInfoAt(X, Y);
3837 ADestNode := TORTreeNode(tvNotes.GetNodeAt(X, Y));
3838 DoAttachIDChild(TORTreeNode(tvNotes.Selected), ADestNode);
3839end;
3840
3841procedure TfrmNotes.tvNotesStartDrag(Sender: TObject; var DragObject: TDragObject);
3842//const
3843//TX_CAP_NO_DRAG = 'Item cannot be moved'; <-- original line. //kt 7/19/2007
3844//TX_NO_EDIT_DRAG = 'Items can not be dragged while a note is being edited.'; <-- original line. //kt 7/19/2007
3845var
3846 WhyNot: string;
3847 //Saved: boolean;
3848 TX_CAP_NO_DRAG : string; //kt
3849 TX_NO_EDIT_DRAG : string; //kt
3850begin
3851 TX_CAP_NO_DRAG := DKLangConstW('fNotes_Item_cannot_be_moved'); //kt added 7/19/2007
3852 TX_NO_EDIT_DRAG := DKLangConstW('fNotes_Items_can_not_be_dragged_while_a_note_is_being_editedx'); //kt added 7/19/2007
3853 if EditingIndex <> -1 then
3854 begin
3855 InfoBox(TX_NO_EDIT_DRAG, TX_CAP_NO_DRAG, MB_ICONERROR or MB_OK);
3856 CancelDrag;
3857 Exit;
3858 end;
3859 if (tvNotes.Selected.ImageIndex in [IMG_ADDENDUM, IMG_GROUP_OPEN, IMG_GROUP_SHUT, IMG_TOP_LEVEL]) or
3860 (not uIDNotesActive) or
3861 (lstNotes.ItemIEN = 0) then
3862 begin
3863 CancelDrag;
3864 Exit;
3865 end;
3866(* if EditingIndex <> -1 then
3867 begin
3868 SaveCurrentNote(Saved);
3869 if not Saved then Exit;
3870 end;*)
3871 if not CanBeAttached(PDocTreeObject(tvNotes.Selected.Data)^.DocID, WhyNot) then
3872 begin
3873 InfoBox(WhyNot, TX_CAP_NO_DRAG, MB_OK);
3874 CancelDrag;
3875 end;
3876end;
3877
3878//===================== Listview events =================================
3879
3880procedure TfrmNotes.lvNotesColumnClick(Sender: TObject; Column: TListColumn);
3881var
3882 i, ClickedColumn: Integer;
3883begin
3884 if Column.Index = 0 then ClickedColumn := 5 else ClickedColumn := Column.Index;
3885 if ClickedColumn = ColumnToSort then
3886 ColumnSortForward := not ColumnSortForward
3887 else
3888 ColumnSortForward := True;
3889 for i := 0 to lvNotes.Columns.Count - 1 do
3890 lvNotes.Columns[i].ImageIndex := IMG_NONE;
3891 if ColumnSortForward then lvNotes.Columns[Column.Index].ImageIndex := IMG_ASCENDING
3892 else lvNotes.Columns[Column.Index].ImageIndex := IMG_DESCENDING;
3893 ColumnToSort := ClickedColumn;
3894 case ColumnToSort of
3895 5: FCurrentContext.SortBy := 'R';
3896 1: FCurrentContext.SortBy := 'D';
3897 2: FCurrentContext.SortBy := 'S';
3898 3: FCurrentContext.SortBy := 'A';
3899 4: FCurrentContext.SortBy := 'L';
3900 else
3901 FCurrentContext.SortBy := 'R';
3902 end;
3903 FCurrentContext.ListAscending := ColumnSortForward;
3904 (Sender as TCustomListView).AlphaSort;
3905 //with lvNotes do if Selected <> nil then Scroll(0, Selected.Top - TopItem.Top);
3906end;
3907
3908procedure TfrmNotes.lvNotesCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
3909var
3910 ix: Integer;
3911begin
3912 if ColumnToSort = 0 then
3913 Compare := CompareText(Item1.Caption,Item2.Caption)
3914 else begin
3915 ix := ColumnToSort - 1;
3916 Compare := CompareText(Item1.SubItems[ix],Item2.SubItems[ix]);
3917 end;
3918 if not ColumnSortForward then Compare := -Compare;
3919end;
3920
3921procedure TfrmNotes.lvNotesSelectItem(Sender: TObject; Item: TListItem;
3922 Selected: Boolean);
3923begin
3924 if uChanging or (not Selected) then Exit;
3925 with lvNotes do
3926 begin
3927// StatusText('Retrieving selected progress note...'); <-- original line. //kt 7/19/2007
3928 StatusText(DKLangConstW('fNotes_Retrieving_selected_progress_notexxx')); //kt added 7/19/2007
3929 lstNotes.SelectByID(Item.SubItems[5]);
3930 lstNotesClick(Self);
3931 if (vmHTML in FViewMode) then begin //kt 8/09
3932 SendMessage(HTMLViewer.Handle, WM_VSCROLL, SB_TOP, 0); //kt 8/09
3933 end else begin //kt 8/09
3934 SendMessage(memNote.Handle, WM_VSCROLL, SB_TOP, 0);
3935 end; //kt 8/09
3936 end;
3937end;
3938
3939procedure TfrmNotes.lvNotesResize(Sender: TObject);
3940begin
3941 inherited;
3942 with lvNotes do
3943 begin
3944 if not FCurrentContext.ShowSubject then
3945 begin
3946 Columns[1].Width := 2 * (Width div 5);
3947 Columns[2].Width := 0;
3948 end
3949 else
3950 begin
3951 Columns[1].Width := Width div 5;
3952 Columns[2].Width := Columns[1].Width;
3953 end;
3954 end;
3955end;
3956
3957procedure TfrmNotes.EnableDisableIDNotes;
3958begin
3959 uIDNotesActive := IDNotesInstalled;
3960 mnuActDetachFromIDParent.Visible := uIDNotesActive;
3961 popNoteListDetachFromIDParent.Visible := uIDNotesActive;
3962 mnuActAddIDEntry.Visible := uIDNotesActive;
3963 popNoteListAddIDEntry.Visible := uIDNotesActive;
3964 mnuActAttachtoIDParent.Visible := uIDNotesActive;
3965 popNoteListAttachtoIDParent.Visible := uIDNotesActive;
3966 if uIDNotesActive then
3967 tvNotes.DragMode := dmAutomatic
3968 else
3969 tvNotes.DragMode := dmManual;
3970end;
3971
3972procedure TfrmNotes.ShowPCEButtons(Editing: boolean);
3973begin
3974 if frmFrame.Timedout then Exit;
3975
3976 FEditingNotePCEObj := Editing;
3977 if Editing or AnytimeEncounters then
3978 begin
3979 cmdPCE.Visible := TRUE;
3980 if Editing then
3981 begin
3982 cmdPCE.Enabled := CanEditPCE(uPCEEdit);
3983 cmdNewNote.Visible := AnytimeEncounters;
3984 cmdNewNote.Enabled := FALSE;
3985 end
3986 else
3987 begin
3988 cmdPCE.Enabled := (GetAskPCE(0) <> apDisable);
3989 cmdNewNote.Visible := TRUE;
3990 cmdNewNote.Enabled := (FStarting = False); //TRUE;
3991 end;
3992 if cmdNewNote.Visible then
3993 cmdPCE.Top := cmdNewNote.Top-cmdPCE.Height;
3994 end
3995 else
3996 begin
3997 cmdPCE.Enabled := FALSE;
3998 cmdPCE.Visible := FALSE;
3999 cmdNewNote.Visible := TRUE;
4000 cmdNewNote.Enabled := (FStarting = False); //TRUE;
4001 end;
4002 if cmdPCE.Visible then
4003 lblSpace1.Top := cmdPCE.Top - lblSpace1.Height
4004 else
4005 lblSpace1.Top := cmdNewNote.Top - lblSpace1.Height;
4006 popNoteMemoEncounter.Enabled := cmdPCE.Enabled;
4007 popNoteMemoEncounter.Visible := cmdPCE.Visible;
4008end;
4009
4010procedure TfrmNotes.mnuIconLegendClick(Sender: TObject);
4011begin
4012 inherited;
4013 ShowIconLegend(ilNotes);
4014end;
4015
4016procedure TfrmNotes.mnuActAttachtoIDParentClick(Sender: TObject);
4017var
4018 AChildNode: TORTreeNode;
4019 AParentID: string;
4020 SavedDocID: string;
4021 Saved: boolean;
4022begin
4023 inherited;
4024 if not uIDNotesActive then exit;
4025 if lstNotes.ItemIEN = 0 then exit;
4026 SavedDocID := lstNotes.ItemID;
4027 if EditingIndex <> -1 then
4028 begin
4029 SaveCurrentNote(Saved);
4030 if not Saved then Exit;
4031 LoadNotes;
4032 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
4033 end;
4034 if tvNotes.Selected = nil then exit;
4035 AChildNode := TORTreeNode(tvNotes.Selected);
4036 AParentID := SelectParentNodeFromList(tvNotes);
4037 if AParentID = '' then exit;
4038 with tvNotes do Selected := FindPieceNode(AParentID, 1, U, Items.GetFirstNode);
4039 DoAttachIDChild(AChildNode, TORTreeNode(tvNotes.Selected));
4040end;
4041
4042procedure TfrmNotes.DoAttachIDChild(AChild, AParent: TORTreeNode);
4043//const
4044//TX_ATTACH_CNF = 'Confirm Attachment'; <-- original line. //kt 7/19/2007
4045//TX_ATTACH_FAILURE = 'Attachment failed'; <-- original line. //kt 7/19/2007
4046var
4047 ErrMsg, WhyNot: string;
4048 SavedDocID: string;
4049 TX_ATTACH_CNF : string; //kt
4050 TX_ATTACH_FAILURE : string; //kt
4051begin
4052 SetupVars; //kt added 7/19/2007 to replace constants with vars.
4053 TX_ATTACH_CNF := DKLangConstW('fNotes_Confirm_Attachment'); //kt added 7/19/2007
4054 TX_ATTACH_FAILURE := DKLangConstW('fNotes_Attachment_failed'); //kt added 7/19/2007
4055 if (AChild = nil) or (AParent = nil) then exit;
4056 ErrMsg := '';
4057 if not CanBeAttached(PDocTreeObject(AChild.Data)^.DocID, WhyNot) then
4058 ErrMsg := ErrMsg + WhyNot + CRLF + CRLF;
4059 if not CanReceiveAttachment(PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
4060 ErrMsg := ErrMsg + WhyNot;
4061 if ErrMsg <> '' then
4062 begin
4063 InfoBox(ErrMsg, TX_ATTACH_FAILURE, MB_OK);
4064 Exit;
4065 end
4066 else
4067 begin
4068 WhyNot := '';
4069 if (InfoBox('ATTACH: ' + AChild.Text + CRLF + CRLF +
4070 ' TO: ' + AParent.Text + CRLF + CRLF +
4071// 'Are you sure?', TX_ATTACH_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) <-- original line. //kt 7/19/2007
4072 DKLangConstW('fNotes_Are_you_surex'), TX_ATTACH_CNF, MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) <> IDYES) //kt added 7/19/2007
4073 then Exit;
4074 SavedDocID := PDocTreeObject(AParent.Data)^.DocID;
4075 end;
4076 if AChild.ImageIndex in [IMG_ID_CHILD, IMG_ID_CHILD_ADD] then
4077 begin
4078 if DetachEntryFromParent(PDocTreeObject(AChild.Data)^.DocID, WhyNot) then
4079 begin
4080 if AttachEntryToParent(PDocTreeObject(AChild.Data)^.DocID, PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
4081 begin
4082 LoadNotes;
4083 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
4084 if tvNotes.Selected <> nil then tvNotes.Selected.Expand(False);
4085 end
4086 else
4087 InfoBox(WhyNot, TX_ATTACH_FAILURE, MB_OK);
4088 end
4089 else
4090 begin
4091 WhyNot := StringReplace(WhyNot, 'ATTACH', 'DETACH', [rfIgnoreCase]);
4092 WhyNot := StringReplace(WhyNot, 'to an ID', 'from an ID', [rfIgnoreCase]);
4093 InfoBox(WhyNot, TX_DETACH_FAILURE, MB_OK);
4094 Exit;
4095 end;
4096 end
4097 else
4098 begin
4099 if AttachEntryToParent(PDocTreeObject(AChild.Data)^.DocID, PDocTreeObject(AParent.Data)^.DocID, WhyNot) then
4100 begin
4101 LoadNotes;
4102 with tvNotes do Selected := FindPieceNode(SavedDocID, U, Items.GetFirstNode);
4103 if tvNotes.Selected <> nil then tvNotes.Selected.Expand(False);
4104 end
4105 else
4106 InfoBox(WhyNot, TX_ATTACH_FAILURE, MB_OK);
4107 end;
4108end;
4109
4110function TfrmNotes.SetNoteTreeLabel(AContext: TTIUContext): string;
4111var
4112 x: string;
4113
4114 function SetDateRangeText(AContext: TTIUContext): string;
4115 var
4116 x1: string;
4117 begin
4118 with AContext do
4119 if BeginDate <> '' then
4120 begin
4121 x1 := ' from ' + UpperCase(BeginDate);
4122// if EndDate <> '' then x1 := x1 + ' to ' + UpperCase(EndDate) <-- original line. //kt 7/19/2007
4123 if EndDate <> '' then x1 := x1 + DKLangConstW('fNotes_to') + UpperCase(EndDate) //kt added 7/19/2007
4124 else x1 := x1 + ' to TODAY';
4125 end;
4126 Result := x1;
4127 end;
4128
4129begin
4130 with AContext do
4131 begin
4132// if MaxDocs > 0 then x := 'Last ' + IntToStr(MaxDocs) + ' ' else x := 'All '; <-- original line. //kt 7/19/2007
4133 if MaxDocs > 0 then x := DKLangConstW('fNotes_Last') + IntToStr(MaxDocs) + ' ' else x := DKLangConstW('fNotes_All'); //kt added 7/19/2007
4134 case StrToIntDef(Status, 0) of
4135// NC_ALL : x := x + 'Signed Notes'; <-- original line. //kt 7/19/2007
4136 NC_ALL : x := x + DKLangConstW('fNotes_Signed_Notes'); //kt added 7/19/2007
4137 NC_UNSIGNED : begin
4138// x := x + 'Unsigned Notes for '; <-- original line. //kt 7/19/2007
4139 x := x + DKLangConstW('fNotes_Unsigned_Notes_for'); //kt added 7/19/2007
4140 if Author > 0 then x := x + ExternalName(Author, 200)
4141 else x := x + User.Name;
4142 x := x + SetDateRangeText(AContext);
4143 end;
4144 NC_UNCOSIGNED : begin
4145// x := x + 'Uncosigned Notes for '; <-- original line. //kt 7/19/2007
4146 x := x + DKLangConstW('fNotes_Uncosigned_Notes_for'); //kt added 7/19/2007
4147 if Author > 0 then x := x + ExternalName(Author, 200)
4148 else x := x + User.Name;
4149 x := x + SetDateRangeText(AContext);
4150 end;
4151// NC_BY_AUTHOR : x := x + 'Signed Notes for ' + ExternalName(Author, 200) + SetDateRangeText(AContext); <-- original line. //kt 7/19/2007
4152 NC_BY_AUTHOR : x := x + DKLangConstW('fNotes_Signed_Notes_for') + ExternalName(Author, 200) + SetDateRangeText(AContext); //kt added 7/19/2007
4153// NC_BY_DATE : x := x + 'Signed Notes ' + SetDateRangeText(AContext); <-- original line. //kt 7/19/2007
4154 NC_BY_DATE : x := x + DKLangConstW('fNotes_Signed_Notes') + SetDateRangeText(AContext); //kt added 7/19/2007
4155 else
4156// x := 'Custom List'; <-- original line. //kt 7/19/2007
4157 x := DKLangConstW('fNotes_Custom_List'); //kt added 7/19/2007
4158 end;
4159 end;
4160 Result := x;
4161end;
4162
4163procedure TfrmNotes.memNewNoteKeyDown(Sender: TObject; var Key: Word;
4164 Shift: TShiftState);
4165begin
4166 inherited;
4167 FNavigatingTab := (Key = VK_TAB) and ([ssShift,ssCtrl] * Shift <> []);
4168 if FNavigatingTab then
4169 Key := 0;
4170end;
4171
4172procedure TfrmNotes.UpdateNoteAuthor(DocInfo: string);
4173//const
4174//TX_INVALID_AUTHOR1 = 'The author returned by the template ('; <-- original line. //kt 7/19/2007
4175//TX_INVALID_AUTHOR2 = ') is not valid.' + #13#10 + 'The note''s author will remain as '; <-- original line. //kt 7/19/2007
4176//TC_INVALID_AUTHOR = 'Invalid Author'; <-- original line. //kt 7/19/2007
4177//TX_COSIGNER_REQD = ' requires a cosigner for this note.'; <-- original line. //kt 7/19/2007
4178//TC_COSIGNER_REQD = 'Cosigner Required'; <-- original line. //kt 7/19/2007
4179var
4180 NewAuth, NewAuthName, AuthNameCheck, x: string;
4181 ADummySender: TObject;
4182 TX_INVALID_AUTHOR1 : string; //kt
4183 TX_INVALID_AUTHOR2 : string; //kt
4184 TC_INVALID_AUTHOR : string; //kt
4185 TX_COSIGNER_REQD : string; //kt
4186 TC_COSIGNER_REQD : string; //kt
4187begin
4188 TX_INVALID_AUTHOR1 := DKLangConstW('fNotes_The_author_returned_by_the_template_x'); //kt added 7/19/2007
4189 TX_INVALID_AUTHOR2 := DKLangConstW('fNotes_x_is_not_validx') + #13#10 + DKLangConstW('fNotes_The_notexxs_author_will_remain_as'); //kt added 7/19/2007
4190 TC_INVALID_AUTHOR := DKLangConstW('fNotes_Invalid_Author'); //kt added 7/19/2007
4191 TX_COSIGNER_REQD := DKLangConstW('fNotes_requires_a_cosigner_for_this_notex'); //kt added 7/19/2007
4192 TC_COSIGNER_REQD := DKLangConstW('fNotes_Cosigner_Required'); //kt added 7/19/2007
4193 SetupVars; //kt added 7/19/2007 to replace constants with vars.
4194 if DocInfo = '' then Exit;
4195 NewAuth := GetXMLParamReturnValueTIU(DocInfo, 'AUTHOR_IEN');
4196 if NewAuth = '' then Exit;
4197 AuthNameCheck := ExternalName(StrToInt64Def(NewAuth, 0), 200);
4198 if AuthNameCheck = '' then
4199 begin
4200 NewAuthName := GetXMLParamReturnValueTIU(DocInfo, 'AUTHOR_NAME');
4201 InfoBox(TX_INVALID_AUTHOR1 + UpperCase(NewAuthName) + TX_INVALID_AUTHOR2 + UpperCase(FEditNote.AuthorName),
4202 TC_INVALID_AUTHOR, MB_OK and MB_ICONERROR);
4203 Exit;
4204 end;
4205 with FEditNote do if StrToInt64Def(NewAuth, 0) <> Author then
4206 begin
4207 Author := StrToInt64Def(NewAuth, 0);
4208 AuthorName := AuthNameCheck;
4209 x := lstNotes.Items[EditingIndex];
4210 SetPiece(x, U, 5, NewAuth + ';' + AuthNameCheck);
4211 lstNotes.Items[EditingIndex] := x;
4212 if AskCosignerForTitle(Title, Author, DateTime) then
4213 begin
4214 InfoBox(UpperCase(AuthNameCheck) + TX_COSIGNER_REQD, TC_COSIGNER_REQD, MB_OK);
4215 //Cosigner := 0; CosignerName := ''; // not sure about this yet
4216 ADummySender := TObject.Create;
4217 try
4218 cmdChangeClick(ADummySender);
4219 finally
4220 FreeAndNil(ADummySender);
4221 end;
4222 end
4223 else cmdChangeClick(Self);
4224 end;
4225end;
4226
4227procedure TfrmNotes.sptHorzCanResize(Sender: TObject; var NewSize: Integer;
4228 var Accept: Boolean);
4229begin
4230 inherited;
4231 if pnlWrite.Visible then
4232 if NewSize > frmNotes.ClientWidth - memNewNote.Constraints.MinWidth - sptHorz.Width then
4233 NewSize := frmNotes.ClientWidth - memNewNote.Constraints.MinWidth - sptHorz.Width;
4234end;
4235
4236(*
4237//kt 5-2-05 added following function (initially copied from fReports.pas)
4238procedure TfrmNotes.WebBrowser1DocumentComplete(Sender: TObject;
4239 const pDisp: IDispatch; var URL: OleVariant);
4240var
4241 WebDoc: IHtmlDocument2;
4242 v: variant;
4243begin
4244 {
4245 inherited;
4246 if uHTMLDoc = '' then Exit;
4247 if not(uReportType = 'H') then Exit; //this can be removed if & when browser replaces memtext control
4248 if not Assigned(WebBrowser1.Document) then Exit;
4249 WebDoc := WebBrowser1.Document as IHtmlDocument2;
4250 v := VarArrayCreate([0, 0], varVariant);
4251 v[0] := uHTMLDoc;
4252 WebDoc.write(PSafeArray(TVarData(v).VArray));
4253 WebDoc.close;
4254 //uHTMLDoc := '';
4255 }
4256end;
4257*)
4258
4259procedure TfrmNotes.popNoteMemoInsTemplateClick(Sender: TObject);
4260begin
4261 frmDrawers.mnuInsertTemplateClick(Sender);
4262end;
4263
4264procedure TfrmNotes.popNoteMemoPreviewClick(Sender: TObject);
4265begin
4266 frmDrawers.mnuPreviewTemplateClick(Sender);
4267end;
4268
4269procedure TfrmNotes.tvNotesAddition(Sender: TObject; Node: TTreeNode);
4270begin
4271 inherited;
4272 TAccessibleTreeNode.WrapControl(Node as TORTreeNode);
4273end;
4274
4275procedure TfrmNotes.tvNotesDeletion(Sender: TObject; Node: TTreeNode);
4276begin
4277 TAccessibleTreeNode.UnwrapControl(Node as TORTreeNode);
4278 inherited;
4279end;
4280
4281{Tab Order tricks. Need to change
4282 tvNotes
4283
4284 frmDrawers.pnlTemplateButton
4285 frmDrawers.pnlEncounterButton
4286 cmdNewNote
4287 cmdPCE
4288
4289 lvNotes
4290 memNote
4291
4292to
4293 tvNotes
4294
4295 lvNotes
4296 memNote
4297
4298 frmDrawers.pnlTemplateButton
4299 frmDrawers.pnlEncounterButton
4300 cmdNewNote
4301 cmdPCE
4302}
4303
4304procedure TfrmNotes.tvNotesExit(Sender: TObject);
4305begin
4306 if IncSecond(FMousing,1) < Now then
4307 begin
4308 if (Screen.ActiveControl = frmDrawers.pnlTemplatesButton) or
4309 (Screen.ActiveControl = frmDrawers.pnlEncounterButton) or
4310 (Screen.ActiveControl = cmdNewNote) or
4311 (Screen.ActiveControl = cmdPCE) then
4312 FindNextControl( cmdPCE, True, True, False).SetFocus;
4313 end;
4314 FMousing := 0;
4315end;
4316
4317procedure TfrmNotes.pnlReadExit(Sender: TObject);
4318begin
4319 inherited;
4320 if IncSecond(FMousing,1) < Now then
4321 begin
4322 if (Screen.ActiveControl = frmFrame.pnlPatient) then
4323 FindNextControl( tvNotes, True, True, False).SetFocus
4324 else
4325 if (Screen.ActiveControl = frmDrawers.pnlTemplatesButton) or
4326 (Screen.ActiveControl = frmDrawers.pnlEncounterButton) or
4327 (Screen.ActiveControl = cmdNewNote) or
4328 (Screen.ActiveControl = cmdPCE) then
4329 FindNextControl( frmDrawers.pnlTemplatesButton, False, True, False).SetFocus;
4330 end;
4331 FMousing := 0;
4332end;
4333
4334procedure TfrmNotes.cmdNewNoteExit(Sender: TObject);
4335begin
4336 inherited;
4337 if IncSecond(FMousing,1) < Now then
4338 begin
4339 if (Screen.ActiveControl = lvNotes) or
4340 (Screen.ActiveControl = memNote) then
4341 frmFrame.pnlPatient.SetFocus
4342 else
4343 if (Screen.ActiveControl = tvNotes) then
4344 FindNextControl( frmFrame.pnlPatient, False, True, False).SetFocus;
4345 end;
4346 FMousing := 0;
4347end;
4348
4349procedure TfrmNotes.frmFramePnlPatientExit(Sender: TObject);
4350begin
4351 FOldFramePnlPatientExit(Sender);
4352 if IncSecond(FMousing,1) < Now then
4353 begin
4354 if (Screen.ActiveControl = lvNotes) or
4355 (Screen.ActiveControl = memNote) then
4356 FindNextControl( lvNotes, False, True, False).SetFocus;
4357 end;
4358 FMousing := 0;
4359end;
4360
4361procedure TfrmNotes.FormHide(Sender: TObject);
4362begin
4363 inherited;
4364 frmFrame.pnlPatient.OnExit := FOldFramePnlPatientExit;
4365 frmDrawers.pnlTemplatesButton.OnExit := FOldDrawerPnlTemplatesButtonExit;
4366 frmDrawers.pnlEncounterButton.OnExit := FOldDrawerPnlEncounterButtonExit;
4367 frmDrawers.edtSearch.OnExit := FOldDrawerEdtSearchExit;
4368end;
4369
4370procedure TfrmNotes.FormShow(Sender: TObject);
4371begin
4372 inherited;
4373 FOldFramePnlPatientExit := frmFrame.pnlPatient.OnExit;
4374 frmFrame.pnlPatient.OnExit := frmFramePnlPatientExit;
4375 FOldDrawerPnlTemplatesButtonExit := frmDrawers.pnlTemplatesButton.OnExit;
4376 frmDrawers.pnlTemplatesButton.OnExit := frmDrawerPnlTemplatesButtonExit;
4377 FOldDrawerPnlEncounterButtonExit := frmDrawers.pnlEncounterButton.OnExit;
4378 frmDrawers.pnlEncounterButton.OnExit := frmDrawerPnlEncounterButtonExit;
4379 FOldDrawerEdtSearchExit := frmDrawers.edtSearch.OnExit;
4380 frmDrawers.edtSearch.OnExit := frmDrawerEdtSearchExit;
4381end;
4382
4383procedure TfrmNotes.frmDrawerEdtSearchExit(Sender: TObject);
4384begin
4385 FOldDrawerEdtSearchExit(Sender);
4386 cmdNewNoteExit(Sender);
4387end;
4388
4389procedure TfrmNotes.frmDrawerPnlTemplatesButtonExit(Sender: TObject);
4390begin
4391 FOldDrawerPnlTemplatesButtonExit(Sender);
4392 if Boolean(Hi(GetKeyState(VK_TAB))) and (memNewNote.CanFocus) and
4393 Boolean(Hi(GetKeyState(VK_SHIFT))) then
4394 memNewNote.SetFocus
4395 else
4396 cmdNewNoteExit(Sender);
4397end;
4398
4399procedure TfrmNotes.frmDrawerPnlEncounterButtonExit(Sender: TObject);
4400begin
4401 FOldDrawerPnlEncounterButtonExit(Sender);
4402 cmdNewNoteExit(Sender);
4403end;
4404
4405procedure TfrmNotes.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
4406 Y: Integer);
4407begin
4408 inherited;
4409 FMousing := Now;
4410end;
4411
4412procedure TfrmNotes.SetHTMLEditMode(HTMLEditMode : boolean; Quiet : boolean);
4413//kt added function 7/09
4414var Mode : TViewModeSet; //kt
4415const HTML_MODE_S : Array[false..true] of string[16] = ('PLAIN','FORMATTED');
4416begin
4417 if FEditNote.Lines = nil then FEditNote.Lines := TStringList.Create; //kt
4418 if HTMLEditMode then begin
4419 if (FViewMode = [vmHTML,vmEdit]) then exit; //no change needed.
4420 FEditNote.Lines.Assign(memNewNote.Lines);
4421 end else begin
4422 if (FViewMode = [vmText,vmEdit]) then exit; //no change needed.
4423 if HtmlEditor.GetTextLen > 0 then begin
4424 if MessageDlg('Do you want to convert this note to PLAIN TEXT?'+#10#13+
4425 '(May cause loss of formatting information.)',mtWarning, mbOKCancel,0) <> mrOK then begin
4426 exit;
4427 end;
4428 end;
4429 FEditNote.Lines.Text := HTMLEditor.Text;
4430 end;
4431 Mode := [vmEdit] + [vmHTML_MODE[HTMLEditMode]]; //kt
4432 SetDisplayToHTMLvsText(Mode,FEditNote.Lines);
4433 if not Quiet then begin
4434 if MessageDlg('Start new notes in '+HTML_MODE_S[HTMLEditMode]+' TEXT by default?',mtConfirmation,[mbYES,mbNO],0) = mrYES then begin
4435 fOptionsNotes.SetDefaultEditHTMLMode(HTMLEditMode);
4436 end;
4437 end;
4438end;
4439
4440procedure TfrmNotes.ToggleHTMLEditMode;
4441//kt added function 6/09
4442var NewHTMLMode: boolean;
4443begin
4444 if not (vmEdit in FViewMode) then exit; //quit if not in edit mode
4445 NewHTMLMode := not (vmHTML in FViewMode);
4446 SetHTMLEditMode(NewHTMLMode);
4447end;
4448
4449
4450procedure TfrmNotes.SetDisplayToHTMLvsText(Mode : TViewModeSet;
4451 Lines : TStrings;
4452 ActivateOnly : boolean {default=False});
4453//kt added function 7/09
4454//If ActivateOnly=True, then the visibility is set, but the control is not filled with text.
4455
4456type
4457 TPanelVisibilityMode = (pvmReadMode, pvmWriteMode); //kt
4458
4459 procedure SetPanelVisibility(Mode: TPanelVisibilityMode; HTMLMode : boolean);
4460
4461 procedure SetpnlReadVisibility(Visible : boolean; HTMLMode : boolean);
4462 begin
4463 pnlRead.Visible := Visible;
4464 if Visible then begin
4465 memNote.Visible := not HTMLMode;
4466 memNote.TabStop := not HTMLMode;
4467 pnlHTMLViewer.Visible := HTMLMode;
4468 HTMLViewer.Visible := HTMLMode;
4469 if HTMLMode then begin
4470 HtmlViewer.BringToFront;
4471 end else begin
4472 MemNote.BringToFront;
4473 end;
4474 end else begin
4475 memNote.Visible := false;
4476 memNote.TabStop := false;
4477 pnlHTMLViewer.Visible := false;
4478 HTMLViewer.Visible := false;
4479 end;
4480 end; {SetDisplayToHTMLvsText.SetPanelVisibility.SetpnlReadVisibility}
4481
4482 procedure SetpnlWriteVisibility(Visible : boolean; HTMLMode : boolean);
4483 begin
4484 pnlWrite.Visible := Visible;
4485 if Visible then begin
4486 pnlHTMLWrite.Visible := HTMLMode;
4487 pnlHTMLEdit.Visible := HTMLMode;
4488 HTMLEditor.Visible := HTMLMode;
4489 pnlTextWrite.Visible := not HTMLMode;
4490 MemNewNote.Visible := not HTMLMode;
4491 if HTMLMode then begin
4492 HTMLEditor.BringToFront;
4493 end else begin
4494 MemNewNote.BringToFront;
4495 end;
4496 end else begin
4497 pnlHTMLWrite.Visible := false;
4498 pnlHTMLEdit.Visible := false;
4499 HTMLEditor.Visible := false;
4500 pnlTextWrite.Visible := false;
4501 memNewNote.Visible := false;
4502 end;
4503 end; {SetDisplayToHTMLvsText.SetPanelVisibility.SetpnlWriteVisibility}
4504
4505 begin {SetDisplayToHTMLvsText.SetPanelVisibility}
4506 SetpnlReadVisibility ((Mode=pvmReadMode), HTMLMode);
4507 SetpnlWriteVisibility((Mode=pvmWriteMode),HTMLMode);
4508 Application.ProcessMessages;
4509 end; {SetDisplayToHTMLvsText.SetPanelVisibility}
4510
4511 procedure SetHTMLorTextEditor(HTMLEditMode : boolean;
4512 Lines : TStrings;
4513 ActivateOnly : boolean {default=False});
4514 procedure ActivateHtmlEditor(Lines : TStrings);
4515 var HTMLText : string;
4516 begin
4517 HtmlEditor.Editable := true;
4518 if ActivateOnly=false then begin
4519 if Lines <> nil then begin
4520 if rHTMLTools.IsHTML(Lines) then begin
4521 HTMLText := Lines.Text;
4522 end else begin
4523 HTMLText := Text2HTML(Lines);
4524 if HTMLText='' then HTMLText := ' ';
4525 end;
4526 end else HTMLText := ' ';
4527 HtmlEditor.HTMLText := HTMLText;
4528 HTMLEditor.KeyStruck := false;
4529 end;
4530 end; {SetDisplayToHTMLvsText.SetHTMLorTextEditor.ActivateHtmlEditor}
4531
4532 procedure ActiveMemoEditor(Lines : TStrings);
4533 begin
4534 if ActivateOnly=false then begin
4535 memNewNote.Lines.Assign(Lines); //kt new
4536 end;
4537 //kt HtmlEditor.Active := false; //stop intercepting OnMessages
4538 HtmlEditor.Clear;
4539 end; {SetDisplayToHTMLvsText.SetHTMLorTextEditor.ActiveMemoEditor}
4540
4541 begin {SetDisplayToHTMLvsText.SetHTMLorTextEditor}
4542 FHTMLEditMode := emHTML_MODE[HTMLEditMode];
4543 FViewMode := [vmEdit] + [vmHTML_MODE[HTMLEditMode]];
4544 SetPanelVisibility(pvmWriteMode,HTMLEditMode);
4545 pnlRight.Repaint; //kt TEMP
4546 if HTMLEditMode then begin
4547 ActivateHtmlEditor(Lines);
4548 end else begin
4549 ActiveMemoEditor(Lines);
4550 end;
4551 pnlRight.Repaint; //kt TEMP
4552 end; {SetDisplayToHTMLvsText.SetHTMLorTextEditor}
4553
4554 procedure SetHTMLorTextViewer(HTMLViewMode : boolean;
4555 Lines : TStrings;
4556 ActivateOnly : boolean); //kt
4557 //Set forms such that either HTML Viewer is visible, or standard edit window.
4558 procedure ActivateHtmlViewer(Lines : TStrings);
4559 begin
4560 with frmNotes do begin
4561
4562 pnlHtmlViewer.Visible := true;
4563 //memNote.Visible := false;
4564 //memNote.TabStop := false;
4565 HtmlViewer.BringToFront;
4566 if ActivateOnly=False then begin
4567 FixHTML(Lines);
4568 HtmlViewer.HTMLText := Lines.Text;
4569 end;
4570 HtmlViewer.Editable := false;
4571 HtmlViewer.BackgroundColor := clCream;
4572 HtmlViewer.TabStop := true;
4573 RedrawActivate(HtmlViewer.Handle);
4574 end;
4575 end; {SetDisplayToHTMLvsText.SetHTMLorTextViewer.ActivateHtmlViewer}
4576
4577 procedure ActivateMemoViewer(Lines : TStrings);
4578 begin
4579 with frmNotes do begin
4580 pnlHtmlViewer.Visible := false;
4581 HtmlViewer.Clear;
4582 //HtmlEditor.Clear; //don't this here. Only clear in ClearEditControls...
4583 HtmlViewer.TabStop := false;
4584 if ActivateOnly=False then memNote.Lines.Assign(Lines); //new
4585 memNote.Visible := true;
4586 memNote.TabStop := true;
4587 memNote.BringToFront;
4588 RedrawActivate(memNote.Handle);
4589 end;
4590 end; {SetDisplayToHTMLvsText.SetHTMLorTextViewer.ActivateMemoViewer}
4591
4592 begin {SetHTMLorTextViewer}
4593 FViewMode := [vmView] + [vmHTML_MODE[HTMLViewMode]];
4594 SetPanelVisibility(pvmReadMode,HTMLviewMode);
4595 //pnlRight.Repaint; //kt TEMP
4596 if HTMLViewMode then begin
4597 ActivateHtmlViewer(Lines);
4598 end else begin
4599 ActivateMemoViewer(Lines);
4600 HtmlViewer.Clear;
4601 end;
4602 pnlRight.Repaint; //kt TEMP
4603 end; {SetDisplayToHTMLvsText.SetHTMLorTextViewer}
4604
4605begin {SetDisplayToHTMLvsText}
4606 if vmEdit in Mode then begin
4607 SetHTMLorTextEditor((vmHTML in Mode),Lines,ActivateOnly);
4608 end else begin
4609 SetHTMLorTextViewer((vmHTML in Mode),Lines,ActivateOnly);
4610 end;
4611end; {SetDisplayToHTMLvsText}
4612
4613procedure TfrmNotes.btnBoldClick(Sender: TObject);
4614//kt added function
4615begin
4616 inherited;
4617 HtmlEditor.ToggleBold;
4618end;
4619
4620procedure TfrmNotes.btnItalicClick(Sender: TObject);
4621//kt added function
4622begin
4623 inherited;
4624 HtmlEditor.ToggleItalic;
4625end;
4626
4627procedure TfrmNotes.btnLessIndentClick(Sender: TObject);
4628//kt added function
4629begin
4630 inherited;
4631 HtmlEditor.Outdent;
4632end;
4633
4634procedure TfrmNotes.btnMoreIndentClick(Sender: TObject);
4635//kt added function
4636begin
4637 inherited;
4638 HtmlEditor.Indent;
4639end;
4640
4641procedure TfrmNotes.btnRightAlignClick(Sender: TObject);
4642//kt added function
4643begin
4644 inherited;
4645 HtmlEditor.AlignRight;
4646end;
4647
4648procedure TfrmNotes.btnImageClick(Sender: TObject);
4649//kt added function
4650begin
4651 if frmImages.ImagesCount > 0 then begin
4652 popupAddImage.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
4653 //Will allow user to :
4654 // Cancel, or trigger mnuAddNewImageClick or mnuSelectExistingImageClick
4655 end else begin
4656 mnuAddNewImageClick(self);
4657 end;
4658end;
4659
4660procedure TfrmNotes.mnuAddNewImageClick(Sender: TObject);
4661//kt added function
4662var
4663 i, AddResult: integer;
4664 oneImage: string;
4665 ImageFName : string;
4666begin
4667 inherited;
4668 UploadForm.AllowNonImages := false; //only allow selection of IMAGES
4669 AddResult := UploadForm.ShowModal;
4670 UploadForm.AllowNonImages := true; // restore to allow any file
4671 if IsAbortResult(AddResult) then exit;
4672 for i := 0 to UploadForm.UploadedImages.Count-1 do begin
4673 ImageFName := CPRSDir+'\Cache\' + UploadForm.UploadedImages.Strings[i];
4674 oneImage := '<img src="'+ ImageFName + '" ' + ALT_IMG_TAG_CONVERT + ' >';
4675 HTMLEditor.InsertHTMLAtCaret(oneImage+#13#10);
4676 end;
4677end;
4678
4679procedure TfrmNotes.mnuSelectExistingImageClick(Sender: TObject);
4680//kt added function
4681var
4682 oneImage: string;
4683 ImageFName : string;
4684begin
4685 inherited;
4686 frmImagePickExisting := TfrmImagePickExisting.Create(Self);
4687 if frmImagePickExisting.ShowModal = mrOK then begin
4688 ImageFName := frmImagePickExisting.SelectedImageFName;
4689 if ImageFName <> '' then begin
4690 if frmImages.ThumbnailIndexForFName(ImageFName) = IMAGE_INDEX_IMAGE then begin
4691 oneImage := '<img src="'+ ImageFName + '" ' + ALT_IMG_TAG_CONVERT + ' >';
4692 end else begin
4693 oneImage := '<embed src="'+ ImageFName + '" ' + ALT_IMG_TAG_CONVERT + ' >';
4694 end;
4695 HTMLEditor.InsertHTMLAtCaret(oneImage+#13#10);
4696 end;
4697 end;
4698 FreeAndNil(frmImagePickExisting);
4699end;
4700
4701
4702procedure TfrmNotes.btnCenterAlignClick(Sender: TObject);
4703//kt added function
4704begin
4705 inherited;
4706 HtmlEditor.AlignCenter;
4707end;
4708
4709procedure TfrmNotes.btnLeftAlignClick(Sender: TObject);
4710//kt added function
4711begin
4712 inherited;
4713 HtmlEditor.AlignLeft;
4714end;
4715
4716procedure TfrmNotes.btnNumbersClick(Sender: TObject);
4717//kt added function
4718begin
4719 inherited;
4720 HtmlEditor.ToggleNumbering;
4721end;
4722
4723procedure TfrmNotes.btnBulletsClick(Sender: TObject);
4724//kt added function
4725begin
4726 inherited;
4727 HtmlEditor.ToggleBullet;
4728end;
4729
4730procedure TfrmNotes.btnUnderlineClick(Sender: TObject);
4731//kt added function
4732begin
4733 inherited;
4734 HtmlEditor.ToggleUnderline;
4735end;
4736
4737procedure TfrmNotes.btnTextColorClick(Sender: TObject);
4738//kt added function
4739begin
4740 inherited;
4741 HtmlEditor.TextForeColorDialog;
4742end;
4743
4744procedure TfrmNotes.btnBackColorClick(Sender: TObject);
4745//kt added function
4746begin
4747 inherited;
4748 HtmlEditor.TextBackColorDialog;
4749end;
4750
4751procedure TfrmNotes.btnFontsClick(Sender: TObject);
4752//kt added function
4753begin
4754 inherited;
4755 HtmlEditor.FontDialog;
4756end;
4757
4758procedure TfrmNotes.cbFontSizeChange(Sender: TObject);
4759//kt added function
4760const
4761 FontSizes : array [0..6] of byte = (8,10,12,14,18,24,36);
4762begin
4763 inherited;
4764 //HtmlEditor.FontSize := StrToInt(cbFontSize.Text);
4765 HtmlEditor.FontSize := FontSizes[cbFontSize.ItemIndex];
4766end;
4767
4768procedure TfrmNotes.cbFontNamesChange(Sender: TObject);
4769//kt added function
4770var i : integer;
4771 FontName : string;
4772const
4773 TEXT_BAR = '---------------';
4774begin
4775 inherited;
4776 if cbFontNames.Text[1]='<' then exit;
4777 FontName := cbFontNames.Text;
4778 HtmlEditor.FontName := FontName;
4779 i := cbFontNames.Items.IndexOf(TEXT_BAR);
4780 if i < 1 then cbFontNames.Items.Insert(0,TEXT_BAR);
4781 if i > 5 then cbFontNames.Items.Delete(5);
4782 if cbFontNames.Items.IndexOf(FontName)> i then begin
4783 cbFontNames.Items.Insert(0,FontName);
4784 end;
4785end;
4786
4787(*
4788//kt made this entire temp function
4789procedure TfrmNotes.WebBrowser1CommandStateChange(Sender: TObject;
4790 Command: Integer; Enable: WordBool);
4791
4792 var
4793 s,ts: String;
4794 Buff : array[0..255] of char;
4795 pBuff : pChar;
4796
4797begin
4798 inherited;
4799 pBuff := @Buff;
4800 case Command of
4801// CSC_UPDATECOMMANDS: ts := '<Some property>'; <-- original line. //kt 7/19/2007
4802// CSC_UPDATECOMMANDS: ts := DKLangConstW('fNotes_xSome_propertyx'); //kt added 7/19/2007
4803 -1: ts := DKLangConstW('fNotes_xSome_propertyx'); //kt changed 9/7/07
4804 CSC_NAVIGATEFORWARD: ts := ''; //'<Navigate Forward>';
4805 CSC_NAVIGATEBACK: ts := ''; //'<Nagivate Backwards>';
4806 else ts := '??';
4807 end; {case}
4808 if ts<>'' then begin
4809// s := 'Browser Status change: ' + ts + '; Enabled= ' + BoolToStr(Enable); <-- original line. //kt 7/19/2007
4810 s := DKLangConstW('fNotes_Browser_Status_changex')+' ' + ts + DKLangConstW('fNotes_x_Enabledx') + BoolToStr(Enable); //kt added 7/19/2007
4811 //Application.MessageBox(StrPCopy(pBuff,s),'Note');
4812 end;
4813end;
4814*)
4815
4816procedure TfrmNotes.memNewNoteKeyPress(Sender: TObject; var Key: Char);
4817begin
4818 inherited;
4819 if FNavigatingTab then
4820 Key := #0; //Disable shift-tab processinend;
4821end;
4822
4823procedure TfrmNotes.memNewNoteKeyUp(Sender: TObject; var Key: Word;
4824 Shift: TShiftState);
4825begin
4826 inherited;
4827 if FNavigatingTab then
4828 begin
4829 if ssShift in Shift then
4830 FindNextControl(Sender as TWinControl, False, True, False).SetFocus //previous control
4831 else if ssCtrl in Shift then
4832 if frmDrawers.pnlTemplatesButton.CanFocus then
4833 frmDrawers.pnlTemplatesButton.SetFocus
4834 else
4835 FindNextControl(Sender as TWinControl, True, True, False).SetFocus; //next control
4836 FNavigatingTab := False;
4837 end;
4838 if (key = VK_ESCAPE) then begin
4839 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
4840 key := 0;
4841 end;
4842end;
4843
4844procedure TfrmNotes.memPCEShowExit(Sender: TObject);
4845begin
4846 inherited;
4847 //Fix the Tab Order Make Drawers Buttons Accessible
4848 if Boolean(Hi(GetKeyState(VK_TAB))) then
4849 if Boolean(Hi(GetKeyState(VK_SHIFT))) then
4850 cmdPCE.SetFocus
4851 else
4852 frmFrame.pnlPatient.SetFocus;
4853end;
4854
4855procedure TfrmNotes.cmdChangeExit(Sender: TObject);
4856begin
4857 inherited;
4858 //Fix the Tab Order Make Drawers Buttons Accessible
4859 if Boolean(Hi(GetKeyState(VK_TAB))) and
4860 Boolean(Hi(GetKeyState(VK_SHIFT))) then
4861 tvNotes.SetFocus;
4862end;
4863
4864procedure TfrmNotes.cmdPCEExit(Sender: TObject);
4865begin
4866 inherited;
4867 //Fix the Tab Order Make Drawers Buttons Accessible
4868 if Boolean(Hi(GetKeyState(VK_TAB))) and
4869 Not Boolean(Hi(GetKeyState(VK_SHIFT))) then
4870 if memPCEShow.Visible then //CQ7120
4871 memPCEShow.SetFocus; //CQ7120
4872end;
4873
4874procedure TfrmNotes.ViewInfo(Sender: TObject);
4875begin
4876 inherited;
4877 frmFrame.ViewInfo(Sender);
4878end;
4879
4880procedure TfrmNotes.mnuViewInformationClick(Sender: TObject);
4881begin
4882 inherited;
4883 mnuViewDemo.Enabled := frmFrame.pnlPatient.Enabled;
4884 mnuViewVisits.Enabled := frmFrame.pnlVisit.Enabled;
4885 mnuViewPrimaryCare.Enabled := frmFrame.pnlPrimaryCare.Enabled;
4886 mnuViewMyHealtheVet.Enabled := not (Copy(frmFrame.laMHV.Hint, 1, 2) = 'No');
4887 mnuInsurance.Enabled := not (Copy(frmFrame.laVAA2.Hint, 1, 2) = 'No');
4888 mnuViewFlags.Enabled := frmFrame.lblFlag.Enabled;
4889 mnuViewRemoteData.Enabled := frmFrame.lblCirn.Enabled;
4890 mnuViewReminders.Enabled := frmFrame.pnlReminders.Enabled;
4891 mnuViewPostings.Enabled := frmFrame.pnlPostings.Enabled;
4892end;
4893
4894procedure TfrmNotes.mnuSearchNotesClick(Sender: TObject);
4895//kt added
4896begin
4897 inherited;
4898 Application.CreateForm(TfrmPtDocSearch, frmPtDocSearch);
4899 if frmPtDocSearch.ShowModal > -1 then begin
4900 //open diff note it selected
4901
4902 end;
4903 frmPtDocSearch.Free;
4904end;
4905
4906procedure TfrmNotes.ChangeToNote(IEN : String; ADFN : String = '-1');
4907//kt added 6/26/10
4908//Effect changing note by simulating a notification click.
4909begin
4910end;
4911
4912
4913initialization
4914 uPCEEdit := TPCEData.Create;
4915 uPCEShow := TPCEData.Create;
4916
4917finalization
4918 if (uPCEEdit <> nil) then uPCEEdit.Free; //CQ7012 Added test for nil
4919 if (uPCEShow <> nil) then uPCEShow.Free; //CQ7012 Added test for nil
4920
4921end.
4922
Note: See TracBrowser for help on using the repository browser.