| 1 | unit rODLab;
 | 
|---|
| 2 | 
 | 
|---|
| 3 | interface
 | 
|---|
| 4 | 
 | 
|---|
| 5 | uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, TRPCB, dialogs ;
 | 
|---|
| 6 | 
 | 
|---|
| 7 |      { Laboratory Ordering Calls }
 | 
|---|
| 8 | function  ODForLab(Location: integer; Division: integer = 0): TStrings;
 | 
|---|
| 9 | procedure LoadLabTestData(LoadData: TStringList; LabTestIEN: string) ;
 | 
|---|
| 10 | procedure LoadSamples(LoadList: TStringList) ;
 | 
|---|
| 11 | procedure LoadSpecimens(SpecimenList: TStringList) ;
 | 
|---|
| 12 | function  SubsetOfSpecimens(const StartFrom: string; Direction: Integer): TStrings;
 | 
|---|
| 13 | function  CalcStopDate(Text: string): string ;
 | 
|---|
| 14 | function  MaxDays(Location, Schedule: integer): integer;
 | 
|---|
| 15 | function  IsLabCollectTime(ADateTime: TFMDateTime; Location: integer): boolean;
 | 
|---|
| 16 | function  ImmediateCollectTimes: TStrings;
 | 
|---|
| 17 | function  LabCollectFutureDays(Location: integer; Division: integer = 0): integer;
 | 
|---|
| 18 | function  GetDefaultImmCollTime: TFMDateTime;
 | 
|---|
| 19 | function  ValidImmCollTime(CollTime: TFMDateTime): string;
 | 
|---|
| 20 | function  GetOneCollSamp(LRFSAMP: integer): TStrings;
 | 
|---|
| 21 | function  GetOneSpecimen(LRFSPEC: integer): string;
 | 
|---|
| 22 | procedure GetLabTimesForDate(Dest: TStrings; LabDate: TFMDateTime; Location: integer);
 | 
|---|
| 23 | function  GetLastCollectionTime: string;
 | 
|---|
| 24 | procedure GetPatientBBInfo(Dest: TStrings; PatientID: string; Loc: integer);
 | 
|---|
| 25 | procedure GetPatientBloodResults(Dest: TStrings; PatientID: string; ATests: TStringList);
 | 
|---|
| 26 | procedure GetPatientBloodResultsRaw(Dest: TStrings; PatientID: string; ATests: TStringList);
 | 
|---|
| 27 | function  StatAllowed(PatientID: string): boolean;
 | 
|---|
| 28 | procedure GetBloodComponents(Dest: TStrings);
 | 
|---|
| 29 | 
 | 
|---|
| 30 | implementation
 | 
|---|
| 31 | 
 | 
|---|
| 32 | uses  rODBase;
 | 
|---|
| 33 | (*    fODBase, rODBase, fODLab;*)
 | 
|---|
| 34 | 
 | 
|---|
| 35 | procedure GetBloodComponents(Dest: TStrings);
 | 
|---|
| 36 | begin
 | 
|---|
| 37 |   tCallV(Dest, 'ORWDXVB COMPORD', []);
 | 
|---|
| 38 | end;
 | 
|---|
| 39 | 
 | 
|---|
| 40 | function  StatAllowed(PatientID: string): boolean;
 | 
|---|
| 41 | begin
 | 
|---|
| 42 |   Result := (StrToInt(sCallV('ORWDXVB STATALOW',[PatientID])) > 0);
 | 
|---|
| 43 | end;
 | 
|---|
| 44 | 
 | 
|---|
| 45 | procedure GetPatientBloodResultsRaw(Dest: TStrings; PatientID: string; ATests: TStringList);
 | 
|---|
| 46 | begin
 | 
|---|
| 47 |   tCallV(Dest, 'ORWDXVB RAW', [PatientID, ATests]);
 | 
|---|
| 48 | end;
 | 
|---|
| 49 | 
 | 
