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