Module

rODMeds

Path

C:\CPRS\CPRS30\Orders\rODMeds.pas

Last Modified

7/15/2014 3:26:42 PM

Units Used in Interface

Name Comments
uConst -
uCore -

Procedures

Name Owner Declaration Scope Comments
CheckExistingPI - procedure CheckExistingPI(AOrderId: string; var APtI: string); Interfaced -
ClearMaxData - procedure ClearMaxData; Interfaced -
IsActivateOI - procedure IsActivateOI(var AMsg: string; theOI: integer); Interfaced -
ListForOrderable - procedure ListForOrderable(var AListIEN, ACount: Integer; const DGrpNm: string); Interfaced -
ListForQuickOrders - procedure ListForQuickOrders(var AListIEN, ACount: Integer; const DGrpNm: string); Interfaced -
LoadAdminInfo - procedure LoadAdminInfo(const Schedule: string; OrdItem: Integer; var StartText: string; var AdminTime: TFMDateTime; var Duration: string; Admin: string = ''); Interfaced -
LoadAllIVRoutes - procedure LoadAllIVRoutes(Dest: TStrings); Interfaced -
LoadDosageFormIVRoutes - procedure LoadDosageFormIVRoutes(Dest: TStrings; OrderIDs: TStringList); Interfaced -
LoadDOWSchedules - procedure LoadDOWSchedules(Dest: TStrings); Interfaced -
LoadFormularyAltDose - procedure LoadFormularyAltDose(AList: TStringList; DispDrug, OI: Integer; ForInpatient: Boolean); Interfaced -
LoadFormularyAltOI - procedure LoadFormularyAltOI(AList: TStringList; AnIEN: Integer; ForInpatient: Boolean); Interfaced -
LoadSchedules - procedure LoadSchedules(Dest: TStrings; IsInptDlg: boolean = False); Interfaced -
SubsetOfOrderable - procedure SubsetOfOrderable(Dest: TStringList; Append: Boolean; ListIEN, First, Last: Integer); Interfaced -
SubsetOfQuickOrders - procedure SubsetOfQuickOrders(Dest: TStringList; AListIEN, First, Last: Integer); Interfaced -

Functions

Name Owner Declaration Scope Comments
AdminTimeHelpText - function AdminTimeHelpText(): string; Interfaced
Function ValidateDaySupplyandQuantity(DaySupply, Quantity: integer): boolean;
function ValidateMaxQuantity(Quantity: integer): boolean;
function ValidateQuantityErrorMsg(Quantity: integer): String;
 decrement last char & concat '~' for $ORDER on M side, limit string length
 use Pred to make the index 0-based (first value = 1 on M side)
 decrement last char & concat '~' for $ORDER on M side, limit string length
 use Pred to made the index 0-based (first value = 1 on M side)
 if uMedSchedules = nil then CallV('ORWDPS ALLSCHD', [nil]); uMedSchedules.Assign(...);
 if uMedSchedules = nil then CallV('ORWDPS ALLSCHD', [nil]); uMedSchedules.Assign(...);
 Returns init values for inpatient meds dialog.  The results must be used immediately. 
 Returns init values for outpatient meds dialog.  The results must be used immediately.
