1 | //kt -- Modified with SourceScanner on 1/17/2008
|
---|
2 | unit rTIU;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, uConst, TRPCB, uTIU, DKLang;
|
---|
7 |
|
---|
8 | type
|
---|
9 | TPatchInstalled = record
|
---|
10 | PatchInstalled: boolean;
|
---|
11 | PatchChecked: boolean;
|
---|
12 | end;
|
---|
13 |
|
---|
14 | { Progress Note Titles }
|
---|
15 | function DfltNoteTitle: Integer;
|
---|
16 | function DfltNoteTitleName: string;
|
---|
17 | procedure ResetNoteTitles;
|
---|
18 | function IsConsultTitle(TitleIEN: Integer): Boolean;
|
---|
19 | function IsPRFTitle(TitleIEN: Integer): Boolean;
|
---|
20 | function IsClinProcTitle(TitleIEN: Integer): Boolean;
|
---|
21 | procedure ListNoteTitlesShort(Dest: TStrings);
|
---|
22 | procedure LoadBoilerPlate(Dest: TStrings; Title: Integer);
|
---|
23 | function PrintNameForTitle(TitleIEN: Integer): string;
|
---|
24 | function SubSetOfNoteTitles(const StartFrom: string; Direction: Integer; IDNotesOnly: boolean): TStrings;
|
---|
25 |
|
---|
26 | { TIU Preferences }
|
---|
27 | procedure ResetTIUPreferences;
|
---|
28 | function AskCosignerForNotes: Boolean;
|
---|
29 | function AskCosignerForDocument(ADocument: Integer; AnAuthor: Int64): Boolean;
|
---|
30 | function AskCosignerForTitle(ATitle: integer; AnAuthor: Int64; ADate: TFMDateTime): Boolean;
|
---|
31 | function AskSubjectForNotes: Boolean;
|
---|
32 | function CanCosign(ATitle, ADocType: integer; AUser: Int64; ADate: TFMDateTime): Boolean;
|
---|
33 | function CanChangeCosigner(IEN: integer): boolean;
|
---|
34 | procedure DefaultCosigner(var IEN: Int64; var Name: string);
|
---|
35 | function ReturnMaxNotes: Integer;
|
---|
36 | function SortNotesAscending: Boolean;
|
---|
37 | function GetCurrentTIUContext: TTIUContext;
|
---|
38 | procedure SaveCurrentTIUContext(AContext: TTIUContext) ;
|
---|
39 | function TIUSiteParams: string;
|
---|
40 | function DfltTIULocation: Integer;
|
---|
41 | function DfltTIULocationName: string;
|
---|
42 |
|
---|
43 | { Data Retrieval }
|
---|
44 | procedure ActOnDocument(var AuthSts: TActionRec; IEN: Integer; const ActionName: string);
|
---|
45 | function AuthorSignedDocument(IEN: Integer): boolean;
|
---|
46 | function CosignDocument(IEN: Integer): Boolean;
|
---|
47 | //function CPTRequiredForNote(IEN: Integer): Boolean;
|
---|
48 | procedure ListNotes(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
|
---|
49 | Person: int64; OccLim: Integer; SortAscending: Boolean);
|
---|
50 | procedure ListNotesForTree(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
|
---|
51 | Person: int64; OccLim: Integer; SortAscending: Boolean);
|
---|
52 | procedure ListConsultRequests(Dest: TStrings);
|
---|
53 | procedure ListDCSumm(Dest: TStrings);
|
---|
54 | procedure LoadDetailText(Dest: TStrings; IEN: Integer); //**KCM**
|
---|
55 | procedure LoadDocumentText(Dest: TStrings; IEN: Integer);
|
---|
56 | procedure GetNoteForEdit(var EditRec: TEditNoteRec; IEN: Integer);
|
---|
57 | function VisitStrForNote(IEN: Integer): string;
|
---|
58 | function GetCurrentSigners(IEN: integer): TStrings;
|
---|
59 | function TitleForNote(IEN: Int64): Integer;
|
---|
60 | function GetConsultIENforNote(NoteIEN: integer): Integer;
|
---|
61 | function GetPackageRefForNote(NoteIEN: integer): string;
|
---|
62 | procedure LockDocument(IEN: Int64; var AnErrMsg: string);
|
---|
63 | procedure UnlockDocument(IEN: Int64);
|
---|
64 | function LastSaveClean(IEN: Int64): Boolean;
|
---|
65 | function NoteHasText(NoteIEN: integer): boolean;
|
---|
66 | function GetTIUListItem(IEN: Int64): string;
|
---|
67 |
|
---|
68 | { Data Storage }
|
---|
69 | //procedure ClearCPTRequired(IEN: Integer);
|
---|
70 | procedure DeleteDocument(var DeleteSts: TActionRec; IEN: Integer; const Reason: string);
|
---|
71 | function JustifyDocumentDelete(IEN: Integer): Boolean;
|
---|
72 | procedure SignDocument(var SignSts: TActionRec; IEN: Integer; const ESCode: string);
|
---|
73 | procedure PutNewNote(var CreatedDoc: TCreatedDoc; const NoteRec: TNoteRec);
|
---|
74 | procedure PutAddendum(var CreatedDoc: TCreatedDoc; const NoteRec: TNoteRec; AddendumTo: Integer);
|
---|
75 | procedure PutEditedNote(var UpdatedDoc: TCreatedDoc; const NoteRec: TNoteRec; NoteIEN: Integer);
|
---|
76 | procedure PutTextOnly(var ErrMsg: string; NoteText: TStrings; NoteIEN: Int64);
|
---|
77 | procedure SetText(var ErrMsg: string; NoteText: TStrings; NoteIEN: Int64; Suppress: Integer);
|
---|
78 | procedure InitParams(NoteIEN: Int64; Suppress: Integer);
|
---|
79 | procedure UpdateAdditionalSigners(IEN: integer; Signers: TStrings);
|
---|
80 | procedure ChangeCosigner(IEN: integer; Cosigner: int64);
|
---|
81 |
|
---|
82 | { Printing }
|
---|
83 | function AllowChartPrintForNote(ANote: Integer): Boolean;
|
---|
84 | procedure PrintNoteToDevice(ANote: Integer; const ADevice: string; ChartCopy: Boolean;
|
---|
85 | var ErrMsg: string);
|
---|
86 | function GetFormattedNote(ANote: Integer; ChartCopy: Boolean): TStrings;
|
---|
87 |
|
---|
88 | // Interdisciplinary Notes
|
---|
89 | function IDNotesInstalled: boolean;
|
---|
90 | function CanTitleBeIDChild(Title: integer; var WhyNot: string): boolean;
|
---|
91 | function CanReceiveAttachment(DocID: string; var WhyNot: string): boolean;
|
---|
92 | function CanBeAttached(DocID: string; var WhyNot: string): boolean;
|
---|
93 | function DetachEntryFromParent(DocID: string; var WhyNot: string): boolean;
|
---|
94 | function AttachEntryToParent(DocID, ParentDocID: string; var WhyNot: string): boolean;
|
---|
95 | function OneNotePerVisit(NoteEIN: Integer; DFN: String;VisitStr: String): boolean;
|
---|
96 |
|
---|
97 |
|
---|
98 | //User Classes
|
---|
99 | function SubSetOfUserClasses(const StartFrom: string; Direction: Integer): TStrings;
|
---|
100 | function UserDivClassInfo(User: Int64): TStrings;
|
---|
101 | function UserInactive(EIN: String): boolean;
|
---|
102 |
|
---|
103 | //Miscellaneous
|
---|
104 | function TIUPatch175Installed: boolean;
|
---|
105 |
|
---|
106 | const
|
---|
107 | CLS_PROGRESS_NOTES = 3;
|
---|
108 |
|
---|
109 | implementation
|
---|
110 |
|
---|
111 | uses rMisc;
|
---|
112 |
|
---|
113 | var
|
---|
114 | uTIUSiteParams: string;
|
---|
115 | uTIUSiteParamsLoaded: boolean = FALSE;
|
---|
116 | uNoteTitles: TNoteTitles;
|
---|
117 | uTIUPrefs: TTIUPrefs;
|
---|
118 | uPatch175Installed: TPatchInstalled;
|
---|
119 |
|
---|
120 |
|
---|
121 | { Progress Note Titles -------------------------------------------------------------------- }
|
---|
122 |
|
---|
123 | procedure LoadNoteTitles;
|
---|
124 | { private - called one time to set up the uNoteTitles object }
|
---|
125 | const
|
---|
126 | CLASS_PROGRESS_NOTES = 3;
|
---|
127 | var
|
---|
128 | x: string;
|
---|
129 | begin
|
---|
130 | if uNoteTitles <> nil then Exit;
|
---|
131 | CallV('TIU PERSONAL TITLE LIST', [User.DUZ, CLS_PROGRESS_NOTES]);
|
---|
132 | RPCBrokerV.Results.Insert(0, '~SHORT LIST'); // insert so can call ExtractItems
|
---|
133 | uNoteTitles := TNoteTitles.Create;
|
---|
134 | ExtractItems(uNoteTitles.ShortList, RPCBrokerV.Results, 'SHORT LIST');
|
---|
135 | x := ExtractDefault(RPCBrokerV.Results, 'SHORT LIST');
|
---|
136 | uNoteTitles.DfltTitle := StrToIntDef(Piece(x, U, 1), 0);
|
---|
137 | uNoteTitles.DfltTitleName := Piece(x, U, 2);
|
---|
138 | end;
|
---|
139 |
|
---|
140 | procedure ResetNoteTitles;
|
---|
141 | begin
|
---|
142 | if uNoteTitles <> nil then
|
---|
143 | begin
|
---|
144 | uNoteTitles.Free;
|
---|
145 | uNoteTitles := nil;
|
---|
146 | LoadNoteTitles;
|
---|
147 | end;
|
---|
148 | end;
|
---|
149 |
|
---|
150 | function DfltNoteTitle: Integer;
|
---|
151 | { returns the IEN of the user defined default progress note title (if any) }
|
---|
152 | begin
|
---|
153 | if uNoteTitles = nil then LoadNoteTitles;
|
---|
154 | Result := uNoteTitles.DfltTitle;
|
---|
155 | end;
|
---|
156 |
|
---|
157 | function DfltNoteTitleName: string;
|
---|
158 | { returns the name of the user defined default progress note title (if any) }
|
---|
159 | begin
|
---|
160 | if uNoteTitles = nil then LoadNoteTitles;
|
---|
161 | Result := uNoteTitles.DfltTitleName;
|
---|
162 | end;
|
---|
163 |
|
---|
164 | function IsConsultTitle(TitleIEN: Integer): Boolean;
|
---|
165 | begin
|
---|
166 | Result := False;
|
---|
167 | if TitleIEN <= 0 then Exit;
|
---|
168 | Result := sCallV('TIU IS THIS A CONSULT?', [TitleIEN]) = '1';
|
---|
169 | end;
|
---|
170 |
|
---|
171 | function IsPRFTitle(TitleIEN: Integer): Boolean;
|
---|
172 | begin
|
---|
173 | Result := False;
|
---|
174 | if TitleIEN <= 0 then Exit;
|
---|
175 | Result := sCallV('TIU ISPRF', [TitleIEN]) = '1';
|
---|
176 | end;
|
---|
177 |
|
---|
178 | function IsClinProcTitle(TitleIEN: Integer): Boolean;
|
---|
179 | begin
|
---|
180 | Result := False;
|
---|
181 | if TitleIEN <= 0 then Exit;
|
---|
182 | Result := sCallV('TIU IS THIS A CLINPROC?', [TitleIEN]) = '1';
|
---|
183 | end;
|
---|
184 |
|
---|
185 | procedure ListNoteTitlesShort(Dest: TStrings);
|
---|
186 | { returns the user defined list (short list) of progress note titles }
|
---|
187 | begin
|
---|
188 | if uNoteTitles = nil then LoadNoteTitles;
|
---|
189 | Dest.AddStrings(uNoteTitles.ShortList);
|
---|
190 | if uNoteTitles.ShortList.Count > 0 then
|
---|
191 | begin
|
---|
192 | Dest.Add('0^________________________________________________________________________');
|
---|
193 | Dest.Add('0^ ');
|
---|
194 | end;
|
---|
195 | end;
|
---|
196 |
|
---|
197 | procedure LoadBoilerPlate(Dest: TStrings; Title: Integer);
|
---|
198 | { returns the boilerplate text (if any) for a given progress note title }
|
---|
199 | begin
|
---|
200 | CallV('TIU LOAD BOILERPLATE TEXT', [Title, Patient.DFN, Encounter.VisitStr]);
|
---|
201 | Dest.Assign(RPCBrokerV.Results);
|
---|
202 | end;
|
---|
203 |
|
---|
204 | function PrintNameForTitle(TitleIEN: Integer): string;
|
---|
205 | begin
|
---|
206 | Result := sCallV('TIU GET PRINT NAME', [TitleIEN]);
|
---|
207 | end;
|
---|
208 |
|
---|
209 | function SubSetOfNoteTitles(const StartFrom: string; Direction: Integer; IDNotesOnly: boolean): TStrings;
|
---|
210 | { returns a pointer to a list of progress note titles (for use in a long list box) -
|
---|
211 | The return value is a pointer to RPCBrokerV.Results, so the data must be used BEFORE
|
---|
212 | the next broker call! }
|
---|
213 | begin
|
---|
214 | if IDNotesOnly then
|
---|
215 | CallV('TIU LONG LIST OF TITLES', [CLS_PROGRESS_NOTES, StartFrom, Direction, IDNotesOnly])
|
---|
216 | else
|
---|
217 | CallV('TIU LONG LIST OF TITLES', [CLS_PROGRESS_NOTES, StartFrom, Direction]);
|
---|
218 | //MixedCaseList(RPCBrokerV.Results);
|
---|
219 | Result := RPCBrokerV.Results;
|
---|
220 | end;
|
---|
221 |
|
---|
222 | { TIU Preferences ------------------------------------------------------------------------- }
|
---|
223 |
|
---|
224 | procedure LoadTIUPrefs;
|
---|
225 | { private - creates TIUPrefs object for reference throughout the session }
|
---|
226 | var
|
---|
227 | x: string;
|
---|
228 | begin
|
---|
229 | uTIUPrefs := TTIUPrefs.Create;
|
---|
230 | with uTIUPrefs do
|
---|
231 | begin
|
---|
232 | x := sCallV('TIU GET PERSONAL PREFERENCES', [User.DUZ]);
|
---|
233 | DfltLoc := StrToIntDef(Piece(x, U, 2), 0);
|
---|
234 | DfltLocName := ExternalName(DfltLoc, FN_HOSPITAL_LOCATION);
|
---|
235 | SortAscending := Piece(x, U, 4) = 'A';
|
---|
236 | SortBy := Piece(x, U, 3);
|
---|
237 | AskNoteSubject := Piece(x, U, 8) = '1';
|
---|
238 | DfltCosigner := StrToInt64Def(Piece(x, U, 9), 0);
|
---|
239 | DfltCosignerName := ExternalName(DfltCosigner, FN_NEW_PERSON);
|
---|
240 | MaxNotes := StrToIntDef(Piece(x, U, 10), 0);
|
---|
241 | x := sCallV('TIU REQUIRES COSIGNATURE', [TYP_PROGRESS_NOTE, 0, User.DUZ]);
|
---|
242 | AskCosigner := Piece(x, U, 1) = '1';
|
---|
243 | end;
|
---|
244 | end;
|
---|
245 |
|
---|
246 | procedure ResetTIUPreferences;
|
---|
247 | begin
|
---|
248 | if uTIUPrefs <> nil then
|
---|
249 | begin
|
---|
250 | uTIUPrefs.Free;
|
---|
251 | uTIUPrefs := nil;
|
---|
252 | LoadTIUPrefs;
|
---|
253 | end;
|
---|
254 | end;
|
---|
255 |
|
---|
256 | function AskCosignerForDocument(ADocument: Integer; AnAuthor: Int64): Boolean;
|
---|
257 | begin
|
---|
258 | Result := Piece(sCallV('TIU REQUIRES COSIGNATURE', [0, ADocument, AnAuthor]), U, 1) = '1';
|
---|
259 | end;
|
---|
260 |
|
---|
261 | function AskCosignerForTitle(ATitle: integer; AnAuthor: Int64; ADate: TFMDateTime): Boolean;
|
---|
262 | { returns TRUE if a cosignature is required for a document title and author }
|
---|
263 | begin
|
---|
264 | if TIUPatch175Installed then
|
---|
265 | Result := Piece(sCallV('TIU REQUIRES COSIGNATURE', [ATitle, 0, AnAuthor, ADate]), U, 1) = '1'
|
---|
266 | else
|
---|
267 | Result := Piece(sCallV('TIU REQUIRES COSIGNATURE', [ATitle, 0, AnAuthor]), U, 1) = '1';
|
---|
268 | end;
|
---|
269 |
|
---|
270 | function AskCosignerForNotes: Boolean;
|
---|
271 | { returns true if cosigner should be asked when creating a new progress note }
|
---|
272 | begin
|
---|
273 | if uTIUPrefs = nil then LoadTIUPrefs;
|
---|
274 | Result := uTIUPrefs.AskCosigner;
|
---|
275 | end;
|
---|
276 |
|
---|
277 | function AskSubjectForNotes: Boolean;
|
---|
278 | { returns true if subject should be asked when creating a new progress note }
|
---|
279 | begin
|
---|
280 | if uTIUPrefs = nil then LoadTIUPrefs;
|
---|
281 | Result := uTIUPrefs.AskNoteSubject;
|
---|
282 | end;
|
---|
283 |
|
---|
284 | function CanCosign(ATitle, ADocType: integer; AUser: Int64; ADate: TFMDateTime): Boolean;
|
---|
285 | begin
|
---|
286 | if ATitle > 0 then ADocType := 0;
|
---|
287 | if TIUPatch175Installed and (ADocType = 0) then
|
---|
288 | Result := Piece(sCallV('TIU REQUIRES COSIGNATURE', [ATitle, ADocType, AUser, ADate]), U, 1) <> '1'
|
---|
289 | else
|
---|
290 | Result := Piece(sCallV('TIU REQUIRES COSIGNATURE', [ATitle, ADocType, AUser]), U, 1) <> '1';
|
---|
291 | end;
|
---|
292 |
|
---|
293 | procedure DefaultCosigner(var IEN: Int64; var Name: string);
|
---|
294 | { returns the IEN (from the New Person file) and Name of this user's default cosigner }
|
---|
295 | begin
|
---|
296 | if uTIUPrefs = nil then LoadTIUPrefs;
|
---|
297 | IEN := uTIUPrefs.DfltCosigner;
|
---|
298 | Name := uTIUPrefs.DfltCosignerName;
|
---|
299 | end;
|
---|
300 |
|
---|
301 | function ReturnMaxNotes: Integer;
|
---|
302 | begin
|
---|
303 | if uTIUPrefs = nil then LoadTIUPrefs;
|
---|
304 | Result := uTIUPrefs.MaxNotes;
|
---|
305 | if Result = 0 then Result := 100;
|
---|
306 | end;
|
---|
307 |
|
---|
308 | function SortNotesAscending: Boolean;
|
---|
309 | { returns true if progress notes should be sorted from oldest to newest (chronological) }
|
---|
310 | begin
|
---|
311 | if uTIUPrefs = nil then LoadTIUPrefs;
|
---|
312 | Result := uTIUPrefs.SortAscending;
|
---|
313 | end;
|
---|
314 |
|
---|
315 | function DfltTIULocation: Integer;
|
---|
316 | { returns the IEN of the user defined default progress note title (if any) }
|
---|
317 | begin
|
---|
318 | if uTIUPrefs = nil then LoadTIUPrefs;
|
---|
319 | Result := uTIUPrefs.DfltLoc;
|
---|
320 | end;
|
---|
321 |
|
---|
322 | function DfltTIULocationName: string;
|
---|
323 | { returns the name of the user defined default progress note title (if any) }
|
---|
324 | begin
|
---|
325 | if uTIUPrefs = nil then LoadTIUPrefs;
|
---|
326 | Result := uTIUPrefs.DfltLocName;
|
---|
327 | end;
|
---|
328 |
|
---|
329 | { Data Retrieval --------------------------------------------------------------------------- }
|
---|
330 |
|
---|
331 | procedure ActOnDocument(var AuthSts: TActionRec; IEN: Integer; const ActionName: string);
|
---|
332 | var
|
---|
333 | x: string;
|
---|
334 | begin
|
---|
335 | if not (IEN > 0) then
|
---|
336 | begin
|
---|
337 | AuthSts.Success := True;
|
---|
338 | AuthSts.Reason := '';
|
---|
339 | Exit;
|
---|
340 | end;
|
---|
341 | x := sCallV('TIU AUTHORIZATION', [IEN, ActionName]);
|
---|
342 | AuthSts.Success := Piece(x, U, 1) = '1';
|
---|
343 | AuthSts.Reason := Piece(x, U, 2);
|
---|
344 | end;
|
---|
345 |
|
---|
346 | function AuthorSignedDocument(IEN: Integer): boolean;
|
---|
347 | begin
|
---|
348 | Result := SCallV('TIU HAS AUTHOR SIGNED?', [IEN, User.DUZ]) = '1';
|
---|
349 | end;
|
---|
350 |
|
---|
351 | function CosignDocument(IEN: Integer): Boolean;
|
---|
352 | var
|
---|
353 | x: string;
|
---|
354 | begin
|
---|
355 | x := sCallV('TIU WHICH SIGNATURE ACTION', [IEN]);
|
---|
356 | Result := x = 'COSIGNATURE';
|
---|
357 | end;
|
---|
358 |
|
---|
359 | (*function CPTRequiredForNote(IEN: Integer): Boolean;
|
---|
360 | begin
|
---|
361 | If IEN > 0 then
|
---|
362 | Result := sCallV('ORWPCE CPTREQD', [IEN]) = '1'
|
---|
363 | else
|
---|
364 | Result := False;
|
---|
365 | end;*)
|
---|
366 |
|
---|
367 | procedure ListConsultRequests(Dest: TStrings);
|
---|
368 | { lists outstanding consult requests for a patient: IEN^Request D/T^Service^Procedure }
|
---|
369 | begin
|
---|
370 | CallV('GMRC LIST CONSULT REQUESTS', [Patient.DFN]);
|
---|
371 | //MixedCaseList(RPCBrokerV.Results);
|
---|
372 | { remove first returned string, it is just a count }
|
---|
373 | if RPCBrokerV.Results.Count > 0 then RPCBrokerV.Results.Delete(0);
|
---|
374 | SetListFMDateTime('mmm dd,yy hh:nn', TStringList(RPCBrokerV.Results), U, 2);
|
---|
375 | Dest.Assign(RPCBrokerV.Results);
|
---|
376 | end;
|
---|
377 |
|
---|
378 | procedure ListNotes(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
|
---|
379 | Person: int64; OccLim: Integer; SortAscending: Boolean);
|
---|
380 | { retrieves existing progress notes for a patient according to the parameters passed in
|
---|
381 | Pieces: IEN^Title^FMDateOfNote^Patient^Author^Location^Status^Visit
|
---|
382 | Return: IEN^ExDateOfNote^Title, Location, Author^ImageCount^Visit }
|
---|
383 | var
|
---|
384 | i: Integer;
|
---|
385 | x: string;
|
---|
386 | SortSeq: Char;
|
---|
387 | begin
|
---|
388 | if SortAscending then SortSeq := 'A' else SortSeq := 'D';
|
---|
389 | //if OccLim = 0 then OccLim := MaxNotesReturned;
|
---|
390 | CallV('TIU DOCUMENTS BY CONTEXT',
|
---|
391 | [3, Context, Patient.DFN, Early, Late, Person, OccLim, SortSeq]);
|
---|
392 | with RPCBrokerV do
|
---|
393 | begin
|
---|
394 | for i := 0 to Results.Count - 1 do
|
---|
395 | begin
|
---|
396 | x := Results[i];
|
---|
397 | x := Piece(x, U, 1) + U + FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(x, U, 3))) +
|
---|
398 | U + Piece(x, U, 2) + ', ' + Piece(x, U, 6) + ', ' + Piece(Piece(x, U, 5), ';', 2) +
|
---|
399 | U + Piece(x, U, 11) + U + Piece(x, U, 8) + U + Piece(x, U, 3);
|
---|
400 | Results[i] := x;
|
---|
401 | end; {for}
|
---|
402 | Dest.Assign(Results);
|
---|
403 | end; {with}
|
---|
404 | end;
|
---|
405 |
|
---|
406 | procedure ListNotesForTree(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
|
---|
407 | Person: int64; OccLim: Integer; SortAscending: Boolean);
|
---|
408 | { retrieves existing progress notes for a patient according to the parameters passed in
|
---|
409 | Pieces: IEN^Title^FMDateOfNote^Patient^Author^Location^Status^Visit
|
---|
410 | Return: IEN^ExDateOfNote^Title, Location, Author^ImageCount^Visit }
|
---|
411 | var
|
---|
412 | SortSeq: Char;
|
---|
413 | const
|
---|
414 | SHOW_ADDENDA = True;
|
---|
415 | begin
|
---|
416 | if SortAscending then SortSeq := 'A' else SortSeq := 'D';
|
---|
417 | if Context > 0 then
|
---|
418 | begin
|
---|
419 | CallV('TIU DOCUMENTS BY CONTEXT', [3, Context, Patient.DFN, Early, Late, Person, OccLim, SortSeq, SHOW_ADDENDA]);
|
---|
420 | Dest.Assign(RPCBrokerV.Results);
|
---|
421 | end;
|
---|
422 | end;
|
---|
423 |
|
---|
424 | procedure ListDCSumm(Dest: TStrings);
|
---|
425 | { returns the list of discharge summaries for a patient - see ListNotes for pieces }
|
---|
426 | var
|
---|
427 | i: Integer;
|
---|
428 | x: string;
|
---|
429 | begin
|
---|
430 | CallV('TIU SUMMARIES', [Patient.DFN]);
|
---|
431 | with RPCBrokerV do
|
---|
432 | begin
|
---|
433 | SortByPiece(TStringList(Results), U, 3); // sort on date/time of summary
|
---|
434 | for i := 0 to Results.Count - 1 do
|
---|
435 | begin
|
---|
436 | x := Results[i];
|
---|
437 | x := Piece(x, U, 1) + U + FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(x, U, 3)))
|
---|
438 | + U + Piece(x, U, 2) + ', ' + Piece(x, U, 6) + ', ' + Piece(Piece(x, U, 5), ';', 2);
|
---|
439 | Results[i] := x;
|
---|
440 | end; {for}
|
---|
441 | Dest.Assign(Results);
|
---|
442 | end; {with}
|
---|
443 | end;
|
---|
444 |
|
---|
445 | procedure LoadDocumentText(Dest: TStrings; IEN: Integer);
|
---|
446 | { returns the text of a document (progress note, discharge summary, etc.) }
|
---|
447 | begin
|
---|
448 | CallV('TIU GET RECORD TEXT', [IEN]);
|
---|
449 | Dest.Assign(RPCBrokerV.Results);
|
---|
450 | end;
|
---|
451 |
|
---|
452 | procedure LoadDetailText(Dest: TStrings; IEN: Integer); //**KCM**
|
---|
453 | begin
|
---|
454 | CallV('TIU DETAILED DISPLAY', [IEN]);
|
---|
455 | Dest.Assign(RPCBrokerV.Results);
|
---|
456 | end;
|
---|
457 |
|
---|
458 | procedure GetNoteForEdit(var EditRec: TEditNoteRec; IEN: Integer);
|
---|
459 | { retrieves internal/external values for progress note fields & loads them into EditRec
|
---|
460 | Fields: Title:.01, RefDate:1301, Author:1204, Cosigner:1208, Subject:1701, Location:1205 }
|
---|
461 | var
|
---|
462 | i, j: Integer;
|
---|
463 | //x: string;
|
---|
464 |
|
---|
465 | function FindDT(const FieldID: string): TFMDateTime;
|
---|
466 | var
|
---|
467 | i: Integer;
|
---|
468 | begin
|
---|
469 | Result := 0;
|
---|
470 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
471 | if Piece(Results[i], U, 1) = FieldID then
|
---|
472 | begin
|
---|
473 | Result := MakeFMDateTime(Piece(Results[i], U, 2));
|
---|
474 | Break;
|
---|
475 | end;
|
---|
476 | end;
|
---|
477 |
|
---|
478 | function FindExt(const FieldID: string): string;
|
---|
479 | var
|
---|
480 | i: Integer;
|
---|
481 | begin
|
---|
482 | Result := '';
|
---|
483 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
484 | if Piece(Results[i], U, 1) = FieldID then
|
---|
485 | begin
|
---|
486 | Result := Piece(Results[i], U, 3);
|
---|
487 | Break;
|
---|
488 | end;
|
---|
489 | end;
|
---|
490 |
|
---|
491 | function FindInt(const FieldID: string): Integer;
|
---|
492 | var
|
---|
493 | i: Integer;
|
---|
494 | begin
|
---|
495 | Result := 0;
|
---|
496 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
497 | if Piece(Results[i], U, 1) = FieldID then
|
---|
498 | begin
|
---|
499 | Result := StrToIntDef(Piece(Results[i], U, 2), 0);
|
---|
500 | Break;
|
---|
501 | end;
|
---|
502 | end;
|
---|
503 |
|
---|
504 | function FindInt64(const FieldID: string): Int64;
|
---|
505 | var
|
---|
506 | i: Integer;
|
---|
507 | begin
|
---|
508 | Result := 0;
|
---|
509 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
510 | if Piece(Results[i], U, 1) = FieldID then
|
---|
511 | begin
|
---|
512 | Result := StrToInt64Def(Piece(Results[i], U, 2), 0);
|
---|
513 | Break;
|
---|
514 | end;
|
---|
515 | end;
|
---|
516 |
|
---|
517 | function FindVal(const FieldID: string): string;
|
---|
518 | var
|
---|
519 | i: Integer;
|
---|
520 | begin
|
---|
521 | Result := '';
|
---|
522 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
523 | if Piece(Results[i], U, 1) = FieldID then
|
---|
524 | begin
|
---|
525 | Result := Piece(Results[i], U, 2);
|
---|
526 | Break;
|
---|
527 | end;
|
---|
528 | end;
|
---|
529 |
|
---|
530 | begin
|
---|
531 | CallV('TIU LOAD RECORD FOR EDIT', [IEN, '.01;.06;.07;1301;1204;1208;1701;1205;1405;2101;70201;70202']);
|
---|
532 | FillChar(EditRec, SizeOf(EditRec), 0);
|
---|
533 | with EditRec do
|
---|
534 | begin
|
---|
535 | Title := FindInt('.01');
|
---|
536 | TitleName := FindExt('.01');
|
---|
537 | DateTime := FindDT('1301');
|
---|
538 | Author := FindInt64('1204');
|
---|
539 | AuthorName := FindExt('1204');
|
---|
540 | Cosigner := FindInt64('1208');
|
---|
541 | CosignerName := FindExt('1208');
|
---|
542 | Subject := FindExt('1701');
|
---|
543 | Location := FindInt('1205');
|
---|
544 | LocationName := FindExt('1205');
|
---|
545 | IDParent := FindInt('2101');
|
---|
546 | ClinProcSummCode := FindInt('70201');
|
---|
547 | ClinProcDateTime := FindDT('70202');
|
---|
548 | VisitDate := FindDT('.07');
|
---|
549 | PkgRef := FindVal('1405');
|
---|
550 | PkgIEN := StrToIntDef(Piece(PkgRef, ';', 1), 0);
|
---|
551 | PkgPtr := Piece(PkgRef, ';', 2);
|
---|
552 | if Title = TYP_ADDENDUM then Addend := FindInt('.06');
|
---|
553 | with RPCBrokerV do
|
---|
554 | begin
|
---|
555 | for i := 0 to Results.Count - 1 do if Results[i] = '$TXT' then break;
|
---|
556 | for j := i downto 0 do Results.Delete(j);
|
---|
557 | // -------------------- v19.1 (RV) LOST NOTES?----------------------------
|
---|
558 | //Lines := Results; 'Lines' is being overwritten by subsequent Broker calls
|
---|
559 | if not Assigned(Lines) then Lines := TStringList.Create;
|
---|
560 | Lines.Assign(Results);
|
---|
561 | // -----------------------------------------------------------------------
|
---|
562 | end;
|
---|
563 | end;
|
---|
564 | end;
|
---|
565 |
|
---|
566 | function VisitStrForNote(IEN: Integer): string;
|
---|
567 | begin
|
---|
568 | Result := sCallV('ORWPCE NOTEVSTR', [IEN]);
|
---|
569 | end;
|
---|
570 |
|
---|
571 | function TitleForNote(IEN: Int64): Integer;
|
---|
572 | begin
|
---|
573 | Result := StrToIntDef(sCallV('TIU GET DOCUMENT TITLE', [IEN]), 3);
|
---|
574 | // with RPCBrokerV do
|
---|
575 | // begin
|
---|
576 | // ClearParameters := True;
|
---|
577 | // RemoteProcedure := 'XWB GET VARIABLE VALUE';
|
---|
578 | // Param[0].PType := reference;
|
---|
579 | // Param[0].Value := '$G(^TIU(8925,' + IntToStr(IEN) + ',0))';
|
---|
580 | // CallBroker;
|
---|
581 | // Result := StrToIntDef(Piece(Results[0], U, 1), 3);
|
---|
582 | // end;
|
---|
583 | end;
|
---|
584 |
|
---|
585 | function GetPackageRefForNote(NoteIEN: integer): string;
|
---|
586 | begin
|
---|
587 | Result := sCallV('TIU GET REQUEST', [NoteIEN]);
|
---|
588 | end;
|
---|
589 |
|
---|
590 | function GetConsultIENforNote(NoteIEN: integer): Integer;
|
---|
591 | var
|
---|
592 | x: string;
|
---|
593 | begin
|
---|
594 | x := sCallV('TIU GET REQUEST', [NoteIEN]);
|
---|
595 | if Piece(x, ';', 2) <> PKG_CONSULTS then
|
---|
596 | Result := -1
|
---|
597 | else
|
---|
598 | Result := StrTOIntDef(Piece(x, ';', 1), -1);
|
---|
599 | end;
|
---|
600 |
|
---|
601 | procedure LockDocument(IEN: Int64; var AnErrMsg: string);
|
---|
602 | var
|
---|
603 | x: string;
|
---|
604 | begin
|
---|
605 | x := sCallV('TIU LOCK RECORD', [IEN]);
|
---|
606 | if CharAt(x, 1) = '0' then AnErrMsg := '' else AnErrMsg := Piece(x, U, 2);
|
---|
607 | end;
|
---|
608 |
|
---|
609 | procedure UnlockDocument(IEN: Int64);
|
---|
610 | begin
|
---|
611 | CallV('TIU UNLOCK RECORD', [IEN]);
|
---|
612 | end;
|
---|
613 |
|
---|
614 | function LastSaveClean(IEN: Int64): Boolean;
|
---|
615 | begin
|
---|
616 | Result := sCallV('TIU WAS THIS SAVED?', [IEN]) = '1';
|
---|
617 | end;
|
---|
618 |
|
---|
619 | function GetTIUListItem(IEN: Int64): string;
|
---|
620 | begin
|
---|
621 | Result := sCallV('ORWTIU GET LISTBOX ITEM', [IEN]);
|
---|
622 | end;
|
---|
623 |
|
---|
624 | { Data Updates ----------------------------------------------------------------------------- }
|
---|
625 |
|
---|
626 | (*procedure ClearCPTRequired(IEN: Integer);
|
---|
627 | { sets CREDIT STOP CODE ON COMPLETION to NO when no more need to get encounter information }
|
---|
628 | begin
|
---|
629 | with RPCBrokerV do
|
---|
630 | begin
|
---|
631 | ClearParameters := True;
|
---|
632 | RemoteProcedure := 'TIU UPDATE RECORD';
|
---|
633 | Param[0].PType := literal;
|
---|
634 | Param[0].Value := IntToStr(IEN);
|
---|
635 | Param[1].PType := list;
|
---|
636 | with Param[1] do Mult['.11'] := '0'; // **** block removed in v19.1 {RV} ****
|
---|
637 | CallBroker;
|
---|
638 | end;
|
---|
639 | end;*)
|
---|
640 |
|
---|
641 | procedure DeleteDocument(var DeleteSts: TActionRec; IEN: Integer; const Reason: string);
|
---|
642 | { delete a TIU document given the internal entry number, return reason if unable to delete }
|
---|
643 | var
|
---|
644 | x: string;
|
---|
645 | begin
|
---|
646 | x := sCallV('TIU DELETE RECORD', [IEN, Reason]);
|
---|
647 | DeleteSts.Success := Piece(x, U, 1) = '0';
|
---|
648 | DeleteSts.Reason := Piece(x, U, 2);
|
---|
649 | end;
|
---|
650 |
|
---|
651 | function JustifyDocumentDelete(IEN: Integer): Boolean;
|
---|
652 | begin
|
---|
653 | Result := sCallV('TIU JUSTIFY DELETE?', [IEN]) = '1';
|
---|
654 | end;
|
---|
655 |
|
---|
656 | procedure SignDocument(var SignSts: TActionRec; IEN: Integer; const ESCode: string);
|
---|
657 | { update signed status of a TIU document, return reason if signature is not accepted }
|
---|
658 | var
|
---|
659 | x: string;
|
---|
660 | begin
|
---|
661 | (* with RPCBrokerV do // temp - to insure sign doesn't go interactive
|
---|
662 | begin
|
---|
663 | ClearParameters := True;
|
---|
664 | RemoteProcedure := 'TIU UPDATE RECORD';
|
---|
665 | Param[0].PType := literal;
|
---|
666 | Param[0].Value := IntToStr(IEN);
|
---|
667 | Param[1].PType := list;
|
---|
668 | with Param[1] do Mult['.11'] := '0'; // **** block removed in v19.1 {RV} ****
|
---|
669 | CallBroker;
|
---|
670 | end; // temp - end*)
|
---|
671 | x := sCallV('TIU SIGN RECORD', [IEN, ESCode]);
|
---|
672 | SignSts.Success := Piece(x, U, 1) = '0';
|
---|
673 | SignSts.Reason := Piece(x, U, 2);
|
---|
674 | end;
|
---|
675 |
|
---|
676 | procedure PutNewNote(var CreatedDoc: TCreatedDoc; const NoteRec: TNoteRec);
|
---|
677 | { create a new progress note with the data in NoteRec and return its internal entry number
|
---|
678 | load broker directly since there isn't a good way to set up mutilple subscript arrays }
|
---|
679 | (*var
|
---|
680 | i: Integer;*)
|
---|
681 | var
|
---|
682 | ErrMsg: string;
|
---|
683 | begin
|
---|
684 | with RPCBrokerV do
|
---|
685 | begin
|
---|
686 | ClearParameters := True;
|
---|
687 | RemoteProcedure := 'TIU CREATE RECORD';
|
---|
688 | Param[0].PType := literal;
|
---|
689 | Param[0].Value := Patient.DFN; //*DFN*
|
---|
690 | Param[1].PType := literal;
|
---|
691 | Param[1].Value := IntToStr(NoteRec.Title);
|
---|
692 | Param[2].PType := literal;
|
---|
693 | Param[2].Value := ''; //FloatToStr(Encounter.DateTime);
|
---|
694 | Param[3].PType := literal;
|
---|
695 | Param[3].Value := ''; //IntToStr(Encounter.Location);
|
---|
696 | Param[4].PType := literal;
|
---|
697 | Param[4].Value := '';
|
---|
698 | Param[5].PType := list;
|
---|
699 | with Param[5] do
|
---|
700 | begin
|
---|
701 | //Mult['.11'] := BOOLCHAR[NoteRec.NeedCPT]; // **** removed in v19.1 {RV} ****
|
---|
702 | Mult['1202'] := IntToStr(NoteRec.Author);
|
---|
703 | Mult['1301'] := FloatToStr(NoteRec.DateTime);
|
---|
704 | Mult['1205'] := IntToStr(Encounter.Location);
|
---|
705 | if NoteRec.Cosigner > 0 then Mult['1208'] := IntToStr(NoteRec.Cosigner);
|
---|
706 | if NoteRec.PkgRef <> '' then Mult['1405'] := NoteRec.PkgRef;
|
---|
707 | Mult['1701'] := FilteredString(Copy(NoteRec.Subject, 1, 80));
|
---|
708 | if NoteRec.IDParent > 0 then Mult['2101'] := IntToStr(NoteRec.IDParent);
|
---|
709 | (* if NoteRec.Lines <> nil then
|
---|
710 | for i := 0 to NoteRec.Lines.Count - 1 do
|
---|
711 | Mult['"TEXT",' + IntToStr(i+1) + ',0'] := FilteredString(NoteRec.Lines[i]);*)
|
---|
712 | end;
|
---|
713 | Param[6].PType := literal;
|
---|
714 | Param[6].Value := Encounter.VisitStr;
|
---|
715 | Param[7].PType := literal;
|
---|
716 | Param[7].Value := '1'; // suppress commit logic
|
---|
717 | CallBroker;
|
---|
718 | CreatedDoc.IEN := StrToIntDef(Piece(Results[0], U, 1), 0);
|
---|
719 | CreatedDoc.ErrorText := Piece(Results[0], U, 2);
|
---|
720 | end;
|
---|
721 | if ( NoteRec.Lines <> nil ) and ( CreatedDoc.IEN <> 0 ) then
|
---|
722 | begin
|
---|
723 | SetText(ErrMsg, NoteRec.Lines, CreatedDoc.IEN, 1);
|
---|
724 | if ErrMsg <> '' then
|
---|
725 | begin
|
---|
726 | CreatedDoc.IEN := 0;
|
---|
727 | CreatedDoc.ErrorText := ErrMsg;
|
---|
728 | end;
|
---|
729 | end;
|
---|
730 | end;
|
---|
731 |
|
---|
732 | procedure PutAddendum(var CreatedDoc: TCreatedDoc; const NoteRec: TNoteRec; AddendumTo: Integer);
|
---|
733 | { create a new addendum for note identified in AddendumTo, returns IEN of new document
|
---|
734 | load broker directly since there isn't a good way to set up mutilple subscript arrays }
|
---|
735 | (*var
|
---|
736 | i: Integer;*)
|
---|
737 | var
|
---|
738 | ErrMsg: string;
|
---|
739 | begin
|
---|
740 | with RPCBrokerV do
|
---|
741 | begin
|
---|
742 | ClearParameters := True;
|
---|
743 | RemoteProcedure := 'TIU CREATE ADDENDUM RECORD';
|
---|
744 | Param[0].PType := literal;
|
---|
745 | Param[0].Value := IntToStr(AddendumTo);
|
---|
746 | Param[1].PType := list;
|
---|
747 | with Param[1] do
|
---|
748 | begin
|
---|
749 | Mult['1202'] := IntToStr(NoteRec.Author);
|
---|
750 | Mult['1301'] := FloatToStr(NoteRec.DateTime);
|
---|
751 | if NoteRec.Cosigner > 0 then Mult['1208'] := IntToStr(NoteRec.Cosigner);
|
---|
752 | (* if NoteRec.Lines <> nil then
|
---|
753 | for i := 0 to NoteRec.Lines.Count - 1 do
|
---|
754 | Mult['"TEXT",' + IntToStr(i+1) + ',0'] := FilteredString(NoteRec.Lines[i]);*)
|
---|
755 | end;
|
---|
756 | Param[2].PType := literal;
|
---|
757 | Param[2].Value := '1'; // suppress commit logic
|
---|
758 | CallBroker;
|
---|
759 | CreatedDoc.IEN := StrToIntDef(Piece(Results[0], U, 1), 0);
|
---|
760 | CreatedDoc.ErrorText := Piece(Results[0], U, 2);
|
---|
761 | end;
|
---|
762 | if ( NoteRec.Lines <> nil ) and ( CreatedDoc.IEN <> 0 ) then
|
---|
763 | begin
|
---|
764 | SetText(ErrMsg, NoteRec.Lines, CreatedDoc.IEN, 1);
|
---|
765 | if ErrMsg <> '' then
|
---|
766 | begin
|
---|
767 | CreatedDoc.IEN := 0;
|
---|
768 | CreatedDoc.ErrorText := ErrMsg;
|
---|
769 | end;
|
---|
770 | end;
|
---|
771 | end;
|
---|
772 |
|
---|
773 | procedure PutEditedNote(var UpdatedDoc: TCreatedDoc; const NoteRec: TNoteRec; NoteIEN: Integer);
|
---|
774 | { update the fields and content of the note identified in NoteIEN, returns 1 if successful
|
---|
775 | load broker directly since there isn't a good way to set up mutilple subscript arrays }
|
---|
776 | (*var
|
---|
777 | i: Integer;*)
|
---|
778 | var
|
---|
779 | ErrMsg: string;
|
---|
780 | begin
|
---|
781 | // First, file field data
|
---|
782 | with RPCBrokerV do
|
---|
783 | begin
|
---|
784 | ClearParameters := True;
|
---|
785 | RemoteProcedure := 'TIU UPDATE RECORD';
|
---|
786 | Param[0].PType := literal;
|
---|
787 | Param[0].Value := IntToStr(NoteIEN);
|
---|
788 | Param[1].PType := list;
|
---|
789 | with Param[1] do
|
---|
790 | begin
|
---|
791 | if NoteRec.Addend = 0 then
|
---|
792 | begin
|
---|
793 | Mult['.01'] := IntToStr(NoteRec.Title);
|
---|
794 | //Mult['.11'] := BOOLCHAR[NoteRec.NeedCPT]; // **** removed in v19.1 {RV} ****
|
---|
795 | end;
|
---|
796 | Mult['1202'] := IntToStr(NoteRec.Author);
|
---|
797 | if NoteRec.Cosigner > 0 then Mult['1208'] := IntToStr(NoteRec.Cosigner);
|
---|
798 | if NoteRec.PkgRef <> '' then Mult['1405'] := NoteRec.PkgRef;
|
---|
799 | Mult['1301'] := FloatToStr(NoteRec.DateTime);
|
---|
800 | Mult['1701'] := FilteredString(Copy(NoteRec.Subject, 1, 80));
|
---|
801 | if NoteRec.ClinProcSummCode > 0 then Mult['70201'] := IntToStr(NoteRec.ClinProcSummCode);
|
---|
802 | if NoteRec.ClinProcDateTime > 0 then Mult['70202'] := FloatToStr(NoteRec.ClinProcDateTime);
|
---|
803 | (* for i := 0 to NoteRec.Lines.Count - 1 do
|
---|
804 | Mult['"TEXT",' + IntToStr(i+1) + ',0'] := FilteredString(NoteRec.Lines[i]);*)
|
---|
805 | end;
|
---|
806 | CallBroker;
|
---|
807 | UpdatedDoc.IEN := StrToIntDef(Piece(Results[0], U, 1), 0);
|
---|
808 | UpdatedDoc.ErrorText := Piece(Results[0], U, 2);
|
---|
809 | end;
|
---|
810 |
|
---|
811 | if UpdatedDoc.IEN <= 0 then //v22.12 - RV
|
---|
812 | //if UpdatedDoc.ErrorText <> '' then //v22.5 - RV
|
---|
813 | begin
|
---|
814 | // UpdatedDoc.ErrorText := UpdatedDoc.ErrorText + #13#10 + #13#10 + 'Document #: ' + IntToStr(NoteIEN); <-- original line. //kt 1/17/2008
|
---|
815 | UpdatedDoc.ErrorText := UpdatedDoc.ErrorText + #13#10 + #13#10 + DKLangConstW('rTIU_Document_xx') + IntToStr(NoteIEN); //kt added 1/17/2008
|
---|
816 | exit;
|
---|
817 | end;
|
---|
818 |
|
---|
819 | // next, if no error, file document body
|
---|
820 | SetText(ErrMsg, NoteRec.Lines, NoteIEN, 0);
|
---|
821 | if ErrMsg <> '' then
|
---|
822 | begin
|
---|
823 | UpdatedDoc.IEN := 0;
|
---|
824 | UpdatedDoc.ErrorText := ErrMsg;
|
---|
825 | end;
|
---|
826 | end;
|
---|
827 |
|
---|
828 | procedure PutTextOnly(var ErrMsg: string; NoteText: TStrings; NoteIEN: Int64);
|
---|
829 | var
|
---|
830 | i: Integer;
|
---|
831 | begin
|
---|
832 | with RPCBrokerV do
|
---|
833 | begin
|
---|
834 | ClearParameters := True;
|
---|
835 | RemoteProcedure := 'TIU UPDATE RECORD';
|
---|
836 | Param[0].PType := literal;
|
---|
837 | Param[0].Value := IntToStr(NoteIEN);
|
---|
838 | Param[1].PType := list;
|
---|
839 | for i := 0 to Pred(NoteText.Count) do
|
---|
840 | Param[1].Mult['"TEXT",' + IntToStr(Succ(i)) + ',0'] := FilteredString(NoteText[i]);
|
---|
841 | Param[2].PType := literal;
|
---|
842 | Param[2].Value :='1'; // suppress commit code
|
---|
843 | CallBroker;
|
---|
844 | if Piece(Results[0], U, 1) = '0' then ErrMsg := Piece(Results[0], U, 2) else ErrMsg := '';
|
---|
845 | end;
|
---|
846 | end;
|
---|
847 |
|
---|
848 | procedure SetText(var ErrMsg: string; NoteText: TStrings; NoteIEN: Int64; Suppress: Integer);
|
---|
849 | const
|
---|
850 | DOCUMENT_PAGE_SIZE = 300;
|
---|
851 | //TX_SERVER_ERROR = 'An error occurred on the server.' ; <-- original line. //kt 1/17/2008
|
---|
852 | var
|
---|
853 | i, j, page, pages: Integer;
|
---|
854 | TX_SERVER_ERROR : string; //kt
|
---|
855 | begin
|
---|
856 | TX_SERVER_ERROR := DKLangConstW('rTIU_An_error_occurred_on_the_serverx') ; //kt added 1/17/2008
|
---|
857 | // Compute pages, initialize Params
|
---|
858 | pages := ( NoteText.Count div DOCUMENT_PAGE_SIZE );
|
---|
859 | if (NoteText.Count mod DOCUMENT_PAGE_SIZE) > 0 then pages := pages + 1;
|
---|
860 | page := 1;
|
---|
861 | InitParams( NoteIEN, Suppress );
|
---|
862 | // Loop through NoteRec.Lines
|
---|
863 | for i := 0 to NoteText.Count - 1 do
|
---|
864 | begin
|
---|
865 | j := i + 1;
|
---|
866 | //Add each successive line to Param[1].Mult...
|
---|
867 | RPCBrokerV.Param[1].Mult['"TEXT",' + IntToStr(j) + ',0'] := FilteredString(NoteText[i]);
|
---|
868 | // When current page is filled, call broker, increment page, itialize params,
|
---|
869 | // and continue...
|
---|
870 | if ( j mod DOCUMENT_PAGE_SIZE ) = 0 then
|
---|
871 | begin
|
---|
872 | RPCBrokerV.Param[1].Mult['"HDR"'] := IntToStr(page) + U + IntToStr(pages);
|
---|
873 | CallBroker;
|
---|
874 | if RPCBrokerV.Results.Count > 0 then
|
---|
875 | ErrMsg := Piece(RPCBrokerV.Results[0], U, 4)
|
---|
876 | else
|
---|
877 | ErrMsg := TX_SERVER_ERROR;
|
---|
878 | if ErrMsg <> '' then Exit;
|
---|
879 | page := page + 1;
|
---|
880 | InitParams( NoteIEN, Suppress );
|
---|
881 | end; // if
|
---|
882 | end; // for
|
---|
883 | // finally, file any remaining partial page
|
---|
884 | if ( NoteText.Count mod DOCUMENT_PAGE_SIZE ) <> 0 then
|
---|
885 | begin
|
---|
886 | RPCBrokerV.Param[1].Mult['"HDR"'] := IntToStr(page) + U + IntToStr(pages);
|
---|
887 | CallBroker;
|
---|
888 | if RPCBrokerV.Results.Count > 0 then
|
---|
889 | ErrMsg := Piece(RPCBrokerV.Results[0], U, 4)
|
---|
890 | else
|
---|
891 | ErrMsg := TX_SERVER_ERROR;
|
---|
892 | end;
|
---|
893 | end;
|
---|
894 |
|
---|
895 | procedure InitParams( NoteIEN: Int64; Suppress: Integer );
|
---|
896 | begin
|
---|
897 | with RPCBrokerV do
|
---|
898 | begin
|
---|
899 | ClearParameters := True;
|
---|
900 | RemoteProcedure := 'TIU SET DOCUMENT TEXT';
|
---|
901 | Param[0].PType := literal;
|
---|
902 | Param[0].Value := IntToStr(NoteIEN);
|
---|
903 | Param[1].PType := list;
|
---|
904 | Param[2].PType := literal;
|
---|
905 | Param[2].Value := IntToStr(Suppress);
|
---|
906 | end;
|
---|
907 | end;
|
---|
908 |
|
---|
909 | { Printing --------------------------------------------------------------------------------- }
|
---|
910 |
|
---|
911 | function AllowChartPrintForNote(ANote: Integer): Boolean;
|
---|
912 | { returns true if a progress note may be printed outside of MAS }
|
---|
913 | begin
|
---|
914 | Result := (Piece(sCallV('TIU GET DOCUMENT PARAMETERS', [ANote]), U, 9) = '1');
|
---|
915 | // or (sCallV('TIU USER IS MEMBER OF CLASS', [User.DUZ, 'MEDICAL INFORMATION SECTION']) = '1');
|
---|
916 | // (V16? - RV) New TIU RPC required, per discussion on NOIS MAR-0900-21265
|
---|
917 | end;
|
---|
918 |
|
---|
919 | procedure PrintNoteToDevice(ANote: Integer; const ADevice: string; ChartCopy: Boolean;
|
---|
920 | var ErrMsg: string);
|
---|
921 | { prints a progress note on the selected device }
|
---|
922 | begin
|
---|
923 | ErrMsg := sCallV('TIU PRINT RECORD', [ANote, ADevice, ChartCopy]);
|
---|
924 | if Piece(ErrMsg, U, 1) = '0' then ErrMsg := '' else ErrMsg := Piece(ErrMsg, U, 2);
|
---|
925 | end;
|
---|
926 |
|
---|
927 | function GetFormattedNote(ANote: Integer; ChartCopy: Boolean): TStrings;
|
---|
928 | begin
|
---|
929 | CallV('ORWTIU WINPRINT NOTE',[ANote, ChartCopy]);
|
---|
930 | Result := RPCBrokerV.Results;
|
---|
931 | end;
|
---|
932 |
|
---|
933 | function GetCurrentSigners(IEN: integer): TStrings;
|
---|
934 | begin
|
---|
935 | CallV('TIU GET ADDITIONAL SIGNERS', [IEN]);
|
---|
936 | MixedCaseList(RPCBrokerV.Results);
|
---|
937 | Result := RPCBrokerV.Results ;
|
---|
938 | end;
|
---|
939 |
|
---|
940 | procedure UpdateAdditionalSigners(IEN: integer; Signers: TStrings);
|
---|
941 | begin
|
---|
942 | CallV('TIU UPDATE ADDITIONAL SIGNERS', [IEN, Signers]);
|
---|
943 | end;
|
---|
944 |
|
---|
945 | function CanChangeCosigner(IEN: integer): boolean;
|
---|
946 | begin
|
---|
947 | Result := Piece(sCallV('TIU CAN CHANGE COSIGNER?', [IEN]), U, 1) = '1';
|
---|
948 | end;
|
---|
949 |
|
---|
950 | procedure ChangeCosigner(IEN: integer; Cosigner: int64);
|
---|
951 | begin
|
---|
952 | with RPCBrokerV do
|
---|
953 | begin
|
---|
954 | ClearParameters := True;
|
---|
955 | RemoteProcedure := 'TIU UPDATE RECORD';
|
---|
956 | Param[0].PType := literal;
|
---|
957 | Param[0].Value := IntToStr(IEN);
|
---|
958 | Param[1].PType := list;
|
---|
959 | with Param[1] do
|
---|
960 | if Cosigner > 0 then
|
---|
961 | Mult['1208'] := IntToStr(Cosigner)
|
---|
962 | else
|
---|
963 | Mult['1208'] := '@';
|
---|
964 | CallBroker;
|
---|
965 | end;
|
---|
966 | end;
|
---|
967 |
|
---|
968 | // Determine if given note title is allowed more than once per visit. 12/2002-GRE
|
---|
969 | function OneNotePerVisit(NoteEIN: Integer; DFN: String; VisitStr: String):boolean;
|
---|
970 | var x: string;
|
---|
971 | begin
|
---|
972 | x := sCallV('TIU ONE VISIT NOTE?', [IntToStr(NoteEIN),DFN,VisitStr]);
|
---|
973 | if StrToInt(x) > 0 then
|
---|
974 | Result := True //Only one per visit
|
---|
975 | else
|
---|
976 | Result := False;
|
---|
977 | end;
|
---|
978 |
|
---|
979 | function GetCurrentTIUContext: TTIUContext;
|
---|
980 | var
|
---|
981 | x: string;
|
---|
982 | AContext: TTIUContext;
|
---|
983 | begin
|
---|
984 | x := sCallV('ORWTIU GET TIU CONTEXT', [User.DUZ]) ;
|
---|
985 | with AContext do
|
---|
986 | begin
|
---|
987 | Changed := True;
|
---|
988 | BeginDate := Piece(x, ';', 1);
|
---|
989 | FMBeginDate := StrToFMDateTime(BeginDate);
|
---|
990 | EndDate := Piece(x, ';', 2);
|
---|
991 | FMEndDate := StrToFMDateTime(EndDate);
|
---|
992 | Status := Piece(x, ';', 3);
|
---|
993 | if (StrToIntDef(Status, 0) < 1) or (StrToIntDef(Status, 0) > 5) then Status := '1';
|
---|
994 | Author := StrToInt64Def(Piece(x, ';', 4), 0);
|
---|
995 | MaxDocs := StrToIntDef(Piece(x, ';', 5), 0);
|
---|
996 | ShowSubject := StrToIntDef(Piece(x, ';', 6), 0) > 0; //TIU PREFERENCE??
|
---|
997 | SortBy := Piece(x, ';', 7); //TIU PREFERENCE??
|
---|
998 | ListAscending := StrToIntDef(Piece(x, ';', 8), 0) > 0;
|
---|
999 | TreeAscending := StrToIntDef(Piece(x, ';', 9), 0) > 0; //TIU PREFERENCE??
|
---|
1000 | GroupBy := Piece(x, ';', 10);
|
---|
1001 | SearchField := Piece(x, ';', 11);
|
---|
1002 | KeyWord := Piece(x, ';', 12);
|
---|
1003 | Filtered := (Keyword <> '');
|
---|
1004 | end;
|
---|
1005 | Result := AContext;
|
---|
1006 | end;
|
---|
1007 |
|
---|
1008 | procedure SaveCurrentTIUContext(AContext: TTIUContext) ;
|
---|
1009 | var
|
---|
1010 | x: string;
|
---|
1011 | begin
|
---|
1012 | with AContext do
|
---|
1013 | begin
|
---|
1014 | SetPiece(x, ';', 1, BeginDate);
|
---|
1015 | SetPiece(x, ';', 2, EndDate);
|
---|
1016 | SetPiece(x, ';', 3, Status);
|
---|
1017 | if Author > 0 then
|
---|
1018 | SetPiece(x, ';', 4, IntToStr(Author))
|
---|
1019 | else
|
---|
1020 | SetPiece(x, ';', 4, '');
|
---|
1021 | SetPiece(x, ';', 5, IntToStr(MaxDocs));
|
---|
1022 | SetPiece(x, ';', 6, BOOLCHAR[ShowSubject]); //TIU PREFERENCE??
|
---|
1023 | SetPiece(x, ';', 7, SortBy); //TIU PREFERENCE??
|
---|
1024 | SetPiece(x, ';', 8, BOOLCHAR[ListAscending]);
|
---|
1025 | SetPiece(x, ';', 9, BOOLCHAR[TreeAscending]); //TIU PREFERENCE??
|
---|
1026 | SetPiece(x, ';', 10, GroupBy);
|
---|
1027 | SetPiece(x, ';', 11, SearchField);
|
---|
1028 | SetPiece(x, ';', 12, KeyWord);
|
---|
1029 | end;
|
---|
1030 | CallV('ORWTIU SAVE TIU CONTEXT', [x]);
|
---|
1031 | end;
|
---|
1032 |
|
---|
1033 | function TIUSiteParams: string;
|
---|
1034 | begin
|
---|
1035 | if(not uTIUSiteParamsLoaded) then
|
---|
1036 | begin
|
---|
1037 | uTIUSiteParams := sCallV('TIU GET SITE PARAMETERS', []) ;
|
---|
1038 | uTIUSiteParamsLoaded := TRUE;
|
---|
1039 | end;
|
---|
1040 | Result := uTIUSiteParams;
|
---|
1041 | end;
|
---|
1042 |
|
---|
1043 | // ===================Interdisciplinary Notes RPCs =====================
|
---|
1044 |
|
---|
1045 | function IDNotesInstalled: boolean;
|
---|
1046 | begin
|
---|
1047 | Result := True; // old patch check no longer called
|
---|
1048 | end;
|
---|
1049 |
|
---|
1050 | function CanTitleBeIDChild(Title: integer; var WhyNot: string): boolean;
|
---|
1051 | var
|
---|
1052 | x: string;
|
---|
1053 | begin
|
---|
1054 | Result := False;
|
---|
1055 | x := sCallV('ORWTIU CANLINK', [Title]);
|
---|
1056 | if Piece(x, U, 1) = '1' then
|
---|
1057 | Result := True
|
---|
1058 | else if Piece(x, U, 1) = '0' then
|
---|
1059 | begin
|
---|
1060 | Result := False;
|
---|
1061 | WhyNot := Piece(x, U, 2);
|
---|
1062 | end;
|
---|
1063 | end;
|
---|
1064 |
|
---|
1065 | function CanBeAttached(DocID: string; var WhyNot: string): boolean;
|
---|
1066 | var
|
---|
1067 | x: string;
|
---|
1068 | //const
|
---|
1069 | //TX_NO_ATTACH = 'This note appears to be an interdisciplinary parent. Please drag the child note you wish to ' + CRLF + <-- original line. //kt 1/17/2008
|
---|
1070 | // 'attach instead of attempting to drag the parent, or check with IRM or your' + CRLF + <-- original line. //kt 1/17/2008
|
---|
1071 | // 'clinical coordinator.'; <-- original line. //kt 1/17/2008
|
---|
1072 | var
|
---|
1073 | TX_NO_ATTACH : string;
|
---|
1074 |
|
---|
1075 | begin
|
---|
1076 | TX_NO_ATTACH := DKLangConstW('rTIU_This_note_appears_to_be_an_interdisciplinary_parentx__Please_drag_the_child_note_you_wish_to') + CRLF + //kt added 1/17/2008
|
---|
1077 | // 'attach instead of attempting to drag the parent, or check with IRM or your' + CRLF + <-- original line. //kt 1/17/2008
|
---|
1078 | DKLangConstW('rTIU_attach_instead_of_attempting_to_drag_the_parentx_or_check_with_IRM_or_your') + CRLF + //kt added 1/17/2008
|
---|
1079 | // 'clinical coordinator.'; <-- original line. //kt 1/17/2008
|
---|
1080 | DKLangConstW('rTIU_clinical_coordinatorx'); //kt added 1/17/2008
|
---|
1081 |
|
---|
1082 |
|
---|
1083 | Result := False;
|
---|
1084 | if StrToIntDef(DocID, 0) = 0 then exit;
|
---|
1085 | x := sCallV('TIU ID CAN ATTACH', [DocID]);
|
---|
1086 | if Piece(x, U, 1) = '1' then
|
---|
1087 | Result := True
|
---|
1088 | else if Piece(x, U, 1) = '0' then
|
---|
1089 | begin
|
---|
1090 | Result := False;
|
---|
1091 | WhyNot := Piece(x, U, 2);
|
---|
1092 | end
|
---|
1093 | else if Piece(x, U, 1) = '-1' then
|
---|
1094 | begin
|
---|
1095 | Result := False;
|
---|
1096 | WhyNot := TX_NO_ATTACH;
|
---|
1097 | end;
|
---|
1098 | end;
|
---|
1099 |
|
---|
1100 | function CanReceiveAttachment(DocID: string; var WhyNot: string): boolean;
|
---|
1101 | var
|
---|
1102 | x: string;
|
---|
1103 | begin
|
---|
1104 | x := sCallV('TIU ID CAN RECEIVE', [DocID]);
|
---|
1105 | if Piece(x, U, 1) = '1' then
|
---|
1106 | Result := True
|
---|
1107 | else
|
---|
1108 | begin
|
---|
1109 | Result := False;
|
---|
1110 | WhyNot := Piece(x, U, 2);
|
---|
1111 | end;
|
---|
1112 | end;
|
---|
1113 |
|
---|
1114 | function AttachEntryToParent(DocID, ParentDocID: string; var WhyNot: string): boolean;
|
---|
1115 | var
|
---|
1116 | x: string;
|
---|
1117 | begin
|
---|
1118 | x := sCallV('TIU ID ATTACH ENTRY', [DocID, ParentDocID]);
|
---|
1119 | if StrToIntDef(Piece(x, U, 1), 0) > 0 then
|
---|
1120 | Result := True
|
---|
1121 | else
|
---|
1122 | begin
|
---|
1123 | Result := False;
|
---|
1124 | WhyNot := Piece(x, U, 2);
|
---|
1125 | end;
|
---|
1126 | end;
|
---|
1127 |
|
---|
1128 | function DetachEntryFromParent(DocID: string; var WhyNot: string): boolean;
|
---|
1129 | var
|
---|
1130 | x: string;
|
---|
1131 | begin
|
---|
1132 | x := sCallV('TIU ID DETACH ENTRY', [DocID]);
|
---|
1133 | if StrToIntDef(Piece(x, U, 1), 0) > 0 then
|
---|
1134 | Result := True
|
---|
1135 | else
|
---|
1136 | begin
|
---|
1137 | Result := False;
|
---|
1138 | WhyNot := Piece(x, U, 2);
|
---|
1139 | end;
|
---|
1140 | end;
|
---|
1141 |
|
---|
1142 | function SubSetOfUserClasses(const StartFrom: string; Direction: Integer): TStrings;
|
---|
1143 | begin
|
---|
1144 | CallV('TIU USER CLASS LONG LIST', [StartFrom, Direction]);
|
---|
1145 | Result := RPCBrokerV.Results;
|
---|
1146 | end;
|
---|
1147 |
|
---|
1148 | function UserDivClassInfo(User: Int64): TStrings;
|
---|
1149 | begin
|
---|
1150 | CallV('TIU DIV AND CLASS INFO', [User]);
|
---|
1151 | Result := RPCBrokerV.Results;
|
---|
1152 | end;
|
---|
1153 |
|
---|
1154 | function UserInactive(EIN: String): boolean;
|
---|
1155 | var x: string;
|
---|
1156 | begin
|
---|
1157 | x:= sCallv('TIU USER INACTIVE?', [EIN]) ;
|
---|
1158 | if (StrToInt(x) > 0) then
|
---|
1159 | Result := True
|
---|
1160 | else
|
---|
1161 | Result := False;
|
---|
1162 | end;
|
---|
1163 |
|
---|
1164 | function TIUPatch175Installed: boolean;
|
---|
1165 | begin
|
---|
1166 | with uPatch175Installed do
|
---|
1167 | if not PatchChecked then
|
---|
1168 | begin
|
---|
1169 | PatchInstalled := ServerHasPatch('TIU*1.0*175');
|
---|
1170 | PatchChecked := True;
|
---|
1171 | end;
|
---|
1172 | Result := uPatch175Installed.PatchInstalled;
|
---|
1173 | end;
|
---|
1174 |
|
---|
1175 | function NoteHasText(NoteIEN: integer): boolean;
|
---|
1176 | begin
|
---|
1177 | Result := (StrToIntDef(sCallV('ORWTIU CHKTXT', [NoteIEN]), 0) > 0);
|
---|
1178 | end;
|
---|
1179 |
|
---|
1180 |
|
---|
1181 | initialization
|
---|
1182 | // nothing for now
|
---|
1183 |
|
---|
1184 | finalization
|
---|
1185 | if uNoteTitles <> nil then uNoteTitles.Free;
|
---|
1186 | if uTIUPrefs <> nil then uTIUPrefs.Free;
|
---|
1187 |
|
---|
1188 | end.
|
---|