source: cprs/trunk/CPRS-Chart/rCore.pas@ 1787

Last change on this file since 1787 was 1679, checked in by healthsevak, 10 years ago

Updating the working copy to CPRS version 28

File size: 42.8 KB
RevLine 
[456]1unit rCore;
2
3interface
4
5uses 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
10const
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
16type
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;
[1679]80 Associate: string;
[456]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
92function FMToday: TFMDateTime;
93function FMNow: TFMDateTime;
94function MakeRelativeDateTime(FMDateTime: TFMDateTime): string;
95function StrToFMDateTime(const AString: string): TFMDateTime;
96function ValidDateTimeStr(const AString, Flags: string): TFMDateTime;
97procedure ListDateRangeClinic(Dest: TStrings);
98
99{ General calls }
100
101function ExternalName(IEN: Int64; FileNumber: Double): string;
102function PersonHasKey(APerson: Int64; const AKey: string): Boolean;
103function GlobalRefForFile(const FileID: string): string;
104function SubsetOfGeneric(const StartFrom: string; Direction: Integer; const GlobalRef: string): TStrings;
105function SubsetOfDevices(const StartFrom: string; Direction: Integer): TStrings;
106function SubSetOfPersons(const StartFrom: string; Direction: Integer): TStrings;
107function SubSetOfActiveAndInactivePersons(const StartFrom: string; Direction: Integer): TStrings;
108function GetDefaultPrinter(DUZ: Int64; Location: integer): string;
109
110{ User specific calls }
111
112function GetUserInfo: TUserInfo;
113function GetUserParam(const AParamName: string): string;
[830]114procedure GetUserListParam(Dest: TStrings; const AParamName: string);
[456]115function HasSecurityKey(const KeyName: string): Boolean;
116function HasMenuOptionAccess(const OptionName: string): Boolean;
117function ValidESCode(const ACode: string): Boolean;
118
119{ Notifications calls }
120
121procedure LoadNotifications(Dest: TStrings);
122procedure DeleteAlert(XQAID: string);
123procedure DeleteAlertForUser(XQAID: string);
124function GetXQAData(XQAID: string): string;
125function GetTIUAlertInfo(XQAID: string): string;
126procedure UpdateUnsignedOrderAlerts(PatientDFN: string);
127function UnsignedOrderAlertFollowup(XQAID: string): string;
128procedure UpdateExpiringMedAlerts(PatientDFN: string);
129procedure UpdateExpiringFlaggedOIAlerts(PatientDFN: string; FollowUp: integer);
130procedure AutoUnflagAlertedOrders(PatientDFN, XQAID: string);
131procedure UpdateUnverifiedMedAlerts(PatientDFN: string);
132procedure UpdateUnverifiedOrderAlerts(PatientDFN: string);
133function GetNotificationFollowUpText(PatientDFN: string; Notification: integer; XQADATA: string): TStrings;
134procedure ForwardAlert(XQAID: string; Recip: string; FWDtype: string; Comment: string);
135procedure RenewAlert(XQAID: string);
136function GetSortMethod: string;
137procedure SetSortMethod(Sort: string; Direction: string);
138
139{ Patient List calls }
140
141function DfltPtList: string;
142function DfltPtListSrc: Char;
143procedure SavePtListDflt(const x: string);
144procedure ListSpecialtyAll(Dest: TStrings);
145procedure ListTeamAll(Dest: TStrings);
146procedure ListWardAll(Dest: TStrings);
147procedure ListProviderTop(Dest: TStrings);
148function SubSetOfProviders(const StartFrom: string; Direction: Integer): TStrings;
[830]149function SubSetOfCosigners(const StartFrom: string; Direction: Integer; Date: TFMDateTime;
[1679]150 ATitle: integer; ADocType: integer): TStrings;
[456]151procedure ListClinicTop(Dest: TStrings);
152function SubSetOfClinics(const StartFrom: string; Direction: Integer): TStrings;
153function GetDfltSort: string;
154procedure ResetDfltSort;
155procedure ListPtByDflt(Dest: TStrings);
156procedure ListPtByProvider(Dest: TStrings; ProviderIEN: Int64);
157procedure ListPtByTeam(Dest: TStrings; TeamIEN: Integer);
158procedure ListPtBySpecialty(Dest: TStrings; SpecialtyIEN: Integer);
159procedure ListPtByClinic(Dest: TStrings; ClinicIEN: Integer; FirstDt, LastDt: string);
160procedure ListPtByWard(Dest: TStrings; WardIEN: Integer);
161procedure ListPtByLast5(Dest: TStrings; const Last5: string);
162procedure ListPtByRPLLast5(Dest: TStrings; const Last5: string);
163procedure ListPtByFullSSN(Dest: TStrings; const FullSSN: string);
164procedure ListPtByRPLFullSSN(Dest: TStrings; const FullSSN: string);
165procedure ListPtTop(Dest: TStrings);
166function SubSetOfPatients(const StartFrom: string; Direction: Integer): TStrings;
167function DfltDateRangeClinic: string;
168function MakeRPLPtList(RPLList: string): string;
169function ReadRPLPtList(RPLJobNumber: string; const StartFrom: string; Direction: Integer) : TStrings;
170procedure KillRPLPtList(RPLJobNumber: string);
171
172{ Patient specific calls }
173
174function CalcAge(BirthDate, DeathDate: TFMDateTime): Integer;
175procedure CheckSensitiveRecordAccess(const DFN: string; var AccessStatus: Integer;
176 var MessageText: string);
177procedure CheckRemotePatient(var Dest: string; Patient, ASite: string; var AccessStatus: Integer);
178procedure CurrentLocationForPatient(const DFN: string; var ALocation: Integer; var AName: string; var ASvc: string);
179function DateOfDeath(const DFN: string): TFMDateTime;
180function GetPtIDInfo(const DFN: string): TPtIDInfo;
181function HasLegacyData(const DFN: string; var AMsg: string): Boolean;
182function LogSensitiveRecordAccess(const DFN: string): Boolean;
183function MeansTestRequired(const DFN: string; var AMsg: string): Boolean;
184function RestrictedPtRec(const DFN: string): Boolean;
185procedure SelectPatient(const DFN: string; var PtSelect: TPtSelect);
186function SimilarRecordsFound(const DFN: string; var AMsg: string): Boolean;
187function GetDFNFromICN(AnICN: string): string;
188
189{ Encounter specific calls }
190
191function GetEncounterText(const DFN: string; Location: integer; Provider: Int64): TEncounterText; //*DFN*
192procedure ListApptAll(Dest: TStrings; const DFN: string; From: TFMDateTime = 0;
193 Thru: TFMDateTime = 0);
194procedure ListAdmitAll(Dest: TStrings; const DFN: string);
195function SubSetOfLocations(const StartFrom: string; Direction: Integer): TStrings;
196function SubSetOfNewLocs(const StartFrom: string; Direction: Integer): TStrings;
197function SubSetOfInpatientLocations(const StartFrom: string; Direction: Integer): TStrings;
198function SubSetOfProvWithClass(const StartFrom: string; Direction: Integer; DateTime: string): TStrings;
199function SubSetOfUsersWithClass(const StartFrom: string; Direction: Integer; DateTime: string): TStrings;
200
201{ Remote Data Access calls }
202function HasRemoteData(const DFN: string; var ALocations: TStringList): Boolean;
203function CheckHL7TCPLink: Boolean;
204function GetVistaWebAddress(value: string): string;
205
206implementation
207
208uses Hash, uCore, ShlObj, Windows;
209
210var
211 uPtListDfltSort: string = ''; // Current user's patient selection list default sort order.
212
213{ private calls }
214
215function FormatSSN(const x: string): string;
[830]216{ places the dashes in a social security number }
[456]217begin
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;
221end;
222
223function IsSSN(const x: string): Boolean;
224var
225 i: Integer;
226begin
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;
231end;
232
233function IsFMDate(const x: string): Boolean;
234var
235 i: Integer;
236begin
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;
241end;
242
243{ Date/Time functions - not in ORFn because they make server calls to use server time}
244
245function FMToday: TFMDateTime;
246{ return the current date in Fileman format }
247begin
[830]248 Result := Int(FMNow);
[456]249end;
250
251function FMNow: TFMDateTime;
252{ return the current date/time in Fileman format }
253var
254 x: string;
255begin
256 x := sCallV('ORWU DT', ['NOW']);
257 Result := StrToFloat(x);
258end;
259
260function MakeRelativeDateTime(FMDateTime: TFMDateTime): string;
261var
262 Offset: Integer;
263 h,n,s,l: Word;
264 ADateTime: TDateTime;
265 ATime: string;
266begin
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;
277end;
278
279function StrToFMDateTime(const AString: string): TFMDateTime;
280{ use %DT the validate and convert a string to Fileman format (accepts T, T-1, NOW, etc.) }
281var
282 x: string;
283begin
284 x := sCallV('ORWU DT', [AString]);
285 Result := StrToFloat(x);
286end;
287
288function ValidDateTimeStr(const AString, Flags: string): TFMDateTime;
289{ use %DT to validate & convert a string to Fileman format, accepts %DT flags }
290begin
291 Result := StrToFloat(sCallV('ORWU VALDT', [AString, Flags]));
292end;
293
294procedure ListDateRangeClinic(Dest: TStrings);
295{ returns date ranges for displaying clinic appointments in patient lookup }
296begin
297 CallV('ORWPT CLINRNG', [nil]);
[830]298 FastAssign(RPCBrokerV.Results, Dest);
[456]299end;
300
301function DfltDateRangeClinic;
302{ returns current default date range settings for displaying clinic appointments in patient lookup }
303begin
304 Result := sCallV('ORQPT DEFAULT CLINIC DATE RANG', [nil]);
305end;
306
307{ General calls }
308
309function ExternalName(IEN: Int64; FileNumber: Double): string;
310{ returns the external name of the IEN within a file }
311begin
312 Result := sCallV('ORWU EXTNAME', [IEN, FileNumber]);
313end;
314
315function PersonHasKey(APerson: Int64; const AKey: string): Boolean;
316begin
317 Result := sCallV('ORWU NPHASKEY', [APerson, AKey]) = '1';
318end;
319
320function GlobalRefForFile(const FileID: string): string;
321begin
322 Result := sCallV('ORWU GBLREF', [FileID]);
323end;
324
325function SubsetOfGeneric(const StartFrom: string; Direction: Integer; const GlobalRef: string): TStrings;
326begin
327 CallV('ORWU GENERIC', [StartFrom, Direction, GlobalRef]);
328 Result := RPCBrokerV.Results;
329end;
330
331function 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! }
334begin
335 CallV('ORWU DEVICE', [StartFrom, Direction]);
336 Result := RPCBrokerV.Results;
337end;
338
339function 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! }
342begin
343 CallV('ORWU NEWPERS', [StartFrom, Direction]);
344// MixedCaseList(RPCBrokerV.Results);
345 Result := RPCBrokerV.Results;
346end;
347
348{ User specific calls }
349
350function 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?}
355var
356 x: string;
357begin
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;
403end;
404
405function GetUserParam(const AParamName: string): string;
406begin
407 Result := sCallV('ORWU PARAM', [AParamName]);
408end;
409
[830]410procedure GetUserListParam(Dest: TStrings; const AParamName: string);
411var
412 tmplst: TStringList;
413begin
414 tmplst := TStringList.Create;
415 try
416 tCallV(tmplst, 'ORWU PARAMS', [AParamName]);
417 FastAssign(tmplst, Dest);
418 finally
419 tmplst.Free;
420 end;
421end;
422
[456]423function HasSecurityKey(const KeyName: string): Boolean;
424{ returns true if the currently logged in user has a given security key }
425var
426 x: string;
427begin
428 Result := False;
429 x := sCallV('ORWU HASKEY', [KeyName]);
430 if x = '1' then Result := True;
431end;
432
433function HasMenuOptionAccess(const OptionName: string): Boolean;
434begin
435 Result := (sCallV('ORWU HAS OPTION ACCESS', [OptionName]) = '1');
436end;
437
438function ValidESCode(const ACode: string): Boolean;
439{ returns true if the electronic signature code in ACode is valid }
440begin
441 Result := sCallV('ORWU VALIDSIG', [Encrypt(ACode)]) = '1';
442end;
443
444{ Notifications Calls }
445
446procedure LoadNotifications(Dest: TStrings);
447var
448 tmplst: TStringList;
449begin
450 tmplst := TStringList.Create;
451 try
452 //UpdateUnsignedOrderAlerts(Patient.DFN); //moved to AFTER signature and DC actions
453 tCallV(tmplst, 'ORWORB FASTUSER', [nil]);
[830]454 FastAssign(tmplst, Dest);
[456]455 finally
456 tmplst.Free;
457 end;
458end;
459
460procedure UpdateUnsignedOrderAlerts(PatientDFN: string);
461begin
462 CallV('ORWORB KILL UNSIG ORDERS ALERT',[PatientDFN]);
463end;
464
465function UnsignedOrderAlertFollowup(XQAID: string): string;
466begin
467 Result := sCallV('ORWORB UNSIG ORDERS FOLLOWUP',[XQAID]);
468end;
469
470procedure UpdateExpiringMedAlerts(PatientDFN: string);
471begin
472 CallV('ORWORB KILL EXPIR MED ALERT',[PatientDFN]);
473end;
474
475procedure UpdateExpiringFlaggedOIAlerts(PatientDFN: string; FollowUp: integer);
476begin
477 CallV('ORWORB KILL EXPIR OI ALERT',[PatientDFN, FollowUp]);
478end;
479
480procedure UpdateUnverifiedMedAlerts(PatientDFN: string);
481begin
482 CallV('ORWORB KILL UNVER MEDS ALERT',[PatientDFN]);
483end;
484
485procedure UpdateUnverifiedOrderAlerts(PatientDFN: string);
486begin
487 CallV('ORWORB KILL UNVER ORDERS ALERT',[PatientDFN]);
488end;
489
490procedure AutoUnflagAlertedOrders(PatientDFN, XQAID: string);
491begin
492 CallV('ORWORB AUTOUNFLAG ORDERS',[PatientDFN, XQAID]);
493end;
494
495procedure DeleteAlert(XQAID: string);
496//deletes an alert
497begin
498 CallV('ORB DELETE ALERT',[XQAID]);
499end;
500
501procedure DeleteAlertForUser(XQAID: string);
502//deletes an alert
503begin
504 CallV('ORB DELETE ALERT',[XQAID, True]);
505end;
506
507procedure ForwardAlert(XQAID: string; Recip: string; FWDtype: string; Comment: string);
508// Forwards an alert with comment to Recip[ient]
509begin
510 CallV('ORB FORWARD ALERT', [XQAID, Recip, FWDtype, Comment]);
511end;
512
513procedure RenewAlert(XQAID: string);
514// Restores/renews an alert
515begin
516 CallV('ORB RENEW ALERT', [XQAID]);
517end;
518
519function GetSortMethod: string;
520// Returns alert sort method
521begin
522 Result := sCallV('ORWORB GETSORT',[nil]);
523end;
524
525procedure SetSortMethod(Sort: string; Direction: string);
526// Sets alert sort method for user
527begin
528 CallV('ORWORB SETSORT', [Sort, Direction]);
529end;
530
531function GetXQAData(XQAID: string): string;
532// Returns data associated with an alert
533begin
534 Result := sCallV('ORWORB GETDATA',[XQAID]);
535end;
536
537function GetTIUAlertInfo(XQAID: string): string;
538// Returns DFN and document type associated with a TIU alert
539begin
540 Result := sCallV('TIU GET ALERT INFO',[XQAID]);
541end;
542
543function GetNotificationFollowUpText(PatientDFN: string; Notification: integer; XQADATA: string): TStrings;
544// Returns follow-up text for an alert
545begin
546 CallV('ORWORB TEXT FOLLOWUP', [PatientDFN, Notification, XQADATA]);
547 Result := RPCBrokerV.Results;
548end;
549
550{ Patient List Calls }
551
552function 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 }
555begin
556 Result := sCallV('ORQPT DEFAULT LIST SOURCE', [nil]);
557 if Length(Result) > 0 then Result := Pieces(Result, U, 2, 3);
558end;
559
560function DfltPtListSrc: Char;
561begin
562 Result := CharAt(sCallV('ORWPT DFLTSRC', [nil]), 1);
563end;
564
565procedure SavePtListDflt(const x: string);
566begin
567 CallV('ORWPT SAVDFLT', [x]);
568end;
569
570procedure ListSpecialtyAll(Dest: TStrings);
571{ lists all treating specialties: IEN^Treating Specialty Name }
572begin
573 CallV('ORQPT SPECIALTIES', [nil]);
574 MixedCaseList(RPCBrokerV.Results);
[830]575 FastAssign(RPCBrokerV.Results, Dest);
[456]576end;
577
578procedure ListTeamAll(Dest: TStrings);
579{ lists all patient care teams: IEN^Team Name }
580begin
581 CallV('ORQPT TEAMS', [nil]);
582 MixedCaseList(RPCBrokerV.Results);
[830]583 FastAssign(RPCBrokerV.Results, Dest);
[456]584end;
585
586procedure ListWardAll(Dest: TStrings);
587{ lists all active inpatient wards: IEN^Ward Name }
588begin
589 CallV('ORQPT WARDS', [nil]);
590 //MixedCaseList(RPCBrokerV.Results);
[830]591 FastAssign(RPCBrokerV.Results, Dest);
[456]592end;
593
594procedure ListProviderTop(Dest: TStrings);
595{ checks parameters for list of commonly selected providers }
596begin
597end;
598
599function 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! }
602begin
603 CallV('ORWU NEWPERS', [StartFrom, Direction, 'PROVIDER']);
604// MixedCaseList(RPCBrokerV.Results);
605 Result := RPCBrokerV.Results;
606end;
607
[830]608function SubSetOfCosigners(const StartFrom: string; Direction: Integer; Date: TFMDateTime;
[1679]609 ATitle: integer; ADocType: integer): TStrings;
[830]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! }
612begin
613 if ATitle > 0 then ADocType := 0;
[1679]614 // CQ #17218 - Correcting order of parameters for this call - jcs
615 //CallV('ORWU2 COSIGNER', [StartFrom, Direction, Date, ATitle, ADocType]);
[830]616 CallV('ORWU2 COSIGNER', [StartFrom, Direction, Date, ADocType, ATitle]);
617
618 // MixedCaseList(RPCBrokerV.Results);
619 Result := RPCBrokerV.Results;
620end;
621
[456]622function 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! }
625begin
626 CallV('ORWU NEWPERS', [StartFrom, Direction, 'PROVIDER', DateTime]);
627 MixedCaseList(RPCBrokerV.Results);
628 Result := RPCBrokerV.Results;
629end;
630
631function 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! }
634begin
635 CallV('ORWU NEWPERS', [StartFrom, Direction, '', DateTime]);
636 MixedCaseList(RPCBrokerV.Results);
637 Result := RPCBrokerV.Results;
638end;
639
640function 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!}
643begin
644 CallV('ORWU NEWPERS', [StartFrom, Direction, '', '', '', True]); //TRUE = return all active and inactive users
645 MixedCaseList(RPCBrokerV.Results);
646 Result := RPCBrokerV.Results;
647end;
648
649
650procedure ListClinicTop(Dest: TStrings);
651{ checks parameters for list of commonly selected clinics }
652begin
653end;
654
655function 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! }
658begin
659 CallV('ORWU CLINLOC', [StartFrom, Direction]);
660 MixedCaseList(RPCBrokerV.Results);
661 Result := RPCBrokerV.Results;
662end;
663
664function GetDfltSort: string;
665{ Assigns uPtLstDfltSort to user's default patient list sort order (string character).}
666begin
667 uPtListDfltSort := sCallV('ORQPT DEFAULT LIST SORT', [nil]);
668 if uPtListDfltSort = '' then uPtListDfltSort := 'A'; // Default is always "A" for alpha.
669 result := uPtListDfltSort;
670end;
671
672procedure ResetDfltSort;
673begin
674 uPtListDfltSort := '';
675end;
676
677procedure ListPtByDflt(Dest: TStrings);
678{ loads the default patient list into Dest, Pieces: DFN^PATIENT NAME, ETC. }
679var
680 i, SourceType: Integer;
681 ATime, APlace, Sort, Source, x: string;
682 tmplst: TORStringList;
683begin
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);
[830]722 FastAssign(tmplst, Dest);
[456]723 finally
724 tmplst.Free;
725 end;
726end;
727
728procedure ListPtByProvider(Dest: TStrings; ProviderIEN: Int64);
729{ lists all patients associated with a given provider: DFN^Patient Name }
730begin
731 CallV('ORQPT PROVIDER PATIENTS', [ProviderIEN]);
732 SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
733 MixedCaseList(RPCBrokerV.Results);
[830]734 FastAssign(RPCBrokerV.Results, Dest);
[456]735end;
736
737procedure ListPtByTeam(Dest: TStrings; TeamIEN: Integer);
738{ lists all patients associated with a given team: DFN^Patient Name }
739begin
740 CallV('ORQPT TEAM PATIENTS', [TeamIEN]);
741 SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
742 MixedCaseList(RPCBrokerV.Results);
[830]743 FastAssign(RPCBrokerV.Results, Dest);
[456]744end;
745
746procedure ListPtBySpecialty(Dest: TStrings; SpecialtyIEN: Integer);
747{ lists all patients associated with a given specialty: DFN^Patient Name }
748begin
749 CallV('ORQPT SPECIALTY PATIENTS', [SpecialtyIEN]);
750 SortByPiece(TStringList(RPCBrokerV.Results), U, 2);
751 MixedCaseList(RPCBrokerV.Results);
[830]752 FastAssign(RPCBrokerV.Results, Dest);
[456]753end;
754
755procedure ListPtByClinic(Dest: TStrings; ClinicIEN: Integer; FirstDt, LastDt: string); //TFMDateTime);
756{ lists all patients associated with a given clinic: DFN^Patient Name^App't }
757var
758 i: Integer;
759 x, ATime, APlace, Sort: string;
760begin
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);
[830]780 FastAssign(Results, Dest);
[456]781 end;
782end;
783
784procedure ListPtByWard(Dest: TStrings; WardIEN: Integer);
785{ lists all patients associated with a given ward: DFN^Patient Name^Room/Bed }
786var
787 Sort: string;
788begin
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);
[830]796 FastAssign(RPCBrokerV.Results, Dest);
[456]797end;
798
799procedure ListPtByLast5(Dest: TStrings; const Last5: string);
800var
801 i: Integer;
802 x, ADate, AnSSN: string;
803begin
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);
[830]818 FastAssign(RPCBrokerV.Results, Dest);
[456]819end;
820
821procedure ListPtByRPLLast5(Dest: TStrings; const Last5: string);
822var
823 i: Integer;
824 x, ADate, AnSSN: string;
825begin
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);
[830]840 FastAssign(RPCBrokerV.Results, Dest);
[456]841end;
842
843procedure ListPtByFullSSN(Dest: TStrings; const FullSSN: string);
844{ lists all patients found in the SSN xref that match FullSSN: DFN^Patient Name }
845var
846 i: integer;
847 x, ADate, AnSSN: string;
848begin
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);
[830]869 FastAssign(RPCBrokerV.Results, Dest);
[456]870end;
871
872procedure ListPtByRPLFullSSN(Dest: TStrings; const FullSSN: string);
873{ lists all patients found in the SSN xref that match FullSSN: DFN^Patient Name }
874var
875 i: integer;
876 x, ADate, AnSSN: string;
877begin
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);
[830]898 FastAssign(RPCBrokerV.Results, Dest);
[456]899end;
900
901procedure ListPtTop(Dest: TStrings);
902{ currently returns the last patient selected }
903begin
904 CallV('ORWPT TOP', [nil]);
905 MixedCaseList(RPCBrokerV.Results);
[830]906 FastAssign(RPCBrokerV.Results, Dest);
[456]907end;
908
909function 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! }
912begin
913 CallV('ORWPT LIST ALL', [StartFrom, Direction]);
914 MixedCaseList(RPCBrokerV.Results);
915 Result := RPCBrokerV.Results;
916end;
917
918function MakeRPLPtList(RPLList: string): string;
919{ Creates "RPL" Restricted Patient List based on Team List info in user's record. }
920begin
921 result := sCallV('ORQPT MAKE RPL', [RPLList]);
922end;
923
924function 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! }
927begin
928 CallV('ORQPT READ RPL', [RPLJobNumber, StartFrom, Direction]);
929 MixedCaseList(RPCBrokerV.Results);
930 Result := RPCBrokerV.Results;
931end;
932
933procedure KillRPLPtList(RPLJobNumber: string);
934begin
935 CallV('ORQPT KILL RPL', [RPLJobNumber]);
936end;
937
938{ Patient Specific Calls }
939
940function CalcAge(BirthDate, DeathDate: TFMDateTime): Integer;
941{ calculates age based on today's date and a birthdate (in Fileman format) }
942begin
943 if (DeathDate > BirthDate) then
944 Result := Trunc(DeathDate - BirthDate) div 10000
945 else
946 Result := Trunc(FMToday - BirthDate) div 10000
947end;
948
949procedure CheckSensitiveRecordAccess(const DFN: string; var AccessStatus: Integer;
950 var MessageText: string);
951begin
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;
964end;
965
966procedure CheckRemotePatient(var Dest: string; Patient, ASite: string; var AccessStatus: Integer);
967
968begin
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;
993end;
994
995procedure CurrentLocationForPatient(const DFN: string; var ALocation: Integer; var AName: string; var ASvc: string);
996var
997 x: string;
998begin
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);
1003end;
1004
1005function DateOfDeath(const DFN: string): TFMDateTime;
1006{ returns 0 or the date a patient died }
1007begin
1008 Result := MakeFMDateTime(sCallV('ORWPT DIEDON', [DFN]));
1009end;
1010
1011function GetPtIDInfo(const DFN: string): TPtIDInfo; //*DFN*
[1679]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] }
[456]1014var
1015 x: string;
1016begin
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;
1041end;
1042
1043function HasLegacyData(const DFN: string; var AMsg: string): Boolean;
1044var
1045 i: Integer;
1046begin
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;
1055end;
1056
1057function LogSensitiveRecordAccess(const DFN: string): Boolean;
1058begin
1059 Result := sCallV('DG SENSITIVE RECORD BULLETIN', [DFN]) = '1';
1060end;
1061
1062function MeansTestRequired(const DFN: string; var AMsg: string): Boolean;
1063var
1064 i: Integer;
1065begin
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;
1074end;
1075
1076function RestrictedPtRec(const DFN: string): Boolean; //*DFN*
1077{ returns true if the record for a patient identified by DFN is restricted }
1078begin
1079 Result := Piece(sCallV('ORWPT SELCHK', [DFN]), U, 1) = '1';
1080end;
1081
1082procedure 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]^
[1679]1085 ADMITTIME[10]^CONVERTED[11]^SVCONN[12]^SC%[13]^ICN[14]^Age[15]^TreatSpec[16] }
[456]1086var
1087 x: string;
1088begin
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);
[1679]1117 Associate := Piece(x, U, 4);
[456]1118 x := sCallV('ORWPT INPLOC', [DFN]);
1119 WardService := Piece(x, U, 3);
1120 end;
1121 end;
1122end;
1123
1124function SimilarRecordsFound(const DFN: string; var AMsg: string): Boolean;
1125begin
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 *)
1148end;
1149
1150function GetDFNFromICN(AnICN: string): string;
1151begin
1152 Result := Piece(sCallV('VAFCTFU CONVERT ICN TO DFN', [AnICN]), U, 1);
1153end;
1154
1155{ Encounter specific calls }
1156
1157function GetEncounterText(const DFN: string; Location: integer; Provider: Int64): TEncounterText; //*DFN*
1158{ returns resolved external values Pieces: LOCNAME[1]^PROVNAME[2]^ROOMBED[3] }
1159var
1160 x: string;
1161begin
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;
1171end;
1172
1173procedure 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 }
1177const
1178 SKIP_ADMITS = 1;
1179begin
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);
[830]1186 FastAssign(Results, Dest);
[456]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;
[830]1202 FastAssign(Results, Dest);
[456]1203 end;
1204 *)
1205end;
1206
1207procedure ListAdmitAll(Dest: TStrings; const DFN: string); //*DFN*
1208{ lists all admissions for a patient: MovementTime^LocIEN^LocName^Type }
1209var
1210 i: Integer;
1211 ATime, x: string;
1212begin
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;
[830]1224 FastAssign(Results, Dest);
[456]1225 end;
1226end;
1227
1228function 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! }
1231begin
1232 CallV('ORWU HOSPLOC', [StartFrom, Direction]);
1233 Result := RPCBrokerV.Results;
1234end;
1235
1236function 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.}
1240begin
1241 CallV('ORWU1 NEWLOC', [StartFrom, Direction]);
1242 Result := RPCBrokerV.Results;
1243end;
1244
1245function 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! }
1248begin
1249 CallV('ORWU INPLOC', [StartFrom, Direction]);
1250 Result := RPCBrokerV.Results;
1251end;
1252
1253{ Remote Data Access calls }
1254
1255function HasRemoteData(const DFN: string; var ALocations: TStringList): Boolean;
1256begin
1257 CallV('ORWCIRN FACLIST', [DFN]);
[830]1258 FastAssign(RPCBrokerV.Results, ALocations);
[456]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
1269end;
1270
1271function CheckHL7TCPLink: Boolean;
1272 begin
1273 CallV('ORWCIRN CHECKLINK',[nil]);
1274 Result := RPCBrokerV.Results[0] = '1';
1275 end;
1276
1277function GetVistaWebAddress(value: string): string;
1278begin
1279 CallV('ORWCIRN WEBADDR', [value]);
1280 result := RPCBrokerV.Results[0];
1281end;
1282
1283function GetDefaultPrinter(DUZ: Int64; Location: integer): string;
1284begin
1285 Result := sCallV('ORWRP GET DEFAULT PRINTER', [DUZ, Location]) ;
1286end;
1287
1288end.
Note: See TracBrowser for help on using the repository browser.