MPIFVTQ ;SLC/ARS-BUILD DATA TO QUERY MPI RESPONSE PROCESS (ADDPAT) ; 1/12/10 9:28am
;;1.0;MASTER PATIENT INDEX VISTA;**1,9,17,21,23,28,33,35,52,54**;30 Apr 99;Build 2
;
; Integration Agreements Utilized:
; ^DPT( -9 node check - #2762
; ^DPT( "MPI" node - #2070
; EXC, START, STOP ^RGHLLOG - #2796
; NAME^VAFCPID2 - #3492
;
Q ;NOT an entry point
;
VTQ1(MPIIT,MPIOUT,HL,MPIQRYNM,MPISND) ;
;MPIIT=DFN in patient file.
;MPIOUT=Array you want the VTQ/RDF put into.
;HL=Array of encoding characters and Field separator.
;MPIQRYNM=Name of query to put into message.
;MPISND (OPTIONAL) = item #'s separated by ; to be used to query.
; default is DOB;SSN;LAST NAME;FIRST NAME;SUFFIX OF NAME;SEX;DOD;
; POB-CITY;POB-STATE;MIDDLE NAME
;
;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).
;
;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).
;
;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.
;
N MPITEST,MPISSN,MPIDTH,MPINM,MPIDOB,ERR,MPITST11,MPITST13
S MPIOUT(0)=""
I '$D(MPISND) S MPISND="00122;00108.1;00108.2;00110;00740;00111;00108.4;00126.1;00126.2;00108.3;00114.1;00114.2;00114.3;00114.4;00114.5;00114.6;00114.8;00114.9;00116;00119;00125;00127;00100"
;validation check
I '$D(HL) S MPIOUT(0)="-1^no encoding characters" Q
I $G(HL("FS"))=""!($G(HL("ECH"))="") S MPIOUT(0)="-1^no encoding characters" Q
I MPIIT="" S MPIOUT(0)="-1^invalid DFN" Q
I $G(^DPT(MPIIT,-9))'="" S MPIOUT(0)="-1^Patient merged "_^DPT(MPIIT,-9) Q
S MPIMPI=$G(^DPT(MPIIT,"MPI"))
S:MPIMPI'="" MPIZICN=$P(^DPT(MPIIT,"MPI"),"^",1)
I '$D(MPIFRES),$G(MPIZICN)'="" S MPIOUT(0)="-1^ICN already assigned "_MPIZICN Q
S MPITEST=$G(^DPT(MPIIT,0))
S MPITST11=$G(^DPT(MPIIT,.11)),MPITST13=$G(^DPT(MPIIT,.13))
I MPITEST="" S MPIOUT(0)="-1^invalid DFN" Q
I $P(MPITEST,"^")=""&($P(MPITEST,"^",2)="")&($P(MPITEST,"^",3)="")&($P(MPITEST,"^",9)="") D Q
.K MPIARR
.S MPIOUT(0)="-1^invalid DFN" ;**54 changed the error message to allow the local/missing job to skip this record"
.S MPIARR(991.01)="@",MPIARR(991.02)="@",MPIARR(991.03)="@",MPIARR(991.05)="@"
.; **54 MVI 896 REMOVED SETTING OF VARIABLES MPIARR(992) & MPIARR(993)
.I $G(MPIZICN)'="" S ERR=$$DELALLTF^VAFCTFU(MPIZICN) ;clean up tf list
.S ERR=$$UPDATE^MPIFAPI(MPIIT,"MPIARR",1,1) K MPIARR
.;PATCH 33 - stub entry with local, remove local and don't send to MPI
S MPISSN=$P(MPITEST,"^",9)
S MPIDTH=""
S:$G(^DPT(MPIIT,.35))'="" MPIDTH=$P(^DPT(MPIIT,.35),"^",1)
I $G(MPIDTH)'="" S MPIOUT(0)="0^Patient has Date of Death "_MPIDTH
D VTQC(MPISSN,MPIDTH,MPISND,.HL,MPIQRYNM,.MPIOUT,MPIIT)
Q
EXC(IEN) ;
Q:'$D(^DPT(IEN))
D LOCAL^MPIFQ3(IEN)
D START^RGHLLOG()
D EXC^RGHLLOG(209,"DFN= "_IEN_" is Missing Required Field(s)",IEN)
D STOP^RGHLLOG()
Q
;
VTQC(MPISSN,MPIDTH,MPISND,HL,MPIQRYNM,MPIOUT,MPIIT) ;
N MPIPOB,MPIPOBS,MPINM,MPI2MN,MPI1NM,QUERY,MPIDOB,RDF,MPIMOD
N MPIHDTH,MPIZDOB,MPIXDOB,MPIMPI,MPIZICN,QUEDOB,MPI2NM,MPICS,MPIESC,MPIHDOB,MPIMNM,MPIMN
N MPINMSFX,MPIRS,MPISCS,MPISEX,MPIZLOC,MPISTR1,MPISTR2,MPISTR3,MPICITY,MPISTPRV,XNOD
N MPIZIPPL,MPICNTRY,MPICNTY,MPIRESPH,MPIMRTST,MPIETH,MPIDLT,MPIMBI
I $G(MPIQRYNM)="" S MPIQRYNM="VTQ_PID_ICN_LOAD_1"
S MPICS=$E(HL("ECH"),1)
S MPIRS=$E(HL("ECH"),2)
S MPISCS=$E(HL("ECH"),4)
S MPIESC=$E(HL("ECH"),3)
;build RDF as the third segment
D BLDRDF^MPIFSA2(.MPIOUT,3,MPIRS,MPICS)
S QUERY="VTQ"_HL("FS")_MPIIT_HL("FS")_"T"_HL("FS")_MPIQRYNM_HL("FS")_"ICN"_HL("FS")
;
I MPISND["00108" S MPINM=$P(MPITEST,"^") D NAME^VAFCPID2(MPIIT,.MPINM) ;agressive name reformatting
; ^ sending all or part of name
I MPISND["00108.1" S MPI2NM=$P(MPINM,",",1) I MPI2NM'="" S QUERY=QUERY_"@00108.1"_MPICS_"EQ"_MPICS_MPI2NM
; ^ sending last name
;I MPISND["00122"&(MPISSN'="")&(MPISSN'["P") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00122"_MPICS_"EQ"_MPICS_MPISSN
; ^ **35 SENDING PSUEDO TO KNOW THAT THE SITE HAS A VALUE FOR SSN
I MPISND["00122"&(MPISSN'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00122"_MPICS_"EQ"_MPICS_MPISSN
; ^ sending SSN
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
; ^ sending first name
I MPISND["00110" D
.S MPIDOB=$P(MPITEST,"^",3)
.Q:MPIDOB=""
.S MPIHDOB=$$HLDATE^HLFNC(MPIDOB)
.; send date of birth (convert to hl7 date format)
.S MPIMOD=MPIDOB#100
.I MPIQRYNM'="VTQ_PID_ICN_LOAD_1" S MPIZDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"GN"_MPICS_MPIHDOB
.I MPIQRYNM="VTQ_PID_ICN_LOAD_1" S MPIZDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"EQ"_MPICS_MPIHDOB
.S MPIXDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"EQ"_MPICS_MPIHDOB
.S QUEDOB=$S(MPIMOD>0:MPIXDOB,1:MPIZDOB)
.S QUERY=QUERY_QUEDOB
; ^ sending date of birth
I $D(MPIDTH),(MPISND["00740")&(MPIDTH'="") S MPIHDTH=$$HLDATE^HLFNC(MPIDTH),QUERY=QUERY_MPICS_"AND"_MPIRS_"@00740"_MPICS_"EQ"_MPICS_MPIHDTH
; ^ sending date of death
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
; ^ sending Sex
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
; ^ sending suffix name
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
; send place of birth - city
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)
; send place of birth - state
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
; send middle name
; **52 - Initiate project
; get address data
D ADDR(MPITST11)
I MPISND["00114.1"&(MPISTR1'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.1"_MPICS_"EQ"_MPICS_MPISTR1
; ^ send Street address line 1
I MPISND["00114.2"&(MPISTR2'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.2"_MPICS_"EQ"_MPICS_MPISTR2
; ^ send Street Address Line 2
I MPISND["00114.3"&(MPICITY'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.3"_MPICS_"EQ"_MPICS_MPICITY
; ^ send City
;I MPISND["00114.4"&(MPISTPRV'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.4"_MPICS_"EQ"_MPICS_MPISTPRV
; ^ send State/Province depending on US or Foreign address
;I MPISND["00114.5"&(MPIZIPPL'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.5"_MPICS_"EQ"_MPICS_MPIZIPPL
; ^ send Zip code/ Postal code depending on US or Foreign address
;I MPISND["00114.6"&(MPICNTRY'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.6"_MPICS_"EQ"_MPICS_MPICNTRY
; ^ send Country
I MPISND["00114.8"&(MPISTR3'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.8"_MPICS_"EQ"_MPICS_MPISTR3
; ^ send Address Line 3
;I MPISND["00114.9"&(MPICNTY'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.9"_MPICS_"EQ"_MPICS_MPICNTY
; ^ send County
I MPISND["00116" S MPIRESPH=$P(MPITST13,"^") I MPIRESPH'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00116"_MPICS_"EQ"_MPICS_MPIRESPH
; ^ send Residence Phone
;I MPISND["00119" S MPIMRTST=$P(MPITEST,"^",5) I MPIMRTST'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00119"_MPICS_"EQ"_MPICS_MPIMRTST
; ^ send Marital Status
;I MPISND["00125" S XNOD=$O(^DPT(MPIIT,.06,"")) I XNOD'="" S MPIETH=$P($G(^DPT(MPIIT,.06,XNOD,0)),"^") I MPIETH'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00125"_MPICS_"EQ"_MPICS_MPIETH
; ^ send Ethnicity
;I MPISND["00127" S MPIMBI=$P($G(^DPT(MPIIT,"MPIMB")),"^") I MPIMBI'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00127"_MPICS_"EQ"_MPICS_MPIMBI
; ^ send Multiple Birth Indicator
;S MPIDLT=$$GETDLT(MPIIT)
;I MPISND["00100"&(MPIDLT'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00100"_MPICS_"EQ"_MPICS_MPIDLT
; ^ send Date Last Treated
I $G(MPIOUT(0))="" S MPIOUT(0)="1^good data"
S MPIOUT(2)=QUERY
Q
GETDLT(MPIIT) ;Get Date Last Treated
N TFIEN,TFZN
S TFIEN=$O(^DGCN(391.91,"APAT",MPIIT,+$$SITE^VASITE,0))
I $G(TFIEN)'="" S TFZN=^DGCN(391.91,TFIEN,0)
Q $P($G(TFZN),"^",3)
;
ADDR(MPITST11) ;Get Address information
;
S MPISTR1=$P($G(MPITST11),"^") ;Street address line 1
S MPISTR2=$P($G(MPITST11),"^",2) ;Street address line 2
S MPISTR3=$P($G(MPITST11),"^",3) ;Street address line 3
S MPICITY=$P($G(MPITST11),"^",4) ;City
;S MPICNTRY=$P($G(MPITST11),"^",10) ;Country
;S MPICNTY=$P($G(MPITST11),"^",7) ;County
;I MPICNTRY=""!(MPICNTRY=1) D
;. ;Have USA address
;. S MPISTPRV=$P($G(MPITST11),"^",5) ;State
;. S MPIZIPPL=$P($G(MPITST11),"^",6) ;Zip code
;I MPICNTRY'="",(MPICNTRY'=1) D
;. ;Foreign Country
;. S MPISTPRV=$P($G(MPITST11),"^",8) ;Province
;. S MPIZIPPL=$P($G(MPITST11),"^",9) ;Postal code
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMPIFVTQ 8985 printed Oct 16, 2024@18:12:31 Page 2
MPIFVTQ ;SLC/ARS-BUILD DATA TO QUERY MPI RESPONSE PROCESS (ADDPAT) ; 1/12/10 9:28am
+1 ;;1.0;MASTER PATIENT INDEX VISTA;**1,9,17,21,23,28,33,35,52,54**;30 Apr 99;Build 2
+2 ;
+3 ; Integration Agreements Utilized:
+4 ; ^DPT( -9 node check - #2762
+5 ; ^DPT( "MPI" node - #2070
+6 ; EXC, START, STOP ^RGHLLOG - #2796
+7 ; NAME^VAFCPID2 - #3492
+8 ;
+9 ;NOT an entry point
QUIT
+10 ;
VTQ1(MPIIT,MPIOUT,HL,MPIQRYNM,MPISND) ;
+1 ;MPIIT=DFN in patient file.
+2 ;MPIOUT=Array you want the VTQ/RDF put into.
+3 ;HL=Array of encoding characters and Field separator.
+4 ;MPIQRYNM=Name of query to put into message.
+5 ;MPISND (OPTIONAL) = item #'s separated by ; to be used to query.
+6 ; default is DOB;SSN;LAST NAME;FIRST NAME;SUFFIX OF NAME;SEX;DOD;
+7 ; POB-CITY;POB-STATE;MIDDLE NAME
+8 ;
+9 ;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).
+10 ;
+11 ;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).
+12 ;
+13 ;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.
+14 ;
+15 NEW MPITEST,MPISSN,MPIDTH,MPINM,MPIDOB,ERR,MPITST11,MPITST13
+16 SET MPIOUT(0)=""
+17 IF '$DATA(MPISND)
SET MPISND="00122;00108.1;00108.2;00110;00740;00111;00108.4;00126.1;00126.2;00108.3;00114.1;00114.2;00114.3;00114.4;00114.5;00114.6;00114.8;00114.9;00116;00119;00125;00127;00100"
+18 ;validation check
+19 IF '$DATA(HL)
SET MPIOUT(0)="-1^no encoding characters"
QUIT
+20 IF $GET(HL("FS"))=""!($GET(HL("ECH"))="")
SET MPIOUT(0)="-1^no encoding characters"
QUIT
+21 IF MPIIT=""
SET MPIOUT(0)="-1^invalid DFN"
QUIT
+22 IF $GET(^DPT(MPIIT,-9))'=""
SET MPIOUT(0)="-1^Patient merged "_^DPT(MPIIT,-9)
QUIT
+23 SET MPIMPI=$GET(^DPT(MPIIT,"MPI"))
+24 if MPIMPI'=""
SET MPIZICN=$PIECE(^DPT(MPIIT,"MPI"),"^",1)
+25 IF '$DATA(MPIFRES)
IF $GET(MPIZICN)'=""
SET MPIOUT(0)="-1^ICN already assigned "_MPIZICN
QUIT
+26 SET MPITEST=$GET(^DPT(MPIIT,0))
+27 SET MPITST11=$GET(^DPT(MPIIT,.11))
SET MPITST13=$GET(^DPT(MPIIT,.13))
+28 IF MPITEST=""
SET MPIOUT(0)="-1^invalid DFN"
QUIT
+29 IF $PIECE(MPITEST,"^")=""&($PIECE(MPITEST,"^",2)="")&($PIECE(MPITEST,"^",3)="")&($PIECE(MPITEST,"^",9)="")
Begin DoDot:1
+30 KILL MPIARR
+31 ;**54 changed the error message to allow the local/missing job to skip this record"
SET MPIOUT(0)="-1^invalid DFN"
+32 SET MPIARR(991.01)="@"
SET MPIARR(991.02)="@"
SET MPIARR(991.03)="@"
SET MPIARR(991.05)="@"
+33 ; **54 MVI 896 REMOVED SETTING OF VARIABLES MPIARR(992) & MPIARR(993)
+34 ;clean up tf list
IF $GET(MPIZICN)'=""
SET ERR=$$DELALLTF^VAFCTFU(MPIZICN)
+35 SET ERR=$$UPDATE^MPIFAPI(MPIIT,"MPIARR",1,1)
KILL MPIARR
+36 ;PATCH 33 - stub entry with local, remove local and don't send to MPI
End DoDot:1
QUIT
+37 SET MPISSN=$PIECE(MPITEST,"^",9)
+38 SET MPIDTH=""
+39 if $GET(^DPT(MPIIT,.35))'=""
SET MPIDTH=$PIECE(^DPT(MPIIT,.35),"^",1)
+40 IF $GET(MPIDTH)'=""
SET MPIOUT(0)="0^Patient has Date of Death "_MPIDTH
+41 DO VTQC(MPISSN,MPIDTH,MPISND,.HL,MPIQRYNM,.MPIOUT,MPIIT)
+42 QUIT
EXC(IEN) ;
+1 if '$DATA(^DPT(IEN))
QUIT
+2 DO LOCAL^MPIFQ3(IEN)
+3 DO START^RGHLLOG()
+4 DO EXC^RGHLLOG(209,"DFN= "_IEN_" is Missing Required Field(s)",IEN)
+5 DO STOP^RGHLLOG()
+6 QUIT
+7 ;
VTQC(MPISSN,MPIDTH,MPISND,HL,MPIQRYNM,MPIOUT,MPIIT) ;
+1 NEW MPIPOB,MPIPOBS,MPINM,MPI2MN,MPI1NM,QUERY,MPIDOB,RDF,MPIMOD
+2 NEW MPIHDTH,MPIZDOB,MPIXDOB,MPIMPI,MPIZICN,QUEDOB,MPI2NM,MPICS,MPIESC,MPIHDOB,MPIMNM,MPIMN
+3 NEW MPINMSFX,MPIRS,MPISCS,MPISEX,MPIZLOC,MPISTR1,MPISTR2,MPISTR3,MPICITY,MPISTPRV,XNOD
+4 NEW MPIZIPPL,MPICNTRY,MPICNTY,MPIRESPH,MPIMRTST,MPIETH,MPIDLT,MPIMBI
+5 IF $GET(MPIQRYNM)=""
SET MPIQRYNM="VTQ_PID_ICN_LOAD_1"
+6 SET MPICS=$EXTRACT(HL("ECH"),1)
+7 SET MPIRS=$EXTRACT(HL("ECH"),2)
+8 SET MPISCS=$EXTRACT(HL("ECH"),4)
+9 SET MPIESC=$EXTRACT(HL("ECH"),3)
+10 ;build RDF as the third segment
+11 DO BLDRDF^MPIFSA2(.MPIOUT,3,MPIRS,MPICS)
+12 SET QUERY="VTQ"_HL("FS")_MPIIT_HL("FS")_"T"_HL("FS")_MPIQRYNM_HL("FS")_"ICN"_HL("FS")
+13 ;
+14 ;agressive name reformatting
IF MPISND["00108"
SET MPINM=$PIECE(MPITEST,"^")
DO NAME^VAFCPID2(MPIIT,.MPINM)
+15 ; ^ sending all or part of name
+16 IF MPISND["00108.1"
SET MPI2NM=$PIECE(MPINM,",",1)
IF MPI2NM'=""
SET QUERY=QUERY_"@00108.1"_MPICS_"EQ"_MPICS_MPI2NM
+17 ; ^ sending last name
+18 ;I MPISND["00122"&(MPISSN'="")&(MPISSN'["P") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00122"_MPICS_"EQ"_MPICS_MPISSN
+19 ; ^ **35 SENDING PSUEDO TO KNOW THAT THE SITE HAS A VALUE FOR SSN
+20 IF MPISND["00122"&(MPISSN'="")
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00122"_MPICS_"EQ"_MPICS_MPISSN
+21 ; ^ sending SSN
+22 IF MPISND["00108.2"
SET MPI1NM=$PIECE(MPINM,",",2)
SET MPI1NM=$PIECE(MPI1NM," ",1)
IF MPI1NM'=""
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00108.2"_MPICS_"EQ"_MPICS_MPI1NM
+23 ; ^ sending first name
+24 IF MPISND["00110"
Begin DoDot:1
+25 SET MPIDOB=$PIECE(MPITEST,"^",3)
+26 if MPIDOB=""
QUIT
+27 SET MPIHDOB=$$HLDATE^HLFNC(MPIDOB)
+28 ; send date of birth (convert to hl7 date format)
+29 SET MPIMOD=MPIDOB#100
+30 IF MPIQRYNM'="VTQ_PID_ICN_LOAD_1"
SET MPIZDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"GN"_MPICS_MPIHDOB
+31 IF MPIQRYNM="VTQ_PID_ICN_LOAD_1"
SET MPIZDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"EQ"_MPICS_MPIHDOB
+32 SET MPIXDOB=MPICS_"AND"_MPIRS_"@00110"_MPICS_"EQ"_MPICS_MPIHDOB
+33 SET QUEDOB=$SELECT(MPIMOD>0:MPIXDOB,1:MPIZDOB)
+34 SET QUERY=QUERY_QUEDOB
End DoDot:1
+35 ; ^ sending date of birth
+36 IF $DATA(MPIDTH)
IF (MPISND["00740")&(MPIDTH'="")
SET MPIHDTH=$$HLDATE^HLFNC(MPIDTH)
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00740"_MPICS_"EQ"_MPICS_MPIHDTH
+37 ; ^ sending date of death
+38 IF MPISND["00111"
if $GET(^DPT(MPIIT,0))'=""
SET MPISEX=$PIECE(^DPT(MPIIT,0),"^",2)
IF MPISEX'=""
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00111"_MPICS_"EQ"_MPICS_MPISEX
+39 ; ^ sending Sex
+40 IF MPISND["00108.4"
SET MPI1NM=$PIECE(MPINM,",",2)
SET MPINMSFX=$PIECE(MPI1NM," ",3)
IF MPINMSFX'=""
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00108.4"_MPICS_"EQ"_MPICS_MPINMSFX
+41 ; ^ sending suffix name
+42 IF MPISND["00126.1"
SET MPIPOB=$PIECE(^DPT(MPIIT,0),"^",11)
IF MPIPOB'=""
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00126.1"_MPICS_"EQ"_MPICS_MPIPOB
+43 ; send place of birth - city
+44 IF MPISND["00126.2"
SET MPIPOBS=$PIECE(^DPT(MPIIT,0),"^",12)
IF MPIPOBS'=""
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00126.2"_MPICS_"EQ"_MPICS_$PIECE($GET(^DIC(5,+MPIPOBS,0)),"^",2)
+45 ; send place of birth - state
+46 IF MPISND["00108.3"
SET MPIMN=$PIECE($PIECE(MPINM,",",2)," ",2)
IF MPIMN'=""
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00108.3"_MPICS_"EQ"_MPICS_MPIMN
+47 ; send middle name
+48 ; **52 - Initiate project
+49 ; get address data
+50 DO ADDR(MPITST11)
+51 IF MPISND["00114.1"&(MPISTR1'="")
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.1"_MPICS_"EQ"_MPICS_MPISTR1
+52 ; ^ send Street address line 1
+53 IF MPISND["00114.2"&(MPISTR2'="")
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.2"_MPICS_"EQ"_MPICS_MPISTR2
+54 ; ^ send Street Address Line 2
+55 IF MPISND["00114.3"&(MPICITY'="")
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.3"_MPICS_"EQ"_MPICS_MPICITY
+56 ; ^ send City
+57 ;I MPISND["00114.4"&(MPISTPRV'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.4"_MPICS_"EQ"_MPICS_MPISTPRV
+58 ; ^ send State/Province depending on US or Foreign address
+59 ;I MPISND["00114.5"&(MPIZIPPL'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.5"_MPICS_"EQ"_MPICS_MPIZIPPL
+60 ; ^ send Zip code/ Postal code depending on US or Foreign address
+61 ;I MPISND["00114.6"&(MPICNTRY'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.6"_MPICS_"EQ"_MPICS_MPICNTRY
+62 ; ^ send Country
+63 IF MPISND["00114.8"&(MPISTR3'="")
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.8"_MPICS_"EQ"_MPICS_MPISTR3
+64 ; ^ send Address Line 3
+65 ;I MPISND["00114.9"&(MPICNTY'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00114.9"_MPICS_"EQ"_MPICS_MPICNTY
+66 ; ^ send County
+67 IF MPISND["00116"
SET MPIRESPH=$PIECE(MPITST13,"^")
IF MPIRESPH'=""
SET QUERY=QUERY_MPICS_"AND"_MPIRS_"@00116"_MPICS_"EQ"_MPICS_MPIRESPH
+68 ; ^ send Residence Phone
+69 ;I MPISND["00119" S MPIMRTST=$P(MPITEST,"^",5) I MPIMRTST'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00119"_MPICS_"EQ"_MPICS_MPIMRTST
+70 ; ^ send Marital Status
+71 ;I MPISND["00125" S XNOD=$O(^DPT(MPIIT,.06,"")) I XNOD'="" S MPIETH=$P($G(^DPT(MPIIT,.06,XNOD,0)),"^") I MPIETH'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00125"_MPICS_"EQ"_MPICS_MPIETH
+72 ; ^ send Ethnicity
+73 ;I MPISND["00127" S MPIMBI=$P($G(^DPT(MPIIT,"MPIMB")),"^") I MPIMBI'="" S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00127"_MPICS_"EQ"_MPICS_MPIMBI
+74 ; ^ send Multiple Birth Indicator
+75 ;S MPIDLT=$$GETDLT(MPIIT)
+76 ;I MPISND["00100"&(MPIDLT'="") S QUERY=QUERY_MPICS_"AND"_MPIRS_"@00100"_MPICS_"EQ"_MPICS_MPIDLT
+77 ; ^ send Date Last Treated
+78 IF $GET(MPIOUT(0))=""
SET MPIOUT(0)="1^good data"
+79 SET MPIOUT(2)=QUERY
+80 QUIT
GETDLT(MPIIT) ;Get Date Last Treated
+1 NEW TFIEN,TFZN
+2 SET TFIEN=$ORDER(^DGCN(391.91,"APAT",MPIIT,+$$SITE^VASITE,0))
+3 IF $GET(TFIEN)'=""
SET TFZN=^DGCN(391.91,TFIEN,0)
+4 QUIT $PIECE($GET(TFZN),"^",3)
+5 ;
ADDR(MPITST11) ;Get Address information
+1 ;
+2 ;Street address line 1
SET MPISTR1=$PIECE($GET(MPITST11),"^")
+3 ;Street address line 2
SET MPISTR2=$PIECE($GET(MPITST11),"^",2)
+4 ;Street address line 3
SET MPISTR3=$PIECE($GET(MPITST11),"^",3)
+5 ;City
SET MPICITY=$PIECE($GET(MPITST11),"^",4)
+6 ;S MPICNTRY=$P($G(MPITST11),"^",10) ;Country
+7 ;S MPICNTY=$P($G(MPITST11),"^",7) ;County
+8 ;I MPICNTRY=""!(MPICNTRY=1) D
+9 ;. ;Have USA address
+10 ;. S MPISTPRV=$P($G(MPITST11),"^",5) ;State
+11 ;. S MPIZIPPL=$P($G(MPITST11),"^",6) ;Zip code
+12 ;I MPICNTRY'="",(MPICNTRY'=1) D
+13 ;. ;Foreign Country
+14 ;. S MPISTPRV=$P($G(MPITST11),"^",8) ;Province
+15 ;. S MPIZIPPL=$P($G(MPITST11),"^",9) ;Postal code
+16 QUIT