[456] | 1 | unit rCore;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses SysUtils, Classes, Forms, ORNet, ORFn, ORClasses;
|
---|
| 6 |
|
---|
| 7 | { record types used to return data from the RPC's. Generally, the delimited strings returned
|
---|
| 8 | by the RPC are mapped into the records defined below. }
|
---|
| 9 |
|
---|
| 10 | const
|
---|
| 11 | UC_UNKNOWN = 0; // user class unknown
|
---|
| 12 | UC_CLERK = 1; // user class clerk
|
---|
| 13 | UC_NURSE = 2; // user class nurse
|
---|
| 14 | UC_PHYSICIAN = 3; // user class physician
|
---|
| 15 |
|
---|
| 16 | type
|
---|
| 17 | TUserInfo = record // record for ORWU USERINFO
|
---|
| 18 | DUZ: Int64;
|
---|
| 19 | Name: string;
|
---|
| 20 | UserClass: Integer;
|
---|
| 21 | CanSignOrders: Boolean;
|
---|
| 22 | IsProvider: Boolean;
|
---|
| 23 | OrderRole: Integer;
|
---|
| 24 | NoOrdering: Boolean;
|
---|
| 25 | DTIME: Integer;
|
---|
| 26 | CountDown: Integer;
|
---|
| 27 | EnableVerify: Boolean;
|
---|
| 28 | NotifyAppsWM: Boolean;
|
---|
| 29 | PtMsgHang: Integer;
|
---|
| 30 | Domain: string;
|
---|
| 31 | Service: Integer;
|
---|
| 32 | AutoSave: Integer;
|
---|
| 33 | InitialTab: Integer;
|
---|
| 34 | UseLastTab: Boolean;
|
---|
| 35 | WebAccess: Boolean;
|
---|
| 36 | IsRPL: string;
|
---|
| 37 | RPLList: string;
|
---|
| 38 | HasCorTabs: Boolean;
|
---|
| 39 | HasRptTab: Boolean;
|
---|
| 40 | IsReportsOnly: Boolean;
|
---|
| 41 | ToolsRptEdit: Boolean;
|
---|
| 42 | DisableHold: Boolean;
|
---|
| 43 | GECStatusCheck: Boolean;
|
---|
| 44 | StationNumber: string;
|
---|
| 45 | IsProductionAccount: boolean;
|
---|
| 46 | end;
|
---|
| 47 |
|
---|
| 48 | TPtIDInfo = record // record for ORWPT IDINFO
|
---|
| 49 | Name: string;
|
---|
| 50 | SSN: string;
|
---|
| 51 | DOB: string;
|
---|
| 52 | Age: string;
|
---|
| 53 | Sex: string;
|
---|
| 54 | SCSts: string;
|
---|
| 55 | Vet: string;
|
---|
| 56 | Location: string;
|
---|
| 57 | RoomBed: string;
|
---|
| 58 | //ADD VWPT BELOW FOR HRN
|
---|
| 59 | HRN : string;
|
---|
| 60 | AltHRN :string;
|
---|
| 61 | end;
|
---|
| 62 |
|
---|
| 63 | TPtSelect = record // record for ORWPT SELECT
|
---|
| 64 | Name: string;
|
---|
| 65 | ICN: string;
|
---|
| 66 | SSN: string;
|
---|
| 67 | DOB: TFMDateTime;
|
---|
| 68 | Age: Integer;
|
---|
| 69 | Sex: Char;
|
---|
| 70 | LocationIEN: Integer;
|
---|
| 71 | Location: string;
|
---|
| 72 | WardService: string;
|
---|
| 73 | RoomBed: string;
|
---|
| 74 | SpecialtyIEN: Integer;
|
---|
| 75 | CWAD: string;
|
---|
| 76 | Restricted: Boolean;
|
---|
| 77 | AdmitTime: TFMDateTime;
|
---|
| 78 | ServiceConnected: Boolean;
|
---|
| 79 | SCPercent: Integer;
|
---|
| 80 | PrimaryTeam: string;
|
---|
| 81 | PrimaryProvider: string;
|
---|
| 82 | Attending: string;
|
---|
| 83 | //ADD VWPT BELOW FOR HRN AltHRN
|
---|
| 84 | HRN : string;
|
---|
| 85 | AltHRN : string;
|
---|
| 86 | end;
|
---|
| 87 |
|
---|
| 88 | TEncounterText = record // record for ORWPT ENCTITL
|
---|
| 89 | LocationName: string;
|
---|
| 90 | LocationAbbr: string;
|
---|
| 91 | RoomBed: string;
|
---|
| 92 | ProviderName: string;
|
---|
| 93 | end;
|
---|
| 94 |
|
---|
| 95 | { Date/Time functions - right now these make server calls to use server time}
|
---|
| 96 |
|
---|
| 97 | function FMToday: TFMDateTime;
|
---|
| 98 | function FMNow: TFMDateTime;
|
---|
| 99 | function MakeRelativeDateTime(FMDateTime: TFMDateTime): string;
|
---|
| 100 | function StrToFMDateTime(const AString: string): TFMDateTime;
|
---|
| 101 | function ValidDateTimeStr(const AString, Flags: string): TFMDateTime;
|
---|
| 102 | procedure ListDateRangeClinic(Dest: TStrings);
|
---|
| 103 |
|
---|
| 104 | { General calls }
|
---|
| 105 |
|
---|
| 106 | function ExternalName(IEN: Int64; FileNumber: Double): string;
|
---|
| 107 | function PersonHasKey(APerson: Int64; const AKey: string): Boolean;
|
---|
| 108 | function GlobalRefForFile(const FileID: string): string;
|
---|
| 109 | function SubsetOfGeneric(const StartFrom: string; Direction: Integer; const GlobalRef: string): TStrings;
|
---|
| 110 | function SubsetOfDevices(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 111 | function SubSetOfPersons(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 112 | function SubSetOfActiveAndInactivePersons(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 113 | function GetDefaultPrinter(DUZ: Int64; Location: integer): string;
|
---|
| 114 |
|
---|
| 115 | { User specific calls }
|
---|
| 116 |
|
---|
| 117 | function GetUserInfo: TUserInfo;
|
---|
| 118 | function GetUserParam(const AParamName: string): string;
|
---|
[830] | 119 | procedure GetUserListParam(Dest: TStrings; const AParamName: string);
|
---|
[456] | 120 | function HasSecurityKey(const KeyName: string): Boolean;
|
---|
| 121 | function HasMenuOptionAccess(const OptionName: string): Boolean;
|
---|
| 122 | function ValidESCode(const ACode: string): Boolean;
|
---|
| 123 |
|
---|
| 124 | { Notifications calls }
|
---|
| 125 |
|
---|
| 126 | procedure LoadNotifications(Dest: TStrings);
|
---|
| 127 | procedure DeleteAlert(XQAID: string);
|
---|
| 128 | procedure DeleteAlertForUser(XQAID: string);
|
---|
| 129 | function GetXQAData(XQAID: string): string;
|
---|
| 130 | function GetTIUAlertInfo(XQAID: string): string;
|
---|
| 131 | procedure UpdateUnsignedOrderAlerts(PatientDFN: string);
|
---|
| 132 | function UnsignedOrderAlertFollowup(XQAID: string): string;
|
---|
| 133 | procedure UpdateExpiringMedAlerts(PatientDFN: string);
|
---|
| 134 | procedure UpdateExpiringFlaggedOIAlerts(PatientDFN: string; FollowUp: integer);
|
---|
| 135 | procedure AutoUnflagAlertedOrders(PatientDFN, XQAID: string);
|
---|
| 136 | procedure UpdateUnverifiedMedAlerts(PatientDFN: string);
|
---|
| 137 | procedure UpdateUnverifiedOrderAlerts(PatientDFN: string);
|
---|
| 138 | function GetNotificationFollowUpText(PatientDFN: string; Notification: integer; XQADATA: string): TStrings;
|
---|
| 139 | procedure ForwardAlert(XQAID: string; Recip: string; FWDtype: string; Comment: string);
|
---|
| 140 | procedure RenewAlert(XQAID: string);
|
---|
| 141 | function GetSortMethod: string;
|
---|
| 142 | procedure SetSortMethod(Sort: string; Direction: string);
|
---|
| 143 |
|
---|
| 144 | { Patient List calls }
|
---|
| 145 |
|
---|
| 146 | function DfltPtList: string;
|
---|
| 147 | function DfltPtListSrc: Char;
|
---|
| 148 | procedure SavePtListDflt(const x: string);
|
---|
| 149 | procedure ListSpecialtyAll(Dest: TStrings);
|
---|
| 150 | procedure ListTeamAll(Dest: TStrings);
|
---|
| 151 | procedure ListWardAll(Dest: TStrings);
|
---|
| 152 | procedure ListProviderTop(Dest: TStrings);
|
---|
| 153 | function SubSetOfProviders(const StartFrom: string; Direction: Integer): TStrings;
|
---|
[830] | 154 | function SubSetOfCosigners(const StartFrom: string; Direction: Integer; Date: TFMDateTime;
|
---|
| 155 | ADocType: integer; ATitle: integer): TStrings;
|
---|
[456] | 156 | procedure ListClinicTop(Dest: TStrings);
|
---|
| 157 | function SubSetOfClinics(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 158 | function GetDfltSort: string;
|
---|
| 159 | procedure ResetDfltSort;
|
---|
| 160 | procedure ListPtByDflt(Dest: TStrings);
|
---|
| 161 | procedure ListPtByProvider(Dest: TStrings; ProviderIEN: Int64);
|
---|
| 162 | procedure ListPtByTeam(Dest: TStrings; TeamIEN: Integer);
|
---|
| 163 | procedure ListPtBySpecialty(Dest: TStrings; SpecialtyIEN: Integer);
|
---|
| 164 | procedure ListPtByClinic(Dest: TStrings; ClinicIEN: Integer; FirstDt, LastDt: string);
|
---|
| 165 | procedure ListPtByWard(Dest: TStrings; WardIEN: Integer);
|
---|
| 166 | procedure ListPtByLast5(Dest: TStrings; const Last5: string);
|
---|
| 167 | procedure ListPtByRPLLast5(Dest: TStrings; const Last5: string);
|
---|
| 168 | procedure ListPtByFullSSN(Dest: TStrings; const FullSSN: string);
|
---|
| 169 | procedure ListPtByRPLFullSSN(Dest: TStrings; const FullSSN: string);
|
---|
| 170 | procedure ListPtTop(Dest: TStrings);
|
---|
| 171 | function SubSetOfPatients(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 172 | function DfltDateRangeClinic: string;
|
---|
| 173 | function MakeRPLPtList(RPLList: string): string;
|
---|
| 174 | function ReadRPLPtList(RPLJobNumber: string; const StartFrom: string; Direction: Integer) : TStrings;
|
---|
| 175 | procedure KillRPLPtList(RPLJobNumber: string);
|
---|
| 176 |
|
---|
| 177 | // VWPT ADDITIONS FOR ENHANCED PATIENT LOOKUP
|
---|
| 178 | procedure ListPtByOther (Dest: Tstrings; const othertext: string ;caption :string);//:string; radbutton:Tobject);
|
---|
| 179 | procedure ListPtByTimson (Dest: Tstrings; const othertext: string);
|
---|
| 180 | //end VWPT
|
---|
| 181 |
|
---|
| 182 | { Patient specific calls }
|
---|
| 183 |
|
---|
| 184 | function CalcAge(BirthDate, DeathDate: TFMDateTime): Integer;
|
---|
| 185 | procedure CheckSensitiveRecordAccess(const DFN: string; var AccessStatus: Integer;
|
---|
| 186 | var MessageText: string);
|
---|
| 187 | procedure CheckRemotePatient(var Dest: string; Patient, ASite: string; var AccessStatus: Integer);
|
---|
| 188 | procedure CurrentLocationForPatient(const DFN: string; var ALocation: Integer; var AName: string; var ASvc: string);
|
---|
| 189 | function DateOfDeath(const DFN: string): TFMDateTime;
|
---|
| 190 | function GetPtIDInfo(const DFN: string): TPtIDInfo;
|
---|
| 191 | function HasLegacyData(const DFN: string; var AMsg: string): Boolean;
|
---|
| 192 | function LogSensitiveRecordAccess(const DFN: string): Boolean;
|
---|
| 193 | function MeansTestRequired(const DFN: string; var AMsg: string): Boolean;
|
---|
| 194 | function RestrictedPtRec(const DFN: string): Boolean;
|
---|
| 195 | procedure SelectPatient(const DFN: string; var PtSelect: TPtSelect);
|
---|
| 196 | function SimilarRecordsFound(const DFN: string; var AMsg: string): Boolean;
|
---|
| 197 | function GetDFNFromICN(AnICN: string): string;
|
---|
| 198 |
|
---|
| 199 | { Encounter specific calls }
|
---|
| 200 |
|
---|
| 201 | function GetEncounterText(const DFN: string; Location: integer; Provider: Int64): TEncounterText; //*DFN*
|
---|
| 202 | procedure ListApptAll(Dest: TStrings; const DFN: string; From: TFMDateTime = 0;
|
---|
| 203 | Thru: TFMDateTime = 0);
|
---|
| 204 | procedure ListAdmitAll(Dest: TStrings; const DFN: string);
|
---|
| 205 | function SubSetOfLocations(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 206 | function SubSetOfNewLocs(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 207 | function SubSetOfInpatientLocations(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 208 | function SubSetOfProvWithClass(const StartFrom: string; Direction: Integer; DateTime: string): TStrings;
|
---|
| 209 | function SubSetOfUsersWithClass(const StartFrom: string; Direction: Integer; DateTime: string): TStrings;
|
---|
| 210 |
|
---|
| 211 | { Remote Data Access calls }
|
---|
| 212 | function HasRemoteData(const DFN: string; var ALocations: TStringList): Boolean;
|
---|
| 213 | function CheckHL7TCPLink: Boolean;
|
---|
| 214 | function GetVistaWebAddress(value: string): string;
|
---|
| 215 |
|
---|
| 216 | implementation
|
---|
| 217 |
|
---|
| 218 | uses Hash, uCore, ShlObj, Windows;
|
---|
| 219 |
|
---|
| 220 | var
|
---|
| 221 | uPtListDfltSort: string = ''; // Current user's patient selection list default sort order.
|
---|
| 222 |
|
---|
| 223 | { private calls }
|
---|
| 224 |
|
---|
| 225 | function FormatSSN(const x: string): string;
|
---|
[830] | 226 | { places the dashes in a social security number }
|
---|
[456] | 227 | //vwpt code 4/17/0 see below
|
---|
| 228 | var
|
---|
| 229 |
|
---|
| 230 | i:Integer;
|
---|
| 231 | //end vwpt
|
---|
| 232 | begin
|
---|
| 233 | //vwpt code to prevent extra dashes 4/17/07
|
---|
| 234 | Result := x;
|
---|
| 235 | ///take out for i := 1 to Length(x) do if (x[i] in ['-'..'-']) then Exit;
|
---|
| 236 | //end vwpt
|
---|
| 237 | if Length(x) > 8
|
---|
| 238 | then Result := Copy(x,1,3) + '-' + Copy(x,4,2) + '-' + Copy(x,6,Length(x))
|
---|
| 239 | else Result := x;
|
---|
| 240 | end;
|
---|
| 241 |
|
---|
| 242 | function IsSSN(const x: string): Boolean;
|
---|
| 243 | var
|
---|
| 244 | i: Integer;
|
---|
| 245 | begin
|
---|
| 246 | Result := False;
|
---|
| 247 | if (Length(x) < 9) or (Length(x) > 10) then Exit;
|
---|
| 248 | for i := 1 to 9 do if not (x[i] in ['0'..'9']) then Exit;
|
---|
| 249 | Result := True;
|
---|
| 250 | end;
|
---|
| 251 |
|
---|
| 252 | function IsFMDate(const x: string): Boolean;
|
---|
| 253 | var
|
---|
| 254 | i: Integer;
|
---|
| 255 | begin
|
---|
| 256 | Result := False;
|
---|
| 257 | if Length(x) <> 7 then Exit;
|
---|
| 258 | for i := 1 to 7 do if not (x[i] in ['0'..'9']) then Exit;
|
---|
| 259 | Result := True;
|
---|
| 260 | end;
|
---|
| 261 |
|
---|
| 262 | { Date/Time functions - not in ORFn because they make server calls to use server time}
|
---|
| 263 |
|
---|
| 264 | function FMToday: TFMDateTime;
|
---|
| 265 | { return the current date in Fileman format }
|
---|
| 266 | begin
|
---|
[830] | 267 | Result := Int(FMNow);
|
---|
[456] | 268 | end;
|
---|
| 269 |
|
---|
| 270 | function FMNow: TFMDateTime;
|
---|
| 271 | { return the current date/time in Fileman format }
|
---|
| 272 | var
|
---|
| 273 | x: string;
|
---|
| 274 | begin
|
---|
| 275 | x := sCallV('ORWU DT', ['NOW']);
|
---|
| 276 | Result := StrToFloat(x);
|
---|
| 277 | end;
|
---|
| 278 |
|
---|
| 279 | function MakeRelativeDateTime(FMDateTime: TFMDateTime): string;
|
---|
| 280 | var
|
---|
| 281 | Offset: Integer;
|
---|
| 282 | h,n,s,l: Word;
|
---|
| 283 | ADateTime: TDateTime;
|
---|
| 284 | ATime: string;
|
---|
| 285 | begin
|
---|
| 286 | Result := '';
|
---|
| 287 | if FMDateTime <= 0 then Exit;
|
---|
| 288 | ADateTime := FMDateTimeToDateTime(FMDateTime);
|
---|
| 289 | Offset := Trunc(Int(ADateTime) - Int(FMDateTimeToDateTime(FMToday)));
|
---|
| 290 | if Offset < 0 then Result := 'T' + IntToStr(Offset)
|
---|
| 291 | else if Offset = 0 then Result := 'T'
|
---|
| 292 | else Result := 'T+' + IntToStr(Offset);
|
---|
| 293 | DecodeTime(ADateTime, h, n, s, l);
|
---|
| 294 | ATime := Format('@%.2d:%.2d', [h, n]);
|
---|
| 295 | if ATime <> '@00:00' then Result := Result + ATime;
|
---|
| 296 | end;
|
---|
| 297 |
|
---|
| 298 | function StrToFMDateTime(const AString: string): TFMDateTime;
|
---|
| 299 | { use %DT the validate and convert a string to Fileman format (accepts T, T-1, NOW, etc.) }
|
---|
| 300 | var
|
---|
| 301 | x: string;
|
---|
| 302 | begin
|
---|
| 303 | x := sCallV('ORWU DT', [AString]);
|
---|
| 304 | Result := StrToFloat(x);
|
---|
| 305 | end;
|
---|
| 306 |
|
---|
| 307 | function ValidDateTimeStr(const AString, Flags: string): TFMDateTime;
|
---|
| 308 | { use %DT to validate & convert a string to Fileman format, accepts %DT flags }
|
---|
| 309 | begin
|
---|
| 310 | Result := StrToFloat(sCallV('ORWU VALDT', [AString, Flags]));
|
---|
| 311 | end;
|
---|
| 312 |
|
---|
| 313 | procedure ListDateRangeClinic(Dest: TStrings);
|
---|
| 314 | { returns date ranges for displaying clinic appointments in patient lookup }
|
---|
| 315 | begin
|
---|
| 316 | CallV('ORWPT CLINRNG', [nil]);
|
---|
[830] | 317 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 318 | end;
|
---|
| 319 |
|
---|
| 320 | function DfltDateRangeClinic;
|
---|
| 321 | { returns current default date range settings for displaying clinic appointments in patient lookup }
|
---|
| 322 | begin
|
---|
| 323 | Result := sCallV('ORQPT DEFAULT CLINIC DATE RANG', [nil]);
|
---|
| 324 | end;
|
---|
| 325 |
|
---|
| 326 | { General calls }
|
---|
| 327 |
|
---|
| 328 | function ExternalName(IEN: Int64; FileNumber: Double): string;
|
---|
| 329 | { returns the external name of the IEN within a file }
|
---|
| 330 | begin
|
---|
| 331 | Result := sCallV('ORWU EXTNAME', [IEN, FileNumber]);
|
---|
| 332 | end;
|
---|
| 333 |
|
---|
| 334 | function PersonHasKey(APerson: Int64; const AKey: string): Boolean;
|
---|
| 335 | begin
|
---|
| 336 | Result := sCallV('ORWU NPHASKEY', [APerson, AKey]) = '1';
|
---|
| 337 | end;
|
---|
| 338 |
|
---|
| 339 | function GlobalRefForFile(const FileID: string): string;
|
---|
| 340 | begin
|
---|
| 341 | Result := sCallV('ORWU GBLREF', [FileID]);
|
---|
| 342 | end;
|
---|
| 343 |
|
---|
| 344 | function SubsetOfGeneric(const StartFrom: string; Direction: Integer; const GlobalRef: string): TStrings;
|
---|
| 345 | begin
|
---|
| 346 | CallV('ORWU GENERIC', [StartFrom, Direction, GlobalRef]);
|
---|
| 347 | Result := RPCBrokerV.Results;
|
---|
| 348 | end;
|
---|
| 349 |
|
---|
| 350 | function SubsetOfDevices(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 351 | { returns a pointer to a list of devices (for use in a long list box) - The return value is
|
---|
| 352 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 353 | begin
|
---|
| 354 | CallV('ORWU DEVICE', [StartFrom, Direction]);
|
---|
| 355 | Result := RPCBrokerV.Results;
|
---|
| 356 | end;
|
---|
| 357 |
|
---|
| 358 | function SubSetOfPersons(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 359 | { returns a pointer to a list of persons (for use in a long list box) - The return value is
|
---|
| 360 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 361 | begin
|
---|
| 362 | CallV('ORWU NEWPERS', [StartFrom, Direction]);
|
---|
| 363 | // MixedCaseList(RPCBrokerV.Results);
|
---|
| 364 | Result := RPCBrokerV.Results;
|
---|
| 365 | end;
|
---|
| 366 |
|
---|
| 367 | { User specific calls }
|
---|
| 368 |
|
---|
| 369 | function GetUserInfo: TUserInfo;
|
---|
| 370 | { returns a record of user information,
|
---|
| 371 | Pieces: DUZ^NAME^USRCLS^CANSIGN^ISPROVIDER^ORDERROLE^NOORDER^DTIME^CNTDN^VERORD^NOTIFYAPPS^
|
---|
| 372 | MSGHANG^DOMAIN^SERVICE^AUTOSAVE^INITTAB^LASTTAB^WEBACCESS^ALLOWHOLD^ISRPL^RPLLIST^
|
---|
| 373 | CORTABS^RPTTAB^STATION#^GECStatus^Production account?}
|
---|
| 374 | var
|
---|
| 375 | x: string;
|
---|
| 376 | begin
|
---|
| 377 | x := sCallV('ORWU USERINFO', [nil]);
|
---|
| 378 | with Result do
|
---|
| 379 | begin
|
---|
| 380 | DUZ := StrToInt64Def(Piece(x, U, 1), 0);
|
---|
| 381 | Name := Piece(x, U, 2);
|
---|
| 382 | UserClass := StrToIntDef(Piece(x, U, 3), 0);
|
---|
| 383 | CanSignOrders := Piece(x, U, 4) = '1';
|
---|
| 384 | IsProvider := Piece(x, U, 5) = '1';
|
---|
| 385 | OrderRole := StrToIntDef(Piece(x, U, 6), 0);
|
---|
| 386 | NoOrdering := Piece(x, U, 7) = '1';
|
---|
| 387 | DTIME := StrToIntDef(Piece(x, U, 8), 300);
|
---|
| 388 | CountDown := StrToIntDef(Piece(x, U, 9), 10);
|
---|
| 389 | EnableVerify := Piece(x, U, 10) = '1';
|
---|
| 390 | NotifyAppsWM := Piece(x, U, 11) = '1';
|
---|
| 391 | PtMsgHang := StrToIntDef(Piece(x, U, 12), 5);
|
---|
| 392 | Domain := Piece(x, U, 13);
|
---|
| 393 | Service := StrToIntDef(Piece(x, U, 14), 0);
|
---|
| 394 | AutoSave := StrToIntDef(Piece(x, U, 15), 180);
|
---|
| 395 | InitialTab := StrToIntDef(Piece(x, U, 16), 1);
|
---|
| 396 | UseLastTab := Piece(x, U, 17) = '1';
|
---|
| 397 | WebAccess := Piece(x, U, 18) <> '1';
|
---|
| 398 | DisableHold := Piece(x, U, 19) = '1';
|
---|
| 399 | IsRPL := Piece(x, U, 20);
|
---|
| 400 | RPLList := Piece(x, U, 21);
|
---|
| 401 | HasCorTabs := Piece(x, U, 22) = '1';
|
---|
| 402 | HasRptTab := Piece(x, U, 23) = '1';
|
---|
| 403 | StationNumber := Piece(x, U, 24);
|
---|
| 404 | GECStatusCheck := Piece(x, U, 25) = '1';
|
---|
| 405 | IsProductionAccount := Piece(x, U, 26) = '1';
|
---|
| 406 | IsReportsOnly := false;
|
---|
| 407 | if ((HasRptTab) and (not HasCorTabs)) then
|
---|
| 408 | IsReportsOnly := true;
|
---|
| 409 | // Remove next if and nested if should an "override" later be provided for RPL users,etc.:
|
---|
| 410 | if HasCorTabs then
|
---|
| 411 | if (IsRPL = '1') then
|
---|
| 412 | begin
|
---|
| 413 | IsRPL := '0'; // Hard set for now.
|
---|
| 414 | IsReportsOnly := false;
|
---|
| 415 | end;
|
---|
| 416 | // Following hard set to TRUE per VHA mgt decision:
|
---|
| 417 | ToolsRptEdit := true;
|
---|
| 418 | // x := GetUserParam('ORWT TOOLS RPT SETTINGS OFF');
|
---|
| 419 | // if x = '1' then
|
---|
| 420 | // ToolsRptEdit := false;
|
---|
| 421 | end;
|
---|
| 422 | end;
|
---|
| 423 |
|
---|
| 424 | function GetUserParam(const AParamName: string): string;
|
---|
| 425 | begin
|
---|
| 426 | Result := sCallV('ORWU PARAM', [AParamName]);
|
---|
| 427 | end;
|
---|
| 428 |
|
---|
[830] | 429 | procedure GetUserListParam(Dest: TStrings; const AParamName: string);
|
---|
| 430 | var
|
---|
| 431 | tmplst: TStringList;
|
---|
| 432 | begin
|
---|
| 433 | tmplst := TStringList.Create;
|
---|
| 434 | try
|
---|
| 435 | tCallV(tmplst, 'ORWU PARAMS', [AParamName]);
|
---|
| 436 | FastAssign(tmplst, Dest);
|
---|
| 437 | finally
|
---|
| 438 | tmplst.Free;
|
---|
| 439 | end;
|
---|
| 440 | end;
|
---|
| 441 |
|
---|
[456] | 442 | function HasSecurityKey(const KeyName: string): Boolean;
|
---|
| 443 | { returns true if the currently logged in user has a given security key }
|
---|
| 444 | var
|
---|
| 445 | x: string;
|
---|
| 446 | begin
|
---|
| 447 | Result := False;
|
---|
| 448 | x := sCallV('ORWU HASKEY', [KeyName]);
|
---|
| 449 | if x = '1' then Result := True;
|
---|
| 450 | end;
|
---|
| 451 |
|
---|
| 452 | function HasMenuOptionAccess(const OptionName: string): Boolean;
|
---|
| 453 | begin
|
---|
| 454 | Result := (sCallV('ORWU HAS OPTION ACCESS', [OptionName]) = '1');
|
---|
| 455 | end;
|
---|
| 456 |
|
---|
| 457 | function ValidESCode(const ACode: string): Boolean;
|
---|
| 458 | { returns true if the electronic signature code in ACode is valid }
|
---|
| 459 | begin
|
---|
| 460 | Result := sCallV('ORWU VALIDSIG', [Encrypt(ACode)]) = '1';
|
---|
| 461 | end;
|
---|
| 462 |
|
---|
| 463 | { Notifications Calls }
|
---|
| 464 |
|
---|
| 465 | procedure LoadNotifications(Dest: TStrings);
|
---|
| 466 | var
|
---|
| 467 | tmplst: TStringList;
|
---|
| 468 | begin
|
---|
| 469 | tmplst := TStringList.Create;
|
---|
| 470 | try
|
---|
| 471 | //UpdateUnsignedOrderAlerts(Patient.DFN); //moved to AFTER signature and DC actions
|
---|
| 472 | tCallV(tmplst, 'ORWORB FASTUSER', [nil]);
|
---|
[830] | 473 | FastAssign(tmplst, Dest);
|
---|
[456] | 474 | finally
|
---|
| 475 | tmplst.Free;
|
---|
| 476 | end;
|
---|
| 477 | end;
|
---|
| 478 |
|
---|
| 479 | procedure UpdateUnsignedOrderAlerts(PatientDFN: string);
|
---|
| 480 | begin
|
---|
| 481 | CallV('ORWORB KILL UNSIG ORDERS ALERT',[PatientDFN]);
|
---|
| 482 | end;
|
---|
| 483 |
|
---|
| 484 | function UnsignedOrderAlertFollowup(XQAID: string): string;
|
---|
| 485 | begin
|
---|
| 486 | Result := sCallV('ORWORB UNSIG ORDERS FOLLOWUP',[XQAID]);
|
---|
| 487 | end;
|
---|
| 488 |
|
---|
| 489 | procedure UpdateExpiringMedAlerts(PatientDFN: string);
|
---|
| 490 | begin
|
---|
| 491 | CallV('ORWORB KILL EXPIR MED ALERT',[PatientDFN]);
|
---|
| 492 | end;
|
---|
| 493 |
|
---|
| 494 | procedure UpdateExpiringFlaggedOIAlerts(PatientDFN: string; FollowUp: integer);
|
---|
| 495 | begin
|
---|
| 496 | CallV('ORWORB KILL EXPIR OI ALERT',[PatientDFN, FollowUp]);
|
---|
| 497 | end;
|
---|
| 498 |
|
---|
| 499 | procedure UpdateUnverifiedMedAlerts(PatientDFN: string);
|
---|
| 500 | begin
|
---|
| 501 | CallV('ORWORB KILL UNVER MEDS ALERT',[PatientDFN]);
|
---|
| 502 | end;
|
---|
| 503 |
|
---|
| 504 | procedure UpdateUnverifiedOrderAlerts(PatientDFN: string);
|
---|
| 505 | begin
|
---|
| 506 | CallV('ORWORB KILL UNVER ORDERS ALERT',[PatientDFN]);
|
---|
| 507 | end;
|
---|
| 508 |
|
---|
| 509 | procedure AutoUnflagAlertedOrders(PatientDFN, XQAID: string);
|
---|
| 510 | begin
|
---|
| 511 | CallV('ORWORB AUTOUNFLAG ORDERS',[PatientDFN, XQAID]);
|
---|
| 512 | end;
|
---|
| 513 |
|
---|
| 514 | procedure DeleteAlert(XQAID: string);
|
---|
| 515 | //deletes an alert
|
---|
| 516 | begin
|
---|
| 517 | CallV('ORB DELETE ALERT',[XQAID]);
|
---|
| 518 | end;
|
---|
| 519 |
|
---|
| 520 | procedure DeleteAlertForUser(XQAID: string);
|
---|
| 521 | //deletes an alert
|
---|
| 522 | begin
|
---|
| 523 | CallV('ORB DELETE ALERT',[XQAID, True]);
|
---|
| 524 | end;
|
---|
| 525 |
|
---|
| 526 | procedure ForwardAlert(XQAID: string; Recip: string; FWDtype: string; Comment: string);
|
---|
| 527 | // Forwards an alert with comment to Recip[ient]
|
---|
| 528 | begin
|
---|
| 529 | CallV('ORB FORWARD ALERT', [XQAID, Recip, FWDtype, Comment]);
|
---|
| 530 | end;
|
---|
| 531 |
|
---|
| 532 | procedure RenewAlert(XQAID: string);
|
---|
| 533 | // Restores/renews an alert
|
---|
| 534 | begin
|
---|
| 535 | CallV('ORB RENEW ALERT', [XQAID]);
|
---|
| 536 | end;
|
---|
| 537 |
|
---|
| 538 | function GetSortMethod: string;
|
---|
| 539 | // Returns alert sort method
|
---|
| 540 | begin
|
---|
| 541 | Result := sCallV('ORWORB GETSORT',[nil]);
|
---|
| 542 | end;
|
---|
| 543 |
|
---|
| 544 | procedure SetSortMethod(Sort: string; Direction: string);
|
---|
| 545 | // Sets alert sort method for user
|
---|
| 546 | begin
|
---|
| 547 | CallV('ORWORB SETSORT', [Sort, Direction]);
|
---|
| 548 | end;
|
---|
| 549 |
|
---|
| 550 | function GetXQAData(XQAID: string): string;
|
---|
| 551 | // Returns data associated with an alert
|
---|
| 552 | begin
|
---|
| 553 | Result := sCallV('ORWORB GETDATA',[XQAID]);
|
---|
| 554 | end;
|
---|
| 555 |
|
---|
| 556 | function GetTIUAlertInfo(XQAID: string): string;
|
---|
| 557 | // Returns DFN and document type associated with a TIU alert
|
---|
| 558 | begin
|
---|
| 559 | Result := sCallV('TIU GET ALERT INFO',[XQAID]);
|
---|
| 560 | end;
|
---|
| 561 |
|
---|
| 562 | function GetNotificationFollowUpText(PatientDFN: string; Notification: integer; XQADATA: string): TStrings;
|
---|
| 563 | // Returns follow-up text for an alert
|
---|
| 564 | begin
|
---|
| 565 | CallV('ORWORB TEXT FOLLOWUP', [PatientDFN, Notification, XQADATA]);
|
---|
| 566 | Result := RPCBrokerV.Results;
|
---|
| 567 | end;
|
---|
| 568 |
|
---|
| 569 | { Patient List Calls }
|
---|
| 570 |
|
---|
| 571 | function DfltPtList: string;
|
---|
| 572 | { returns the name of the current user's default patient list, null if none is defined
|
---|
| 573 | Pieces: Ptr to Source File^Source Name^Source Type }
|
---|
| 574 | begin
|
---|
| 575 | Result := sCallV('ORQPT DEFAULT LIST SOURCE', [nil]);
|
---|
| 576 | if Length(Result) > 0 then Result := Pieces(Result, U, 2, 3);
|
---|
| 577 | end;
|
---|
| 578 |
|
---|
| 579 | function DfltPtListSrc: Char;
|
---|
| 580 | begin
|
---|
| 581 | Result := CharAt(sCallV('ORWPT DFLTSRC', [nil]), 1);
|
---|
| 582 | end;
|
---|
| 583 |
|
---|
| 584 | procedure SavePtListDflt(const x: string);
|
---|
| 585 | begin
|
---|
| 586 | CallV('ORWPT SAVDFLT', [x]);
|
---|
| 587 | end;
|
---|
| 588 |
|
---|
| 589 | procedure ListSpecialtyAll(Dest: TStrings);
|
---|
| 590 | { lists all treating specialties: IEN^Treating Specialty Name }
|
---|
| 591 | begin
|
---|
| 592 | CallV('ORQPT SPECIALTIES', [nil]);
|
---|
| 593 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 594 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 595 | end;
|
---|
| 596 |
|
---|
| 597 | procedure ListTeamAll(Dest: TStrings);
|
---|
| 598 | { lists all patient care teams: IEN^Team Name }
|
---|
| 599 | begin
|
---|
| 600 | CallV('ORQPT TEAMS', [nil]);
|
---|
| 601 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 602 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 603 | end;
|
---|
| 604 |
|
---|
| 605 | procedure ListWardAll(Dest: TStrings);
|
---|
| 606 | { lists all active inpatient wards: IEN^Ward Name }
|
---|
| 607 | begin
|
---|
| 608 | CallV('ORQPT WARDS', [nil]);
|
---|
| 609 | //MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 610 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 611 | end;
|
---|
| 612 |
|
---|
| 613 | procedure ListProviderTop(Dest: TStrings);
|
---|
| 614 | { checks parameters for list of commonly selected providers }
|
---|
| 615 | begin
|
---|
| 616 | end;
|
---|
| 617 |
|
---|
| 618 | function SubSetOfProviders(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 619 | { returns a pointer to a list of providers (for use in a long list box) - The return value is
|
---|
| 620 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 621 | begin
|
---|
| 622 | CallV('ORWU NEWPERS', [StartFrom, Direction, 'PROVIDER']);
|
---|
| 623 | // MixedCaseList(RPCBrokerV.Results);
|
---|
| 624 | Result := RPCBrokerV.Results;
|
---|
| 625 | end;
|
---|
| 626 |
|
---|
[830] | 627 | function SubSetOfCosigners(const StartFrom: string; Direction: Integer; Date: TFMDateTime;
|
---|
| 628 | ADocType: integer; ATitle: integer): TStrings;
|
---|
| 629 | { returns a pointer to a list of cosigners (for use in a long list box) - The return value is
|
---|
| 630 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 631 | begin
|
---|
| 632 | if ATitle > 0 then ADocType := 0;
|
---|
| 633 | // CQ #17218 - Correcting order of parameters for this call
|
---|
| 634 | // CallV('ORWU2 COSIGNER', [StartFrom, Direction, Date, ATitle, ADocType]);
|
---|
| 635 | CallV('ORWU2 COSIGNER', [StartFrom, Direction, Date, ADocType, ATitle]);
|
---|
| 636 |
|
---|
| 637 | // MixedCaseList(RPCBrokerV.Results);
|
---|
| 638 | Result := RPCBrokerV.Results;
|
---|
| 639 | end;
|
---|
| 640 |
|
---|
[456] | 641 | function SubSetOfProvWithClass(const StartFrom: string; Direction: Integer; DateTime: string): TStrings;
|
---|
| 642 | { returns a pointer to a list of providers (for use in a long list box) - The return value is
|
---|
| 643 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 644 | begin
|
---|
| 645 | CallV('ORWU NEWPERS', [StartFrom, Direction, 'PROVIDER', DateTime]);
|
---|
| 646 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 647 | Result := RPCBrokerV.Results;
|
---|
| 648 | end;
|
---|
| 649 |
|
---|
| 650 | function SubSetOfUsersWithClass(const StartFrom: string; Direction: Integer; DateTime: string): TStrings;
|
---|
| 651 | { returns a pointer to a list of users (for use in a long list box) - The return value is
|
---|
| 652 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 653 | begin
|
---|
| 654 | CallV('ORWU NEWPERS', [StartFrom, Direction, '', DateTime]);
|
---|
| 655 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 656 | Result := RPCBrokerV.Results;
|
---|
| 657 | end;
|
---|
| 658 |
|
---|
| 659 | function SubSetOfActiveAndInactivePersons(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 660 | { returns a pointer to a list of users (for use in a long list box) - The return value is
|
---|
| 661 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call!}
|
---|
| 662 | begin
|
---|
| 663 | CallV('ORWU NEWPERS', [StartFrom, Direction, '', '', '', True]); //TRUE = return all active and inactive users
|
---|
| 664 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 665 | Result := RPCBrokerV.Results;
|
---|
| 666 | end;
|
---|
| 667 |
|
---|
| 668 |
|
---|
| 669 | procedure ListClinicTop(Dest: TStrings);
|
---|
| 670 | { checks parameters for list of commonly selected clinics }
|
---|
| 671 | begin
|
---|
| 672 | end;
|
---|
| 673 |
|
---|
| 674 | function SubSetOfClinics(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 675 | { returns a pointer to a list of clinics (for use in a long list box) - The return value is
|
---|
| 676 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 677 | begin
|
---|
| 678 | CallV('ORWU CLINLOC', [StartFrom, Direction]);
|
---|
| 679 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 680 | Result := RPCBrokerV.Results;
|
---|
| 681 | end;
|
---|
| 682 |
|
---|
| 683 | function GetDfltSort: string;
|
---|
| 684 | { Assigns uPtLstDfltSort to user's default patient list sort order (string character).}
|
---|
| 685 | begin
|
---|
| 686 | uPtListDfltSort := sCallV('ORQPT DEFAULT LIST SORT', [nil]);
|
---|
| 687 | if uPtListDfltSort = '' then uPtListDfltSort := 'A'; // Default is always "A" for alpha.
|
---|
| 688 | result := uPtListDfltSort;
|
---|
| 689 | end;
|
---|
| 690 |
|
---|
| 691 | procedure ResetDfltSort;
|
---|
| 692 | begin
|
---|
| 693 | uPtListDfltSort := '';
|
---|
| 694 | end;
|
---|
| 695 |
|
---|
| 696 | procedure ListPtByDflt(Dest: TStrings);
|
---|
| 697 | { loads the default patient list into Dest, Pieces: DFN^PATIENT NAME, ETC. }
|
---|
| 698 | var
|
---|
| 699 | i, SourceType: Integer;
|
---|
| 700 | ATime, APlace, Sort, Source, x: string;
|
---|
| 701 | tmplst: TORStringList;
|
---|
| 702 | begin
|
---|
| 703 | Sort := GetDfltSort();
|
---|
| 704 | tmplst := TORStringList.Create;
|
---|
| 705 | try
|
---|
| 706 | tCallV(tmplst, 'ORQPT DEFAULT PATIENT LIST', [nil]);
|
---|
| 707 | Source := sCallV('ORWPT DFLTSRC', [nil]);
|
---|
| 708 | if Source = 'C' then // Clinics.
|
---|
| 709 | begin
|
---|
| 710 | if Sort = 'P' then // "Appointments" sort.
|
---|
| 711 | SortByPiece(tmplst, U, 4)
|
---|
| 712 | else
|
---|
| 713 | SortByPiece(tmplst, U, 2);
|
---|
| 714 | for i := 0 to tmplst.Count - 1 do
|
---|
| 715 | begin
|
---|
| 716 | x := tmplst[i];
|
---|
| 717 | ATime := Piece(x, U, 4);
|
---|
| 718 | APlace := Piece(x, U, 3);
|
---|
| 719 | ATime := FormatFMDateTime('hh:nn mmm dd, yyyy', MakeFMDateTime(ATime));
|
---|
| 720 | SetPiece(x, U, 3, ATime);
|
---|
| 721 | x := x + U + APlace;
|
---|
| 722 | tmplst[i] := x;
|
---|
| 723 | end;
|
---|
| 724 | end
|
---|
| 725 | else
|
---|
| 726 | begin
|
---|
| 727 | SourceType := 0; // Default.
|
---|
| 728 | if Source = 'M' then SourceType := 1; // Combinations.
|
---|
| 729 | if Source = 'W' then SourceType := 2; // Wards.
|
---|
| 730 | case SourceType of
|
---|
| 731 | 1 : if Sort = 'S' then tmplst.SortByPieces([3, 8, 2]) // "Source" sort.
|
---|
| 732 | else if Sort = 'P' then tmplst.SortByPieces([8, 2]) // "Appointment" sort.
|
---|
| 733 | else if Sort = 'T' then SortByPiece(tmplst, U, 5) // "Terminal Digit" sort.
|
---|
| 734 | else SortByPiece(tmplst, U, 2); // "Alphabetical" (also the default) sort.
|
---|
| 735 | 2 : if Sort = 'R' then tmplst.SortByPieces([3, 2])
|
---|
| 736 | else SortByPiece(tmplst, U, 2);
|
---|
| 737 | else SortByPiece(tmplst, U, 2);
|
---|
| 738 | end;
|
---|
| 739 | end;
|
---|
| 740 | MixedCaseList(tmplst);
|
---|
[830] | 741 | FastAssign(tmplst, Dest);
|
---|
[456] | 742 | finally
|
---|
| 743 | tmplst.Free;
|
---|
| 744 | end;
|
---|
| 745 | end;
|
---|
| 746 |
|
---|
| 747 | procedure ListPtByProvider(Dest: TStrings; ProviderIEN: Int64);
|
---|
| 748 | { lists all patients associated with a given provider: DFN^Patient Name }
|
---|
| 749 | begin
|
---|
| 750 | CallV('ORQPT PROVIDER PATIENTS', [ProviderIEN]);
|
---|
| 751 | SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 752 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 753 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 754 | end;
|
---|
| 755 |
|
---|
| 756 | procedure ListPtByTeam(Dest: TStrings; TeamIEN: Integer);
|
---|
| 757 | { lists all patients associated with a given team: DFN^Patient Name }
|
---|
| 758 | begin
|
---|
| 759 | CallV('ORQPT TEAM PATIENTS', [TeamIEN]);
|
---|
| 760 | SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 761 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 762 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 763 | end;
|
---|
| 764 |
|
---|
| 765 | procedure ListPtBySpecialty(Dest: TStrings; SpecialtyIEN: Integer);
|
---|
| 766 | { lists all patients associated with a given specialty: DFN^Patient Name }
|
---|
| 767 | begin
|
---|
| 768 | CallV('ORQPT SPECIALTY PATIENTS', [SpecialtyIEN]);
|
---|
| 769 | SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 770 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 771 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 772 | end;
|
---|
| 773 |
|
---|
| 774 | procedure ListPtByClinic(Dest: TStrings; ClinicIEN: Integer; FirstDt, LastDt: string); //TFMDateTime);
|
---|
| 775 | { lists all patients associated with a given clinic: DFN^Patient Name^App't }
|
---|
| 776 | var
|
---|
| 777 | i: Integer;
|
---|
| 778 | x, ATime, APlace, Sort: string;
|
---|
| 779 | begin
|
---|
| 780 | Sort := GetDfltSort();
|
---|
| 781 | CallV('ORQPT CLINIC PATIENTS', [ClinicIEN, FirstDt, LastDt]);
|
---|
| 782 | with RPCBrokerV do
|
---|
| 783 | begin
|
---|
| 784 | if Sort = 'P' then
|
---|
| 785 | SortByPiece(TStringList(Results), U, 4)
|
---|
| 786 | else
|
---|
| 787 | SortByPiece(TStringList(Results), U, 2);
|
---|
| 788 | for i := 0 to Results.Count - 1 do
|
---|
| 789 | begin
|
---|
| 790 | x := Results[i];
|
---|
| 791 | ATime := Piece(x, U, 4);
|
---|
| 792 | APlace := Piece(x, U, 3);
|
---|
| 793 | ATime := FormatFMDateTime('hh:nn mmm dd, yyyy', MakeFMDateTime(ATime));
|
---|
| 794 | SetPiece(x, U, 3, ATime);
|
---|
| 795 | x := x + U + APlace;
|
---|
| 796 | Results[i] := x;
|
---|
| 797 | end;
|
---|
| 798 | MixedCaseList(Results);
|
---|
[830] | 799 | FastAssign(Results, Dest);
|
---|
[456] | 800 | end;
|
---|
| 801 | end;
|
---|
| 802 |
|
---|
| 803 | procedure ListPtByWard(Dest: TStrings; WardIEN: Integer);
|
---|
| 804 | { lists all patients associated with a given ward: DFN^Patient Name^Room/Bed }
|
---|
| 805 | var
|
---|
| 806 | Sort: string;
|
---|
| 807 | begin
|
---|
| 808 | Sort := GetDfltSort();
|
---|
| 809 | CallV('ORWPT BYWARD', [WardIEN]);
|
---|
| 810 | if Sort = 'R' then
|
---|
| 811 | SortByPiece(TStringList(RPCBrokerV.Results), U, 3)
|
---|
| 812 | else
|
---|
| 813 | SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 814 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 815 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 816 | end;
|
---|
| 817 |
|
---|
| 818 | // VWPT ADDITIONS FOR ENHANCED PATIENT LOOKUP
|
---|
| 819 | procedure ListPtByOther (Dest: Tstrings; const othertext: string;caption:string );//:string; radbutton:Tobject);
|
---|
| 820 | var
|
---|
| 821 | i: Integer;
|
---|
| 822 | x,Afieldname: string;
|
---|
| 823 | begin
|
---|
| 824 |
|
---|
| 825 | CallV('ORWPT OTHER-RADIOBUTTONS',[othertext, caption]);
|
---|
| 826 | //SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 827 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 828 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 829 | end;
|
---|
| 830 |
|
---|
| 831 | procedure ListPtByTimson (Dest: Tstrings; const othertext: string);//
|
---|
| 832 |
|
---|
| 833 | var
|
---|
| 834 | i: Integer;
|
---|
| 835 | x,Afieldname: string;
|
---|
| 836 | begin
|
---|
| 837 |
|
---|
| 838 | CallV('ORWPT ENHANCED PATLOOKUP',[othertext]);
|
---|
| 839 | //SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 840 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 841 | Dest.Assign(RPCBrokerV.Results);
|
---|
| 842 | end;
|
---|
| 843 |
|
---|
| 844 |
|
---|
| 845 |
|
---|
| 846 | //END VWPT ADDITIONS
|
---|
[830] | 847 |
|
---|
[456] | 848 | procedure ListPtByLast5(Dest: TStrings; const Last5: string);
|
---|
| 849 | var
|
---|
| 850 | i: Integer;
|
---|
| 851 | x, ADate, AnSSN: string;
|
---|
| 852 | begin
|
---|
| 853 | { Lists all patients found in the BS and BS5 xrefs that match Last5: DFN^Patient Name }
|
---|
| 854 | CallV('ORWPT LAST5', [UpperCase(Last5)]);
|
---|
| 855 | SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 856 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
| 857 | begin
|
---|
| 858 | x := Results[i];
|
---|
| 859 | ADate := Piece(x, U, 3);
|
---|
| 860 | AnSSN := Piece(x, U, 4);
|
---|
| 861 | if IsFMDate(ADate) then ADate := FormatFMDateTimeStr('mmm d, yyyy', ADate);
|
---|
| 862 | if IsSSN(AnSSN) then AnSSN := FormatSSN(AnSSN);
|
---|
| 863 | SetPiece(x, U, 3, AnSSN + ' ' + ADate);
|
---|
| 864 | Results[i] := x;
|
---|
| 865 | end;
|
---|
| 866 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 867 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 868 | end;
|
---|
| 869 |
|
---|
| 870 | procedure ListPtByRPLLast5(Dest: TStrings; const Last5: string);
|
---|
| 871 | var
|
---|
| 872 | i: Integer;
|
---|
| 873 | x, ADate, AnSSN: string;
|
---|
| 874 | begin
|
---|
| 875 | { Lists patients from RPL list that match Last5: DFN^Patient Name }
|
---|
| 876 | CallV('ORWPT LAST5 RPL', [UpperCase(Last5)]);
|
---|
| 877 | SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 878 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
| 879 | begin
|
---|
| 880 | x := Results[i];
|
---|
| 881 | ADate := Piece(x, U, 3);
|
---|
| 882 | AnSSN := Piece(x, U, 4);
|
---|
| 883 | if IsFMDate(ADate) then ADate := FormatFMDateTimeStr('mmm d, yyyy', ADate);
|
---|
| 884 | if IsSSN(AnSSN) then AnSSN := FormatSSN(AnSSN);
|
---|
| 885 | SetPiece(x, U, 3, AnSSN + ' ' + ADate);
|
---|
| 886 | Results[i] := x;
|
---|
| 887 | end;
|
---|
| 888 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 889 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 890 | end;
|
---|
| 891 |
|
---|
| 892 | procedure ListPtByFullSSN(Dest: TStrings; const FullSSN: string);
|
---|
| 893 | { lists all patients found in the SSN xref that match FullSSN: DFN^Patient Name }
|
---|
| 894 | var
|
---|
| 895 | i: integer;
|
---|
| 896 | x, ADate, AnSSN: string;
|
---|
| 897 | begin
|
---|
| 898 | x := FullSSN;
|
---|
| 899 | i := Pos('-', x);
|
---|
| 900 | while i > 0 do
|
---|
| 901 | begin
|
---|
| 902 | x := Copy(x, 1, i-1) + Copy(x, i+1, 12);
|
---|
| 903 | i := Pos('-', x);
|
---|
| 904 | end;
|
---|
| 905 | CallV('ORWPT FULLSSN', [UpperCase(x)]);
|
---|
| 906 | SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 907 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
| 908 | begin
|
---|
| 909 | x := Results[i];
|
---|
| 910 | ADate := Piece(x, U, 3);
|
---|
| 911 | AnSSN := Piece(x, U, 4);
|
---|
| 912 | if IsFMDate(ADate) then ADate := FormatFMDateTimeStr('mmm d, yyyy', ADate);
|
---|
| 913 | if IsSSN(AnSSN) then AnSSN := FormatSSN(AnSSN);
|
---|
| 914 | SetPiece(x, U, 3, AnSSN + ' ' + ADate);
|
---|
| 915 | Results[i] := x;
|
---|
| 916 | end;
|
---|
| 917 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 918 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 919 | end;
|
---|
| 920 |
|
---|
| 921 | procedure ListPtByRPLFullSSN(Dest: TStrings; const FullSSN: string);
|
---|
| 922 | { lists all patients found in the SSN xref that match FullSSN: DFN^Patient Name }
|
---|
| 923 | var
|
---|
| 924 | i: integer;
|
---|
| 925 | x, ADate, AnSSN: string;
|
---|
| 926 | begin
|
---|
| 927 | x := FullSSN;
|
---|
| 928 | i := Pos('-', x);
|
---|
| 929 | while i > 0 do
|
---|
| 930 | begin
|
---|
| 931 | x := Copy(x, 1, i-1) + Copy(x, i+1, 12);
|
---|
| 932 | i := Pos('-', x);
|
---|
| 933 | end;
|
---|
| 934 | CallV('ORWPT FULLSSN RPL', [UpperCase(x)]);
|
---|
| 935 | SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
|
---|
| 936 | with RPCBrokerV do for i := 0 to Results.Count - 1 do
|
---|
| 937 | begin
|
---|
| 938 | x := Results[i];
|
---|
| 939 | ADate := Piece(x, U, 3);
|
---|
| 940 | AnSSN := Piece(x, U, 4);
|
---|
| 941 | if IsFMDate(ADate) then ADate := FormatFMDateTimeStr('mmm d, yyyy', ADate);
|
---|
| 942 | if IsSSN(AnSSN) then AnSSN := FormatSSN(AnSSN);
|
---|
| 943 | SetPiece(x, U, 3, AnSSN + ' ' + ADate);
|
---|
| 944 | Results[i] := x;
|
---|
| 945 | end;
|
---|
| 946 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 947 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 948 | end;
|
---|
| 949 |
|
---|
| 950 | procedure ListPtTop(Dest: TStrings);
|
---|
| 951 | { currently returns the last patient selected }
|
---|
| 952 | begin
|
---|
| 953 | CallV('ORWPT TOP', [nil]);
|
---|
| 954 | MixedCaseList(RPCBrokerV.Results);
|
---|
[830] | 955 | FastAssign(RPCBrokerV.Results, Dest);
|
---|
[456] | 956 | end;
|
---|
| 957 |
|
---|
| 958 | function SubSetOfPatients(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 959 | { returns a pointer to a list of patients (for use in a long list box) - The return value is
|
---|
| 960 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 961 | begin
|
---|
| 962 | CallV('ORWPT LIST ALL', [StartFrom, Direction]);
|
---|
| 963 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 964 | Result := RPCBrokerV.Results;
|
---|
| 965 | end;
|
---|
| 966 |
|
---|
| 967 | function MakeRPLPtList(RPLList: string): string;
|
---|
| 968 | { Creates "RPL" Restricted Patient List based on Team List info in user's record. }
|
---|
| 969 | begin
|
---|
| 970 | result := sCallV('ORQPT MAKE RPL', [RPLList]);
|
---|
| 971 | end;
|
---|
| 972 |
|
---|
| 973 | function ReadRPLPtList(RPLJobNumber: string; const StartFrom: string; Direction: Integer) : TStrings;
|
---|
| 974 | { returns a pointer to a list of patients (for use in a long list box) - The return value is
|
---|
| 975 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 976 | begin
|
---|
| 977 | CallV('ORQPT READ RPL', [RPLJobNumber, StartFrom, Direction]);
|
---|
| 978 | MixedCaseList(RPCBrokerV.Results);
|
---|
| 979 | Result := RPCBrokerV.Results;
|
---|
| 980 | end;
|
---|
| 981 |
|
---|
| 982 | procedure KillRPLPtList(RPLJobNumber: string);
|
---|
| 983 | begin
|
---|
| 984 | CallV('ORQPT KILL RPL', [RPLJobNumber]);
|
---|
| 985 | end;
|
---|
| 986 |
|
---|
| 987 | { Patient Specific Calls }
|
---|
| 988 |
|
---|
| 989 | function CalcAge(BirthDate, DeathDate: TFMDateTime): Integer;
|
---|
| 990 | { calculates age based on today's date and a birthdate (in Fileman format) }
|
---|
| 991 | begin
|
---|
| 992 | if (DeathDate > BirthDate) then
|
---|
| 993 | Result := Trunc(DeathDate - BirthDate) div 10000
|
---|
| 994 | else
|
---|
| 995 | Result := Trunc(FMToday - BirthDate) div 10000
|
---|
| 996 | end;
|
---|
| 997 |
|
---|
| 998 | procedure CheckSensitiveRecordAccess(const DFN: string; var AccessStatus: Integer;
|
---|
| 999 | var MessageText: string);
|
---|
| 1000 | begin
|
---|
| 1001 | CallV('DG SENSITIVE RECORD ACCESS', [DFN]);
|
---|
| 1002 | AccessStatus := -1;
|
---|
| 1003 | MessageText := '';
|
---|
| 1004 | with RPCBrokerV do
|
---|
| 1005 | begin
|
---|
| 1006 | if Results.Count > 0 then
|
---|
| 1007 | begin
|
---|
| 1008 | AccessStatus := StrToIntDef(Results[0], -1);
|
---|
| 1009 | Results.Delete(0);
|
---|
| 1010 | if Results.Count > 0 then MessageText := Results.Text;
|
---|
| 1011 | end;
|
---|
| 1012 | end;
|
---|
| 1013 | end;
|
---|
| 1014 |
|
---|
| 1015 | procedure CheckRemotePatient(var Dest: string; Patient, ASite: string; var AccessStatus: Integer);
|
---|
| 1016 |
|
---|
| 1017 | begin
|
---|
| 1018 | CallV('XWB DIRECT RPC', [ASite, 'ORWCIRN RESTRICT', 0, Patient]);
|
---|
| 1019 | AccessStatus := -1;
|
---|
| 1020 | Dest := '';
|
---|
| 1021 | with RPCBrokerV do
|
---|
| 1022 | begin
|
---|
| 1023 | if Results.Count > 0 then
|
---|
| 1024 | begin
|
---|
| 1025 | if Results[0] = '' then Results.Delete(0);
|
---|
| 1026 | end;
|
---|
| 1027 | if Results.Count > 0 then
|
---|
| 1028 | begin
|
---|
| 1029 | if (length(piece(Results[0],'^',2)) > 0) and ((StrToIntDef(piece(Results[0],'^',1),0) = -1)) then
|
---|
| 1030 | begin
|
---|
| 1031 | AccessStatus := -1;
|
---|
| 1032 | Dest := piece(Results[0],'^',2);
|
---|
| 1033 | end
|
---|
| 1034 | else
|
---|
| 1035 | begin
|
---|
| 1036 | AccessStatus := StrToIntDef(Results[0], -1);
|
---|
| 1037 | Results.Delete(0);
|
---|
| 1038 | if Results.Count > 0 then Dest := Results.Text;
|
---|
| 1039 | end;
|
---|
| 1040 | end;
|
---|
| 1041 | end;
|
---|
| 1042 | end;
|
---|
| 1043 |
|
---|
| 1044 | procedure CurrentLocationForPatient(const DFN: string; var ALocation: Integer; var AName: string; var ASvc: string);
|
---|
| 1045 | var
|
---|
| 1046 | x: string;
|
---|
| 1047 | begin
|
---|
| 1048 | x := sCallV('ORWPT INPLOC', [DFN]);
|
---|
| 1049 | ALocation := StrToIntDef(Piece(x, U, 1), 0);
|
---|
| 1050 | AName := Piece(x, U, 2);
|
---|
| 1051 | ASvc := Piece(x, U, 3);
|
---|
| 1052 | end;
|
---|
| 1053 |
|
---|
| 1054 | function DateOfDeath(const DFN: string): TFMDateTime;
|
---|
| 1055 | { returns 0 or the date a patient died }
|
---|
| 1056 | begin
|
---|
| 1057 | Result := MakeFMDateTime(sCallV('ORWPT DIEDON', [DFN]));
|
---|
| 1058 | end;
|
---|
| 1059 |
|
---|
| 1060 | function GetPtIDInfo(const DFN: string): TPtIDInfo; //*DFN*
|
---|
| 1061 | //VWPT ADD HRN ,ALT HRN (FUTURE)
|
---|
[830] | 1062 | // Pieces: SSN[1]^DOB[2]^SEX[3]^VET[4]^SC%[5]^WARD[6]^RM-BED[7]^NAME[8]^HRN[9]^ALTHRN[10] }
|
---|
[456] | 1063 | // Pieces: SSN[1]^DOB[2]^SEX[3]^VET[4]^SC%[5]^WARD[6]^RM-BED[7]^NAME[8] }
|
---|
| 1064 | var
|
---|
| 1065 | x: string;
|
---|
| 1066 | begin
|
---|
| 1067 | x := sCallV('ORWPT ID INFO', [DFN]);
|
---|
| 1068 | with Result do // map string into TPtIDInfo record
|
---|
| 1069 | begin
|
---|
| 1070 | Name := MixedCase(Piece(x, U, 8)); // Name
|
---|
| 1071 | SSN := Piece(x, U, 1);
|
---|
| 1072 | DOB := Piece(x, U, 2);
|
---|
| 1073 | Age := '';
|
---|
| 1074 | if IsSSN(SSN) then SSN := FormatSSN(Piece(x, U, 1)); // SSN (PID)
|
---|
| 1075 | if IsFMDate(DOB) then DOB := FormatFMDateTimeStr('mmm dd,yyyy', DOB); // Date of Birth
|
---|
| 1076 | //Age := IntToStr(CalcAge(MakeFMDateTime(Piece(x, U, 2)))); // Age
|
---|
| 1077 | Sex := Piece(x, U, 3); // Sex
|
---|
| 1078 | if Length(Sex) = 0 then Sex := 'U';
|
---|
| 1079 | case Sex[1] of
|
---|
| 1080 | 'F','f': Sex := 'Female';
|
---|
| 1081 | 'M','m': Sex := 'Male';
|
---|
| 1082 | else Sex := 'Unknown';
|
---|
| 1083 | end;
|
---|
| 1084 | if Piece(x, U, 4) = 'Y' then Vet := 'Veteran' else Vet := ''; // Veteran?
|
---|
| 1085 | if Length(Piece(x, U, 5)) > 0 // % Service Connected
|
---|
| 1086 | then SCSts := Piece(x, U, 5) + '% Service Connected'
|
---|
| 1087 | else SCSts := '';
|
---|
| 1088 | Location := Piece(x, U, 6); // Inpatient Location
|
---|
| 1089 | RoomBed := Piece(x, U, 7); // Inpatient Room-Bed
|
---|
| 1090 | // VWPT ADD HRN
|
---|
| 1091 | HRN := Piece(x, U, 9);
|
---|
| 1092 | AltHRN := Piece(x, U, 10);
|
---|
| 1093 | end;
|
---|
| 1094 | end;
|
---|
| 1095 |
|
---|
| 1096 | function HasLegacyData(const DFN: string; var AMsg: string): Boolean;
|
---|
| 1097 | var
|
---|
| 1098 | i: Integer;
|
---|
| 1099 | begin
|
---|
| 1100 | Result := False;
|
---|
| 1101 | AMsg := '';
|
---|
| 1102 | CallV('ORWPT LEGACY', [DFN]);
|
---|
| 1103 | with RPCBrokerV do if Results.Count > 0 then
|
---|
| 1104 | begin
|
---|
| 1105 | Result := Results[0] = '1';
|
---|
| 1106 | for i := 1 to Results.Count - 1 do AMsg := AMsg + Results[i] + CRLF;
|
---|
| 1107 | end;
|
---|
| 1108 | end;
|
---|
| 1109 |
|
---|
| 1110 | function LogSensitiveRecordAccess(const DFN: string): Boolean;
|
---|
| 1111 | begin
|
---|
| 1112 | Result := sCallV('DG SENSITIVE RECORD BULLETIN', [DFN]) = '1';
|
---|
| 1113 | end;
|
---|
| 1114 |
|
---|
| 1115 | function MeansTestRequired(const DFN: string; var AMsg: string): Boolean;
|
---|
| 1116 | var
|
---|
| 1117 | i: Integer;
|
---|
| 1118 | begin
|
---|
| 1119 | Result := False;
|
---|
| 1120 | AMsg := '';
|
---|
| 1121 | CallV('DG CHK PAT/DIV MEANS TEST', [DFN]);
|
---|
| 1122 | with RPCBrokerV do if Results.Count > 0 then
|
---|
| 1123 | begin
|
---|
| 1124 | Result := Results[0] = '1';
|
---|
| 1125 | for i := 1 to Results.Count - 1 do AMsg := AMsg + Results[i] + CRLF;
|
---|
| 1126 | end;
|
---|
| 1127 | end;
|
---|
| 1128 |
|
---|
| 1129 | function RestrictedPtRec(const DFN: string): Boolean; //*DFN*
|
---|
| 1130 | { returns true if the record for a patient identified by DFN is restricted }
|
---|
| 1131 | begin
|
---|
| 1132 | Result := Piece(sCallV('ORWPT SELCHK', [DFN]), U, 1) = '1';
|
---|
| 1133 | end;
|
---|
| 1134 |
|
---|
| 1135 | procedure SelectPatient(const DFN: string; var PtSelect: TPtSelect); //*DFN*
|
---|
| 1136 | { selects the patient (updates DISV, calls Pt Select actions) & returns key fields
|
---|
| 1137 | Pieces: NAME[1]^SEX[2]^DOB[3]^SSN[4]^LOCIEN[5]^LOCNAME[6]^ROOMBED[7]^CWAD[8]^SENSITIVE[9]^
|
---|
| 1138 | //VWPT add HRN and ALTERNATE HRN used with PID hl7 segments
|
---|
| 1139 | ADMITTIME[10]^CONVERTED[11]^SVCONN[12]^SC%[13]^ICN[14]^Age[15]^TreatSpec[16]^HRN[17]^AltHRN[18] }
|
---|
[830] | 1140 | // BEFORE THIS VWPT WAS ADMITTIME[10]^CONVERTED[11]^SVCONN[12]^SC%[13]^ICN[14]^Age[15]^TreatSpec[16] }
|
---|
[456] | 1141 | var
|
---|
| 1142 | x: string;
|
---|
| 1143 | begin
|
---|
| 1144 | x := sCallV('ORWPT SELECT', [DFN]);
|
---|
| 1145 | with PtSelect do
|
---|
| 1146 | begin
|
---|
| 1147 | Name := Piece(x, U, 1);
|
---|
| 1148 | ICN := Piece(x, U, 14);
|
---|
| 1149 | SSN := FormatSSN(Piece(x, U, 4));
|
---|
| 1150 | DOB := MakeFMDateTime(Piece(x, U, 3));
|
---|
| 1151 | Age := StrToIntDef(Piece(x, U, 15), 0);
|
---|
| 1152 | //Age := CalcAge(DOB, DateOfDeath(DFN));
|
---|
| 1153 | if Length(Piece(x, U, 2)) > 0 then Sex := Piece(x, U, 2)[1] else Sex := 'U';
|
---|
| 1154 | LocationIEN := StrToIntDef(Piece(x, U, 5), 0);
|
---|
| 1155 | Location := Piece(x, U, 6);
|
---|
| 1156 | RoomBed := Piece(x, U, 7);
|
---|
| 1157 | SpecialtyIEN := StrToIntDef(Piece(x, u, 16), 0);
|
---|
| 1158 | CWAD := Piece(x, U, 8);
|
---|
| 1159 | Restricted := Piece(x, U, 9) = '1';
|
---|
| 1160 | AdmitTime := MakeFMDateTime(Piece(x, U, 10));
|
---|
| 1161 | ServiceConnected := Piece(x, U, 12) = '1';
|
---|
| 1162 | SCPercent := StrToIntDef(Piece(x, U, 13), 0);
|
---|
| 1163 | //VWPT ADD HRN AltHRN (future)
|
---|
| 1164 | HRN := Piece(x, U, 17);
|
---|
| 1165 | AltHRN := Piece(x, U, 18);
|
---|
| 1166 | end;
|
---|
| 1167 | x := sCallV('ORWPT1 PRCARE', [DFN]);
|
---|
| 1168 | with PtSelect do
|
---|
| 1169 | begin
|
---|
| 1170 | PrimaryTeam := Piece(x, U, 1);
|
---|
| 1171 | PrimaryProvider := Piece(x, U, 2);
|
---|
| 1172 | if Length(Location) > 0 then
|
---|
| 1173 | begin
|
---|
| 1174 | Attending := Piece(x, U, 3);
|
---|
| 1175 | x := sCallV('ORWPT INPLOC', [DFN]);
|
---|
| 1176 | WardService := Piece(x, U, 3);
|
---|
| 1177 | end;
|
---|
| 1178 | end;
|
---|
| 1179 | end;
|
---|
| 1180 |
|
---|
| 1181 | function SimilarRecordsFound(const DFN: string; var AMsg: string): Boolean;
|
---|
| 1182 | begin
|
---|
| 1183 | Result := False;
|
---|
| 1184 | AMsg := '';
|
---|
| 1185 | CallV('DG CHK BS5 XREF Y/N', [DFN]);
|
---|
| 1186 | with RPCBrokerV do if Results.Count > 0 then
|
---|
| 1187 | begin
|
---|
| 1188 | Result := Results[0] = '1';
|
---|
| 1189 | Results.Delete(0);
|
---|
| 1190 | AMsg := Results.Text;
|
---|
| 1191 | end;
|
---|
| 1192 | (*
|
---|
| 1193 | CallV('DG CHK BS5 XREF ARRAY', [DFN]);
|
---|
| 1194 | with RPCBrokerV do if Results.Count > 0 then
|
---|
| 1195 | begin
|
---|
| 1196 | Result := Results[0] = '1';
|
---|
| 1197 | for i := 1 to Results.Count - 1 do
|
---|
| 1198 | begin
|
---|
| 1199 | if Piece(Results[i], U, 1) = '0' then AMsg := AMsg + Copy(Results[i], 3, Length(Results[i])) + CRLF;
|
---|
| 1200 | if Piece(Results[i], U, 1) = '1' then AMsg := AMsg + Piece(Results[i], U, 3) + #9 +
|
---|
| 1201 | FormatFMDateTimeStr('mmm dd,yyyy', Piece(Results[i], U, 4)) + #9 + Piece(Results[i], U, 5) + CRLF;
|
---|
| 1202 | end;
|
---|
| 1203 | end;
|
---|
| 1204 | *)
|
---|
| 1205 | end;
|
---|
| 1206 |
|
---|
| 1207 | function GetDFNFromICN(AnICN: string): string;
|
---|
| 1208 | begin
|
---|
| 1209 | Result := Piece(sCallV('VAFCTFU CONVERT ICN TO DFN', [AnICN]), U, 1);
|
---|
| 1210 | end;
|
---|
| 1211 |
|
---|
| 1212 | { Encounter specific calls }
|
---|
| 1213 |
|
---|
| 1214 | function GetEncounterText(const DFN: string; Location: integer; Provider: Int64): TEncounterText; //*DFN*
|
---|
| 1215 | { returns resolved external values Pieces: LOCNAME[1]^PROVNAME[2]^ROOMBED[3] }
|
---|
| 1216 | var
|
---|
| 1217 | x: string;
|
---|
| 1218 | begin
|
---|
| 1219 | x := sCallV('ORWPT ENCTITL', [DFN, Location, Provider]);
|
---|
| 1220 | with Result do
|
---|
| 1221 | begin
|
---|
| 1222 | LocationName := Piece(x, U, 1);
|
---|
| 1223 | LocationAbbr := Piece(x, U, 2);
|
---|
| 1224 | RoomBed := Piece(x, U, 3);
|
---|
| 1225 | ProviderName := Piece(x, U, 4);
|
---|
| 1226 | // ProviderName := sCallV('ORWU1 NAMECVT', [Provider]);
|
---|
| 1227 | end;
|
---|
| 1228 | end;
|
---|
| 1229 |
|
---|
| 1230 | procedure ListApptAll(Dest: TStrings; const DFN: string; From: TFMDateTime = 0;
|
---|
| 1231 | Thru: TFMDateTime = 0);
|
---|
| 1232 | { lists appts/visits for a patient (uses same call as cover sheet)
|
---|
| 1233 | V|A;DateTime;LocIEN^DateTime^LocName^Status }
|
---|
| 1234 | const
|
---|
| 1235 | SKIP_ADMITS = 1;
|
---|
| 1236 | begin
|
---|
| 1237 | CallV('ORWCV VST', [Patient.DFN, From, Thru, SKIP_ADMITS]);
|
---|
| 1238 | with RPCBrokerV do
|
---|
| 1239 | begin
|
---|
| 1240 | InvertStringList(TStringList(Results));
|
---|
| 1241 | MixedCaseList(Results);
|
---|
| 1242 | SetListFMDateTime('mmm dd,yyyy hh:nn', TStringList(Results), U, 2);
|
---|
[830] | 1243 | FastAssign(Results, Dest);
|
---|
[456] | 1244 | end;
|
---|
| 1245 | (*
|
---|
| 1246 | CallV('ORWPT APPTLST', [DFN]);
|
---|
| 1247 | with RPCBrokerV do
|
---|
| 1248 | begin
|
---|
| 1249 | SortByPiece(TStringList(Results), U, 1);
|
---|
| 1250 | InvertStringList(TStringList(Results));
|
---|
| 1251 | for i := 0 to Results.Count - 1 do
|
---|
| 1252 | begin
|
---|
| 1253 | x := Results[i];
|
---|
| 1254 | ATime := Piece(x, U, 1);
|
---|
| 1255 | ATime := FormatFMDateTime('mmm dd, yyyy hh:nn', MakeFMDateTime(ATime));
|
---|
| 1256 | SetPiece(x, U, 5, ATime);
|
---|
| 1257 | Results[i] := x;
|
---|
| 1258 | end;
|
---|
[830] | 1259 | FastAssign(Results, Dest);
|
---|
[456] | 1260 | end;
|
---|
| 1261 | *)
|
---|
| 1262 | end;
|
---|
| 1263 |
|
---|
| 1264 | procedure ListAdmitAll(Dest: TStrings; const DFN: string); //*DFN*
|
---|
| 1265 | { lists all admissions for a patient: MovementTime^LocIEN^LocName^Type }
|
---|
| 1266 | var
|
---|
| 1267 | i: Integer;
|
---|
| 1268 | ATime, x: string;
|
---|
| 1269 | begin
|
---|
| 1270 | CallV('ORWPT ADMITLST', [DFN]);
|
---|
| 1271 | with RPCBrokerV do
|
---|
| 1272 | begin
|
---|
| 1273 | for i := 0 to Results.Count - 1 do
|
---|
| 1274 | begin
|
---|
| 1275 | x := Results[i];
|
---|
| 1276 | ATime := Piece(x, U, 1);
|
---|
| 1277 | ATime := FormatFMDateTime('mmm dd, yyyy hh:nn', MakeFMDateTime(ATime));
|
---|
| 1278 | SetPiece(x, U, 5, ATime);
|
---|
| 1279 | Results[i] := x;
|
---|
| 1280 | end;
|
---|
[830] | 1281 | FastAssign(Results, Dest);
|
---|
[456] | 1282 | end;
|
---|
| 1283 | end;
|
---|
| 1284 |
|
---|
| 1285 | function SubSetOfLocations(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 1286 | { returns a pointer to a list of locations (for use in a long list box) - The return value is
|
---|
| 1287 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 1288 | begin
|
---|
| 1289 | CallV('ORWU HOSPLOC', [StartFrom, Direction]);
|
---|
| 1290 | Result := RPCBrokerV.Results;
|
---|
| 1291 | end;
|
---|
| 1292 |
|
---|
| 1293 | function SubSetOfNewLocs(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 1294 | { Returns a pointer to a list of locations (for use in a long list box) - the return value is
|
---|
| 1295 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call!
|
---|
| 1296 | Filtered by C, W, and Z types - i.e., Clinics, Wards, and "Other" type locations.}
|
---|
| 1297 | begin
|
---|
| 1298 | CallV('ORWU1 NEWLOC', [StartFrom, Direction]);
|
---|
| 1299 | Result := RPCBrokerV.Results;
|
---|
| 1300 | end;
|
---|
| 1301 |
|
---|
| 1302 | function SubSetOfInpatientLocations(const StartFrom: string; Direction: Integer): TStrings;
|
---|
| 1303 | { returns a pointer to a list of locations (for use in a long list box) - The return value is
|
---|
| 1304 | a pointer to RPCBrokerV.Results, so the data must be used BEFORE the next broker call! }
|
---|
| 1305 | begin
|
---|
| 1306 | CallV('ORWU INPLOC', [StartFrom, Direction]);
|
---|
| 1307 | Result := RPCBrokerV.Results;
|
---|
| 1308 | end;
|
---|
| 1309 |
|
---|
| 1310 | { Remote Data Access calls }
|
---|
| 1311 |
|
---|
| 1312 | function HasRemoteData(const DFN: string; var ALocations: TStringList): Boolean;
|
---|
| 1313 | begin
|
---|
| 1314 | CallV('ORWCIRN FACLIST', [DFN]);
|
---|
[830] | 1315 | FastAssign(RPCBrokerV.Results, ALocations);
|
---|
[456] | 1316 | Result := not (Piece(RPCBrokerV.Results[0], U, 1) = '-1');
|
---|
| 1317 |
|
---|
| 1318 | // '-1^NO DFN'
|
---|
| 1319 | // '-1^PATIENT NOT IN DATABASE'
|
---|
| 1320 | // '-1^NO MPI Node'
|
---|
| 1321 | // '-1^NO ICN'
|
---|
| 1322 | // '-1^Parameter missing.'
|
---|
| 1323 | // '-1^No patient DFN.'
|
---|
| 1324 | // '-1^Could not find Treating Facilities'
|
---|
| 1325 | // '-1^Remote access not allowed' <===parameter ORWCIRN REMOTE DATA ALLOW
|
---|
| 1326 | end;
|
---|
| 1327 |
|
---|
| 1328 | function CheckHL7TCPLink: Boolean;
|
---|
| 1329 | begin
|
---|
| 1330 | CallV('ORWCIRN CHECKLINK',[nil]);
|
---|
| 1331 | Result := RPCBrokerV.Results[0] = '1';
|
---|
| 1332 | end;
|
---|
| 1333 |
|
---|
| 1334 | function GetVistaWebAddress(value: string): string;
|
---|
| 1335 | begin
|
---|
| 1336 | CallV('ORWCIRN WEBADDR', [value]);
|
---|
| 1337 | result := RPCBrokerV.Results[0];
|
---|
| 1338 | end;
|
---|
| 1339 |
|
---|
| 1340 | function GetDefaultPrinter(DUZ: Int64; Location: integer): string;
|
---|
| 1341 | begin
|
---|
| 1342 | Result := sCallV('ORWRP GET DEFAULT PRINTER', [DUZ, Location]) ;
|
---|
| 1343 | end;
|
---|
| 1344 |
|
---|
| 1345 | end.
|
---|