[456] | 1 | unit rODMeds;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
[829] | 5 | uses SysUtils, Classes, ORNet, ORFn, uCore, uConst, Windows;
|
---|
[456] | 6 |
|
---|
[829] | 7 | type
|
---|
| 8 | TAdminTimeHelpText = record
|
---|
| 9 | HelpText: string;
|
---|
| 10 | end;
|
---|
| 11 |
|
---|
| 12 | TInpatientClozapineText = record
|
---|
| 13 | dispText: string;
|
---|
| 14 | end;
|
---|
| 15 |
|
---|
| 16 | TDrugHasMaxData = record
|
---|
| 17 | CaptureMaxData: boolean;
|
---|
| 18 | MaxSupply: integer;
|
---|
| 19 | MaxQuantity: integer;
|
---|
| 20 | MaxRefills: integer;
|
---|
| 21 | end;
|
---|
| 22 |
|
---|
[456] | 23 | function DEACheckFailed(AnOI: Integer; ForInpatient: Boolean): Boolean;
|
---|
| 24 | function DEACheckFailedForIVOnOutPatient(AnOI: Integer; AnOIType: Char): boolean;
|
---|
| 25 | procedure ListForOrderable(var AListIEN, ACount: Integer; const DGrpNm: string);
|
---|
| 26 | procedure SubsetOfOrderable(Dest: TStringList; Append: Boolean; ListIEN, First, Last: Integer);
|
---|
| 27 | function IndexOfOrderable(ListIEN: Integer; From: string): Integer;
|
---|
| 28 | procedure IsActivateOI(var AMsg: string; theOI: integer);
|
---|
| 29 | procedure ListForQuickOrders(var AListIEN, ACount: Integer; const DGrpNm: string);
|
---|
| 30 | procedure SubsetOfQuickOrders(Dest: TStringList; AListIEN, First, Last: Integer);
|
---|
| 31 | function IndexOfQuickOrder(AListIEN: Integer; From: string): Integer;
|
---|
| 32 | procedure LoadFormularyAltOI(AList: TStringList; AnIEN: Integer; ForInpatient: Boolean);
|
---|
| 33 | procedure LoadFormularyAltDose(AList: TStringList; DispDrug, OI: Integer; ForInpatient: Boolean);
|
---|
| 34 | procedure LoadAdminInfo(const Schedule: string; OrdItem: Integer; var StartText: string;
|
---|
[829] | 35 | var AdminTime: TFMDateTime; var Duration: string; Admin: string = '');
|
---|
[456] | 36 | function GetAdminTime(const StartText, Schedule: string; OrdItem: Integer): TFMDateTime;
|
---|
| 37 | procedure LoadSchedules(Dest: TStrings; IsInptDlg: boolean = False);
|
---|
[829] | 38 | procedure LoadDOWSchedules(Dest: TStrings);
|
---|
| 39 | procedure LoadAllIVRoutes(Dest: TStrings);
|
---|
| 40 | procedure LoadDosageFormIVRoutes(Dest: TStrings; OrderIDs: TStringList; Default: boolean);
|
---|
[456] | 41 | function QtyToDays(Quantity: Double; const UnitsPerDose, Schedule, Duration, Drug: string): Integer;
|
---|
| 42 | function DaysToQty(DaysSupply: Integer; const UnitsPerDose, Schedule, Duration, Drug: string): Integer;
|
---|
| 43 | function DurToQty(DaysSupply: Integer; const UnitStr, SchedStr: string): Integer;
|
---|
| 44 | function DefaultDays(const ADrug, UnitStr, SchedStr: string): Integer;
|
---|
| 45 | function CalcMaxRefills(const Drug: string; Days, OrdItem: Integer; Discharge: Boolean): Integer;
|
---|
| 46 | function ScheduleRequired(OrdItem: Integer; const ARoute, ADrug: string): Boolean;
|
---|
| 47 | function ODForMedsIn: TStrings;
|
---|
| 48 | function ODForMedsOut: TStrings;
|
---|
| 49 | function OIForMed(AnIEN: Integer; ForInpatient: Boolean; HavePI: boolean = True; PKIActive: Boolean = False): TStrings;
|
---|
| 50 | function GetPickupForLocation(const Loc: string): string;
|
---|
| 51 | function QOHasRouteDefined(AQOID: integer): boolean;
|
---|
| 52 | procedure CheckExistingPI(AOrderId: string; var APtI: string);
|
---|
[829] | 53 | function PassDrugTest(OI: integer; OrderType: string; InptOrder: boolean; CheckForClozapineOnly: boolean = false): boolean;
|
---|
| 54 | function AdminTimeHelpText(): string;
|
---|
| 55 | //function ValidateDaySupplyandQuantity(DaySupply, Quantity: integer): boolean;
|
---|
| 56 | //function ValidateMaxQuantity(Quantity: integer): boolean;
|
---|
| 57 | function ValidateDrugAutoAccept(tempDrug, tempUnit, tempSch, tempDur: string; OI, tempSupply, tempQuantity, tempRefills: integer): boolean;
|
---|
| 58 | function ValidateDaySupplyandQuantityErrorMsg(DaySupply, quantity: integer): String;
|
---|
| 59 | procedure ClearMaxData;
|
---|
| 60 | function DifferentOrderLocations(ID: string; Loc: integer): boolean;
|
---|
| 61 | function IsClozapineOrder: boolean;
|
---|
| 62 | //function ValidateQuantityErrorMsg(Quantity: integer): String;
|
---|
| 63 | function GetQOOrderableItem(DialogIEN: string): integer;
|
---|
[456] | 64 |
|
---|
[829] | 65 |
|
---|
[456] | 66 | implementation
|
---|
[829] | 67 | var
|
---|
| 68 | uAdminTimeHelpText: TAdminTimeHelpText;
|
---|
| 69 | uDrugHasMaxData: TDrugHasMaxData;
|
---|
| 70 | uInpatientClozapineText : TInpatientClozapineText;
|
---|
[456] | 71 |
|
---|
| 72 | function DEACheckFailed(AnOI: Integer; ForInpatient: Boolean): Boolean;
|
---|
| 73 | var
|
---|
| 74 | PtType: Char;
|
---|
| 75 | begin
|
---|
| 76 | if ForInpatient then PtType := 'I' else PtType := 'O';
|
---|
| 77 | Result := sCallV('ORWDPS1 FAILDEA', [AnOI, Encounter.Provider, PtType]) = '1';
|
---|
| 78 | end;
|
---|
| 79 |
|
---|
| 80 | function DEACheckFailedForIVOnOutPatient(AnOI: Integer; AnOIType: Char): boolean;
|
---|
| 81 | begin
|
---|
| 82 | Result := sCallV('ORWDPS1 IVDEA',[AnOI,AnOIType,Encounter.Provider]) = '1';
|
---|
| 83 | end;
|
---|
| 84 |
|
---|
| 85 | procedure ListForOrderable(var AListIEN, ACount: Integer; const DGrpNm: string);
|
---|
| 86 | begin
|
---|
| 87 | CallV('ORWUL FV4DG', [DGrpNm]);
|
---|
| 88 | AListIEN := StrToIntDef(Piece(RPCBrokerV.Results[0], U, 1), 0);
|
---|
| 89 | ACount := StrToIntDef(Piece(RPCBrokerV.Results[0], U, 2), 0);
|
---|
| 90 | end;
|
---|
| 91 |
|
---|
| 92 | procedure SubsetOfOrderable(Dest: TStringList; Append: Boolean; ListIEN, First, Last: Integer);
|
---|
| 93 | var
|
---|
| 94 | i: Integer;
|
---|
| 95 | begin
|
---|
| 96 | CallV('ORWUL FVSUB', [ListIEN, First+1, Last+1]); // M side not 0-based
|
---|
[829] | 97 | if Append then FastAddStrings(RPCBrokerV.Results, Dest) else
|
---|
[456] | 98 | begin
|
---|
| 99 | for i := Pred(RPCBrokerV.Results.Count) downto 0 do Dest.Insert(0, RPCBrokerV.Results[i]);
|
---|
| 100 | end;
|
---|
| 101 | end;
|
---|
| 102 |
|
---|
| 103 | function IndexOfOrderable(ListIEN: Integer; From: string): Integer;
|
---|
| 104 | var
|
---|
| 105 | x: string;
|
---|
| 106 | begin
|
---|
| 107 | Result := -1;
|
---|
| 108 | if From = '' then Exit;
|
---|
| 109 | // decrement last char & concat '~' for $ORDER on M side, limit string length
|
---|
| 110 | x := UpperCase(Copy(From, 1, 220));
|
---|
| 111 | x := Copy(x, 1, Length(x) - 1) + Pred(x[Length(x)]) + '~';
|
---|
| 112 | x := sCallV('ORWUL FVIDX', [ListIEN, x]);
|
---|
| 113 | // use Pred to make the index 0-based (first value = 1 on M side)
|
---|
| 114 | if CompareText(Copy(Piece(x, U, 2), 1, Length(From)), From) = 0
|
---|
| 115 | then Result := Pred(StrToIntDef(Piece(x, U, 1), 0));
|
---|
| 116 | end;
|
---|
| 117 |
|
---|
| 118 | procedure IsActivateOI(var AMsg: string; theOI: integer);
|
---|
| 119 | begin
|
---|
| 120 | AMsg := SCallV('ORWDXA ISACTOI', [theOI]);
|
---|
| 121 | end;
|
---|
| 122 |
|
---|
| 123 | procedure ListForQuickOrders(var AListIEN, ACount: Integer; const DGrpNm: string);
|
---|
| 124 | begin
|
---|
| 125 | CallV('ORWUL QV4DG', [DGrpNm]);
|
---|
| 126 | AListIEN := StrToIntDef(Piece(RPCBrokerV.Results[0], U, 1), 0);
|
---|
| 127 | ACount := StrToIntDef(Piece(RPCBrokerV.Results[0], U, 2), 0);
|
---|
| 128 | end;
|
---|
| 129 |
|
---|
| 130 | procedure SubsetOfQuickOrders(Dest: TStringList; AListIEN, First, Last: Integer);
|
---|
| 131 | var
|
---|
| 132 | i: Integer;
|
---|
| 133 | begin
|
---|
| 134 | CallV('ORWUL QVSUB', [AListIEN,'','']);
|
---|
| 135 | for i := 0 to RPCBrokerV.Results.Count -1 do
|
---|
| 136 | Dest.Add(RPCBrokerV.Results[i]);
|
---|
| 137 | end;
|
---|
| 138 |
|
---|
| 139 | function IndexOfQuickOrder(AListIEN: Integer; From: string): Integer;
|
---|
| 140 | var
|
---|
| 141 | x: string;
|
---|
| 142 | begin
|
---|
| 143 | Result := -1;
|
---|
| 144 | if From = '' then Exit;
|
---|
| 145 | // decrement last char & concat '~' for $ORDER on M side, limit string length
|
---|
| 146 | x := UpperCase(Copy(From, 1, 220));
|
---|
| 147 | x := Copy(x, 1, Length(x) - 1) + Pred(x[Length(x)]) + '~';
|
---|
| 148 | x := sCallV('ORWUL QVIDX', [AListIEN, x]);
|
---|
| 149 | // use Pred to made the index 0-based (first value = 1 on M side)
|
---|
| 150 | if CompareText(Copy(Piece(x, U, 2), 1, Length(From)), From) = 0
|
---|
| 151 | then Result := Pred(StrToIntDef(Piece(x, U, 1), 0));
|
---|
| 152 | end;
|
---|
| 153 |
|
---|
| 154 | procedure LoadFormularyAltOI(AList: TStringList; AnIEN: Integer; ForInpatient: Boolean);
|
---|
| 155 | var
|
---|
| 156 | PtType: Char;
|
---|
| 157 | begin
|
---|
| 158 | if ForInpatient then PtType := 'I' else PtType := 'O';
|
---|
| 159 | CallV('ORWDPS1 FORMALT', [AnIEN, PtType]);
|
---|
[829] | 160 | FastAssign(RPCBrokerV.Results, AList);
|
---|
[456] | 161 | end;
|
---|
| 162 |
|
---|
| 163 | procedure LoadFormularyAltDose(AList: TStringList; DispDrug, OI: Integer; ForInpatient: Boolean);
|
---|
| 164 | var
|
---|
| 165 | PtType: Char;
|
---|
| 166 | begin
|
---|
| 167 | if ForInpatient then PtType := 'I' else PtType := 'O';
|
---|
| 168 | CallV('ORWDPS1 DOSEALT', [DispDrug, OI, PtType]);
|
---|
[829] | 169 | FastAssign(RPCBrokerV.Results, AList);
|
---|
[456] | 170 | end;
|
---|
| 171 |
|
---|
| 172 | procedure LoadAdminInfo(const Schedule: string; OrdItem: Integer; var StartText: string;
|
---|
[829] | 173 | var AdminTime: TFMDateTime; var Duration: string; Admin: string = '');
|
---|
[456] | 174 | var
|
---|
| 175 | x: string;
|
---|
| 176 | begin
|
---|
[829] | 177 | x := sCallV('ORWDPS2 ADMIN', [Patient.DFN, Schedule, OrdItem, Encounter.Location, Admin]);
|
---|
[456] | 178 | StartText := Piece(x, U, 1);
|
---|
| 179 | AdminTime := MakeFMDateTime(Piece(x, U, 4));
|
---|
| 180 | Duration := Piece(x, U, 3);
|
---|
| 181 | end;
|
---|
| 182 |
|
---|
| 183 | function GetAdminTime(const StartText, Schedule: string; OrdItem: Integer): TFMDateTime;
|
---|
| 184 | var
|
---|
| 185 | x: string;
|
---|
| 186 | begin
|
---|
| 187 | x := sCallV('ORWDPS2 REQST', [Patient.DFN, Schedule, OrdItem, Encounter.Location, StartText]);
|
---|
| 188 | Result := MakeFMDateTime(x);
|
---|
| 189 | end;
|
---|
| 190 |
|
---|
| 191 | procedure LoadSchedules(Dest: TStrings; IsInptDlg: boolean);
|
---|
| 192 | begin
|
---|
| 193 | // if uMedSchedules = nil then CallV('ORWDPS ALLSCHD', [nil]); uMedSchedules.Assign(...);
|
---|
[829] | 194 | CallV('ORWDPS1 SCHALL', [patient.dfn, patient.location]);
|
---|
| 195 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 196 | If (Dest.IndexOfName('OTHER') < 0) and IsInptDlg then
|
---|
| 197 | Dest.Add('OTHER');
|
---|
| 198 | end;
|
---|
| 199 |
|
---|
[829] | 200 | procedure LoadAllIVRoutes(Dest: TStrings);
|
---|
| 201 | begin
|
---|
| 202 | CallV('ORWDPS32 ALLIVRTE', []);
|
---|
| 203 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
| 204 | end;
|
---|
| 205 |
|
---|
| 206 | procedure LoadDosageFormIVRoutes(Dest: TStrings; OrderIDs: TStringList; Default: boolean);
|
---|
| 207 | begin
|
---|
| 208 | CallV('ORWDPS33 IVDOSFRM', [OrderIDs, Default, False]);
|
---|
| 209 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
| 210 | end;
|
---|
| 211 | procedure LoadDOWSchedules(Dest: TStrings);
|
---|
| 212 | begin
|
---|
| 213 | // if uMedSchedules = nil then CallV('ORWDPS ALLSCHD', [nil]); uMedSchedules.Assign(...);
|
---|
| 214 | CallV('ORWDPS1 DOWSCH', [patient.dfn, patient.location]);
|
---|
| 215 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
| 216 | end;
|
---|
| 217 |
|
---|
[456] | 218 | function QtyToDays(Quantity: Double; const UnitsPerDose, Schedule, Duration, Drug: string): Integer;
|
---|
| 219 | begin
|
---|
| 220 | Result := StrToIntDef(sCallV('ORWDPS2 QTY2DAY',
|
---|
| 221 | [Quantity, UnitsPerDose, Schedule, Duration, Patient.DFN, Drug]), 0);
|
---|
| 222 | end;
|
---|
| 223 |
|
---|
| 224 | function DaysToQty(DaysSupply: Integer; const UnitsPerDose, Schedule, Duration, Drug: string): Integer;
|
---|
| 225 | begin
|
---|
| 226 | Result := StrToIntDef(sCallV('ORWDPS2 DAY2QTY',
|
---|
| 227 | [DaysSupply, UnitsPerDose, Schedule, Duration, Patient.DFN, Drug]), 0);
|
---|
[829] | 228 | if uDrugHasMaxData.CaptureMaxData = True then uDrugHasMaxData.MaxQuantity := Result;
|
---|
[456] | 229 | end;
|
---|
| 230 |
|
---|
| 231 | function DurToQty(DaysSupply: Integer; const UnitStr, SchedStr: string): Integer;
|
---|
| 232 | begin
|
---|
| 233 | Result := StrToIntDef(sCallV('ORWDPS2 DAY2QTY', [DaysSupply, UnitStr, SchedStr]), 0);
|
---|
| 234 | end;
|
---|
| 235 |
|
---|
| 236 | function DefaultDays(const ADrug, UnitStr, SchedStr: string): Integer;
|
---|
| 237 | begin
|
---|
| 238 | Result := StrToIntDef(sCallV('ORWDPS1 DFLTSPLY', [UnitStr, SchedStr, Patient.DFN, ADrug]), 0);
|
---|
[829] | 239 | if uDrugHasMaxData.CaptureMaxData = True then uDrugHasMaxData.MaxSupply := Result;
|
---|
[456] | 240 | end;
|
---|
| 241 |
|
---|
| 242 | function CalcMaxRefills(const Drug: string; Days, OrdItem: Integer; Discharge: Boolean): Integer;
|
---|
| 243 | begin
|
---|
| 244 | Result := StrToIntDef(sCallV('ORWDPS2 MAXREF', [Patient.DFN, Drug, Days, OrdItem, Discharge]), 0);
|
---|
[829] | 245 | if uDrugHasMaxData.CaptureMaxData = True then uDrugHasMaxData.MaxRefills := Result;
|
---|
[456] | 246 | end;
|
---|
| 247 |
|
---|
| 248 | function ScheduleRequired(OrdItem: Integer; const ARoute, ADrug: string): Boolean;
|
---|
| 249 | begin
|
---|
| 250 | Result := sCallV('ORWDPS2 SCHREQ', [OrdItem, ARoute, ADrug]) = '1';
|
---|
| 251 | end;
|
---|
| 252 |
|
---|
| 253 | function ODForMedsIn: TStrings;
|
---|
| 254 | { Returns init values for inpatient meds dialog. The results must be used immediately. }
|
---|
| 255 | begin
|
---|
| 256 | CallV('ORWDPS1 ODSLCT', [PST_UNIT_DOSE, Patient.DFN, Encounter.Location]);
|
---|
| 257 | Result := RPCBrokerV.Results;
|
---|
| 258 | end;
|
---|
| 259 |
|
---|
| 260 | function ODForMedsOut: TStrings;
|
---|
| 261 | { Returns init values for outpatient meds dialog. The results must be used immediately. }
|
---|
| 262 | begin
|
---|
| 263 | CallV('ORWDPS1 ODSLCT', [PST_OUTPATIENT, Patient.DFN, Encounter.Location]);
|
---|
| 264 | Result := RPCBrokerV.Results;
|
---|
| 265 | end;
|
---|
| 266 |
|
---|
| 267 | function OIForMed(AnIEN: Integer; ForInpatient: Boolean; HavePI: Boolean; PKIActive: Boolean): TStrings;
|
---|
| 268 | var
|
---|
| 269 | PtType: Char;
|
---|
| 270 | NeedPI: Char;
|
---|
| 271 | IsPKIActive: Char;
|
---|
| 272 | begin
|
---|
| 273 | if HavePI then NeedPI := 'Y' else NeedPI := 'N';
|
---|
| 274 | if ForInpatient then PtType := 'U' else PtType := 'O';
|
---|
| 275 | if PKIActive then IsPKIActive := 'Y' else IsPKIActive := 'N';
|
---|
| 276 | CallV('ORWDPS2 OISLCT', [AnIEN, PtType, Patient.DFN, NeedPI, IsPKIActive]);
|
---|
| 277 | Result := RPCBrokerV.Results;
|
---|
| 278 | end;
|
---|
| 279 |
|
---|
| 280 | function GetPickupForLocation(const Loc: string): string;
|
---|
| 281 | begin
|
---|
| 282 | Result := sCallV('ORWDPS1 LOCPICK',[Loc]);
|
---|
| 283 | end;
|
---|
| 284 |
|
---|
| 285 | function QOHasRouteDefined(AQOID: integer): boolean;
|
---|
| 286 | begin
|
---|
| 287 | Result := False;
|
---|
| 288 | if ( sCallV('ORWDPS1 HASROUTE',[AQOID])='1' ) then
|
---|
| 289 | Result := True;
|
---|
| 290 | end;
|
---|
| 291 |
|
---|
| 292 | procedure CheckExistingPI(AOrderId: string; var APtI: string);
|
---|
| 293 | begin
|
---|
| 294 | APtI := sCallV('ORWDPS2 CHKPI', [AOrderId]);
|
---|
| 295 | end;
|
---|
| 296 |
|
---|
[829] | 297 | function PassDrugTest(OI: integer; OrderType: string; InptOrder: boolean; CheckForClozapineOnly: boolean = false): boolean;
|
---|
| 298 | var
|
---|
| 299 | MessCap, MessText: string;
|
---|
| 300 | i: integer;
|
---|
| 301 | begin
|
---|
| 302 | result := false;
|
---|
| 303 | MessText := '';
|
---|
| 304 | uDrugHasMaxData.CaptureMaxData := false;
|
---|
| 305 | uDrugHasMaxData.MaxSupply := 0;
|
---|
| 306 | uDrugHasMaxData.MaxQuantity := 0;
|
---|
| 307 | uDrugHasMaxData.MaxRefills := 0;
|
---|
| 308 | CallV('ORALWORD ALLWORD', [Patient.DFN, OI, OrderType, Encounter.Provider]);
|
---|
| 309 | for i := 0 to RPCBrokerV.Results.Count -1 do
|
---|
| 310 | begin
|
---|
| 311 | if i = 0 then
|
---|
| 312 | begin
|
---|
| 313 | MessCap := Piece(RPCBrokerV.Results.strings[i],U,1);
|
---|
| 314 | if Piece(RPCBrokerV.Results.strings[i],U,2) = '1' then uDrugHasMaxData.CaptureMaxData := True;
|
---|
| 315 | end;
|
---|
| 316 | if i >0 then MessText := MessText + RPCBrokerV.Results.Strings[i] + CRLF;
|
---|
| 317 | end;
|
---|
| 318 | if CheckForClozapineOnly = True then
|
---|
| 319 | begin
|
---|
| 320 | Result := uDrugHasMaxData.CaptureMaxData = True;
|
---|
| 321 | Exit;
|
---|
| 322 | end;
|
---|
| 323 | if (MessText = '') and (MessCap = '') then
|
---|
| 324 | begin
|
---|
| 325 | Result := True;
|
---|
| 326 | if (InptOrder = true) and (uDrugHasMaxData.CaptureMaxData = true) then
|
---|
| 327 | begin
|
---|
| 328 | uDrugHasMaxData.CaptureMaxData := false;
|
---|
| 329 | if uInpatientClozapineText.dispText = '' then
|
---|
| 330 | begin
|
---|
| 331 | CallV('ORDDPAPI CLOZMSG', []);
|
---|
| 332 | for i := 0 to RPCBrokerV.Results.Count -1 do
|
---|
| 333 | if i = 0 then uInpatientClozapineText.dispText := RPCBrokerV.Results.Strings[i]
|
---|
| 334 | else uInpatientClozapineText.dispText := uInpatientClozapineText.dispText + CRLF + RPCBrokerV.Results.Strings[i];
|
---|
| 335 | end;
|
---|
| 336 | if uInpatientClozapineText.dispText <> '' then infoBox(uInpatientClozapineText.dispText, 'Inpatient Drug Warning', MB_OK);
|
---|
| 337 | end;
|
---|
| 338 | exit;
|
---|
| 339 | end;
|
---|
| 340 | infoBox(MessText, MessCap,MB_OK);
|
---|
| 341 | end;
|
---|
| 342 |
|
---|
| 343 | function AdminTimeHelpText(): string;
|
---|
| 344 | var
|
---|
| 345 | i: integer;
|
---|
| 346 | begin
|
---|
| 347 | if uAdminTimeHelpText.HelpText = '' then
|
---|
| 348 | begin
|
---|
| 349 | CallV('ORDDPAPI ADMTIME',[]);
|
---|
| 350 | for I := 0 to RPCBrokerV.Results.Count - 1 do
|
---|
| 351 | if I = 0 then uAdminTimeHelpText.HelpText := RPCBrokerV.Results.Strings[i]
|
---|
| 352 | else uAdminTimeHelpText.HelpText := uAdminTimeHelpText.HelpText + CRLF +RPCBrokerV.Results.Strings[i];
|
---|
| 353 | end;
|
---|
| 354 | Result := uAdminTimeHelpText.helpText
|
---|
| 355 | end;
|
---|
| 356 |
|
---|
| 357 | function ValidateDrugAutoAccept(tempDrug, tempUnit, tempSch, tempDur: string; OI, tempSupply, tempQuantity, tempRefills: integer): boolean;
|
---|
| 358 | var
|
---|
| 359 | daySupply, Quantity, Refills: integer;
|
---|
| 360 | begin
|
---|
| 361 | Result := True;
|
---|
| 362 | if uDrugHasMaxData.CaptureMaxData = false then exit;
|
---|
| 363 | daySupply := DefaultDays(tempDrug, tempUnit, tempSch);
|
---|
| 364 | if (tempSupply > daySupply) and (uDrugHasMaxData.MaxSupply > 0) then
|
---|
| 365 | begin
|
---|
| 366 | infoBox('For this medication Day Supply cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxSupply), 'Cannot Save Error', MB_OK);
|
---|
| 367 | Result := false;
|
---|
| 368 | uDrugHasMaxData.CaptureMaxData := false;
|
---|
| 369 | Exit;
|
---|
| 370 | end;
|
---|
| 371 | Quantity := DaysToQty(daySupply, tempUnit, tempSch, tempDur, tempDrug);
|
---|
| 372 | if (tempQuantity > Quantity) and (uDrugHasMaxData.MaxQuantity > 0) then
|
---|
| 373 | begin
|
---|
| 374 | infoBox('For this medication Quantity cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxQuantity), 'Cannot Save Error', MB_OK);
|
---|
| 375 | Result := false;
|
---|
| 376 | uDrugHasMaxData.CaptureMaxData := false;
|
---|
| 377 | Exit;
|
---|
| 378 | end;
|
---|
| 379 | Refills := CalcMaxRefills(tempDrug, daySupply, OI, false);
|
---|
| 380 | if tempRefills > Refills then
|
---|
| 381 | begin
|
---|
| 382 | infoBox('For this medication Quantity cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxRefills), 'Cannot Save Error', MB_OK);
|
---|
| 383 | Result := false;
|
---|
| 384 | uDrugHasMaxData.CaptureMaxData := false;
|
---|
| 385 | Exit;
|
---|
| 386 | end;
|
---|
| 387 | end;
|
---|
| 388 |
|
---|
| 389 | function ValidateDaySupplyandQuantity(DaySupply, Quantity: integer): boolean;
|
---|
| 390 | var
|
---|
| 391 | str: string;
|
---|
| 392 | begin
|
---|
| 393 | Result := True;
|
---|
| 394 | str := '';
|
---|
| 395 | if uDrugHasMaxData.CaptureMaxData = false then exit;
|
---|
| 396 | if (daySupply > uDrugHasMaxData.MaxSupply) and (uDrugHasMaxData.MaxSupply > 0) then
|
---|
| 397 | begin
|
---|
| 398 | str := 'For this medication Day Supply cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxSupply);
|
---|
| 399 | Result := false;
|
---|
| 400 | end;
|
---|
| 401 | if (Quantity > uDrugHasMaxData.MaxQuantity) and (uDrugHasMaxData.MaxQuantity > 0) then
|
---|
| 402 | begin
|
---|
| 403 | if str <> '' then str := str + CRLF + 'For this medication Day Supply cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxQuantity)
|
---|
| 404 | else str := 'For this medication Day Supply cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxQuantity);
|
---|
| 405 | result := false;
|
---|
| 406 | end;
|
---|
| 407 | if str <> '' then infoBox(str, 'Cannot Save Error', MB_OK);
|
---|
| 408 | //uDrugHasMaxData.CaptureMaxData := false;
|
---|
| 409 | end;
|
---|
| 410 |
|
---|
| 411 | function ValidateMaxQuantity(Quantity: integer): boolean;
|
---|
| 412 | begin
|
---|
| 413 | Result := True;
|
---|
| 414 | if uDrugHasMaxData.CaptureMaxData = false then exit;
|
---|
| 415 | if uDrugHasMaxData.MaxQuantity = 0 then exit;
|
---|
| 416 | if Quantity > uDrugHasMaxData.MaxQuantity then
|
---|
| 417 | begin
|
---|
| 418 | infoBox('For this medication Day Supply cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxQuantity), 'Cannot Save Error', MB_OK);
|
---|
| 419 | Result := false;
|
---|
| 420 | end;
|
---|
| 421 | end;
|
---|
| 422 |
|
---|
| 423 | function ValidateDaySupplyandQuantityErrorMsg(DaySupply, quantity: integer): String;
|
---|
| 424 | begin
|
---|
| 425 | Result := '';
|
---|
| 426 | if uDrugHasMaxData.CaptureMaxData = false then exit;
|
---|
| 427 | if (daySupply > uDrugHasMaxData.MaxSupply) and (uDrugHasMaxData.MaxSupply > 0) then
|
---|
| 428 | begin
|
---|
| 429 | Result := 'For this medication Day Supply cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxSupply);
|
---|
| 430 | end;
|
---|
| 431 | if (Quantity > uDrugHasMaxData.MaxQuantity) and (uDrugHasMaxData.MaxQuantity > 0) then
|
---|
| 432 | begin
|
---|
| 433 | if Result <> '' then Result := Result + CRLF + 'For this medication Quantity cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxQuantity)
|
---|
| 434 | else Result := 'For this medication Quantity cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxQuantity);
|
---|
| 435 | end;
|
---|
| 436 | //uDrugHasMaxData.CaptureMaxData := false;
|
---|
| 437 | end;
|
---|
| 438 |
|
---|
| 439 | function ValidateQuantityErrorMsg(Quantity: integer): String;
|
---|
| 440 | begin
|
---|
| 441 | Result := '';
|
---|
| 442 | if uDrugHasMaxData.CaptureMaxData = false then exit;
|
---|
| 443 | if uDrugHasMaxData.MaxQuantity = 0 then exit;
|
---|
| 444 | if Quantity > uDrugHasMaxData.MaxQuantity then
|
---|
| 445 | begin
|
---|
| 446 | Result := 'For this medication Quantity cannot be greater then ' + InttoStr(uDrugHasMaxData.MaxQuantity);
|
---|
| 447 | end;
|
---|
| 448 | end;
|
---|
| 449 |
|
---|
| 450 | procedure ClearMaxData;
|
---|
| 451 | begin
|
---|
| 452 | uDrugHasMaxData.CaptureMaxData := false;
|
---|
| 453 | end;
|
---|
| 454 |
|
---|
| 455 | function DifferentOrderLocations(ID: string; Loc: integer): boolean;
|
---|
| 456 | begin
|
---|
| 457 | Result := (sCallV('ORWDPS33 COMPLOC', [ID, Loc])='1');
|
---|
| 458 | end;
|
---|
| 459 |
|
---|
| 460 | function IsClozapineOrder: boolean;
|
---|
| 461 | begin
|
---|
| 462 | if uDrugHasMaxData.CaptureMaxData = true then result := true
|
---|
| 463 | else result := false;
|
---|
| 464 | end;
|
---|
| 465 |
|
---|
| 466 | function GetQOOrderableItem(DialogIEN: string): integer;
|
---|
| 467 | begin
|
---|
| 468 | Result := StrtoInt(SCallV('ORWDPS1 QOMEDALT',[DialogIEN]))
|
---|
| 469 | end;
|
---|
| 470 |
|
---|
[456] | 471 | end.
|
---|