source: cprs/branches/tmg-cprs/CPRS-Chart/Orders/rODDiet.pas@ 1717

Last change on this file since 1717 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

File size: 6.2 KB
Line 
1//kt -- Modified with SourceScanner on 8/8/2007
2unit rODDiet;
3
4interface
5
6uses SysUtils, Windows, Classes, ORNet, ORFn, uCore, uConst, rOrders;
7
8type
9 TOutpatientPatchInstalled = record
10 PatchInstalled: boolean;
11 PatchChecked: boolean;
12 end;
13
14 TUserHasFHAUTHKey = record
15 UserHasKey: boolean;
16 KeyChecked: boolean;
17 end;
18
19 TDietParams = record
20 Tray: Boolean;
21 Cafeteria: Boolean;
22 DiningRm: Boolean;
23 Bagged: Boolean;
24 RegIEN: Integer;
25 NPOIEN: Integer;
26 EarlyIEN: string;
27 LateIEN: string;
28 CurTF: string;
29 BTimes: string;
30 NTimes: string;
31 ETimes: string;
32 Alarms: string;
33 OPMaxDays: integer;
34 OPDefaultDiet: integer;
35 end;
36
37function CurrentDietText: string;
38function DietAttributes(OI: Integer): string;
39function ExpandedQuantity(Product, Strength: Integer; const Qty: string): string;
40procedure LoadDietParams(var DietParams: TDietParams; ALocation: string);
41procedure AppendTFProducts(Dest: TStrings);
42function SubSetOfDiets(const StartFrom: string; Direction: Integer): TStrings;
43function SubSetOfOPDiets: TStrings;
44procedure OrderLateTray(NewOrder: TOrder; Meal: Char; const MealTime: string; Bagged: Boolean);
45function IsolationID: string;
46function CurrentIsolation: string;
47procedure LoadIsolations(Dest: TStrings);
48procedure LoadDietQuickList(Dest: TStrings; const GroupID: string);
49function DietDialogType(GroupIEN: Integer): Char;
50function OutpatientPatchInstalled: boolean;
51function UserHasFHAUTHKey: boolean;
52procedure GetCurrentRecurringOPMeals(Dest: TStrings; MealType: string = '');
53function OutpatientLocationConfigured(ALocation: string): boolean;
54
55
56implementation
57
58uses TRPCB, rMisc, rCore;
59
60var
61 uOutpatientPatchInstalled: TOutpatientPatchInstalled;
62 uUserHasFHAUTHKey: TUserHasFHAUTHKey;
63
64function DietAttributes(OI: Integer): string;
65begin
66 CallV('ORWDFH ATTR', [OI]);
67 Result := RPCBrokerV.Results[0];
68end;
69
70procedure LoadDietParams(var DietParams: TDietParams; ALocation: string);
71begin
72 CallV('ORWDFH PARAM', [Patient.DFN, ALocation]);
73 with RPCBrokerV, DietParams do
74 begin
75 if Results.Count > 0 then
76 begin
77 BTimes := Pieces(Results[0], U, 1, 6);
78 NTimes := Pieces(Results[0], U, 7, 12);
79 ETimes := Pieces(Results[0], U, 13, 18);
80 end;
81 if Results.Count > 1 then
82 begin
83 Alarms := Pieces(Results[1], U, 1, 6);
84 Bagged := Piece(Results[1], U, 10) = 'Y';
85 end;
86 if Results.Count > 2 then
87 begin
88 Tray := Pos('T', Results[2]) > 0;
89 Cafeteria := Pos('C', Results[2]) > 0;
90 DiningRm := Pos('D', Results[2]) > 0;
91 RegIEN := StrToIntDef(Piece(Results[2], U, 2), 0);
92 NPOIEN := StrToIntDef(Piece(Results[2], U, 3), 0);
93 EarlyIEN := Piece(Results[2], U, 4);
94 LateIEN := Piece(Results[2], U, 5);
95 CurTF := Piece(Results[2], U, 6);
96 end;
97 if (not Tray) and (not Cafeteria) and (not DiningRm) then Tray := True;
98 if Results.Count > 3 then
99 OPMaxDays := StrToIntDef(Results[3], 30)
100 else
101 OPMaxDays := 30;
102 if Results.Count > 4 then
103 OPDefaultDiet := StrToIntDef(Results[4], 0)
104 end;
105end;
106
107function CurrentDietText: string;
108begin
109 CallV('ORWDFH TXT', [Patient.DFN]);
110 Result := RPCBrokerV.Results.Text;
111end;
112
113function CurrentTFText(const IENStr: string): string;
114begin
115end;
116
117procedure AppendTFProducts(Dest: TStrings);
118begin
119 CallV('ORWDFH TFPROD', [nil]);
120 Dest.AddStrings(RPCBrokerV.Results);
121end;
122
123function ExpandedQuantity(Product, Strength: Integer; const Qty: string): string;
124begin
125 Result := '';
126 if (Product = 0) or (Strength = 0) or (Length(Qty) = 0) then Exit;
127 Result := sCallV('ORWDFH QTY2CC', [Product, Strength, Qty]);
128end;
129
130function SubSetOfDiets(const StartFrom: string; Direction: Integer): TStrings;
131{ returns a pointer to a list of orderable items matching an S.xxx cross reference (for use in
132 a long list box) - The return value is a pointer to RPCBrokerV.Results, so the data must
133 be used BEFORE the next broker call! }
134begin
135 CallV('ORWDFH DIETS', [StartFrom, Direction]);
136 Result := RPCBrokerV.Results;
137end;
138
139function SubSetOfOPDiets: TStrings;
140begin
141 CallV('ORWDFH OPDIETS', [nil]);
142 Result := RPCBrokerV.Results;
143end;
144
145procedure OrderLateTray(NewOrder: TOrder; Meal: Char; const MealTime: string; Bagged: Boolean);
146begin
147 CallV('ORWDFH ADDLATE', [Patient.DFN, Encounter.Provider, Encounter.Location, Meal, MealTime, Bagged]);
148 SetOrderFromResults(NewOrder);
149end;
150
151function IsolationID: string;
152begin
153 Result := sCallV('ORWDFH ISOIEN', [nil]);
154end;
155
156function CurrentIsolation: string;
157begin
158 Result := sCallV('ORWDFH CURISO', [Patient.DFN]);
159end;
160
161procedure LoadIsolations(Dest: TStrings);
162begin
163 CallV('ORWDFH ISOLIST', [nil]);
164 Dest.Assign(RPCBrokerV.Results);
165end;
166
167procedure LoadDietQuickList(Dest: TStrings; const GroupID: string);
168begin
169 CallV('ORWDXQ GETQLST', [GroupID, 'Q']);
170 Dest.Assign(RPCBrokerV.Results);
171end;
172
173function DietDialogType(GroupIEN: Integer): Char;
174begin
175 Result := CharAt(sCallV('ORWDFH FINDTYP', [GroupIEN]), 1);
176 if not (Result in ['A', 'D', 'E', 'N', 'P', 'T', 'M']) then Result := 'D';
177end;
178
179function OutpatientPatchInstalled: boolean;
180begin
181 with uOutpatientPatchInstalled do
182 if not PatchChecked then
183 begin
184 //PatchInstalled := True;
185 { TODO -oRich V. -cOutpatient Meals : Uncomment when available }
186 PatchInstalled := (PackageVersion('FH') >= '5.5');
187 PatchChecked := True;
188 end;
189 Result := uOutpatientPatchInstalled.PatchInstalled;
190end;
191
192function UserHasFHAUTHKey: boolean;
193begin
194 with uUserHasFHAUTHKey do
195 if not KeyChecked then
196 begin
197 UserHasKey := HasSecurityKey('FHAUTH');
198 KeyChecked := True;
199 end;
200 Result := uUserHasFHAUTHKey.UserHasKey;
201end;
202
203procedure GetCurrentRecurringOPMeals(Dest: TStrings; MealType: string = '');
204begin
205 CallV('ORWDFH CURRENT MEALS', [Patient.DFN, MealType]);
206 Dest.Assign(RPCBrokerV.Results);
207 MixedCaseList(Dest);
208end;
209
210function OutpatientLocationConfigured(ALocation: string): boolean;
211begin
212 Result := (sCallV('ORWDFH NFSLOC READY', [ALocation]) = '1');
213end;
214
215end.
Note: See TracBrowser for help on using the repository browser.