CalcMaxRefills - function CalcMaxRefills(const Drug: string; Days, OrdItem: Integer; Discharge: Boolean): Integer; Interfaced -
DaysToQty - function DaysToQty(DaysSupply: Integer; const UnitsPerDose, Schedule, Duration, Drug: string): Integer; Interfaced -
DEACheckFailed - function DEACheckFailed(AnOI: Integer; ForInpatient: Boolean): string; Interfaced -
DEACheckFailedAtSignature - function DEACheckFailedAtSignature(AnOI: Integer; ForInpatient: Boolean): string; Interfaced -
DEACheckFailedForIVOnOutPatient - function DEACheckFailedForIVOnOutPatient(AnOI: Integer; AnOIType: Char): string; Interfaced -
DefaultDays - function DefaultDays(const ADrug, UnitStr, SchedStr: string; OI : Integer): Integer; Interfaced -
DifferentOrderLocations - function DifferentOrderLocations(ID: string; Loc: integer): boolean; Interfaced -
DurToQty - function DurToQty(DaysSupply: Integer; const UnitStr, SchedStr: string): Integer; Interfaced -
GetAdminTime - function GetAdminTime(const StartText, Schedule: string; OrdItem: Integer): TFMDateTime; Interfaced -
GetDefaultAddFreq - function GetDefaultAddFreq(OID: integer): string; Interfaced -
GetPickupForLocation - function GetPickupForLocation(const Loc: string): string; Interfaced -
GetQOOrderableItem - function GetQOOrderableItem(DialogIEN: string): integer; Interfaced Function ValidateQuantityErrorMsg(Quantity: integer): String;
IndexOfOrderable - function IndexOfOrderable(ListIEN: Integer; From: string): Integer; Interfaced -
IndexOfQuickOrder - function IndexOfQuickOrder(AListIEN: Integer; From: string): Integer; Interfaced -
IsClozapineOrder - function IsClozapineOrder: boolean; Interfaced -
ODForMedsIn - function ODForMedsIn: TStrings; Interfaced Returns init values for inpatient meds dialog. The results must be used immediately.
ODForMedsOut - function ODForMedsOut: TStrings; Interfaced Returns init values for outpatient meds dialog. The results must be used immediately.
OIForMed - function OIForMed(AnIEN: Integer; ForInpatient: Boolean; HavePI: boolean = True; PKIActive: Boolean = False): TStrings; Interfaced -
PassDrugTest - function PassDrugTest(OI: integer; OrderType: string; InptOrder: boolean; CheckForClozapineOnly: boolean = false): boolean; Interfaced -
QOHasRouteDefined - function QOHasRouteDefined(AQOID: integer): boolean; Interfaced -
QtyToDays - function QtyToDays(Quantity: Double; const UnitsPerDose, Schedule, Duration, Drug: string): Integer; Interfaced -
ScheduleRequired - function ScheduleRequired(OrdItem: Integer; const ARoute, ADrug: string): Boolean; Interfaced -
ValidateDaySupplyandQuantity - function ValidateDaySupplyandQuantity(DaySupply, Quantity: integer): boolean; Global -
ValidateDaySupplyandQuantityErrorMsg - function ValidateDaySupplyandQuantityErrorMsg(DaySupply, quantity: integer): String; Interfaced -
ValidateDrugAutoAccept - function ValidateDrugAutoAccept(tempDrug, tempUnit, tempSch, tempDur: string; OI, tempSupply, tempRefills: integer; tempQuantity: Double): boolean; Interfaced
Function ValidateDaySupplyandQuantity(DaySupply, Quantity: integer): boolean;
function ValidateMaxQuantity(Quantity: integer): boolean;
ValidateMaxQuantity - function ValidateMaxQuantity(Quantity: integer): boolean; Global -
ValidateQuantityErrorMsg - function ValidateQuantityErrorMsg(Quantity: integer): String; Global -

Global Variables

Name Type Declaration Comments
uAdminTimeHelpText uAdminTimeHelpText: TAdminTimeHelpText; -
uDrugHasMaxData uDrugHasMaxData: TDrugHasMaxData; -
uInpatientClozapineText uInpatientClozapineText : TInpatientClozapineText; -


Module Source

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

Module Calls (2 levels)


rODMeds
 ├uCore
 │ ├rCore
 │ ├uConst
 │ ├uCombatVet
 │ ├rTIU
 │ ├rOrders
 │ ├rConsults
 │ └uOrders
 └uConst

Module Called-By (2 levels)


                      rODMeds
                    uOrders┤ 
                    uCore┤ │ 
                  fODBase┤ │ 
                  rODBase┤ │ 
                   fFrame┤ │ 
                  fOrders┤ │ 
              fOrdersSign┤ │ 
                    fMeds┤ │ 
                fARTAllgy┤ │ 
                   fNotes┤ │ 
                fConsults┤ │ 
          fReminderDialog┤ │ 
                  fReview┤ │ 
             fOrdersRenew┤ │ 
                fOrdersCV┤ │ 
                  fODMeds┤ │ 
                  fOMNavA┤ │ 
          fOrderSaveQuick┤ │ 
                   fOMSet┤ │ 
           fOrdersRelease┤ │ 
                  fOMHTML┤ │ 
                fODMedNVA┤ │ 
 fODChangeUnreleasedRenew┤ │ 
           fOrdersOnChart┤ │ 
          fODReleaseEvent┤ │ 
                fODActive┘ │ 
                 fODMedOIFA┤ 
               fODMeds...┤ │ 
             fODMedNVA...┘ │ 
                 fOrders...┤ 
             fOrdersSign...┤ 
                 fReview...┤ 
            fOrdersRenew...┤ 
             fOtherSchedule┤ 
                fFrame...┤ │ 
               fODMeds...┤ │ 
                 fODMedIV┘ │ 
                  fIVRoutes┤ 
                fFrame...┤ │ 
              fODMedIV...┘ │ 
                 fODMeds...┤ 
                fODMedIV...┤ 
                    fODAuto┤ 
               uOrders...┘ │ 
                  fOMSet...┤ 
               fODMedNVA...┤ 
fODChangeUnreleasedRenew...┤ 
               fRenewOutMed┘ 
          fOrdersRenew...┘