source: WorldVistAEHR/trunk/r/VISTA_OFFICE_EHR-VEPE/VEPERIC.m@ 1356

Last change on this file since 1356 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.1 KB
Line 
1VEPERIC ;KFK;REGISTRATION CHECK; 5/3/05 11:22am ; 6/2/05 1:56pm
2 ;;1.0;VOEB;;Jun 12, 2005
3 ;
4 ; This routine will check an HL7 message that is generated through
5 ; the registration process in COTS, a doctor's office package.
6 ; The results of the lookup are returned in the variable MSG:
7 ;
8 ; DFN = Match is found
9 ; 0 = New patient flag
10 ; -1 = Error Flag
11 ;
12 ; The results of the error will be stored in the ^VEPER(19904.2
13 ; file.
14 ;
15 Q ;No direct entry
16 ;
17LKUP(HL7,HL7DT,VCOB,VDOB,VFI,VHRN,VNAME,VSEX) ;
18 ;
19 N DIC,DIE,DR,ERR,ERRDT,ERRMSG,ERRTYP,FCOB,FDOB,FE,FIN,FOUND,FSEX,MATCH
20 N MSG,MULT,NAN,NOFI,NOHRN,NONAME,RESULTS,SCREEN,VAR,VPID,Y
21 ;
22 D FINDN,FINDF,FINDH
23 I MULT=0 D MSGMP Q MSG
24 I NONAME=0,NOFI=0,NOHRN=0 D MSGNP Q MSG
25 I FIN'=NAN D PID,MSGID D:MATCH=1 MSGMM Q MSG
26 D PID I MATCH'=1 D MSGID
27 Q MSG
28 ;
29MSGM ; Error set if there is a piece of data missing from the VISTA file.
30 ; Full verification can not be completed.
31 S (FE,VAR)="" F S VAR=$O(ERR(VAR)) Q:VAR="" D
32 . S FE=FE_$S(VAR="FSEX":"SEX",VAR="FDOB":"DATE OF BIRTH",1:"HEALTH RECORD NUMBER")_","
33 I $E($L(FE))="," S FE=$E(FE,1,$L(FE)-1)
34 S MSG="-1",ERRTYP="MD"
35 S ERRMSG="Missing Data Error: Match could not be verified because the following pieces of data are missing in the VISTA file - "_FE
36 D SAVE
37 Q
38 ;
39MSGMP ; Multiple mathces were found for incoming data.
40 S MSG="-1",ERRTYP="MP"
41 S ERRMSG="Multiple Match Error: Multiple matches were found for the information that was entered."
42 D SAVE
43 Q
44 ;
45MSGNP ; Flag returned to indicate that this is a new patient.
46 S MSG=0
47 Q
48 ;
49MSGMM ; Error set as a patient mismatch.
50 S MSG="-1",ERRTYP="MM"
51 S ERRMSG="Patient Mismatch Error: Patient appears to already be registered under Patient ID - "_VFI
52 D SAVE
53 Q
54 ;
55MSGID ; Error set if a piece of registration data does not match stored
56 ; data from patient file.
57 S MSG="-1",ERRTYP="ID"
58 S ERRMSG="Match Incomplete Error: Patient information sent in does not match patient information on file. Possible new patient."
59 D SAVE
60 Q
61 ;
62PID ; Verification of patient demoghrapic information.
63 S MATCH=0
64 S VPID=^DPT(NAN,0),FSEX=$P(VPID,U,2),FDOB=$P(VPID,U,3)
65 K ERR
66 F VAR="FSEX","FDOB" D
67 . I @VAR="" S ERR(VAR)=""
68 I $D(ERR) D MSGM Q
69 I FSEX'=VSEX Q
70 I FDOB'=VDOB Q
71 S MATCH=1,MSG=NAN
72 Q
73 ;
74SAVE ; Save errors to error file.
75 N DA,X,Y
76 S ERRDT=""""_$$NOW^XLFDT_""""
77 S DIC="^VEPER(19904.2,",DIC(0)="L",X=ERRDT
78 D ^DIC
79 S DIE=DIC,DA=+Y
80 K DR
81 S DR=".02///^S X=VNAME;.03////"_HL7_";.04////"_VFI_";.05////"_ERRTYP_";.06////"_HL7DT_";1.01////"_ERRMSG D ^DIE
82 Q
83 ;
84FINDN ; Name lookup.
85 S (MULT,NAN,NONAME)=1
86 S FOUND="RESULTS",SCREEN="I $P(^(0),U,2)=VSEX&($P(^(0),U,3)=VDOB)"
87 K RESULTS
88 D FIND^DIC(2,,"@;.02;.03","O",VNAME,"*",,SCREEN,,FOUND)
89 I $P(RESULTS("DILIST",0),U)=0 S NONAME=0 Q
90 I $P(RESULTS("DILIST",0),U)>1 S MULT=0 Q
91 S NAN=RESULTS("DILIST",2,1)
92 Q
93 ;
94FINDF ; Foreign ID lookup.
95 N D,X,Y
96 S (FIN,NOFI)=1
97 S DIC="^AUPNPAT(",DIC(0)="M",D="C",X=VFI
98 D IX^DIC
99 I Y=-1 S NOFI=0 Q
100 S FIN=$P(Y,U)
101 Q
102 ;
103FINDH ; Health Record Number lookup.
104 N D,HRNN,X,Y
105 S (HRNN,NOHRN)=1
106 S DIC="^AUPNPAT(",DIC(0)="M",D="D",X=VHRN
107 D IX^DIC
108 I Y=-1 S NOHRN=0 Q
109 S HRNN=$P(Y,U)
110 Q
Note: See TracBrowser for help on using the repository browser.