source: cprs/branches/foia-cprs/CPRS-Chart/Orders/rODDiet.pas@ 459

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

Adding foia-cprs branch

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