[456] | 1 | unit rODDiet;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses SysUtils, Windows, Classes, ORNet, ORFn, uCore, uConst, rOrders;
|
---|
| 6 |
|
---|
| 7 | type
|
---|
| 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 |
|
---|
| 36 | function CurrentDietText: string;
|
---|
| 37 | function DietAttributes(OI: Integer): string;
|
---|
| 38 | function ExpandedQuantity(Product, Strength: Integer; const Qty: string): string;
|
---|
| 39 | procedure LoadDietParams(var DietParams: TDietParams; ALocation: string);
|
---|
| 40 | procedure AppendTFProducts(Dest: TStrings);
|
---|
| 41 | function SubSetOfDiets(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 42 | function SubSetOfOPDiets: TStrings;
|
---|
| 43 | procedure OrderLateTray(NewOrder: TOrder; Meal: Char; const MealTime: string; Bagged: Boolean);
|
---|
| 44 | function IsolationID: string;
|
---|
| 45 | function CurrentIsolation: string;
|
---|
| 46 | procedure LoadIsolations(Dest: TStrings);
|
---|
| 47 | procedure LoadDietQuickList(Dest: TStrings; const GroupID: string);
|
---|
| 48 | function DietDialogType(GroupIEN: Integer): Char;
|
---|
| 49 | function OutpatientPatchInstalled: boolean;
|
---|
| 50 | function UserHasFHAUTHKey: boolean;
|
---|
| 51 | procedure GetCurrentRecurringOPMeals(Dest: TStrings; MealType: string = '');
|
---|
| 52 | function OutpatientLocationConfigured(ALocation: string): boolean;
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | implementation
|
---|
| 56 |
|
---|
| 57 | uses TRPCB, rMisc, rCore;
|
---|
| 58 |
|
---|
| 59 | var
|
---|
| 60 | uOutpatientPatchInstalled: TOutpatientPatchInstalled;
|
---|
| 61 | uUserHasFHAUTHKey: TUserHasFHAUTHKey;
|
---|
| 62 |
|
---|
| 63 | function DietAttributes(OI: Integer): string;
|
---|
| 64 | begin
|
---|
| 65 | CallV('ORWDFH ATTR', [OI]);
|
---|
| 66 | Result := RPCBrokerV.Results[0];
|
---|
| 67 | end;
|
---|
| 68 |
|
---|
| 69 | procedure LoadDietParams(var DietParams: TDietParams; ALocation: string);
|
---|
| 70 | begin
|
---|
| 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;
|
---|
| 104 | end;
|
---|
| 105 |
|
---|
| 106 | function CurrentDietText: string;
|
---|
| 107 | begin
|
---|
| 108 | CallV('ORWDFH TXT', [Patient.DFN]);
|
---|
| 109 | Result := RPCBrokerV.Results.Text;
|
---|
| 110 | end;
|
---|
| 111 |
|
---|
| 112 | function CurrentTFText(const IENStr: string): string;
|
---|
| 113 | begin
|
---|
| 114 | end;
|
---|
| 115 |
|
---|
| 116 | procedure AppendTFProducts(Dest: TStrings);
|
---|
| 117 | begin
|
---|
| 118 | CallV('ORWDFH TFPROD', [nil]);
|
---|
| 119 | Dest.AddStrings(RPCBrokerV.Results);
|
---|
| 120 | end;
|
---|
| 121 |
|
---|
| 122 | function ExpandedQuantity(Product, Strength: Integer; const Qty: string): string;
|
---|
| 123 | begin
|
---|
| 124 | Result := '';
|
---|
| 125 | if (Product = 0) or (Strength = 0) or (Length(Qty) = 0) then Exit;
|
---|
| 126 | Result := sCallV('ORWDFH QTY2CC', [Product, Strength, Qty]);
|
---|
| 127 | end;
|
---|
| 128 |
|
---|
| 129 | function 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! }
|
---|
| 133 | begin
|
---|
| 134 | CallV('ORWDFH DIETS', [StartFrom, Direction]);
|
---|
| 135 | Result := RPCBrokerV.Results;
|
---|
| 136 | end;
|
---|
| 137 |
|
---|
| 138 | function SubSetOfOPDiets: TStrings;
|
---|
| 139 | begin
|
---|
| 140 | CallV('ORWDFH OPDIETS', [nil]);
|
---|
| 141 | Result := RPCBrokerV.Results;
|
---|
| 142 | end;
|
---|
| 143 |
|
---|
| 144 | procedure OrderLateTray(NewOrder: TOrder; Meal: Char; const MealTime: string; Bagged: Boolean);
|
---|
| 145 | begin
|
---|
| 146 | CallV('ORWDFH ADDLATE', [Patient.DFN, Encounter.Provider, Encounter.Location, Meal, MealTime, Bagged]);
|
---|
| 147 | SetOrderFromResults(NewOrder);
|
---|
| 148 | end;
|
---|
| 149 |
|
---|
| 150 | function IsolationID: string;
|
---|
| 151 | begin
|
---|
| 152 | Result := sCallV('ORWDFH ISOIEN', [nil]);
|
---|
| 153 | end;
|
---|
| 154 |
|
---|
| 155 | function CurrentIsolation: string;
|
---|
| 156 | begin
|
---|
| 157 | Result := sCallV('ORWDFH CURISO', [Patient.DFN]);
|
---|
| 158 | end;
|
---|
| 159 |
|
---|
| 160 | procedure LoadIsolations(Dest: TStrings);
|
---|
| 161 | begin
|
---|
| 162 | CallV('ORWDFH ISOLIST', [nil]);
|
---|
| 163 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 164 | end;
|
---|
| 165 |
|
---|
| 166 | procedure LoadDietQuickList(Dest: TStrings; const GroupID: string);
|
---|
| 167 | begin
|
---|
| 168 | CallV('ORWDXQ GETQLST', [GroupID, 'Q']);
|
---|
| 169 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 170 | end;
|
---|
| 171 |
|
---|
| 172 | function DietDialogType(GroupIEN: Integer): Char;
|
---|
| 173 | begin
|
---|
| 174 | Result := CharAt(sCallV('ORWDFH FINDTYP', [GroupIEN]), 1);
|
---|
| 175 | if not (Result in ['A', 'D', 'E', 'N', 'P', 'T', 'M']) then Result := 'D';
|
---|
| 176 | end;
|
---|
| 177 |
|
---|
| 178 | function OutpatientPatchInstalled: boolean;
|
---|
| 179 | begin
|
---|
| 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;
|
---|
| 189 | end;
|
---|
| 190 |
|
---|
| 191 | function UserHasFHAUTHKey: boolean;
|
---|
| 192 | begin
|
---|
| 193 | with uUserHasFHAUTHKey do
|
---|
| 194 | if not KeyChecked then
|
---|
| 195 | begin
|
---|
| 196 | UserHasKey := HasSecurityKey('FHAUTH');
|
---|
| 197 | KeyChecked := True;
|
---|
| 198 | end;
|
---|
| 199 | Result := uUserHasFHAUTHKey.UserHasKey;
|
---|
| 200 | end;
|
---|
| 201 |
|
---|
| 202 | procedure GetCurrentRecurringOPMeals(Dest: TStrings; MealType: string = '');
|
---|
| 203 | begin
|
---|
| 204 | CallV('ORWDFH CURRENT MEALS', [Patient.DFN, MealType]);
|
---|
| 205 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 206 | MixedCaseList(Dest);
|
---|
| 207 | end;
|
---|
| 208 |
|
---|
| 209 | function OutpatientLocationConfigured(ALocation: string): boolean;
|
---|
| 210 | begin
|
---|
| 211 | Result := (sCallV('ORWDFH NFSLOC READY', [ALocation]) = '1');
|
---|
| 212 | end;
|
---|
| 213 |
|
---|
| 214 | end.
|
---|