Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: VAFCQRY3

VAFCQRY3.m

Go to the documentation of this file.
VAFCQRY3 ;BIR/CMC,CKN-CONT TO BLD PID 2.4 SEGMENT ; 8/21/09 4:45pm
 ;;5.3;PIMS;**575,707,1015,1016**;JUN 30, 2012;Build 20
 ;
CONT(DFN,APID,PID,HL,HLES,SARY,SEQ,ERROR,REP,COMP,SSN,VAFCMN) ; continue to bld pid segment
ADDR ;had to split routine
 I $D(SARY(11))!(SEQ="ALL") S APID(12)="" D
 .I $D(^DPT(DFN,0)) D
 ..;address info
 ..N COUNTY K HL7STRG
 ..S HL7STRG=$$GET1^DIQ(2,DFN_",",.111) D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES)
 ..S $P(APID(12),COMP)=HL7STRG I $P(APID(12),COMP)="" S $P(APID(12),COMP)=HL("Q") K HL7STRG
 ..K HL7STRG S HL7STRG=$$GET1^DIQ(2,DFN_",",.112) D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) ;**707 add HL7TXT call
 ..S $P(APID(12),COMP,2)=HL7STRG I $P(APID(12),COMP,2)="" S $P(APID(12),COMP,2)=HL("Q")
 ..K HL7STRG S HL7STRG=$$GET1^DIQ(2,DFN_",",.113) D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) ;**707 add HL7TXT call
 ..S $P(APID(12),COMP,8)=HL7STRG I $P(APID(12),COMP,8)="" S $P(APID(12),COMP,8)=HL("Q")
 ..K HL7STRG
 ..; **707 changes to include foreign address
 ..N CNTRY S CNTRY=$$GET1^DIQ(2,DFN_",",.1173) ;RETURN EXTERNAL VALUE from country code file #779.004 field .01
 ..I CNTRY="US" S CNTRY="USA"
 ..S HL7STRG=$$GET1^DIQ(2,DFN_",",.114) D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S $P(APID(12),COMP,3)=HL7STRG  I $P(APID(12),COMP,3)="" S $P(APID(12),COMP,3)=HL("Q")
 ..I CNTRY=""!(CNTRY="USA") D
 ...;have USA address
 ...S STATEIEN=$$GET1^DIQ(2,DFN_",",.115,"I") S $P(APID(12),COMP,4)=$$GET1^DIQ(5,+STATEIEN_",",1)
 ...I $P(APID(12),COMP,4)="" S $P(APID(12),COMP,4)=HL("Q")
 ...S $P(APID(12),COMP,5)=$$GET1^DIQ(2,DFN_",",.1112) I $P(APID(12),COMP,5)="" S $P(APID(12),COMP,5)=HL("Q")
 ...S $P(APID(12),COMP,6)=CNTRY I CNTRY="" S $P(APID(12),COMP,6)=HL("Q") ;country
 ..I CNTRY'="",(CNTRY'="USA") D
 ...;Check for foreign address fields
 ...S $P(APID(12),COMP,4)=$P($G(^DPT(DFN,.11)),"^",8) I $P(APID(12),COMP,4)="" S $P(APID(12),COMP,4)=HL("Q") ;province
 ...S $P(APID(12),COMP,5)=$P($G(^DPT(DFN,.11)),"^",9) I $P(APID(12),COMP,5)="" S $P(APID(12),COMP,5)=HL("Q") ;postal code
 ...S $P(APID(12),COMP,6)=CNTRY I CNTRY="" S $P(APID(12),COMP,6)=HL("Q") ;COUNTRY
 ...; ***707 end of code
 ..S $P(APID(12),COMP,7)="P"
