| 1 | unit rODBase; | 
|---|
| 2 |  | 
|---|
| 3 | interface | 
|---|
| 4 |  | 
|---|
| 5 | uses SysUtils, Windows, Classes, ORNet, ORFn, uCore, uConst, rOrders; | 
|---|
| 6 |  | 
|---|
| 7 | type | 
|---|
| 8 | TPrompt = class | 
|---|
| 9 | ID:        string; | 
|---|
| 10 | IEN:       Integer; | 
|---|
| 11 | Sequence:  Double; | 
|---|
| 12 | FmtCode:   string; | 
|---|
| 13 | Omit:      string; | 
|---|
| 14 | Leading:   string; | 
|---|
| 15 | Trailing:  string; | 
|---|
| 16 | NewLine:   Boolean; | 
|---|
| 17 | WrapWP:    Boolean; | 
|---|
| 18 | Children:  string; | 
|---|
| 19 | IsChild:   Boolean; | 
|---|
| 20 | end; | 
|---|
| 21 |  | 
|---|
| 22 | TResponse = class | 
|---|
| 23 | PromptIEN: Integer; | 
|---|
| 24 | PromptID:  string; | 
|---|
| 25 | Instance:  Integer; | 
|---|
| 26 | IValue:    string; | 
|---|
| 27 | EValue:    string; | 
|---|
| 28 | end; | 
|---|
| 29 |  | 
|---|
| 30 | TDialogItem = class | 
|---|
| 31 | ID:        string; | 
|---|
| 32 | Required:  Boolean; | 
|---|
| 33 | Hidden:    Boolean; | 
|---|
| 34 | Prompt:    string; | 
|---|
| 35 | DataType:  Char; | 
|---|
| 36 | Domain:    string; | 
|---|
| 37 | EDefault:  string; | 
|---|
| 38 | IDefault:  string; | 
|---|
| 39 | HelpText:  string; | 
|---|
| 40 | CrossRef:  string; | 
|---|
| 41 | ScreenRef: string; | 
|---|
| 42 | end; | 
|---|
| 43 |  | 
|---|
| 44 | TDialogNames = record | 
|---|
| 45 | Internal: string; | 
|---|
| 46 | Display:  string; | 
|---|
| 47 | BaseIEN:  Integer; | 
|---|
| 48 | BaseName: string; | 
|---|
| 49 | end; | 
|---|
| 50 |  | 
|---|
| 51 | TConstructOrder = record | 
|---|
| 52 | DialogName: string; | 
|---|
| 53 | LeadText:   string; | 
|---|
| 54 | TrailText:  string; | 
|---|
| 55 | DGroup:     Integer; | 
|---|
| 56 | OrderItem:  Integer; | 
|---|
| 57 | DelayEvent: Char; | 
|---|
| 58 | PTEventPtr: String;  // ptr to #100.2 | 
|---|
| 59 | EventPtr:   String;  // ptr to #100.5 | 
|---|
| 60 | Specialty:  Integer; | 
|---|
| 61 | Effective:  TFMDateTime; | 
|---|
| 62 | LogTime:    TFMDateTime; | 
|---|
| 63 | OCList: TStringList; | 
|---|
| 64 | DigSig:       string; | 
|---|
| 65 | ResponseList: TList; | 
|---|
| 66 | IsIMODialog:  boolean;  //imo | 
|---|
| 67 | IsEventDefaultOR: Integer; | 
|---|
| 68 | end; | 
|---|
| 69 |  | 
|---|
| 70 | TPFSSActive = record | 
|---|
| 71 | PFSSActive: boolean; | 
|---|
| 72 | PFSSChecked: boolean; | 
|---|
| 73 | end; | 
|---|
| 74 |  | 
|---|
| 75 | { General Calls } | 
|---|
| 76 | function AskAnotherOrder(ADialog: Integer): Boolean; | 
|---|
| 77 | function DisplayGroupByName(const AName: string): Integer; | 
|---|
| 78 | function DisplayGroupForDialog(const DialogName: string): Integer; | 
|---|
| 79 | procedure IdentifyDialog(var DialogNames: TDialogNames; ADialog: Integer); | 
|---|
| 80 | procedure LoadDialogDefinition(Dest: TList; const DialogName: string); | 
|---|
| 81 | procedure LoadOrderPrompting(Dest: TList; ADialog: Integer); | 
|---|
| 82 | //procedure LoadResponses(Dest: TList; const OrderID: string); | 
|---|
| 83 | procedure LoadResponses(Dest: TList; const OrderID: string; var HasObjects: boolean); | 
|---|
| 84 | procedure PutNewOrder(var AnOrder: TOrder; ConstructOrder: TConstructOrder; OrderSource: string); | 
|---|
| 85 | //procedure PutNewOrderAuto(var AnOrder: TOrder; ADialog: Integer); // no longer used | 
|---|
| 86 | function OIMessage(IEN: Integer): string; | 
|---|
| 87 | function OrderMenuStyle: Integer; | 
|---|
| 88 | function ResolveScreenRef(const ARef: string): string; | 
|---|
| 89 | function SubsetOfEntries(const StartFrom: string; Direction: Integer; | 
|---|
| 90 | const XRef, GblRef, ScreenRef: string): TStrings; | 
|---|
| 91 | function SubSetOfOrderItems(const StartFrom: string; Direction: Integer; | 
|---|
| 92 | const XRef: string): TStrings; | 
|---|
| 93 | function GetDefaultCopay(AnOrderID: string): String; | 
|---|
| 94 | procedure SetDefaultCoPayToNewOrder(AnOrderID, CoPayInfo:string); | 
|---|
| 95 | procedure ValidateNumericStr(const x, Dom: string; var ErrMsg: string); | 
|---|
| 96 | function IsPFSSActive: boolean; | 
|---|
| 97 |  | 
|---|
| 98 | { Quick Order Calls } | 
|---|
| 99 | //function DisplayNameForOD(const InternalName: string): string; | 
|---|
| 100 | function GetQuickName(const CRC: string): string; | 
|---|
| 101 | procedure LoadQuickListForOD(Dest: TStrings; DGroup: Integer); | 
|---|
| 102 | procedure SaveQuickListForOD(Src: TStrings;  DGroup: Integer); | 
|---|
| 103 | //procedure PutQuickName(DialogIEN: Integer; const DisplayName: string); | 
|---|
| 104 | procedure PutQuickOrder(var NewIEN: Integer; const CRC, DisplayName: string; DGroup: Integer; | 
|---|
| 105 | ResponseList: TList); | 
|---|
| 106 |  | 
|---|
| 107 | { Medication Calls } | 
|---|
| 108 | function AmountsForIVFluid(AnIEN: Integer; FluidType: Char): string; | 
|---|
| 109 | procedure AppendMedRoutes(Dest: TStrings); | 
|---|
| 110 | procedure CheckAuthForMeds(var x: string); | 
|---|
| 111 | function DispenseMessage(AnIEN: Integer): string; | 
|---|
| 112 | procedure LookupRoute(const AName: string; var ID, Abbreviation: string); | 
|---|
| 113 | function MedIsSupply(AnIEN: Integer): Boolean; | 
|---|
| 114 | function QuantityMessage(AnIEN: Integer): string; | 
|---|
| 115 | function RequiresCopay(DispenseDrug: Integer): Boolean; | 
|---|
| 116 | procedure LoadFormularyAlt(AList: TStringList; AnIEN: Integer; PSType: Char); | 
|---|
| 117 | function MedTypeIsIV(AnIEN: Integer): Boolean; | 
|---|
| 118 | function ODForMedIn: TStrings; | 
|---|
| 119 | function OIForMedIn(AnIEN: Integer): TStrings; | 
|---|
| 120 | function ODForIVFluids: TStrings; | 
|---|
| 121 | function ODForMedOut: TStrings; | 
|---|
| 122 | function OIForMedOut(AnIEN: Integer): TStrings; | 
|---|
| 123 | function RatedDisabilities: string; | 
|---|
| 124 | //function ValidIVRate(const x: string): Boolean; | 
|---|
| 125 | procedure ValidateIVRate(var x: string); | 
|---|
| 126 | function ValidSchedule(const x: string; PSType: Char = 'I'): Integer; | 
|---|
| 127 | function ValidQuantity(const x: string): Boolean; | 
|---|
| 128 |  | 
|---|
| 129 | { Vitals Calls } | 
|---|
| 130 | function ODForVitals: TStrings; | 
|---|
| 131 |  | 
|---|
| 132 | implementation | 
|---|
| 133 |  | 
|---|
| 134 | uses TRPCB, uOrders, uODBase, fODBase; | 
|---|
| 135 |  | 
|---|
| 136 | var | 
|---|
| 137 | uLastDispenseIEN: Integer; | 
|---|
| 138 | uLastDispenseMsg: string; | 
|---|
| 139 | uLastQuantityMsg: string; | 
|---|
| 140 | uMedRoutes: TStringList; | 
|---|
| 141 | uPFSSActive: TPFSSActive; | 
|---|
| 142 |  | 
|---|
| 143 | { Common Internal Calls } | 
|---|
| 144 |  | 
|---|
| 145 | procedure SetupORDIALOG(AParam: TParamRecord; ResponseList: TList; IsIV: boolean = False); | 
|---|
| 146 | const | 
|---|
| 147 | MAX_STR_LEN = 74; | 
|---|
| 148 | var | 
|---|
| 149 | i,j,ALine,odIdx,piIdx : Integer; | 
|---|
| 150 | Subs, x, ODtxt, thePI: string; | 
|---|
| 151 | WPStrings: TStringList; | 
|---|
| 152 | IVDuration, IVDurVal: string; | 
|---|
| 153 | begin | 
|---|
| 154 | piIdx := 0; | 
|---|
| 155 | odIdx := 0; | 
|---|
| 156 | IVDuration := ''; | 
|---|
| 157 | IVDurVal := ''; | 
|---|
| 158 | AParam.PType := list; | 
|---|
| 159 | for j := 0 to ResponseList.Count - 1 do | 
|---|
| 160 | begin | 
|---|
| 161 | if TResponse(ResponseList.Items[j]).PromptID = 'SIG' then | 
|---|
| 162 | begin | 
|---|
| 163 | ODtxt := TResponse(ResponseList.Items[j]).EValue; | 
|---|
| 164 | odIdx := j; | 
|---|
| 165 | end; | 
|---|
| 166 | if TResponse(ResponseList.Items[j]).PromptID = 'PI' then | 
|---|
| 167 | thePI := TResponse(ResponseList.Items[j]).EValue; | 
|---|
| 168 | if Length(Trim(thePI)) > 0 then | 
|---|
| 169 | piIdx := Pos(thePI, ODtxt); | 
|---|
| 170 | if piIdx > 0 then | 
|---|
| 171 | begin | 
|---|
| 172 | Delete(ODtxt,piIdx,Length(thePI)); | 
|---|
| 173 | TResponse(ResponseList.Items[odIdx]).EValue := ODtxt; | 
|---|
| 174 | end; | 
|---|
| 175 | if (IsIV and (TResponse(ResponseList.Items[j]).PromptID = 'DAYS')) then | 
|---|
| 176 | begin | 
|---|
| 177 | IVDuration := TResponse(ResponseList.Items[j]).EValue; | 
|---|
| 178 | if (Length(IVDuration) > 1) then | 
|---|
| 179 | begin | 
|---|
| 180 | if (Pos('TOTAL',upperCase(IVDuration))>0) or (Pos('FOR',upperCase(IVDuration))>0) then continue; | 
|---|
| 181 | if (Pos('H',upperCase(IVDuration))>0)  then | 
|---|
| 182 | begin | 
|---|
| 183 | IVDurVal := Copy(IVDuration,1,length(IVDuration)-1); | 
|---|
| 184 | TResponse(ResponseList.Items[j]).IValue := 'for ' + IVDurVal + ' hours'; | 
|---|
| 185 | end | 
|---|
| 186 | else if (Pos('D',upperCase(IVDuration))>0) then | 
|---|
| 187 | begin | 
|---|
| 188 | if Pos('DOSES', upperCase(IVDuration)) > 0 then | 
|---|
| 189 | begin | 
|---|
| 190 | IVDurVal := Copy(IVDuration, 1, length(IVDuration)-5); | 
|---|
| 191 | TResponse(ResponseList.Items[j]).IValue := 'for a total of ' + IVDurVal + ' doses'; | 
|---|
| 192 | end | 
|---|
| 193 | else | 
|---|
| 194 | begin | 
|---|
| 195 | IVDurVal := Copy(IVDuration,1,length(IVDuration)-1); | 
|---|
| 196 | TResponse(ResponseList.Items[j]).IValue := 'for ' + IVDurVal + ' days'; | 
|---|
| 197 | end; | 
|---|
| 198 | end | 
|---|
| 199 | else if ((Pos('ML',upperCase(IVDuration))>0) or (Pos('CC',upperCase(IVDuration))>0)) then | 
|---|
| 200 | begin | 
|---|
| 201 | IVDurVal := Copy(IVDuration,1,length(IVDuration)-2); | 
|---|
| 202 | TResponse(ResponseList.Items[j]).IValue := 'with total volume ' + IVDurVal + 'ml'; | 
|---|
| 203 | end | 
|---|
| 204 | else if (Pos('L',upperCase(IVDuration))>0) then | 
|---|
| 205 | begin | 
|---|
| 206 | IVDurVal := Copy(IVDuration,0,length(IVDuration)-1); | 
|---|
| 207 | TResponse(ResponseList.Items[j]).IValue := 'with total volume ' + IVDurVal + 'L'; | 
|---|
| 208 | end; | 
|---|
| 209 | end; | 
|---|
| 210 | end; | 
|---|
| 211 | end; | 
|---|
| 212 |  | 
|---|
| 213 | with AParam, ResponseList do for i := 0 to Count - 1 do | 
|---|
| 214 | begin | 
|---|
| 215 | with TResponse(Items[i]) do | 
|---|
| 216 | begin | 
|---|
| 217 | Subs := IntToStr(PromptIEN) + ',' + IntToStr(Instance); | 
|---|
| 218 | if IValue = TX_WPTYPE then | 
|---|
| 219 | begin | 
|---|
| 220 | WPStrings := TStringList.Create; | 
|---|
| 221 | try | 
|---|
| 222 | WPStrings.Text := EValue; | 
|---|
| 223 | LimitStringLength(WPStrings, MAX_STR_LEN); | 
|---|
| 224 | x := 'ORDIALOG("WP",' + Subs + ')'; | 
|---|
| 225 | Mult[Subs] := x; | 
|---|
| 226 | for ALine := 0 to WPStrings.Count - 1 do | 
|---|
| 227 | begin | 
|---|
| 228 | x := '"WP",' + Subs + ',' + IntToStr(ALine+1) + ',0'; | 
|---|
| 229 | Mult[x] := WPStrings[ALine]; | 
|---|
| 230 | end; {for} | 
|---|
| 231 | finally | 
|---|
| 232 | WPStrings.Free; | 
|---|
| 233 | end; {try} | 
|---|
| 234 | end | 
|---|
| 235 | else Mult[Subs] := IValue; | 
|---|
| 236 | end; {with TResponse} | 
|---|
| 237 | end; {with AParam} | 
|---|
| 238 | end; | 
|---|
| 239 |  | 
|---|
| 240 | { Quick Order Calls } | 
|---|
| 241 |  | 
|---|
| 242 | //function DisplayNameForOD(const InternalName: string): string; | 
|---|
| 243 | //begin | 
|---|
| 244 | //  Result := sCallV('ORWDXQ DLGNAME', [InternalName]); | 
|---|
| 245 | //end; | 
|---|
| 246 |  | 
|---|
| 247 | function GetQuickName(const CRC: string): string; | 
|---|
| 248 | begin | 
|---|
| 249 | Result := sCallV('ORWDXQ GETQNAM', [CRC]); | 
|---|
| 250 | end; | 
|---|
| 251 |  | 
|---|
| 252 | procedure LoadQuickListForOD(Dest: TStrings; DGroup: Integer); | 
|---|
| 253 | begin | 
|---|
| 254 | CallV('ORWDXQ GETQLST', [DGroup]); | 
|---|
| 255 | FastAssign(RPCBrokerV.Results, Dest); | 
|---|
| 256 | end; | 
|---|
| 257 |  | 
|---|
| 258 | procedure SaveQuickListForOD(Src: TStrings;  DGroup: Integer); | 
|---|
| 259 | begin | 
|---|
| 260 | CallV('ORWDXQ PUTQLST', [DGroup, Src]); | 
|---|
| 261 | // ignore return value for now | 
|---|
| 262 | end; | 
|---|
| 263 |  | 
|---|
| 264 | //procedure PutQuickName(DialogIEN: Integer; const DisplayName: string); | 
|---|
| 265 | //begin | 
|---|
| 266 | //  CallV('ORWDXQ PUTQNAM', [DialogIEN, DisplayName]); | 
|---|
| 267 | //  // ignore return value for now | 
|---|
| 268 | //end; | 
|---|
| 269 |  | 
|---|
| 270 | procedure PutQuickOrder(var NewIEN: Integer; const CRC, DisplayName: string; DGroup: Integer; | 
|---|
| 271 | ResponseList: TList); | 
|---|
| 272 | begin | 
|---|
| 273 | with RPCBrokerV do | 
|---|
| 274 | begin | 
|---|
| 275 | ClearParameters := True; | 
|---|
| 276 | RemoteProcedure := 'ORWDXQ DLGSAVE'; | 
|---|
| 277 | Param[0].PType := literal; | 
|---|
| 278 | Param[0].Value := CRC; | 
|---|
| 279 | Param[1].PType := literal; | 
|---|
| 280 | Param[1].Value := DisplayName; | 
|---|
| 281 | Param[2].PType := literal; | 
|---|
| 282 | Param[2].Value := IntToStr(DGroup); | 
|---|
| 283 | SetupORDIALOG(Param[3], ResponseList); | 
|---|
| 284 | CallBroker; | 
|---|
| 285 | if Results.Count = 0 then Exit;  // error creating order | 
|---|
| 286 | NewIEN := StrToIntDef(Results[0], 0); | 
|---|
| 287 | end; | 
|---|
| 288 | end; | 
|---|
| 289 |  | 
|---|
| 290 | { General Calls } | 
|---|
| 291 |  | 
|---|
| 292 | function AskAnotherOrder(ADialog: Integer): Boolean; | 
|---|
| 293 | begin | 
|---|
| 294 | Result := sCallV('ORWDX AGAIN', [ADialog]) = '1'; | 
|---|
| 295 | end; | 
|---|
| 296 |  | 
|---|
| 297 | function DisplayGroupByName(const AName: string): Integer; | 
|---|
| 298 | begin | 
|---|
| 299 | Result := StrToIntDef(sCallV('ORWDX DGNM', [AName]), 0); | 
|---|
| 300 | end; | 
|---|
| 301 |  | 
|---|
| 302 | function DisplayGroupForDialog(const DialogName: string): Integer; | 
|---|
| 303 | begin | 
|---|
| 304 | Result := StrToIntDef(sCallV('ORWDX DGRP', [DialogName]),0); | 
|---|
| 305 | end; | 
|---|
| 306 |  | 
|---|
| 307 | procedure IdentifyDialog(var DialogNames: TDialogNames; ADialog: Integer); | 
|---|
| 308 | var | 
|---|
| 309 | x: string; | 
|---|
| 310 | begin | 
|---|
| 311 | x := sCallV('ORWDXM DLGNAME', [ADialog]); | 
|---|
| 312 | with DialogNames do | 
|---|
| 313 | begin | 
|---|
| 314 | Internal := Piece(x, U, 1); | 
|---|
| 315 | Display  := Piece(x, U, 2); | 
|---|
| 316 | BaseIEN  := StrToIntDef(Piece(x, U, 3), 0); | 
|---|
| 317 | BaseName := Piece(x, U, 4); | 
|---|
| 318 | end; | 
|---|
| 319 | end; | 
|---|
| 320 |  | 
|---|
| 321 | procedure LoadDialogDefinition(Dest: TList; const DialogName: string); | 
|---|
| 322 | { loads a list of TPrompt records | 
|---|
| 323 | Pieces: PromptID[1]^PromptIEN[2]^FmtSeq[3]^Fmt[4]^Omit[5]^Lead[6]^Trail[7]^NwLn[8]^Wrap[9]^Children[10]^IsChild[11] } | 
|---|
| 324 | var | 
|---|
| 325 | i: Integer; | 
|---|
| 326 | APrompt: TPrompt; | 
|---|
| 327 | begin | 
|---|
| 328 | CallV('ORWDX DLGDEF', [DialogName]); | 
|---|
| 329 | with RPCBrokerV do for i := 0 to Results.Count - 1 do | 
|---|
| 330 | begin | 
|---|
| 331 | APrompt := TPrompt.Create; | 
|---|
| 332 | with APrompt do | 
|---|
| 333 | begin | 
|---|
| 334 | ID        := Piece(Results[i], U, 1); | 
|---|
| 335 | IEN       := StrToIntDef(Piece(Results[i], U, 2), 0); | 
|---|
| 336 | if Length(Piece(Results[i], U, 3)) > 0 | 
|---|
| 337 | then Sequence := StrToFloat(Piece(Results[i], U, 3)) | 
|---|
| 338 | else Sequence := 0; | 
|---|
| 339 | FmtCode   := Piece(Results[i], U, 4); | 
|---|
| 340 | Omit      := Piece(Results[i], U, 5); | 
|---|
| 341 | Leading   := Piece(Results[i], U, 6); | 
|---|
| 342 | Trailing  := Piece(Results[i], U, 7); | 
|---|
| 343 | NewLine   := Piece(Results[i], U, 8) = '1'; | 
|---|
| 344 | WrapWP    := Piece(Results[i], U, 9) = '1'; | 
|---|
| 345 | Children  := Piece(Results[i], U, 10); | 
|---|
| 346 | IsChild   := Piece(Results[i], U, 11) = '1'; | 
|---|
| 347 | end; | 
|---|
| 348 | Dest.Add(APrompt); | 
|---|
| 349 | end; | 
|---|
| 350 | end; | 
|---|
| 351 |  | 
|---|
| 352 | procedure LoadOrderPrompting(Dest: TList; ADialog: Integer); | 
|---|
| 353 | // ID^REQ^HID^PROMPT^TYPE^DOMAIN^DEFAULT^IDFLT^HELP | 
|---|
| 354 | var | 
|---|
| 355 | i: Integer; | 
|---|
| 356 | DialogItem: TDialogItem; | 
|---|
| 357 | begin | 
|---|
| 358 | CallV('ORWDXM PROMPTS', [ADialog]); | 
|---|
| 359 | DialogItem := nil; | 
|---|
| 360 | with RPCBrokerV do for i := 0 to Results.Count - 1 do | 
|---|
| 361 | begin | 
|---|
| 362 | if CharAt(Results[i], 1) = '~' then | 
|---|
| 363 | begin | 
|---|
| 364 | DialogItem := TDialogItem.Create;                       // create a new dialog item | 
|---|
| 365 | with DialogItem do | 
|---|
| 366 | begin | 
|---|
| 367 | Results[i] := Copy(Results[i], 2, Length(Results[i])); | 
|---|
| 368 | ID         := Piece(Results[i], U, 1); | 
|---|
| 369 | Required   := Piece(Results[i], U, 2) = '1'; | 
|---|
| 370 | Hidden     := Piece(Results[i], U, 3) = '1'; | 
|---|
| 371 | Prompt     := Piece(Results[i], U, 4); | 
|---|
| 372 | DataType   := CharAt(Piece(Results[i], U, 5), 1); | 
|---|
| 373 | Domain     := Piece(Results[i], U, 6); | 
|---|
| 374 | EDefault   := Piece(Results[i], U, 7); | 
|---|
| 375 | IDefault   := Piece(Results[i], U, 8); | 
|---|
| 376 | HelpText   := Piece(Results[i], U, 9); | 
|---|
| 377 | CrossRef   := Piece(Results[i], U, 10); | 
|---|
| 378 | ScreenRef  := Piece(Results[i], U, 11); | 
|---|
| 379 | if Hidden then DataType := 'H';                       // if hidden, use 'Hidden' type | 
|---|
| 380 | end; | 
|---|
| 381 | Dest.Add(DialogItem); | 
|---|
| 382 | end; | 
|---|
| 383 | if (CharAt(Results[i], 1) = 't') and (DialogItem <> nil) then  // use last DialogItem | 
|---|
| 384 | with DialogItem do EDefault := EDefault + Copy(Results[i], 2, Length(Results[i])) + CRLF; | 
|---|
| 385 | end; | 
|---|
| 386 | end; | 
|---|
| 387 |  | 
|---|
| 388 | procedure ExtractToResponses(Dest: TList; var HasObjects: boolean); | 
|---|
| 389 | { load a list with TResponse records, assumes source strings are in RPCBrokerV.Results } | 
|---|
| 390 | var | 
|---|
| 391 | i: Integer; | 
|---|
| 392 | AResponse: TResponse; | 
|---|
| 393 | WPContainsObjects, TxContainsObjects: boolean; | 
|---|
| 394 | TempBroker: TStrings; | 
|---|
| 395 | begin | 
|---|
| 396 | i := 0; | 
|---|
| 397 | HasObjects := FALSE; | 
|---|
| 398 | TempBroker := TStringlist.Create; | 
|---|
| 399 | FastAssign(RPCBrokerV.Results, TempBroker); | 
|---|
| 400 | try | 
|---|
| 401 | with TempBroker do while i < Count do | 
|---|
| 402 | begin | 
|---|
| 403 | if CharAt(Strings[i], 1) = '~' then | 
|---|
| 404 | begin | 
|---|
| 405 | AResponse := TResponse.Create; | 
|---|
| 406 | with AResponse do | 
|---|
| 407 | begin | 
|---|
| 408 | PromptIEN := StrToIntDef(Piece(Copy(Strings[i], 2, 255), U, 1), 0); | 
|---|
| 409 | Instance := StrToIntDef(Piece(Strings[i], U, 2), 0); | 
|---|
| 410 | PromptID := Piece(Strings[i], U, 3); | 
|---|
| 411 | Inc(i); | 
|---|
| 412 | while (i < Count) and (CharAt(Strings[i], 1) <> '~') do | 
|---|
| 413 | begin | 
|---|
| 414 | if CharAt(Strings[i], 1) = 'i' then IValue := Copy(Strings[i], 2, 255); | 
|---|
| 415 | if CharAt(Strings[i], 1) = 'e' then EValue := Copy(Strings[i], 2, 255); | 
|---|
| 416 | if CharAt(Strings[i], 1) = 't' then | 
|---|
| 417 | begin | 
|---|
| 418 | if Length(EValue) > 0 then EValue := EValue + CRLF; | 
|---|
| 419 | EValue := EValue + Copy(Strings[i], 2, 255); | 
|---|
| 420 | IValue := TX_WPTYPE;  // signals that this is a word processing field | 
|---|
| 421 | end; | 
|---|
| 422 | Inc(i); | 
|---|
| 423 | end; {while i} | 
|---|
| 424 | if IValue <> TX_WPTYPE then ExpandOrderObjects(IValue, TxContainsObjects); | 
|---|
| 425 | ExpandOrderObjects(EValue, WPContainsObjects); | 
|---|
| 426 | HasObjects := HasObjects or WPContainsObjects or TxContainsObjects; | 
|---|
| 427 | Dest.Add(AResponse); | 
|---|
| 428 | end; {with AResponse} | 
|---|
| 429 | end; {if CharAt} | 
|---|
| 430 | end; {With RPCBrokerV} | 
|---|
| 431 | finally | 
|---|
| 432 | TempBroker.Free; | 
|---|
| 433 | end; | 
|---|
| 434 | end; | 
|---|
| 435 |  | 
|---|
| 436 | procedure LoadResponses(Dest: TList; const OrderID: string; var HasObjects: boolean); | 
|---|
| 437 | var | 
|---|
| 438 | Transfer: boolean; | 
|---|
| 439 | begin | 
|---|
| 440 | if ((XferOuttoInOnMeds = True) or (XfInToOutNow = True)) and (CharAt(OrderID,1)='C') then Transfer := true | 
|---|
| 441 | else Transfer := false; | 
|---|
| 442 | CallV('ORWDX LOADRSP', [OrderID, Transfer]); | 
|---|
| 443 | ExtractToResponses(Dest, HasObjects); | 
|---|
| 444 | end; | 
|---|
| 445 |  | 
|---|
| 446 | procedure PutNewOrder(var AnOrder: TOrder; ConstructOrder: TConstructOrder; OrderSource: string); | 
|---|
| 447 | var | 
|---|
| 448 | i: Integer; | 
|---|
| 449 | x, y, z: string; | 
|---|
| 450 | begin | 
|---|
| 451 | with RPCBrokerV do | 
|---|
| 452 | begin | 
|---|
| 453 | ClearParameters := True; | 
|---|
| 454 | RemoteProcedure := 'ORWDX SAVE'; | 
|---|
| 455 | Param[0].PType := literal; | 
|---|
| 456 | Param[0].Value := Patient.DFN;  //*DFN* | 
|---|
| 457 | Param[1].PType := literal; | 
|---|
| 458 | Param[1].Value := IntToStr(Encounter.Provider); | 
|---|
| 459 | Param[2].PType := literal; | 
|---|
| 460 | (*if loc > 0 then Param[2].Value := IntToStr(Loc) | 
|---|
| 461 | else Param[2].Value := IntToStr(Encounter.Location);*) | 
|---|
| 462 | Param[2].Value := IntToStr(Encounter.Location); | 
|---|
| 463 | Param[3].PType := literal; | 
|---|
| 464 | Param[3].Value := ConstructOrder.DialogName; | 
|---|
| 465 | Param[4].PType := literal; | 
|---|
| 466 | Param[4].Value := IntToStr(ConstructOrder.DGroup); | 
|---|
| 467 | Param[5].PType := literal; | 
|---|
| 468 | Param[5].Value := IntToStr(ConstructOrder.OrderItem); | 
|---|
| 469 | Param[6].PType := literal; | 
|---|
| 470 | Param[6].Value := AnOrder.EditOf;        // null if new order, otherwise ORIFN of original | 
|---|
| 471 | if (ConstructOrder.DGroup = IVDisp) then | 
|---|
| 472 | SetupORDIALOG(Param[7], ConstructOrder.ResponseList, True) | 
|---|
| 473 | else | 
|---|
| 474 | SetupORDIALOG(Param[7], ConstructOrder.ResponseList); | 
|---|
| 475 | if Length(ConstructOrder.LeadText)  > 0 | 
|---|
| 476 | then Param[7].Mult['"ORLEAD"']  := ConstructOrder.LeadText; | 
|---|
| 477 | if Length(ConstructOrder.TrailText) > 0 | 
|---|
| 478 | then Param[7].Mult['"ORTRAIL"'] := ConstructOrder.TrailText; | 
|---|
| 479 | Param[7].Mult['"ORCHECK"'] := IntToStr(ConstructOrder.OCList.Count); | 
|---|
| 480 | with ConstructOrder do for i := 0 to OCList.Count - 1 do | 
|---|
| 481 | begin | 
|---|
| 482 | // put quotes around everything to prevent broker from choking | 
|---|
| 483 | y := '"ORCHECK","' + Piece(OCList[i], U, 1) + '","' + Piece(OCList[i], U, 3) + | 
|---|
| 484 | '","' + IntToStr(i+1) + '"'; | 
|---|
| 485 | Param[7].Mult[y] := Pieces(OCList[i], U, 2, 4); | 
|---|
| 486 | end; | 
|---|
| 487 | if ConstructOrder.DelayEvent in ['A','D','T','M','O'] then | 
|---|
| 488 | Param[7].Mult['"OREVENT"'] := ConstructOrder.PTEventPtr; | 
|---|
| 489 | if ConstructOrder.LogTime > 0 | 
|---|
| 490 | then Param[7].Mult['"ORSLOG"'] := FloatToStr(ConstructOrder.LogTime); | 
|---|
| 491 | Param[7].Mult['"ORTS"'] := IntToStr(Patient.Specialty);  // pass in treating specialty for ORTS | 
|---|
| 492 | Param[8].PType := literal; | 
|---|
| 493 | Param[8].Value := ConstructOrder.DigSig; | 
|---|
| 494 | if Constructorder.IsIMODialog then | 
|---|
| 495 | begin | 
|---|
| 496 | Param[9].PType := literal;                       //IMO | 
|---|
| 497 | Param[9].Value := FloatToStr(Encounter.DateTime); | 
|---|
| 498 | end else | 
|---|
| 499 | begin | 
|---|
| 500 | Param[9].PType := literal;                       //IMO | 
|---|
| 501 | Param[9].Value := ''; | 
|---|
| 502 | end; | 
|---|
| 503 | Param[10].PType := literal; | 
|---|
| 504 | Param[10].Value := OrderSource; | 
|---|
| 505 | Param[11].PType := literal; | 
|---|
| 506 | Param[11].Value := IntToStr(Constructorder.IsEventDefaultOR); | 
|---|
| 507 |  | 
|---|
| 508 | CallBroker; | 
|---|
| 509 | if Results.Count = 0 then Exit;          // error creating order | 
|---|
| 510 | x := Results[0]; | 
|---|
| 511 | Results.Delete(0); | 
|---|
| 512 | y := ''; | 
|---|
| 513 |  | 
|---|
| 514 | while (Results.Count > 0) and (CharAt(Results[0], 1) <> '~') and (CharAt(Results[0], 1) <> '|') do | 
|---|
| 515 | begin | 
|---|
| 516 | y := y + Copy(Results[0], 2, Length(Results[0])) + CRLF; | 
|---|
| 517 | Results.Delete(0); | 
|---|
| 518 | end; | 
|---|
| 519 | if Length(y) > 0 then y := Copy(y, 1, Length(y) - 2);  // take off last CRLF | 
|---|
| 520 | z := ''; | 
|---|
| 521 | if (Results.Count > 0) and (Results[0] = '|') then | 
|---|
| 522 | begin | 
|---|
| 523 | Results.Delete(0); | 
|---|
| 524 | while (Results.Count > 0) and (CharAt(Results[0], 1) <> '~') and (CharAt(Results[0], 1) <> '|') do | 
|---|
| 525 | begin | 
|---|
| 526 | z := z + Copy(Results[0], 2, Length(Results[0])); | 
|---|
| 527 | Results.Delete(0); | 
|---|
| 528 | end; | 
|---|
| 529 | end; | 
|---|
| 530 | SetOrderFields(AnOrder, x, y, z); | 
|---|
| 531 | end; | 
|---|
| 532 | end; | 
|---|
| 533 |  | 
|---|
| 534 | { no longer used - | 
|---|
| 535 | procedure PutNewOrderAuto(var AnOrder: TOrder; ADialog: Integer); | 
|---|
| 536 | var | 
|---|
| 537 | i: Integer; | 
|---|
| 538 | y: string; | 
|---|
| 539 | begin | 
|---|
| 540 | CallV('ORWDXM AUTOACK', [Patient.DFN, Encounter.Provider, Encounter.Location, ADialog]); | 
|---|
| 541 | with RPCBrokerV do if Results.Count > 0 then | 
|---|
| 542 | begin | 
|---|
| 543 | y := ''; | 
|---|
| 544 | for i := 1 to Results.Count - 1 do | 
|---|
| 545 | y := y + Copy(Results[i], 2, Length(Results[i])) + CRLF; | 
|---|
| 546 | if Length(y) > 0 then y := Copy(y, 1, Length(y) - 2);  // take off last CRLF | 
|---|
| 547 | SetOrderFields(AnOrder, Results[0], y); | 
|---|
| 548 | end; | 
|---|
| 549 | end; | 
|---|
| 550 | } | 
|---|
| 551 |  | 
|---|
| 552 | function OIMessage(IEN: Integer): string; | 
|---|
| 553 | begin | 
|---|
| 554 | CallV('ORWDX MSG', [IEN]); | 
|---|
| 555 | with RPCBrokerV.Results do SetString(Result, GetText, Length(Text)); | 
|---|
| 556 | end; | 
|---|
| 557 |  | 
|---|
| 558 | function OrderMenuStyle: Integer; | 
|---|
| 559 | begin | 
|---|
| 560 | Result := StrToIntDef(sCallV('ORWDXM MSTYLE', [nil]), 0); | 
|---|
| 561 | end; | 
|---|
| 562 |  | 
|---|
| 563 | function ResolveScreenRef(const ARef: string): string; | 
|---|
| 564 | begin | 
|---|
| 565 | Result := sCallV('ORWDXM RSCRN', [ARef]); | 
|---|
| 566 | end; | 
|---|
| 567 |  | 
|---|
| 568 | function SubSetOfOrderItems(const StartFrom: string; Direction: Integer; | 
|---|
| 569 | const XRef: string): TStrings; | 
|---|
| 570 | { returns a pointer to a list of orderable items matching an S.xxx cross reference (for use in | 
|---|
| 571 | a long list box) -  The return value is  a pointer to RPCBrokerV.Results, so the data must | 
|---|
| 572 | be used BEFORE the next broker call! } | 
|---|
| 573 | begin | 
|---|
| 574 | CallV('ORWDX ORDITM', [StartFrom, Direction, XRef]); | 
|---|
| 575 | Result := RPCBrokerV.Results; | 
|---|
| 576 | end; | 
|---|
| 577 |  | 
|---|
| 578 | function GetDefaultCopay(AnOrderID: string): String; | 
|---|
| 579 | begin | 
|---|
| 580 | with RPCBrokerV do | 
|---|
| 581 | begin | 
|---|
| 582 | ClearParameters := True; | 
|---|
| 583 | RemoteProcedure := 'ORWDPS4 CPLST'; | 
|---|
| 584 | Param[0].PType := literal; | 
|---|
| 585 | Param[0].Value := Patient.DFN; | 
|---|
| 586 | Param[1].PType := list; | 
|---|
| 587 | Param[1].Mult['1'] := AnOrderID; | 
|---|
| 588 | end; | 
|---|
| 589 | CallBroker; | 
|---|
| 590 | if RPCBrokerV.Results.Count > 0 then | 
|---|
| 591 | Result := RPCBrokerV.Results[0] | 
|---|
| 592 | else | 
|---|
| 593 | Result := ''; | 
|---|
| 594 | end; | 
|---|
| 595 |  | 
|---|
| 596 | procedure SetDefaultCoPayToNewOrder(AnOrderID, CoPayInfo:string); | 
|---|
| 597 | var | 
|---|
| 598 | temp,CPExems: string; | 
|---|
| 599 | CoPayValue: array [1..7] of Char; | 
|---|
| 600 | i: integer; | 
|---|
| 601 | begin | 
|---|
| 602 | // SC AO IR EC MST HNC CV | 
|---|
| 603 | CoPayValue[1] := 'N'; | 
|---|
| 604 | CoPayValue[2] := 'N'; | 
|---|
| 605 | CoPayValue[3] := 'N'; | 
|---|
| 606 | CoPayValue[4] := 'N'; | 
|---|
| 607 | CoPayValue[5] := 'N'; | 
|---|
| 608 | CoPayValue[6] := 'N'; | 
|---|
| 609 | CoPayValue[7] := 'N'; | 
|---|
| 610 | temp := Pieces(CoPayInfo,'^',2,6); | 
|---|
| 611 | i := 1; | 
|---|
| 612 | while Length(Piece(temp,'^',i))>0 do | 
|---|
| 613 | begin | 
|---|
| 614 | if Piece(Piece(temp,'^',i),';',1) = 'SC' then | 
|---|
| 615 | begin | 
|---|
| 616 | if Piece( Piece(temp,'^',i),';',2) = '1' then | 
|---|
| 617 | CoPayValue[1] := 'C' | 
|---|
| 618 | else | 
|---|
| 619 | CopayValue[1] := 'U'; | 
|---|
| 620 | end; | 
|---|
| 621 | if Piece(Piece(temp,'^',i),';',1) = 'AO' then | 
|---|
| 622 | begin | 
|---|
| 623 | if Piece( Piece(temp,'^',i),';',2) = '1' then | 
|---|
| 624 | CoPayValue[2] := 'C' | 
|---|
| 625 | else | 
|---|
| 626 | CopayValue[2] := 'U'; | 
|---|
| 627 | end; | 
|---|
| 628 | if Piece(Piece(temp,'^',i),';',1) = 'IR' then | 
|---|
| 629 | begin | 
|---|
| 630 | if Piece( Piece(temp,'^',i),';',2) = '1' then | 
|---|
| 631 | CoPayValue[3] := 'C' | 
|---|
| 632 | else | 
|---|
| 633 | CopayValue[3] := 'U'; | 
|---|
| 634 | end; | 
|---|
| 635 | if Piece(Piece(temp,'^',i),';',1) = 'EC' then | 
|---|
| 636 | begin | 
|---|
| 637 | if Piece( Piece(temp,'^',i),';',2) = '1' then | 
|---|
| 638 | CoPayValue[4] := 'C' | 
|---|
| 639 | else | 
|---|
| 640 | CopayValue[4] := 'U'; | 
|---|
| 641 | end; | 
|---|
| 642 | if Piece(Piece(temp,'^',i),';',1) = 'MST' then | 
|---|
| 643 | begin | 
|---|
| 644 | if Piece( Piece(temp,'^',i),';',2) = '1' then | 
|---|
| 645 | CoPayValue[5] := 'C' | 
|---|
| 646 | else | 
|---|
| 647 | CopayValue[5] := 'U'; | 
|---|
| 648 | end; | 
|---|
| 649 | if Piece(Piece(temp,'^',i),';',1) = 'HNC' then | 
|---|
| 650 | begin | 
|---|
| 651 | if Piece( Piece(temp,'^',i),';',2) = '1' then | 
|---|
| 652 | CoPayValue[6] := 'C' | 
|---|
| 653 | else | 
|---|
| 654 | CopayValue[6] := 'U'; | 
|---|
| 655 | end; | 
|---|
| 656 | if Piece(Piece(temp,'^',i),';',1) = 'CV' then | 
|---|
| 657 | begin | 
|---|
| 658 | if Piece( Piece(temp,'^',i),';',2) = '1' then | 
|---|
| 659 | CoPayValue[7] := 'C' | 
|---|
| 660 | else | 
|---|
| 661 | CopayValue[7] := 'U'; | 
|---|
| 662 | end; | 
|---|
| 663 | i := i + 1; | 
|---|
| 664 | end; | 
|---|
| 665 | CPExems := CoPayValue[1] + CoPayValue[2] + CoPayValue[3] + CoPayValue[4] | 
|---|
| 666 | + CoPayValue[5] + CoPayValue[6] + CoPayValue[7]; | 
|---|
| 667 | CPExems := AnOrderId + '^' + CPExems; | 
|---|
| 668 | with RPCBrokerV do | 
|---|
| 669 | begin | 
|---|
| 670 | ClearParameters := True; | 
|---|
| 671 | RemoteProcedure := 'ORWDPS4 CPINFO'; | 
|---|
| 672 | Param[0].PType := list; | 
|---|
| 673 | Param[0].Mult['1'] := CPExems; | 
|---|
| 674 | CallBroker; | 
|---|
| 675 | end; | 
|---|
| 676 | end; | 
|---|
| 677 |  | 
|---|
| 678 | function SubsetOfEntries(const StartFrom: string; Direction: Integer; | 
|---|
| 679 | const XRef, GblRef, ScreenRef: string): TStrings; | 
|---|
| 680 | { returns a pointer to a list of file entries (for use in a long list box) - | 
|---|
| 681 | The return value is  a pointer to RPCBrokerV.Results, so the data must | 
|---|
| 682 | be used BEFORE the next broker call! } | 
|---|
| 683 | begin | 
|---|
| 684 | CallV('ORWDOR LKSCRN', [StartFrom, Direction, XRef, GblRef, ScreenRef]); | 
|---|
| 685 | Result := RPCBrokerV.Results; | 
|---|
| 686 | end; | 
|---|
| 687 |  | 
|---|
| 688 | procedure ValidateNumericStr(const x, Dom: string; var ErrMsg: string); | 
|---|
| 689 | begin | 
|---|
| 690 | ErrMsg := sCallV('ORWDOR VALNUM', [x, Dom]); | 
|---|
| 691 | if ErrMsg = '0' then ErrMsg := '' else ErrMsg := Piece(ErrMsg, U, 2); | 
|---|
| 692 | end; | 
|---|
| 693 |  | 
|---|
| 694 | function IsPFSSActive: boolean; | 
|---|
| 695 | begin | 
|---|
| 696 | with uPFSSActive do | 
|---|
| 697 | if not PFSSChecked then | 
|---|
| 698 | begin | 
|---|
| 699 | PFSSActive := (sCallV('ORWPFSS IS PFSS ACTIVE?', [nil]) = '1'); | 
|---|
| 700 | PFSSChecked := True; | 
|---|
| 701 | end; | 
|---|
| 702 | Result := uPFSSActive.PFSSActive | 
|---|
| 703 | end; | 
|---|
| 704 |  | 
|---|
| 705 | { Medication Calls } | 
|---|
| 706 |  | 
|---|
| 707 | procedure AppendMedRoutes(Dest: TStrings); | 
|---|
| 708 | var | 
|---|
| 709 | i: Integer; | 
|---|
| 710 | x: string; | 
|---|
| 711 | begin | 
|---|
| 712 | if uMedRoutes = nil then | 
|---|
| 713 | begin | 
|---|
| 714 | CallV('ORWDPS32 ALLROUTE', [nil]); | 
|---|
| 715 | with RPCBrokerV do | 
|---|
| 716 | begin | 
|---|
| 717 | uMedRoutes := TStringList.Create; | 
|---|
| 718 | FastAssign(RPCBrokerV.Results, uMedRoutes); | 
|---|
| 719 | for i := 0 to Results.Count - 1 do if Length(Piece(Results[i], U, 3)) > 0 then | 
|---|
| 720 | begin | 
|---|
| 721 | x := Piece(Results[i], U, 1) + U + Piece(Results[i], U, 3) + | 
|---|
| 722 | ' (' + Piece(Results[i], U, 2) + ')' + U + Piece(Results[i], U, 3); | 
|---|
| 723 | uMedRoutes.Add(x); | 
|---|
| 724 | end; {if Length} | 
|---|
| 725 | SortByPiece(uMedRoutes, U, 2); | 
|---|
| 726 | end; {with RPCBrokerV} | 
|---|
| 727 | end; {if uMedRoutes} | 
|---|
| 728 | FastAddStrings(uMedRoutes, Dest); | 
|---|
| 729 | end; | 
|---|
| 730 |  | 
|---|
| 731 | procedure CheckAuthForMeds(var x: string); | 
|---|
| 732 | begin | 
|---|
| 733 | x := Piece(sCallV('ORWDPS32 AUTH', [Encounter.Provider]), U, 2); | 
|---|
| 734 | end; | 
|---|
| 735 |  | 
|---|
| 736 | function DispenseMessage(AnIEN: Integer): string; | 
|---|
| 737 | var | 
|---|
| 738 | x: string; | 
|---|
| 739 | begin | 
|---|
| 740 | if AnIEN = uLastDispenseIEN then Result := uLastDispenseMsg else | 
|---|
| 741 | begin | 
|---|
| 742 | x := sCallV('ORWDPS32 DRUGMSG', [AnIEN]); | 
|---|
| 743 | uLastDispenseIEN := AnIEN; | 
|---|
| 744 | uLastDispenseMsg := Piece(x, U, 1); | 
|---|
| 745 | uLastQuantityMsg := Piece(x, U, 2); | 
|---|
| 746 | Result := uLastDispenseMsg; | 
|---|
| 747 | end; | 
|---|
| 748 | end; | 
|---|
| 749 |  | 
|---|
| 750 | function QuantityMessage(AnIEN: Integer): string; | 
|---|
| 751 | var | 
|---|
| 752 | x: string; | 
|---|
| 753 | begin | 
|---|
| 754 | if AnIEN = uLastDispenseIEN then Result := uLastQuantityMsg else | 
|---|
| 755 | begin | 
|---|
| 756 | x := sCallV('ORWDPS32 DRUGMSG', [AnIEN]); | 
|---|
| 757 | uLastDispenseIEN := AnIEN; | 
|---|
| 758 | uLastDispenseMsg := Piece(x, U, 1); | 
|---|
| 759 | uLastQuantityMsg := Piece(x, U, 2); | 
|---|
| 760 | Result := uLastQuantityMsg; | 
|---|
| 761 | end; | 
|---|
| 762 | end; | 
|---|
| 763 |  | 
|---|
| 764 | function RequiresCopay(DispenseDrug: Integer): Boolean; | 
|---|
| 765 | begin | 
|---|
| 766 | Result := sCallV('ORWDPS32 SCSTS', [Patient.DFN, DispenseDrug]) = '1'; | 
|---|
| 767 | end; | 
|---|
| 768 |  | 
|---|
| 769 | procedure LoadFormularyAlt(AList: TStringList; AnIEN: Integer; PSType: Char); | 
|---|
| 770 | begin | 
|---|
| 771 | CallV('ORWDPS32 FORMALT', [AnIEN, PSType]); | 
|---|
| 772 | FastAssign(RPCBrokerV.Results, AList); | 
|---|
| 773 | end; | 
|---|
| 774 |  | 
|---|
| 775 | procedure LookupRoute(const AName: string; var ID, Abbreviation: string); | 
|---|
| 776 | var | 
|---|
| 777 | x: string; | 
|---|
| 778 | begin | 
|---|
| 779 | x := sCallV('ORWDPS32 VALROUTE', [AName]); | 
|---|
| 780 | ID := Piece(x, U, 1); | 
|---|
| 781 | Abbreviation := Piece(x, U, 2); | 
|---|
| 782 | end; | 
|---|
| 783 |  | 
|---|
| 784 | function MedIsSupply(AnIEN: Integer): Boolean; | 
|---|
| 785 | begin | 
|---|
| 786 | Result := sCallV('ORWDPS32 ISSPLY', [AnIEN]) = '1'; | 
|---|
| 787 | end; | 
|---|
| 788 |  | 
|---|
| 789 | function MedTypeIsIV(AnIEN: Integer): Boolean; | 
|---|
| 790 | begin | 
|---|
| 791 | Result := sCallV('ORWDPS32 MEDISIV', [AnIEN]) = '1'; | 
|---|
| 792 | end; | 
|---|
| 793 |  | 
|---|
| 794 | function ODForMedIn: TStrings; | 
|---|
| 795 | { Returns init values for inpatient meds dialog.  The results must be used immediately. } | 
|---|
| 796 | begin | 
|---|
| 797 | CallV('ORWDPS32 DLGSLCT', [PST_UNIT_DOSE, patient.dfn, patient.location]); | 
|---|
| 798 | Result := RPCBrokerV.Results; | 
|---|
| 799 | end; | 
|---|
| 800 |  | 
|---|
| 801 | function ODForIVFluids: TStrings; | 
|---|
| 802 | { Returns init values for IV Fluids dialog.  The results must be used immediately. } | 
|---|
| 803 | begin | 
|---|
| 804 | CallV('ORWDPS32 DLGSLCT', [PST_IV_FLUIDS, patient.dfn, patient.location]); | 
|---|
| 805 | Result := RPCBrokerV.Results; | 
|---|
| 806 | end; | 
|---|
| 807 |  | 
|---|
| 808 | function AmountsForIVFluid(AnIEN: Integer; FluidType: Char): string; | 
|---|
| 809 | begin | 
|---|
| 810 | Result := sCallV('ORWDPS32 IVAMT', [AnIEN, FluidType]); | 
|---|
| 811 | end; | 
|---|
| 812 |  | 
|---|
| 813 | function ODForMedOut: TStrings; | 
|---|
| 814 | { Returns init values for outpatient meds dialog.  The results must be used immediately. } | 
|---|
| 815 | begin | 
|---|
| 816 | CallV('ORWDPS32 DLGSLCT', [PST_OUTPATIENT, patient.dfn, patient.location]); | 
|---|
| 817 | Result := RPCBrokerV.Results; | 
|---|
| 818 | end; | 
|---|
| 819 |  | 
|---|
| 820 | function OIForMedIn(AnIEN: Integer): TStrings; | 
|---|
| 821 | { Returns init values for inpatient meds order item.  The results must be used immediately. } | 
|---|
| 822 | begin | 
|---|
| 823 | CallV('ORWDPS32 OISLCT', [AnIEN, PST_UNIT_DOSE, Patient.DFN]); | 
|---|
| 824 | Result := RPCBrokerV.Results; | 
|---|
| 825 | end; | 
|---|
| 826 |  | 
|---|
| 827 | function OIForMedOut(AnIEN: Integer): TStrings; | 
|---|
| 828 | { Returns init values for outpatient meds order item.  The results must be used immediately. } | 
|---|
| 829 | begin | 
|---|
| 830 | CallV('ORWDPS32 OISLCT', [AnIEN, PST_OUTPATIENT, Patient.DFN]); | 
|---|
| 831 | Result := RPCBrokerV.Results; | 
|---|
| 832 | end; | 
|---|
| 833 |  | 
|---|
| 834 | function RatedDisabilities: string; | 
|---|
| 835 | { Returns a list of rated disabilities, if any, for a patient } | 
|---|
| 836 | begin | 
|---|
| 837 | CallV('ORWPCE SCDIS', [Patient.DFN]); | 
|---|
| 838 | Result := RPCBrokerV.Results.Text; | 
|---|
| 839 | end; | 
|---|
| 840 |  | 
|---|
| 841 | procedure ValidateIVRate(var x: string); | 
|---|
| 842 | begin | 
|---|
| 843 | x := sCallV('ORWDPS32 VALRATE', [x]); | 
|---|
| 844 | end; | 
|---|
| 845 |  | 
|---|
| 846 | //function ValidIVRate(const x: string): Boolean; | 
|---|
| 847 | //{ returns true if the text entered as the IV rate is valid } | 
|---|
| 848 | //begin | 
|---|
| 849 | //  Result := sCallV('ORWDPS32 VALRATE', [x]) = '1'; | 
|---|
| 850 | //end; | 
|---|
| 851 |  | 
|---|
| 852 | function ValidSchedule(const x: string; PSType: Char = 'I'): Integer; | 
|---|
| 853 | { returns 1 if schedule is valid, 0 if schedule is not valid, -1 pharmacy routine not there } | 
|---|
| 854 | begin | 
|---|
| 855 | Result := StrToIntDef(sCallV('ORWDPS32 VALSCH', [x, PSType]), -1); | 
|---|
| 856 | end; | 
|---|
| 857 |  | 
|---|
| 858 | function ValidQuantity(const x: string): Boolean; | 
|---|
| 859 | { returns true if the text entered as the quantity is valid } | 
|---|
| 860 | begin | 
|---|
| 861 | Result := sCallV('ORWDPS32 VALQTY', [Trim(x)]) = '1'; | 
|---|
| 862 | end; | 
|---|
| 863 |  | 
|---|
| 864 | function ODForVitals: TStrings; | 
|---|
| 865 | { Returns init values for vitals dialog.  The results must be used immediately. } | 
|---|
| 866 | begin | 
|---|
| 867 | CallV('ORWDOR VMSLCT', [nil]); | 
|---|
| 868 | Result := RPCBrokerV.Results; | 
|---|
| 869 | end; | 
|---|
| 870 |  | 
|---|
| 871 | initialization | 
|---|
| 872 | uLastDispenseIEN := 0; | 
|---|
| 873 | uLastDispenseMsg := ''; | 
|---|
| 874 |  | 
|---|
| 875 | finalization | 
|---|
| 876 | if uMedRoutes <> nil then uMedRoutes.Free; | 
|---|
| 877 |  | 
|---|
| 878 | end. | 
|---|