source: cprs/branches/foia-cprs/CPRS-Chart/rCore.pas@ 459

Last change on this file since 459 was 459, checked in by Kevin Toppenberg, 16 years ago

Adding foia-cprs branch

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