BADADDR ..;BAD ADDRESS INDICATOR (if present overwrite the "P" ermanent type with the Bad Address type
 ..I $D(^DPT(DFN,.11)) N BADADR S BADADR=$P(^DPT(DFN,.11),"^",16) I BADADR'="" S $P(APID(12),COMP,7)="VAB"_BADADR
 ..S COUNTY=$$GET1^DIQ(2,DFN_",",.117) I COUNTY="" S COUNTY=HL("Q") ;**648 add COUNTY Code to PID-11, retained in PID-12 also
 ..S $P(APID(12),COMP,9)=COUNTY ;county code
 ..;place of birth information
 ..S CITY=$$GET1^DIQ(2,DFN_",",.092) S HL7STRG=CITY D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S CITY=HL7STRG D
 ...N X
 ...I $G(CITY)'="" S $P(X,COMP,3)=CITY
 ...I $G(CITY)="" S $P(X,COMP,3)=HL("Q")
 ...S STATEIEN=$$GET1^DIQ(2,DFN_",",.093,"I") S STATE=$$GET1^DIQ(5,+STATEIEN_",",1) D
 ....I $G(STATE)'="" S $P(X,COMP,4)=STATE
 ....I $G(STATE)="" S $P(X,COMP,4)=HL("Q")
 ... S $P(X,COMP,7)="N",APID(12)=$G(APID(12))_REP_X
CONF .;CONFIDENTIAL ADDRESS
 .I $D(^DPT(DFN,.141)) N CNFADD S CNFADD=$$GET1^DIQ(2,DFN_",",.14105) D
 ..N LINE1,LINE2,LINE3,STATEIEN,STATE,CNTRY,ZIP,LVL,LNGTH,NXT,CNFEND,CNFSTRT,SUBCOMP,CNTY,CITY
 ..S SUBCOMP=$E(HL("ECH"),4)
 ..S LINE1=$$GET1^DIQ(2,DFN_",",.1411) S HL7STRG=LINE1 D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S LINE1=HL7STRG
 ..S LINE2=$$GET1^DIQ(2,DFN_",",.1412) S HL7STRG=LINE2 D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S LINE2=HL7STRG
 ..S LINE3=$$GET1^DIQ(2,DFN_",",.1413) S HL7STRG=LINE3 D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S LINE3=HL7STRG
 ..S CNFSTRT=$$FMTHL7^XLFDT($$GET1^DIQ(2,DFN_",",.1417,"I")),CNFEND=$$FMTHL7^XLFDT($$GET1^DIQ(2,DFN_",",.1418,"I"))
 ..S CITY=$$GET1^DIQ(2,DFN_",",.1414) S HL7STRG=CITY D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S CITY=HL7STRG
 ..S CNTRY=$$GET1^DIQ(2,DFN_",",.14116)
 ..;if foriegn address
 ..I CNTRY=""!(CNTRY="USA")!(CNTRY="US") S:CNTRY="US" CNTRY="USA" S STATEIEN=$$GET1^DIQ(2,DFN_",",.1415,"I") S STATE=$$GET1^DIQ(5,+STATEIEN_",",1),CNTY=$$GET1^DIQ(2,DFN_",",.14111),ZIP=$$GET1^DIQ(2,DFN_",",.1416)
 ..E  S STATE=$$GET1^DIQ(2,DFN_",",.14114),ZIP=$$GET1^DIQ(2,DFN_",",.14115)  ;if USA address or null assume USA address
 ..S LVL=0,LNGTH=$L(APID(12))
 ..I $D(^DPT(DFN,.14,0)) N CNFTYP S CNFTYP=0 F  S CNFTYP=$O(^DPT(DFN,.14,CNFTYP)) Q:'CNFTYP  N CNFTYPA S CNFTYPA=$P(^DPT(DFN,.14,CNFTYP,0),"^",2) I CNFTYPA="Y" S CNFTYPA=$P(^DPT(DFN,.14,CNFTYP,0),"^") D
 ...S NXT=""
 ...S $P(NXT,COMP)=$S(LINE1'="":LINE1,1:HL("Q"))
 ...S $P(NXT,COMP,2)=$S(LINE2'="":LINE2,1:HL("Q"))
 ...S $P(NXT,COMP,8)=$S(LINE3'="":LINE3,1:HL("Q"))
 ...S $P(NXT,COMP,3)=$S(CITY'="":CITY,1:HL("Q"))
 ...S $P(NXT,COMP,4)=$S($G(STATE)'="":STATE,1:HL("Q"))
 ...S $P(NXT,COMP,5)=$S(ZIP'="":ZIP,1:HL("Q"))
 ...S $P(NXT,COMP,6)=$S(CNTRY'="":CNTRY,1:HL("Q"))
 ...S $P(NXT,COMP,7)=$S(CNFTYPA=1:"VACAE",CNFTYPA=2:"VACAA",CNFTYPA=3:"VACAC",CNFTYPA=4:"VACAM",CNFTYPA=5:"VACAO",1:HL("Q"))
 ...S $P(NXT,COMP,9)=$S($G(CNTY)'="":CNTY,1:HL("Q"))
 ...S $P(NXT,COMP,12)=CNFSTRT_SUBCOMP_CNFEND
 ...S NXT=REP_NXT
 ...I LVL=0 D
 ....I $L(APID(12)_NXT)'>244 S APID(12)=APID(12)_NXT Q
 ....I $L(APID(12)_NXT)>244 S LVL=1 S LNGTH=244-$L(APID(12)),APID(12)=APID(12)_$E(NXT,1,LNGTH) S LNGTH=LNGTH+1,NXT=$E(NXT,LNGTH,$L(NXT))
 ...I LVL>0 D
 ....I $L($G(APID(12,LVL))_NXT)'>245 S APID(12,LVL)=$G(APID(12,LVL))_NXT Q
 ....I $L($G(APID(12,LVL))_NXT)>245 S LNGTH=244-$L(APID(12,LVL)),APID(12,LVL)=APID(12,LVL)_$E(NXT,1,LNGTH) S LNGTH=LNGTH+1,NXT=$E(NXT,LNGTH,$L(NXT)) S LVL=LVL+1 S APID(12,LVL)=NXT
 I $D(SARY(12))!(SEQ="ALL") S APID(13)=$$GET1^DIQ(2,DFN_",",.117) I APID(13)="" S APID(13)=HL("Q")  ;county code **648 backwards compatibility only
PHONE I $D(SARY(13))!($D(SARY(14)))!(SEQ="ALL") D
 .;**707 change PID-13 to have home and work phones, cell, pager and e-mail address with the components ; **754 add confidential phone number to PID-13
 .N PHONEN,HNUM,WNUM,EMAIL,CELL,PAGER,CONFNUM ;**754
 .S PHONEN=$G(^DPT(DFN,.13))
 .; **707 change to ensure that null doesn't end up for any of these fields cmc 12/7/06
 .S HNUM=$P(PHONEN,"^") I HNUM'="" S HNUM=$$HLPHONE^HLFNC(HNUM) I HNUM'="" S HL7STRG=HNUM D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S HNUM=HL7STRG_COMP_"PRN"_COMP_"PH"
 .S WNUM=$P(PHONEN,"^",2) I WNUM'="" S WNUM=$$HLPHONE^HLFNC(WNUM) I WNUM'="" S HL7STRG=WNUM D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S WNUM=HL7STRG_COMP_"WPN"_COMP_"PH"
 .S CELL=$P(PHONEN,"^",4) I CELL'="" S CELL=$$HLPHONE^HLFNC(CELL) I CELL'="" S HL7STRG=CELL D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S CELL=HL7STRG_COMP_"ORN"_COMP_"CP"
 .S PAGER=$P(PHONEN,"^",5) I PAGER'="" S PAGER=$$HLPHONE^HLFNC(PAGER) I PAGER'="" S HL7STRG=PAGER D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S PAGER=HL7STRG_COMP_"BPN"_COMP_"BP"
 .S EMAIL=$P(PHONEN,"^",3) I EMAIL'="" S HL7STRG=EMAIL D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S EMAIL=COMP_"NET"_COMP_"INTERNET"_COMP_HL7STRG
 .S CONFNUM=$P(PHONEN,"^",15) I CONFNUM'="" S CONFNUM=$$HLPHONE^HLFNC(CONFNUM) I CONFNUM'="" S HL7STRG=CONFNUM D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S CONFNUM=HL7STRG_COMP_"VACPN"_COMP_"PH" ;**574
 .I HNUM'="" S APID(14)=HNUM
 .I WNUM'="",APID(14)'="" S APID(14)=APID(14)_REP_WNUM
 .I WNUM'="",APID(14)="" S APID(14)=WNUM
 .I CELL'="",APID(14)'="" S APID(14)=APID(14)_REP_CELL
 .I CELL'="",APID(14)="" S APID(14)=CELL
 .I PAGER'="",APID(14)'="" S APID(14)=APID(14)_REP_PAGER
 .I PAGER'="",APID(14)="" S APID(14)=PAGER
 .I EMAIL'="",APID(14)'="" S APID(14)=APID(14)_REP_EMAIL
 .I EMAIL'="",APID(14)="" S APID(14)=EMAIL
 .I CONFNUM'="",APID(14)'="" S APID(14)=APID(14)_REP_CONFNUM ;**754
 .I CONFNUM'="",APID(14)="" S APID(14)=CONFNUM ;**754
 .I APID(14)="" S APID(14)=HL("Q")
 I $D(SARY(14))!(SEQ="ALL") N WNUM S WNUM=$P($G(^DPT(DFN,.13)),"^",2) S WNUM=$$HLPHONE^HLFNC(WNUM) S HL7STRG=WNUM D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S APID(15)=HL7STRG I APID(15)="" S APID(15)=HL("Q")
 ;**707 keep work# in PID-14 for backwards compatability but should use PID-13 to get work#
 I $D(SARY(19))!(SEQ="ALL") S APID(20)=SSN  ;ssn passed in PID-3
 I $D(SARY(23))!(SEQ="ALL") D
 .S CITY=$$GET1^DIQ(2,DFN_",",.092) S HL7STRG=CITY D HL7TXT^VAFCQRY1(.HL7STRG,.HL,HLES) S CITY=HL7STRG
 .S STATEIEN=$$GET1^DIQ(2,DFN_",",.093,"I") S STATE=$$GET1^DIQ(5,+STATEIEN_",",1) D
 .I CITY'=""&(STATE'="") S APID(24)=CITY_" "_STATE  ;place of birth (not used) use PID-11 with an 'N' instead
 .I CITY=""&(STATE="") S APID(24)=HL("Q")
 D CONT^VAFCQRY4(DFN,.APID,.PID,.HL,HLES,.SARY,SEQ,.ERROR,REP,COMP)
 ;**707 had to break routine
 Q