source: cprs/branches/foia-cprs/CPRS-Chart/rDCSumm.pas@ 1035

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

Adding foia-cprs branch

File size: 23.3 KB
RevLine 
[459]1unit rDCSumm;
2
3interface
4
5uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, TRPCB, rTIU, uConst, uTIU, uDCSumm;
6
7
8{ Discharge Summary Titles }
9procedure ResetDCSummTitles;
10function DfltDCSummTitle: Integer;
11function DfltDCSummTitleName: string;
12procedure ListDCSummTitlesShort(Dest: TStrings);
13function SubSetOfDCSummTitles(const StartFrom: string; Direction: Integer; IDNoteTitlesOnly: boolean): TStrings;
14
15{ TIU Preferences }
16procedure ResetDCSummPreferences;
17function ReturnMaxDCSumms: Integer;
18function SortDCSummsAscending: Boolean;
19function GetCurrentDCSummContext: TTIUContext;
20procedure SaveCurrentDCSummContext(AContext: TTIUContext) ;
21
22{ Data Retrieval }
23procedure ActOnDCDocument(var AuthSts: TActionRec; IEN: Integer; const ActionName: string);
24(*procedure ListDischargeSummaries(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
25 Person: int64; OccLim: Integer; SortAscending: Boolean);*)
26procedure ListSummsForTree(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
27 Person: int64; OccLim: Integer; SortAscending: Boolean);
28procedure GetDCSummForEdit(var EditRec: TEditDCSummRec; IEN: Integer);
29function LoadDCUrgencies: TStrings;
30function GetAttending(const DFN: string): string; //*DFN*
31function GetDischargeDate(const DFN: string; AdmitDateTime: string): string; //*DFN*
32function RequireRelease(ANote, AType: Integer): Boolean;
33function RequireMASVerification(ANote, AType: Integer): Boolean;
34function AllowMultipleSummsPerAdmission(ANote, AType: Integer): Boolean;
35
36{ Data Storage }
37procedure DeleteDCDocument(var DeleteSts: TActionRec; IEN: Integer; const Reason: string);
38procedure SignDCDocument(var SignSts: TActionRec; IEN: Integer; const ESCode: string);
39procedure PutNewDCSumm(var CreatedDoc: TCreatedDoc; const DCSummRec: TDCSummRec);
40procedure PutDCAddendum(var CreatedDoc: TCreatedDoc; const DCSummRec: TDCSummRec; AddendumTo:
41Integer);
42procedure PutEditedDCSumm(var UpdatedDoc: TCreatedDoc; const DCSummRec: TDCSummRec; NoteIEN:
43Integer);
44procedure ChangeAttending(IEN: integer; AnAttending: int64);
45
46const
47 CLS_DC_SUMM = 244;
48 FN_HOSPITAL_LOCATION = 44;
49 FN_NEW_PERSON = 200;
50 TIU_ST_UNREL = 3;
51 TIU_ST_UNVER = 4;
52 TIU_ST_UNSIG = 5;
53
54implementation
55
56var
57 uDCSummTitles: TDCSummTitles;
58 uDCSummPrefs: TDCSummPrefs;
59
60{ Discharge Summary Titles -------------------------------------------------------------------- }
61procedure LoadDCSummTitles;
62{ private - called one time to set up the uNoteTitles object }
63var
64 x: string;
65begin
66 if uDCSummTitles <> nil then Exit;
67 CallV('TIU PERSONAL TITLE LIST', [User.DUZ, CLS_DC_SUMM]);
68 RPCBrokerV.Results.Insert(0, '~SHORT LIST'); // insert so can call ExtractItems
69 uDCSummTitles := TDCSummTitles.Create;
70 ExtractItems(uDCSummTitles.ShortList, RPCBrokerV.Results, 'SHORT LIST');
71 x := ExtractDefault(RPCBrokerV.Results, 'SHORT LIST');
72 uDCSummTitles.DfltTitle := StrToIntDef(Piece(x, U, 1), 0);
73 uDCSummTitles.DfltTitleName := Piece(x, U, 2);
74end;
75
76procedure ResetDCSummTitles;
77begin
78 if uDCSummTitles <> nil then
79 begin
80 uDCSummTitles.Free;
81 uDCSummTitles := nil;
82 LoadDCSummTitles;
83 end;
84end;
85
86function DfltDCSummTitle: Integer;
87{ returns the IEN of the user defined default Discharge Summary title (if any) }
88begin
89 if uDCSummTitles = nil then LoadDCSummTitles;
90 Result := uDCSummTitles.DfltTitle;
91end;
92
93function DfltDCSummTitleName: string;
94{ returns the name of the user defined default Discharge Summary title (if any) }
95begin
96 if uDCSummTitles = nil then LoadDCSummTitles;
97 Result := uDCSummTitles.DfltTitleName;
98end;
99
100procedure ListDCSummTitlesShort(Dest: TStrings);
101{ returns the user defined list (short list) of Discharge Summary titles }
102begin
103 if uDCSummTitles = nil then LoadDCSummTitles;
104 Dest.AddStrings(uDCSummTitles.ShortList);
105 if uDCSummTitles.ShortList.Count > 0 then
106 begin
107 Dest.Add('0^________________________________________________________________________');
108 Dest.Add('0^ ');
109 end;
110end;
111
112function SubSetOfDCSummTitles(const StartFrom: string; Direction: Integer; IDNoteTitlesOnly: boolean): TStrings;
113{ returns a pointer to a list of Discharge Summary titles (for use in a long list box) -
114 The return value is a pointer to RPCBrokerV.Results, so the data must be used BEFORE
115 the next broker call! }
116begin
117 if IDNoteTitlesOnly then
118 CallV('TIU LONG LIST OF TITLES', [CLS_DC_SUMM, StartFrom, Direction, IDNoteTitlesOnly])
119 else
120 CallV('TIU LONG LIST OF TITLES', [CLS_DC_SUMM, StartFrom, Direction]);
121 //MixedCaseList(RPCBrokerV.Results);
122 Result := RPCBrokerV.Results;
123end;
124
125{ TIU Preferences ------------------------------------------------------------------------- }
126
127procedure LoadDCSummPrefs;
128{ private - creates DCSummPrefs object for reference throughout the session }
129var
130 x: string;
131begin
132 uDCSummPrefs := TDCSummPrefs.Create;
133 with uDCSummPrefs do
134 begin
135 x := sCallV('TIU GET PERSONAL PREFERENCES', [User.DUZ]);
136 DfltLoc := StrToIntDef(Piece(x, U, 2), 0);
137 DfltLocName := ExternalName(DfltLoc, FN_HOSPITAL_LOCATION);
138 SortAscending := Piece(x, U, 4) = 'A';
139 MaxSumms := StrToIntDef(Piece(x, U, 10), 0);
140 x := GetAttending(Patient.DFN);
141 DfltCosigner := StrToInt64Def(Piece(x, U, 1), 0);
142 DfltCosignerName := ExternalName(DfltCosigner, FN_NEW_PERSON);
143 AskCosigner := User.DUZ <> DfltCosigner;
144 end;
145end;
146
147procedure ResetDCSummPreferences;
148begin
149 if uDCSummPrefs <> nil then
150 begin
151 uDCSummPrefs.Free;
152 uDCSummPrefs := nil;
153 LoadDCSummPrefs;
154 end;
155end;
156
157function ReturnMaxDCSumms: Integer;
158begin
159 if uDCSummPrefs = nil then LoadDCSummPrefs;
160 Result := uDCSummPrefs.MaxSumms;
161 if Result = 0 then Result := 100;
162end;
163
164function SortDCSummsAscending: Boolean;
165{ returns true if Discharge Summarys should be sorted from oldest to newest (chronological) }
166begin
167 if uDCSummPrefs = nil then LoadDCSummPrefs;
168 Result := uDCSummPrefs.SortAscending;
169end;
170
171{ Data Retrieval --------------------------------------------------------------------------- }
172
173procedure ActOnDCDocument(var AuthSts: TActionRec; IEN: Integer; const ActionName: string);
174var
175 x: string;
176begin
177 if not (IEN > 0) then
178 begin
179 AuthSts.Success := True;
180 AuthSts.Reason := '';
181 Exit;
182 end;
183 x := sCallV('TIU AUTHORIZATION', [IEN, ActionName]);
184 AuthSts.Success := Piece(x, U, 1) = '1';
185 AuthSts.Reason := Piece(x, U, 2);
186end;
187
188(*procedure ListDischargeSummaries(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
189 Person: int64; OccLim: Integer; SortAscending: Boolean);
190{ retrieves existing progress notes for a patient according to the parameters passed in
191 Pieces: IEN^Title^FMDateOfNote^Patient^Author^Location^Status^Visit
192 Return: IEN^ExDateOfNote^Title, Location, Author }
193var
194 i: Integer;
195 x: string;
196 SortSeq: Char;
197begin
198 if SortAscending then SortSeq := 'A' else SortSeq := 'D';
199 //if OccLim = 0 then OccLim := MaxSummsReturned;
200 CallV('TIU DOCUMENTS BY CONTEXT',
201 [CLS_DC_SUMM, Context, Patient.DFN, Early, Late, Person, OccLim, SortSeq]);
202 with RPCBrokerV do
203 begin
204 for i := 0 to Results.Count - 1 do
205 begin
206 x := Results[i];
207 if Copy(Piece(x, U, 9), 1, 4) = ' ' then SetPiece(x, U, 9, 'Dis: ');
208 x := Piece(x, U, 1) + U + FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(x, U, 3)))
209 + U + Piece(x, U, 2) + ', ' + Piece(x, U, 6) + ', ' + Piece(Piece(x, U, 5), ';', 2) +
210 ' (' + Piece(x,U,7) + '), ' + Piece(x, U, 8) + ', ' + Piece(x, U, 9) +
211 U + Piece(x, U, 3) + U + Piece(x, U, 11);
212 Results[i] := x;
213 end; {for}
214 Dest.Assign(Results);
215 end; {with}
216end;*)
217
218procedure ListSummsForTree(Dest: TStrings; Context: Integer; Early, Late: TFMDateTime;
219 Person: int64; OccLim: Integer; SortAscending: Boolean);
220{ retrieves existing discharge summaries for a patient according to the parameters passed in}
221var
222 SortSeq: Char;
223const
224 SHOW_ADDENDA = True;
225begin
226 if SortAscending then SortSeq := 'A' else SortSeq := 'D';
227 if Context > 0 then
228 begin
229 CallV('TIU DOCUMENTS BY CONTEXT', [CLS_DC_SUMM, Context, Patient.DFN, Early, Late, Person, OccLim, SortSeq, SHOW_ADDENDA]);
230 Dest.Assign(RPCBrokerV.Results);
231 end;
232end;
233
234procedure GetDCSummForEdit(var EditRec: TEditDCSummRec; IEN: Integer);
235{ retrieves internal/external values for Discharge Summary fields & loads them into EditRec
236 Fields: Title:.01, RefDate:1301, Author:1204, Cosigner:1208, Subject:1701, Location:1205 }
237var
238 i, j: Integer;
239
240 function FindDT(const FieldID: string): TFMDateTime;
241 var
242 i: Integer;
243 begin
244 Result := 0;
245 with RPCBrokerV do for i := 0 to Results.Count - 1 do
246 if Piece(Results[i], U, 1) = FieldID then
247 begin
248 Result := MakeFMDateTime(Piece(Results[i], U, 2));
249 Break;
250 end;
251 end;
252
253 function FindExt(const FieldID: string): string;
254 var
255 i: Integer;
256 begin
257 Result := '';
258 with RPCBrokerV do for i := 0 to Results.Count - 1 do
259 if Piece(Results[i], U, 1) = FieldID then
260 begin
261 Result := Piece(Results[i], U, 3);
262 Break;
263 end;
264 end;
265
266 function FindInt(const FieldID: string): Integer;
267 var
268 i: Integer;
269 begin
270 Result := 0;
271 with RPCBrokerV do for i := 0 to Results.Count - 1 do
272 if Piece(Results[i], U, 1) = FieldID then
273 begin
274 Result := StrToIntDef(Piece(Results[i], U, 2), 0);
275 Break;
276 end;
277 end;
278
279 function FindInt64(const FieldID: string): Int64;
280 var
281 i: Integer;
282 begin
283 Result := 0;
284 with RPCBrokerV do for i := 0 to Results.Count - 1 do
285 if Piece(Results[i], U, 1) = FieldID then
286 begin
287 Result := StrToInt64Def(Piece(Results[i], U, 2), 0);
288 Break;
289 end;
290 end;
291
292
293begin
294 CallV('TIU LOAD RECORD FOR EDIT', [IEN, '.01;.06;.07;.09;1202;1205;1208;1209;1301;1302;1307;1701']);
295 FillChar(EditRec, SizeOf(EditRec), 0);
296 with EditRec do
297 begin
298 Title := FindInt('.01');
299 TitleName := FindExt('.01');
300 AdmitDateTime := FindDT('.07');
301 DischargeDateTime := FindDT('1301');
302 UrgencyName := FindExt('.09');
303 Urgency := Copy(UrgencyName,1,1);
304 Dictator := FindInt64('1202');
305 DictatorName := FindExt('1202');
306 Cosigner := FindInt64('1208');
307 CosignerName := FindExt('1208');
308 DictDateTime := FindDT('1307');
309 Attending := FindInt64('1209');
310 AttendingName := FindExt('1209');
311 Transcriptionist := FindInt64('1302');
312 TranscriptionistName := FindExt('1302');
313 Location := FindInt('1205');
314 LocationName := FindExt('1205');
315 if Title = TYP_ADDENDUM then Addend := FindInt('.06');
316 with RPCBrokerV do
317 begin
318 for i := 0 to Results.Count - 1 do if Results[i] = '$TXT' then break;
319 for j := i downto 0 do Results.Delete(j);
320 // -------------------- v19.1 (RV) LOST NOTES?----------------------------
321 //Lines := Results; 'Lines' is being overwritten by subsequent Broker calls
322 if not Assigned(Lines) then Lines := TStringList.Create;
323 Lines.Assign(Results);
324 // -----------------------------------------------------------------------
325 end;
326 end;
327end;
328
329function LoadDCUrgencies: TStrings;
330var
331 i: integer;
332begin
333 CallV('TIU GET DS URGENCIES',[nil]);
334 with RPCBrokerV do
335 for i := 0 to Results.Count-1 do
336 Results[i] := MixedCase(UpperCase(Results[i]));
337 Result := RPCBrokerV.Results;
338end;
339
340{ Data Updates ----------------------------------------------------------------------------- }
341
342procedure DeleteDCDocument(var DeleteSts: TActionRec; IEN: Integer; const Reason: string);
343{ delete a TIU document given the internal entry number, return reason if unable to delete }
344var
345 x: string;
346begin
347 x := sCallV('TIU DELETE RECORD', [IEN, Reason]);
348 DeleteSts.Success := Piece(x, U, 1) = '0';
349 DeleteSts.Reason := Piece(x, U, 2);
350end;
351
352procedure SignDCDocument(var SignSts: TActionRec; IEN: Integer; const ESCode: string);
353{ update signed status of a TIU document, return reason if signature is not accepted }
354var
355 x: string;
356begin
357(* with RPCBrokerV do // temp - to insure sign doesn't go interactive
358 begin
359 ClearParameters := True;
360 RemoteProcedure := 'TIU UPDATE RECORD';
361 Param[0].PType := literal;
362 Param[0].Value := IntToStr(IEN);
363 Param[1].PType := list;
364 with Param[1] do Mult['.11'] := '0'; // **** block removed in v19.1 - {RV} ****
365 CallBroker;
366 end; // temp - end*)
367 x := sCallV('TIU SIGN RECORD', [IEN, ESCode]);
368 SignSts.Success := Piece(x, U, 1) = '0';
369 SignSts.Reason := Piece(x, U, 2);
370end;
371
372procedure PutNewDCSumm(var CreatedDoc: TCreatedDoc; const DCSummRec: TDCSummRec);
373{ create a new discharge summary with the data in DCSummRec and return its internal entry number
374 load broker directly since there isn't a good way to set up multiple subscript arrays }
375(*var
376 i: Integer;*)
377var
378 ErrMsg: string;
379begin
380 with RPCBrokerV do
381 begin
382 ClearParameters := True;
383 RemoteProcedure := 'TIU CREATE RECORD';
384 Param[0].PType := literal;
385 Param[0].Value := Patient.DFN; //*DFN*
386 Param[1].PType := literal;
387 Param[1].Value := IntToStr(DCSummRec.Title);
388 Param[2].PType := literal;
389 Param[2].Value := '';
390 Param[3].PType := literal;
391 Param[3].Value := '';
392 Param[4].PType := literal;
393 Param[4].Value := '';
394 Param[5].PType := list;
395 with Param[5] do
396 begin
397 Mult['.07'] := FloatToStr(DCSummRec.AdmitDateTime);
398 Mult['.09'] := DCSummRec.Urgency;
399 Mult['1202'] := IntToStr(DCSummRec.Dictator);
400 Mult['1205'] := IntToStr(Encounter.Location);
401 Mult['1301'] := FloatToStr(DCSummRec.DischargeDateTime);
402 Mult['1307'] := FloatToStr(DCSummRec.DictDateTime);
403 if DCSummRec.Cosigner > 0 then
404 begin
405 Mult['1208'] := IntToStr(DCSummRec.Cosigner);
406 Mult['1506'] := '1';
407 end
408 else
409 begin
410 Mult['1208'] := '';
411 Mult['1506'] := '0';
412 end ;
413 Mult['1209'] := IntToStr(DCSummRec.Attending);
414 Mult['1302'] := IntToStr(DCSummRec.Transcriptionist);
415 if DCSummRec.IDParent > 0 then Mult['2101'] := IntToStr(DCSummRec.IDParent);
416(* if DCSummRec.Lines <> nil then
417 for i := 0 to DCSummRec.Lines.Count - 1 do
418 Mult['"TEXT",' + IntToStr(i+1) + ',0'] := FilteredString(DCSummRec.Lines[i]);*)
419 end;
420 Param[6].PType := literal;
421 Param[6].Value := DCSummRec.VisitStr;
422 Param[7].PType := literal;
423 Param[7].Value := '1'; // suppress commit logic
424 CallBroker;
425 CreatedDoc.IEN := StrToIntDef(Piece(Results[0], U, 1), 0);
426 CreatedDoc.ErrorText := Piece(Results[0], U, 2);
427 end;
428 if ( DCSummRec.Lines <> nil ) and ( CreatedDoc.IEN <> 0 ) then
429 begin
430 SetText(ErrMsg, DCSummRec.Lines, CreatedDoc.IEN, 1);
431 if ErrMsg <> '' then
432 begin
433 CreatedDoc.IEN := 0;
434 CreatedDoc.ErrorText := ErrMsg;
435 end;
436 end;
437end;
438
439procedure PutDCAddendum(var CreatedDoc: TCreatedDoc; const DCSummRec: TDCSummRec; AddendumTo:
440Integer);
441{ create a new addendum for note identified in AddendumTo, returns IEN of new document
442 load broker directly since there isn't a good way to set up multiple subscript arrays }
443(*var
444 i: Integer;*)
445var
446 ErrMsg: string;
447begin
448 with RPCBrokerV do
449 begin
450 ClearParameters := True;
451 RemoteProcedure := 'TIU CREATE ADDENDUM RECORD';
452 Param[0].PType := literal;
453 Param[0].Value := IntToStr(AddendumTo);
454 Param[1].PType := list;
455 with Param[1] do
456 begin
457 Mult['.09'] := DCSummRec.Urgency;
458 Mult['1202'] := IntToStr(DCSummRec.Dictator);
459 Mult['1301'] := FloatToStr(DCSummRec.DischargeDateTime);
460 Mult['1307'] := FloatToStr(DCSummRec.DictDateTime);
461 if DCSummRec.Cosigner > 0 then
462 begin
463 Mult['1208'] := IntToStr(DCSummRec.Cosigner);
464 Mult['1506'] := '1';
465 end
466 else
467 begin
468 Mult['1208'] := '';
469 Mult['1506'] := '0';
470 end ;
471(* if DCSummRec.Lines <> nil then
472 for i := 0 to DCSummRec.Lines.Count - 1 do
473 Mult['"TEXT",' + IntToStr(i+1) + ',0'] := FilteredString(DCSummRec.Lines[i]);*)
474 end;
475 Param[2].PType := literal;
476 Param[2].Value := '1'; // suppress commit logic
477 CallBroker;
478 CreatedDoc.IEN := StrToIntDef(Piece(Results[0], U, 1), 0);
479 CreatedDoc.ErrorText := Piece(Results[0], U, 2);
480 end;
481 if ( DCSummRec.Lines <> nil ) and ( CreatedDoc.IEN <> 0 ) then
482 begin
483 SetText(ErrMsg, DCSummRec.Lines, CreatedDoc.IEN, 1);
484 if ErrMsg <> '' then
485 begin
486 CreatedDoc.IEN := 0;
487 CreatedDoc.ErrorText := ErrMsg;
488 end;
489 end;
490end;
491
492procedure PutEditedDCSumm(var UpdatedDoc: TCreatedDoc; const DCSummRec: TDCSummRec; NoteIEN:
493Integer);
494{ update the fields and content of the note identified in NoteIEN, returns 1 if successful
495 load broker directly since there isn't a good way to set up mutilple subscript arrays }
496(*var
497 i: Integer;*)
498var
499 ErrMsg: string;
500begin
501 // First, file field data
502 with RPCBrokerV do
503 begin
504 ClearParameters := True;
505 RemoteProcedure := 'TIU UPDATE RECORD';
506 Param[0].PType := literal;
507 Param[0].Value := IntToStr(NoteIEN);
508 Param[1].PType := list;
509 with Param[1] do
510 begin
511 if DCSummRec.Addend = 0 then
512 begin
513 Mult['.01'] := IntToStr(DCSummRec.Title);
514 //Mult['.11'] := BOOLCHAR[DCSummRec.NeedCPT]; // **** removed in v19.1 {RV} ****
515 end;
516 if (DCSummRec.Status in [TIU_ST_UNREL(*, TIU_ST_UNVER*)]) then Mult['.05'] := IntToStr(DCSummRec.Status);
517 Mult['1202'] := IntToStr(DCSummRec.Dictator);
518 Mult['1209'] := IntToStr(DCSummRec.Attending);
519 Mult['1301'] := FloatToStr(DCSummRec.DischargeDateTime);
520 if DCSummRec.Cosigner > 0 then
521 begin
522 Mult['1208'] := IntToStr(DCSummRec.Cosigner);
523 Mult['1506'] := '1';
524 end
525 else
526 begin
527 Mult['1208'] := '';
528 Mult['1506'] := '0';
529 end ;
530(* for i := 0 to DCSummRec.Lines.Count - 1 do
531 Mult['"TEXT",' + IntToStr(i+1) + ',0'] := FilteredString(DCSummRec.Lines[i]);*)
532 end;
533 CallBroker;
534 UpdatedDoc.IEN := StrToIntDef(Piece(Results[0], U, 1), 0);
535 UpdatedDoc.ErrorText := Piece(Results[0], U, 2);
536 end;
537
538 if UpdatedDoc.IEN <= 0 then //v22.12 - RV
539 //if UpdatedDoc.ErrorText <> '' then //v22.5 - RV
540 begin
541 UpdatedDoc.ErrorText := UpdatedDoc.ErrorText + #13#10 + #13#10 + 'Document #: ' + IntToStr(NoteIEN);
542 exit;
543 end;
544
545 // next, if no error, file document body
546 SetText(ErrMsg, DCSummRec.Lines, NoteIEN, 0);
547 if ErrMsg <> '' then
548 begin
549 UpdatedDoc.IEN := 0;
550 UpdatedDoc.ErrorText := ErrMsg;
551 end;
552end;
553
554function GetAttending(const DFN: string): string; //*DFN*
555begin
556 CallV('ORQPT ATTENDING/PRIMARY',[DFN]);
557 Result := Piece(RPCBrokerV.Results[0],';',1);
558end;
559
560function GetDischargeDate(const DFN: string; AdmitDateTime: string): string; //*DFN*
561begin
562 CallV('ORWPT DISCHARGE',[DFN, AdmitDateTime]);
563 Result := RPCBrokerV.Results[0];
564end;
565
566function RequireRelease(ANote, AType: Integer): Boolean;
567{ returns true if a discharge summary must be released }
568begin
569 if ANote > 0 then
570 Result := Piece(sCallV('TIU GET DOCUMENT PARAMETERS', [ANote]), U, 2) = '1'
571 else
572 Result := Piece(sCallV('TIU GET DOCUMENT PARAMETERS', [0, AType]), U, 2) = '1';
573end;
574
575function RequireMASVerification(ANote, AType: Integer): Boolean;
576{ returns true if a discharge summary must be verified }
577var
578 AValue: integer;
579begin
580 Result := False;
581 if ANote > 0 then
582 AValue := StrToIntDef(Piece(sCallV('TIU GET DOCUMENT PARAMETERS', [ANote]), U, 3), 0)
583 else
584 AValue := StrToIntDef(Piece(sCallV('TIU GET DOCUMENT PARAMETERS', [0, AType]), U, 3), 0);
585 case AValue of
586 0: Result := False; // NO
587 1: Result := True; // ALWAYS
588 2: Result := False; // UPLOAD ONLY
589 3: Result := True; // DIRECT ENTRY ONLY
590 end;
591end;
592
593function AllowMultipleSummsPerAdmission(ANote, AType: Integer): Boolean;
594{ returns true if a discharge summary must be released }
595begin
596 if ANote > 0 then
597 Result := Piece(sCallV('TIU GET DOCUMENT PARAMETERS', [ANote]), U, 10) = '1'
598 else
599 Result := Piece(sCallV('TIU GET DOCUMENT PARAMETERS', [0, AType]), U, 10) = '1';
600end;
601
602procedure ChangeAttending(IEN: integer; AnAttending: int64);
603var
604 AttendingIsNotCurrentUser: boolean;
605begin
606 AttendingIsNotCurrentUser := (AnAttending <> User.DUZ);
607 with RPCBrokerV do
608 begin
609 ClearParameters := True;
610 RemoteProcedure := 'TIU UPDATE RECORD';
611 Param[0].PType := literal;
612 Param[0].Value := IntToStr(IEN);
613 Param[1].PType := list;
614 with Param[1] do
615 begin
616 Mult['1209'] := IntToStr(AnAttending);
617 if AttendingIsNotCurrentUser then
618 begin
619 Mult['1208'] := IntToStr(AnAttending);
620 Mult['1506'] := '1';
621 end
622 else
623 begin
624 Mult['1208'] := '';
625 Mult['1506'] := '0';
626 end ;
627 end;
628 CallBroker;
629 end;
630end;
631
632function GetCurrentDCSummContext: TTIUContext;
633var
634 x: string;
635 AContext: TTIUContext;
636begin
637 x := sCallV('ORWTIU GET DCSUMM CONTEXT', [User.DUZ]) ;
638 with AContext do
639 begin
640 Changed := True;
641 BeginDate := Piece(x, ';', 1);
642 EndDate := Piece(x, ';', 2);
643 Status := Piece(x, ';', 3);
644 if (StrToIntDef(Status, 0) < 1) or (StrToIntDef(Status, 0) > 5) then Status := '1';
645 Author := StrToInt64Def(Piece(x, ';', 4), 0);
646 MaxDocs := StrToIntDef(Piece(x, ';', 5), 0);
647 ShowSubject := StrToIntDef(Piece(x, ';', 6), 0) > 0; //TIU PREFERENCE??
648 SortBy := Piece(x, ';', 7); //TIU PREFERENCE??
649 ListAscending := StrToIntDef(Piece(x, ';', 8), 0) > 0;
650 TreeAscending := StrToIntDef(Piece(x, ';', 9), 0) > 0; //TIU PREFERENCE??
651 GroupBy := Piece(x, ';', 10);
652 SearchField := Piece(x, ';', 11);
653 KeyWord := Piece(x, ';', 12);
654 Filtered := (Keyword <> '');
655 end;
656 Result := AContext;
657end;
658
659procedure SaveCurrentDCSummContext(AContext: TTIUContext) ;
660var
661 x: string;
662begin
663 with AContext do
664 begin
665 SetPiece(x, ';', 1, BeginDate);
666 SetPiece(x, ';', 2, EndDate);
667 SetPiece(x, ';', 3, Status);
668 if Author > 0 then
669 SetPiece(x, ';', 4, IntToStr(Author))
670 else
671 SetPiece(x, ';', 4, '');
672 SetPiece(x, ';', 5, IntToStr(MaxDocs));
673 SetPiece(x, ';', 6, BOOLCHAR[ShowSubject]); //TIU PREFERENCE??
674 SetPiece(x, ';', 7, SortBy); //TIU PREFERENCE??
675 SetPiece(x, ';', 8, BOOLCHAR[ListAscending]);
676 SetPiece(x, ';', 9, BOOLCHAR[TreeAscending]); //TIU PREFERENCE??
677 SetPiece(x, ';', 10, GroupBy);
678 SetPiece(x, ';', 11, SearchField);
679 SetPiece(x, ';', 12, KeyWord);
680 end;
681 CallV('ORWTIU SAVE DCSUMM CONTEXT', [x]);
682end;
683
684initialization
685 // nothing for now
686
687finalization
688 if uDCSummTitles <> nil then uDCSummTitles.Free;
689 if uDCSummPrefs <> nil then uDCSummPrefs.Free;
690
691end.
Note: See TracBrowser for help on using the repository browser.