source: WorldVistAEHR/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFVTQ.m@ 862

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

initial load of WorldVistAEHR

File size: 5.5 KB
Line 
1MPIFVTQ ;SLC/ARS-BUILD DATA TO QUERY MPI RESPONSE PROCESS (ADDPAT) ;JUL 16, 1997
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**1,9,17,21,23,28,33,35**;30 Apr 99
3 ;
4 ; Integration Agreements Utilized:
5 ; ^DPT( -9 node check - #2762
6 ; ^DPT( "MPI" node - #2070
7 ; EXC, START, STOP ^RGHLLOG - #2796
8 ; NAME^VAFCPID2 - #3492
9 ;
10 Q ;NOT an entry point
11 ;
12VTQ1(MPIIT,MPIOUT,HL,MPIQRYNM,MPISND) ;
13 ;MPIIT=DFN in patient file.
14 ;MPIOUT=Array you want the VTQ/RDF put into.
15 ;HL=Array of encoding characters and Field separator.
16 ;MPIQRYNM=Name of query to put into message.
17 ;MPISND (OPTIONAL) = item #'s separated by ; to be used to query.
18 ; default is DOB;SSN;LAST NAME;FIRST NAME;SUFFIX OF NAME;SEX;DOD;
19 ; POB-CITY;POB-STATE;MIDDLE NAME
20 ;
21 ;If invalid DFN, Patient Merged, if ICN already assigned, Test SSN, the VTQ query is not built and -1^'error message' returned in MPIOUT(0).
22 ;
23 ;If DOB does not contain a 7 digit date OR if name is not present, -1^Missing Required fields will be returned in MPIOUT(0).
24 ;
25 ;If patient has a date of death, the VTQ query is built with MPIOUT(0) returned with 0^Patient has date of death. Programmer to decide if VTQ should be sent.
26 ;
27 N MPITEST,MPISSN,MPIDTH,MPINM,MPIDOB,ERR
28 S MPIOUT(0)=""
29 I '$D(MPISND) S MPISND="00122;00108.1;00108.2;00110;00740;00111;00108.4;00126.1;00126.2;00108.3"
30 ;validation check
31 I '$D(HL) S MPIOUT(0)="-1^no encoding characters" Q
32 I $G(HL("FS"))=""!($G(HL("ECH"))="") S MPIOUT(0)="-1^no encoding characters" Q
33 I MPIIT="" S MPIOUT(0)="-1^invalid DFN" Q
34 I $G(^DPT(MPIIT,-9))'="" S MPIOUT(0)="-1^Patient merged "_^DPT(MPIIT,-9) Q
35 S MPIMPI=$G(^DPT(MPIIT,"MPI"))
36 S:MPIMPI'="" MPIZICN=$P(^DPT(MPIIT,"MPI"),"^",1)
37 I '$D(MPIFRES),$G(MPIZICN)'="" S MPIOUT(0)="-1^ICN already assigned "_MPIZICN Q
38 S MPITEST=$G(^DPT(MPIIT,0))
39 I MPITEST="" S MPIOUT(0)="-1^invalid DFN" Q
40 I $P(MPITEST,"^")=""&($P(MPITEST,"^",2)="")&($P(MPITEST,"^",3)="")&($P(MPITEST,"^",9)="") D Q
41 .K MPIARR
42 .S MPIOUT(0)="-1^stub entry in DPT"
43 .S MPIARR(991.01)="@",MPIARR(991.02)="@",MPIARR(991.03)="@",MPIARR(991.05)="@",MPIARR(992)=MPIZICN,MPIARR(993)=+$$SITE^VASITE()
44 .S ERR=$$DELALLTF^VAFCTFU(MPIZICN) ;clean up tf list
45 .S ERR=$$UPDATE^MPIFAPI(MPIIT,"MPIARR",1,1) K MPIARR
46 .;PATCH 33 - stub entry with local, remove local and don't send to MPI
47 S MPISSN=$P(MPITEST,"^",9)
48 S MPIDTH=""
49 S:$G(^DPT(MPIIT,.35))'="" MPIDTH=$P(^DPT(MPIIT,.35),"^",1)
50 I $G(MPIDTH)'="" S MPIOUT(0)="0^Patient has Date of Death "_MPIDTH
51 D VTQC(MPISSN,MPIDTH,MPISND,.HL,MPIQRYNM,.MPIOUT,MPIIT)
52 Q
53EXC(IEN) ;
54 Q:'$D(^DPT(IEN))
55 D LOCAL^MPIFQ3(IEN)
56 D START^RGHLLOG()
57 D EXC^RGHLLOG(209,"DFN= "_IEN_" is Missing Required Field(s)",IEN)
58 D STOP^RGHLLOG()
59 Q
60 ;
61VTQC(MPISSN,MPIDTH,MPISND,HL,MPIQRYNM,MPIOUT,MPIIT) ;
62 N MPIPOB,MPIPOBS,MPINM,MPI2MN,MPI1NM,QUERY,MPIDOB,RDF,MPIMOD
63 N MPIHDTH,MPIZDOB,MPIXDOB,MPIMPI,MPIZICN,QUEDOB,MPI2NM,MPICS,MPIESC,MPIHDOB,MPIMNM,MPIMN
64 N MPINMSFX,MPIRS,MPISCS,MPISEX,MPIZLOC
65 I $G(MPIQRYNM)="" S MPIQRYNM="VTQ_PID_ICN_LOAD_1"
66 S MPICS=$E(HL("ECH"),1)
67 S MPIRS=$E(HL("ECH"),2)
68 S MPISCS=$E(HL("ECH"),4)
69 S MPIESC=$E(HL("ECH"),3)
70 ;build RDF as the third segment
71 D BLDRDF^MPIFSA2(.MPIOUT,3,MPIRS,MPICS)
72 S QUERY="VTQ"_HL("FS")_MPIIT_HL("FS")_"T"_HL("FS")_MPIQRYNM_HL("FS")_"ICN"_HL("FS")
73 ;
74 I MPISND["00108" S MPINM=$P(MPITEST,"^") D NAME^VAFCPID2(MPIIT,.MPINM) ;agressive name reformatting
75 ; ^ sending all or part of name
76 I MPISND["00108.1" S MPI2NM=$P(MPINM,",",1) I MPI2NM'="" S QUERY=QUERY_"@00108.1"_MPICS_"EQ"_MPICS_MPI2NM
77 ; ^ sending last name
78 ;I MPISND["00122"&(MPISSN'="")&(MPISSN'["P") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00122"_MPICS_"EQ"_MPICS_MPISSN
79 ; ^ **35 SENDING PSUEDO TO KNOW THAT THE SITE HAS A VALUE FOR SSN
80 I MPISND["00122"&(MPISSN'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00122"_MPICS_"EQ"_MPICS_MPISSN
81 ; ^ sending SSN
82 I MPISND["00108.2" S MPI1NM=$P(MPINM,",",2),MPI1NM=$P(MPI1NM," ",1) I MPI1NM'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00108.2"_MPICS_"EQ"_MPICS_MPI1NM
83 ; ^ sending first name
84 I MPISND["00110" D
85 .S MPIDOB=$P(MPITEST,"^",3)
86 .Q:MPIDOB=""
87 .S MPIHDOB=$$HLDATE^HLFNC(MPIDOB)
88 .; send date of birth (convert to hl7 date format)
89 .S MPIMOD=MPIDOB#100
90 .I MPIQRYNM'="VTQ_PID_ICN_LOAD_1" S MPIZDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"GN"_MPICS_MPIHDOB
91 .I MPIQRYNM="VTQ_PID_ICN_LOAD_1" S MPIZDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"EQ"_MPICS_MPIHDOB
92 .S MPIXDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"EQ"_MPICS_MPIHDOB
93 .S QUEDOB=$S(MPIMOD>0:MPIXDOB,1:MPIZDOB)
94 .S QUERY=QUERY_QUEDOB
95 ; ^ sending date of birth
96 I $D(MPIDTH),(MPISND["00740")&(MPIDTH'="") S MPIHDTH=$$HLDATE^HLFNC(MPIDTH),QUERY=QUERY_MPICS_"AND"_MPIRS_"@00740"_MPICS_"EQ"_MPICS_MPIHDTH
97 ; ^ sending date of death
98 I MPISND["00111" S:$G(^DPT(MPIIT,0))'="" MPISEX=$P(^DPT(MPIIT,0),"^",2) I MPISEX'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00111"_MPICS_"EQ"_MPICS_MPISEX
99 ; ^ sending Sex
100 I MPISND["00108.4" S MPI1NM=$P(MPINM,",",2),MPINMSFX=$P(MPI1NM," ",3) I MPINMSFX'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00108.4"_MPICS_"EQ"_MPICS_MPINMSFX
101 ; ^ sending suffix name
102 I MPISND["00126.1" S MPIPOB=$P(^DPT(MPIIT,0),"^",11) I MPIPOB'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00126.1"_MPICS_"EQ"_MPICS_MPIPOB
103 ; send place of birth - city
104 I MPISND["00126.2" S MPIPOBS=$P(^DPT(MPIIT,0),"^",12) I MPIPOBS'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00126.2"_MPICS_"EQ"_MPICS_$P($G(^DIC(5,+MPIPOBS,0)),"^",2)
105 ; send place of birth - state
106 I MPISND["00108.3" S MPIMN=$P($P(MPINM,",",2)," ",2) I MPIMN'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00108.3"_MPICS_"EQ"_MPICS_MPIMN
107 ; send middle name
108 ;
109 I $G(MPIOUT(0))="" S MPIOUT(0)="1^good data"
110 S MPIOUT(2)=QUERY
111 Q
Note: See TracBrowser for help on using the repository browser.