source: cprs/branches/tmg-cprs/CPRS-Chart/rTIU.pas@ 454

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 39.5 KB
Line 
1//kt -- Modified with SourceScanner on 1/17/2008
2unit rTIU;
3
4interface
5
6uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, uConst, TRPCB, uTIU, DKLang;
7
8type
9 TPatchInstalled = record
10 PatchInstalled: boolean;
11 PatchChecked: boolean;
12 end;
13
14{ Progress Note Titles }
15function DfltNoteTitle: Integer;
16function DfltNoteTitleName: string;
17procedure ResetNoteTitles;
18function IsConsultTitle(TitleIEN: Integer): Boolean;
19function IsPRFTitle(TitleIEN: Integer): Boolean;
20function IsClinProcTitle(TitleIEN: Integer): Boolean;
21procedure ListNoteTitlesShort(Dest: TStrings);
22procedure LoadBoilerPlate(Dest: TStrings; Title: Integer);
23function PrintNameForTitle(TitleIEN: Integer): string;
24function SubSetOfNoteTitles(const StartFrom: string; Direction: Integer; IDNotesOnly: boolean): TStrings;
25
26{ TIU Preferences }
27procedure ResetTIUPreferences;
28function AskCosignerForNotes: Boolean;
29function AskCosignerForDocument(ADocument: Integer; AnAuthor: Int64): Boolean;
30function AskCosignerForTitle(ATitle: integer; AnAuthor: Int64; ADate: TFMDateTime): Boolean;
31function AskSubjectForNotes: Boolean;
32function CanCosign(ATitle, ADocType: integer; AUser: Int64; ADate: TFMDateTime): Boolean;
33function CanChangeCosigner(IEN: integer): boolean;
34procedure DefaultCosigner(var IEN: Int64; var Name: string);
35function ReturnMaxNotes: Integer;
36function SortNotesAscending: Boolean;
37function GetCurrentTIUContext: TTIUContext;
38procedure SaveCurrentTIUContext(AContext: TTIUContext) ;
39function TIUSiteParams: string;
40function DfltTIULocation: Integer;
41function DfltTIULocationName: string;
42
43{ Data Retrieval }
44procedure ActOnDocument(var AuthSts: TActionRec; IEN: Integer; const ActionName: string);
45function AuthorSignedDocument(IEN: Integer): boolean;
46function CosignDocument(IEN: Integer): Boolean;
47//function CPTRequiredForNote(IEN: Integer): Boolean;
48procedure ListNotes(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
49 Person: int64; OccLim: Integer; SortAscending: Boolean);
50procedure ListNotesForTree(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
51 Person: int64; OccLim: Integer; SortAscending: Boolean);
52procedure ListConsultRequests(Dest: TStrings);
53procedure ListDCSumm(Dest: TStrings);
54procedure LoadDetailText(Dest: TStrings; IEN: Integer); //**KCM**
55procedure LoadDocumentText(Dest: TStrings; IEN: Integer);
56procedure GetNoteForEdit(var EditRec: TEditNoteRec; IEN: Integer);
57function VisitStrForNote(IEN: Integer): string;
58function GetCurrentSigners(IEN: integer): TStrings;
59function TitleForNote(IEN: Int64): Integer;
60function GetConsultIENforNote(NoteIEN: integer): Integer;
61function GetPackageRefForNote(NoteIEN: integer): string;
62procedure LockDocument(IEN: Int64; var AnErrMsg: string);
63procedure UnlockDocument(IEN: Int64);
64function LastSaveClean(IEN: Int64): Boolean;
65function NoteHasText(NoteIEN: integer): boolean;
66function GetTIUListItem(IEN: Int64): string;
67
68{ Data Storage }
69//procedure ClearCPTRequired(IEN: Integer);
70procedure DeleteDocument(var DeleteSts: TActionRec; IEN: Integer; const Reason: string);
71function JustifyDocumentDelete(IEN: Integer): Boolean;
72procedure SignDocument(var SignSts: TActionRec; IEN: Integer; const ESCode: string);
73procedure PutNewNote(var CreatedDoc: TCreatedDoc; const NoteRec: TNoteRec);
74procedure PutAddendum(var CreatedDoc: TCreatedDoc; const NoteRec: TNoteRec; AddendumTo: Integer);
75procedure PutEditedNote(var UpdatedDoc: TCreatedDoc; const NoteRec: TNoteRec; NoteIEN: Integer);
76procedure PutTextOnly(var ErrMsg: string; NoteText: TStrings; NoteIEN: Int64);
77procedure SetText(var ErrMsg: string; NoteText: TStrings; NoteIEN: Int64; Suppress: Integer);
78procedure InitParams(NoteIEN: Int64; Suppress: Integer);
79procedure UpdateAdditionalSigners(IEN: integer; Signers: TStrings);
80procedure ChangeCosigner(IEN: integer; Cosigner: int64);
81
82{ Printing }
83function AllowChartPrintForNote(ANote: Integer): Boolean;
84procedure PrintNoteToDevice(ANote: Integer; const ADevice: string; ChartCopy: Boolean;
85 var ErrMsg: string);
86function GetFormattedNote(ANote: Integer; ChartCopy: Boolean): TStrings;
87
88// Interdisciplinary Notes
89function IDNotesInstalled: boolean;
90function CanTitleBeIDChild(Title: integer; var WhyNot: string): boolean;
91function CanReceiveAttachment(DocID: string; var WhyNot: string): boolean;
92function CanBeAttached(DocID: string; var WhyNot: string): boolean;
93function DetachEntryFromParent(DocID: string; var WhyNot: string): boolean;
94function AttachEntryToParent(DocID, ParentDocID: string; var WhyNot: string): boolean;
95function OneNotePerVisit(NoteEIN: Integer; DFN: String;VisitStr: String): boolean;
96
97
98//User Classes
99function SubSetOfUserClasses(const StartFrom: string; Direction: Integer): TStrings;
100function UserDivClassInfo(User: Int64): TStrings;
101function UserInactive(EIN: String): boolean;
102
103//Miscellaneous
104function TIUPatch175Installed: boolean;
105
106const
107 CLS_PROGRESS_NOTES = 3;
108
109implementation
110
111uses rMisc;
112
113var
114 uTIUSiteParams: string;
115 uTIUSiteParamsLoaded: boolean = FALSE;
116 uNoteTitles: TNoteTitles;
117 uTIUPrefs: TTIUPrefs;
118 uPatch175Installed: TPatchInstalled;
119
120
121{ Progress Note Titles -------------------------------------------------------------------- }
122
123procedure LoadNoteTitles;
124{ private - called one time to set up the uNoteTitles object }
125const
126 CLASS_PROGRESS_NOTES = 3;
127var
128 x: string;
129begin
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);
138end;
139
140procedure ResetNoteTitles;
141begin
142 if uNoteTitles <> nil then
143 begin
144 uNoteTitles.Free;
145 uNoteTitles := nil;
146 LoadNoteTitles;
147 end;
148end;
149
150function DfltNoteTitle: Integer;
151{ returns the IEN of the user defined default progress note title (if any) }
152begin
153 if uNoteTitles = nil then LoadNoteTitles;
154 Result := uNoteTitles.DfltTitle;
155end;
156
157function DfltNoteTitleName: string;
158{ returns the name of the user defined default progress note title (if any) }
159begin
160 if uNoteTitles = nil then LoadNoteTitles;
161 Result := uNoteTitles.DfltTitleName;
162end;
163
164function IsConsultTitle(TitleIEN: Integer): Boolean;
165begin
166 Result := False;
167 if TitleIEN <= 0 then Exit;
168 Result := sCallV('TIU IS THIS A CONSULT?', [TitleIEN]) = '1';
169end;
170
171function IsPRFTitle(TitleIEN: Integer): Boolean;
172begin
173 Result := False;
174 if TitleIEN <= 0 then Exit;
175 Result := sCallV('TIU ISPRF', [TitleIEN]) = '1';
176end;
177
178function IsClinProcTitle(TitleIEN: Integer): Boolean;
179begin
180 Result := False;
181 if TitleIEN <= 0 then Exit;
182 Result := sCallV('TIU IS THIS A CLINPROC?', [TitleIEN]) = '1';
183end;
184
185procedure ListNoteTitlesShort(Dest: TStrings);
186{ returns the user defined list (short list) of progress note titles }
187begin
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;
195end;
196
197procedure LoadBoilerPlate(Dest: TStrings; Title: Integer);
198{ returns the boilerplate text (if any) for a given progress note title }
199begin
200 CallV('TIU LOAD BOILERPLATE TEXT', [Title, Patient.DFN, Encounter.VisitStr]);
201 Dest.Assign(RPCBrokerV.Results);
202end;
203
204function PrintNameForTitle(TitleIEN: Integer): string;
205begin
206 Result := sCallV('TIU GET PRINT NAME', [TitleIEN]);
207end;
208
209function 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! }
213begin
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;
220end;
221
222{ TIU Preferences ------------------------------------------------------------------------- }
223
224procedure LoadTIUPrefs;
225{ private - creates TIUPrefs object for reference throughout the session }
226var
227 x: string;
228begin
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;
244end;
245
246procedure ResetTIUPreferences;
247begin
248 if uTIUPrefs <> nil then
249 begin
250 uTIUPrefs.Free;
251 uTIUPrefs := nil;
252 LoadTIUPrefs;
253 end;
254end;
255
256function AskCosignerForDocument(ADocument: Integer; AnAuthor: Int64): Boolean;
257begin
258 Result := Piece(sCallV('TIU REQUIRES COSIGNATURE', [0, ADocument, AnAuthor]), U, 1) = '1';
259end;
260
261function AskCosignerForTitle(ATitle: integer; AnAuthor: Int64; ADate: TFMDateTime): Boolean;
262{ returns TRUE if a cosignature is required for a document title and author }
263begin
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';
268end;
269
270function AskCosignerForNotes: Boolean;
271{ returns true if cosigner should be asked when creating a new progress note }
272begin
273 if uTIUPrefs = nil then LoadTIUPrefs;
274 Result := uTIUPrefs.AskCosigner;
275end;
276
277function AskSubjectForNotes: Boolean;
278{ returns true if subject should be asked when creating a new progress note }
279begin
280 if uTIUPrefs = nil then LoadTIUPrefs;
281 Result := uTIUPrefs.AskNoteSubject;
282end;
283
284function CanCosign(ATitle, ADocType: integer; AUser: Int64; ADate: TFMDateTime): Boolean;
285begin
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';
291end;
292
293procedure DefaultCosigner(var IEN: Int64; var Name: string);
294{ returns the IEN (from the New Person file) and Name of this user's default cosigner }
295begin
296 if uTIUPrefs = nil then LoadTIUPrefs;
297 IEN := uTIUPrefs.DfltCosigner;
298 Name := uTIUPrefs.DfltCosignerName;
299end;
300
301function ReturnMaxNotes: Integer;
302begin
303 if uTIUPrefs = nil then LoadTIUPrefs;
304 Result := uTIUPrefs.MaxNotes;
305 if Result = 0 then Result := 100;
306end;
307
308function SortNotesAscending: Boolean;
309{ returns true if progress notes should be sorted from oldest to newest (chronological) }
310begin
311 if uTIUPrefs = nil then LoadTIUPrefs;
312 Result := uTIUPrefs.SortAscending;
313end;
314
315function DfltTIULocation: Integer;
316{ returns the IEN of the user defined default progress note title (if any) }
317begin
318 if uTIUPrefs = nil then LoadTIUPrefs;
319 Result := uTIUPrefs.DfltLoc;
320end;
321
322function DfltTIULocationName: string;
323{ returns the name of the user defined default progress note title (if any) }
324begin
325 if uTIUPrefs = nil then LoadTIUPrefs;
326 Result := uTIUPrefs.DfltLocName;
327end;
328
329{ Data Retrieval --------------------------------------------------------------------------- }
330
331procedure ActOnDocument(var AuthSts: TActionRec; IEN: Integer; const ActionName: string);
332var
333 x: string;
334begin
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);
344end;
345
346function AuthorSignedDocument(IEN: Integer): boolean;
347begin
348 Result := SCallV('TIU HAS AUTHOR SIGNED?', [IEN, User.DUZ]) = '1';
349end;
350
351function CosignDocument(IEN: Integer): Boolean;
352var
353 x: string;
354begin
355 x := sCallV('TIU WHICH SIGNATURE ACTION', [IEN]);
356 Result := x = 'COSIGNATURE';
357end;
358
359(*function CPTRequiredForNote(IEN: Integer): Boolean;
360begin
361 If IEN > 0 then
362 Result := sCallV('ORWPCE CPTREQD', [IEN]) = '1'
363 else
364 Result := False;
365end;*)
366
367procedure ListConsultRequests(Dest: TStrings);
368{ lists outstanding consult requests for a patient: IEN^Request D/T^Service^Procedure }
369begin
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);
376end;
377
378procedure 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 }
383var
384 i: Integer;
385 x: string;
386 SortSeq: Char;
387begin
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}
404end;
405
406procedure 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 }
411var
412 SortSeq: Char;
413const
414 SHOW_ADDENDA = True;
415begin
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;
422end;
423
424procedure ListDCSumm(Dest: TStrings);
425{ returns the list of discharge summaries for a patient - see ListNotes for pieces }
426var
427 i: Integer;
428 x: string;
429begin
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}
443end;
444
445procedure LoadDocumentText(Dest: TStrings; IEN: Integer);
446{ returns the text of a document (progress note, discharge summary, etc.) }
447begin
448 CallV('TIU GET RECORD TEXT', [IEN]);
449 Dest.Assign(RPCBrokerV.Results);
450end;
451
452procedure LoadDetailText(Dest: TStrings; IEN: Integer); //**KCM**
453begin
454 CallV('TIU DETAILED DISPLAY', [IEN]);
455 Dest.Assign(RPCBrokerV.Results);
456end;
457
458procedure 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 }
461var
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
530begin
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;
564end;
565
566function VisitStrForNote(IEN: Integer): string;
567begin
568 Result := sCallV('ORWPCE NOTEVSTR', [IEN]);
569end;
570
571function TitleForNote(IEN: Int64): Integer;
572begin
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;
583end;
584
585function GetPackageRefForNote(NoteIEN: integer): string;
586begin
587 Result := sCallV('TIU GET REQUEST', [NoteIEN]);
588end;
589
590function GetConsultIENforNote(NoteIEN: integer): Integer;
591var
592 x: string;
593begin
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);
599end;
600
601procedure LockDocument(IEN: Int64; var AnErrMsg: string);
602var
603 x: string;
604begin
605 x := sCallV('TIU LOCK RECORD', [IEN]);
606 if CharAt(x, 1) = '0' then AnErrMsg := '' else AnErrMsg := Piece(x, U, 2);
607end;
608
609procedure UnlockDocument(IEN: Int64);
610begin
611 CallV('TIU UNLOCK RECORD', [IEN]);
612end;
613
614function LastSaveClean(IEN: Int64): Boolean;
615begin
616 Result := sCallV('TIU WAS THIS SAVED?', [IEN]) = '1';
617end;
618
619function GetTIUListItem(IEN: Int64): string;
620begin
621 Result := sCallV('ORWTIU GET LISTBOX ITEM', [IEN]);
622end;
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 }
628begin
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;
639end;*)
640
641procedure 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 }
643var
644 x: string;
645begin
646 x := sCallV('TIU DELETE RECORD', [IEN, Reason]);
647 DeleteSts.Success := Piece(x, U, 1) = '0';
648 DeleteSts.Reason := Piece(x, U, 2);
649end;
650
651function JustifyDocumentDelete(IEN: Integer): Boolean;
652begin
653 Result := sCallV('TIU JUSTIFY DELETE?', [IEN]) = '1';
654end;
655
656procedure SignDocument(var SignSts: TActionRec; IEN: Integer; const ESCode: string);
657{ update signed status of a TIU document, return reason if signature is not accepted }
658var
659 x: string;
660begin
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);
674end;
675
676procedure 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;*)
681var
682 ErrMsg: string;
683begin
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;
730end;
731
732procedure 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;*)
737var
738 ErrMsg: string;
739begin
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;
771end;
772
773procedure 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;*)
778var
779 ErrMsg: string;
780begin
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;
826end;
827
828procedure PutTextOnly(var ErrMsg: string; NoteText: TStrings; NoteIEN: Int64);
829var
830 i: Integer;
831begin
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;
846end;
847
848procedure SetText(var ErrMsg: string; NoteText: TStrings; NoteIEN: Int64; Suppress: Integer);
849const
850 DOCUMENT_PAGE_SIZE = 300;
851//TX_SERVER_ERROR = 'An error occurred on the server.' ; <-- original line. //kt 1/17/2008
852var
853 i, j, page, pages: Integer;
854 TX_SERVER_ERROR : string; //kt
855begin
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;
893end;
894
895procedure InitParams( NoteIEN: Int64; Suppress: Integer );
896begin
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;
907end;
908
909{ Printing --------------------------------------------------------------------------------- }
910
911function AllowChartPrintForNote(ANote: Integer): Boolean;
912{ returns true if a progress note may be printed outside of MAS }
913begin
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
917end;
918
919procedure PrintNoteToDevice(ANote: Integer; const ADevice: string; ChartCopy: Boolean;
920 var ErrMsg: string);
921{ prints a progress note on the selected device }
922begin
923 ErrMsg := sCallV('TIU PRINT RECORD', [ANote, ADevice, ChartCopy]);
924 if Piece(ErrMsg, U, 1) = '0' then ErrMsg := '' else ErrMsg := Piece(ErrMsg, U, 2);
925end;
926
927function GetFormattedNote(ANote: Integer; ChartCopy: Boolean): TStrings;
928begin
929 CallV('ORWTIU WINPRINT NOTE',[ANote, ChartCopy]);
930 Result := RPCBrokerV.Results;
931end;
932
933function GetCurrentSigners(IEN: integer): TStrings;
934begin
935 CallV('TIU GET ADDITIONAL SIGNERS', [IEN]);
936 MixedCaseList(RPCBrokerV.Results);
937 Result := RPCBrokerV.Results ;
938end;
939
940procedure UpdateAdditionalSigners(IEN: integer; Signers: TStrings);
941begin
942 CallV('TIU UPDATE ADDITIONAL SIGNERS', [IEN, Signers]);
943end;
944
945function CanChangeCosigner(IEN: integer): boolean;
946begin
947 Result := Piece(sCallV('TIU CAN CHANGE COSIGNER?', [IEN]), U, 1) = '1';
948end;
949
950procedure ChangeCosigner(IEN: integer; Cosigner: int64);
951begin
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;
966end;
967
968// Determine if given note title is allowed more than once per visit. 12/2002-GRE
969function OneNotePerVisit(NoteEIN: Integer; DFN: String; VisitStr: String):boolean;
970var x: string;
971begin
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;
977end;
978
979function GetCurrentTIUContext: TTIUContext;
980var
981 x: string;
982 AContext: TTIUContext;
983begin
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;
1006end;
1007
1008procedure SaveCurrentTIUContext(AContext: TTIUContext) ;
1009var
1010 x: string;
1011begin
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]);
1031end;
1032
1033function TIUSiteParams: string;
1034begin
1035 if(not uTIUSiteParamsLoaded) then
1036 begin
1037 uTIUSiteParams := sCallV('TIU GET SITE PARAMETERS', []) ;
1038 uTIUSiteParamsLoaded := TRUE;
1039 end;
1040 Result := uTIUSiteParams;
1041end;
1042
1043// ===================Interdisciplinary Notes RPCs =====================
1044
1045function IDNotesInstalled: boolean;
1046begin
1047 Result := True; // old patch check no longer called
1048end;
1049
1050function CanTitleBeIDChild(Title: integer; var WhyNot: string): boolean;
1051var
1052 x: string;
1053begin
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;
1063end;
1064
1065function CanBeAttached(DocID: string; var WhyNot: string): boolean;
1066var
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
1072var
1073 TX_NO_ATTACH : string;
1074
1075begin
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;
1098end;
1099
1100function CanReceiveAttachment(DocID: string; var WhyNot: string): boolean;
1101var
1102 x: string;
1103begin
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;
1112end;
1113
1114function AttachEntryToParent(DocID, ParentDocID: string; var WhyNot: string): boolean;
1115var
1116 x: string;
1117begin
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;
1126end;
1127
1128function DetachEntryFromParent(DocID: string; var WhyNot: string): boolean;
1129var
1130 x: string;
1131begin
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;
1140end;
1141
1142function SubSetOfUserClasses(const StartFrom: string; Direction: Integer): TStrings;
1143begin
1144 CallV('TIU USER CLASS LONG LIST', [StartFrom, Direction]);
1145 Result := RPCBrokerV.Results;
1146end;
1147
1148function UserDivClassInfo(User: Int64): TStrings;
1149begin
1150 CallV('TIU DIV AND CLASS INFO', [User]);
1151 Result := RPCBrokerV.Results;
1152end;
1153
1154function UserInactive(EIN: String): boolean;
1155var x: string;
1156begin
1157 x:= sCallv('TIU USER INACTIVE?', [EIN]) ;
1158 if (StrToInt(x) > 0) then
1159 Result := True
1160 else
1161 Result := False;
1162end;
1163
1164function TIUPatch175Installed: boolean;
1165begin
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;
1173end;
1174
1175function NoteHasText(NoteIEN: integer): boolean;
1176begin
1177 Result := (StrToIntDef(sCallV('ORWTIU CHKTXT', [NoteIEN]), 0) > 0);
1178end;
1179
1180
1181initialization
1182 // nothing for now
1183
1184finalization
1185 if uNoteTitles <> nil then uNoteTitles.Free;
1186 if uTIUPrefs <> nil then uTIUPrefs.Free;
1187
1188end.
Note: See TracBrowser for help on using the repository browser.