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