source: cprs/trunk/CPRS-Chart/Orders/rODDiet.pas@ 1787

Last change on this file since 1787 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

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