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