|---|
| 50 | procedure GetPatientBloodResults(Dest: TStrings; PatientID: string; ATests: TStringList);
 | 
|---|
| 51 | begin
 | 
|---|
| 52 |   tCallV(Dest, 'ORWDXVB RESULTS', [PatientID, ATests]);
 | 
|---|
| 53 | end;
 | 
|---|
| 54 | 
 | 
|---|
| 55 | procedure GetPatientBBInfo(Dest: TStrings; PatientID: string; Loc: integer);
 | 
|---|
| 56 | begin
 | 
|---|
| 57 |   tCallV(Dest, 'ORWDXVB GETALL', [PatientID, Loc]);
 | 
|---|
| 58 | end;
 | 
|---|
| 59 | 
 | 
|---|
| 60 | function ODForLab(Location, Division: integer): TStrings;
 | 
|---|
| 61 | { Returns init values for laboratory dialog.  The results must be used immediately. }
 | 
|---|
| 62 | begin
 | 
|---|
| 63 |   CallV('ORWDLR32 DEF', [Location,Division]);
 | 
|---|
| 64 |   Result := RPCBrokerV.Results;
 | 
|---|
| 65 | end;
 | 
|---|
| 66 | 
 | 
|---|
| 67 | procedure LoadLabTestData(LoadData: TStringList; LabTestIEN: string) ;
 | 
|---|
| 68 | begin
 | 
|---|
| 69 |     tCallV(LoadData, 'ORWDLR32 LOAD', [LabTestIEN]);
 | 
|---|
| 70 | end ;
 | 
|---|
| 71 | 
 | 
|---|
| 72 | procedure LoadSamples(LoadList: TStringList) ;
 | 
|---|
| 73 | begin
 | 
|---|
| 74 |     tCallV(LoadList, 'ORWDLR32 ALLSAMP', [nil]);
 | 
|---|
| 75 | end ;
 | 
|---|
| 76 | 
 | 
|---|
| 77 | function SubsetOfSpecimens(const StartFrom: string; Direction: Integer): TStrings;
 | 
|---|
| 78 | begin
 | 
|---|
| 79 |   Callv('ORWDLR32 ALLSPEC',[StartFrom, Direction]);
 | 
|---|
| 80 |   Result := RPCBrokerV.Results;
 | 
|---|
| 81 | end ;
 | 
|---|
| 82 | 
 | 
|---|
| 83 | procedure LoadSpecimens(SpecimenList: TStringList) ;
 | 
|---|
| 84 | begin
 | 
|---|
| 85 |   tCallV(SpecimenList, 'ORWDLR32 ABBSPEC', [nil]);
 | 
|---|
| 86 | end ;
 | 
|---|
| 87 | 
 | 
|---|
| 88 | function CalcStopDate(Text: string): string ;
 | 
|---|
| 89 | begin
 | 
|---|
| 90 |   Result := sCallV('ORWDLR32 STOP', [Text]);
 | 
|---|
| 91 | end ;
 | 
|---|
| 92 | 
 | 
|---|
| 93 | function MaxDays(Location, Schedule: integer): integer;
 | 
|---|
| 94 | begin
 | 
|---|
| 95 |   Result := StrToInt(sCallV('ORWDLR32 MAXDAYS',[Location, Schedule]));
 | 
|---|
| 96 | end;
 | 
|---|
| 97 | 
 | 
|---|
| 98 | function IsLabCollectTime(ADateTime: TFMDateTime; Location: integer): boolean;
 | 
|---|
| 99 | begin
 | 
|---|
| 100 |   Result := (StrToInt(sCallV('ORWDLR32 LAB COLL TIME',[ADateTime,Location])) > 0);
 | 
|---|
| 101 | end;
 | 
|---|
| 102 | 
 | 
|---|
| 103 | function  LabCollectFutureDays(Location: integer; Division: integer): integer;
 | 
|---|
| 104 | begin
 | 
|---|
| 105 |   Result := StrToInt(sCallV('ORWDLR33 FUTURE LAB COLLECTS',[Location, Division]));
 | 
|---|
| 106 | end;
 | 
|---|
| 107 | 
 | 
|---|
| 108 | function  ImmediateCollectTimes: TStrings;
 | 
|---|
| 109 | begin
 | 
|---|
| 110 |   CallV('ORWDLR32 IMMED COLLECT',[nil]);
 | 
|---|
| 111 |   Result := RPCBrokerV.Results;
 | 
|---|
| 112 | end;
 | 
|---|
| 113 | 
 | 
|---|
| 114 | function  GetDefaultImmCollTime: TFMDateTime;
 | 
|---|
| 115 | begin
 | 
|---|
| 116 |   CallV('ORWDLR32 IC DEFAULT',[nil]);
 | 
|---|
| 117 |   Result := StrToFloat(Piece(RPCBrokerV.Results[0], U, 1));
 | 
|---|
| 118 | end;
 | 
|---|
| 119 | 
 | 
|---|
| 120 | function  ValidImmCollTime(CollTime: TFMDateTime): string;
 | 
|---|
| 121 | begin
 | 
|---|
| 122 |   CallV('ORWDLR32 IC VALID',[CollTime]);
 | 
|---|
| 123 |   Result := RPCBrokerV.Results[0];
 | 
|---|
| 124 | end;
 | 
|---|
| 125 | 
 | 
|---|
| 126 | function  GetOneCollSamp(LRFSAMP: integer): TStrings;
 | 
|---|
| 127 | begin
 | 
|---|
| 128 |   CallV('ORWDLR32 ONE SAMPLE', [LRFSAMP]);
 | 
|---|
| 129 |   Result := RPCBrokerV.Results;
 | 
|---|
| 130 | end;
 | 
|---|
| 131 | 
 | 
|---|
| 132 | function  GetOneSpecimen(LRFSPEC: integer): string;
 | 
|---|
| 133 | begin
 | 
|---|
| 134 |   Result := sCallV('ORWDLR32 ONE SPECIMEN', [LRFSPEC]);
 | 
|---|
| 135 | end;
 | 
|---|
| 136 | 
 | 
|---|
| 137 | function  GetLastCollectionTime: string;
 | 
|---|
| 138 | begin
 | 
|---|
| 139 |   Result := sCallV('ORWDLR33 LASTTIME', [nil]);
 | 
|---|
| 140 | end
 | 
|---|
| 141 | ;
 | 
|---|
| 142 | procedure GetLabTimesForDate(Dest: TStrings; LabDate: TFMDateTime; Location: integer);
 | 
|---|
| 143 | var
 | 
|---|
| 144 |   Prefix: string;
 | 
|---|
| 145 |   i: integer;
 | 
|---|
| 146 | begin
 | 
|---|
| 147 |   CallV('ORWDLR32 GET LAB TIMES', [LabDate, Location]);
 | 
|---|
| 148 |   with Dest do
 | 
|---|
| 149 |     begin
 | 
|---|
| 150 |       Assign(RPCBrokerV.Results);
 | 
|---|
| 151 |       if (Count > 0) and (Piece(Strings[0], U, 1) <> '-1') then
 | 
|---|
| 152 |         for i := 0 to Count - 1 do
 | 
|---|
| 153 |           begin
 | 
|---|
| 154 |             if Strings[i] > '1159' then Prefix := 'PM Collection:  ' else Prefix := 'AM Collection:  ';
 | 
|---|
| 155 |             Strings[i] := Strings[i] + U + Prefix + Copy(Strings[i], 1, 2) + ':' + Copy(Strings[i], 3, 2);
 | 
|---|
| 156 |           end;
 | 
|---|
| 157 |     end;
 | 
|---|
| 158 | end;
 | 
|---|
| 159 | 
 | 
|---|
| 160 | end.
 | 
|---|