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

BYIMSEG1.m

Go to the documentation of this file.
BYIMSEG1 ;IHS/CIM/THL - IMMUNIZATION DATA EXCHANGE;
 ;;2.0;BYIM IMMUNIZATION DATA EXCHANGE;**3,4,5,6,7,8,9**;JUL 11, 2017;Build 22
 ;
 ;this routine will contain code to supplement fields in the
 ;HL7 segments
 ;
IN1MCARE ;MEDICARE IN1 SEGMENTS
 ;PATCH 9 NMCI CHANGE MCR NUMBER
 S INDA(1)=INDA
 D IN1MCR17
 D IN1MCR49
 ;PATCH 9 END
 Q
 ;-----
IN1MCR17 ;
 S X="SEL^SELF^HL70063"
 S INA("IN1MCR17")=X
 S INA("IN1MCR17",1)=X
 S INA("IN1MCR17",INDA)=X
 S INA("IN1MCR17",INDA,1)=X
 S INA("IN1MCR17",9000003,INDA)=X
 S INA("IN1MCR17",9000003,INDA,1)=X
 Q
 ;-----
IN1MCR49 ;
 ;AUPN V99.1 PATCH 26 REQUIRED
 S X=$$GETMCR^AGUTL(INDA,DT)
 S INA("IN1MCR49")=X
 S INA("IN1MCR49",1)=X
 S INA("IN1MCR49",INDA)=X
 S INA("IN1MCR49",INDA,1)=X
 S INA("IN1MCR49",9000003,INDA)=X
 S INA("IN1MCR49",9000003,INDA,1)=X
 Q
 ;-----
IN1RRE ;RAILROAD IN1 SEGMENTS
 ;PATCH 9 NMCI CHANGE MCR NUMBER
 ;AUPN V99.1 PATCH 26 REQUIRED
 S INDA(1)=INDA
 D IN1RRE49
 ;PATCH 9 END
 Q
 ;-----
IN1RRE49 ;
 ;AUPN V99.1 PATCH 26 REQUIRED
 S X=$$GETRRE^AGUTL(INDA,DT)
 S INA("IN1RRE49")=X
 S INA("IN1RRE49",1)=X
 S INA("IN1RRE49",INDA)=X
 S INA("IN1RRE49",INDA,1)=X
 S INA("IN1RRE49",9000003,INDA)=X
 S INA("IN1RRE49",9000003,INDA,1)=X
 Q
 ;-----
OBXCE ;EP;
 D VSET^BYIMSEGS(INDA)
 D OBXCE1
 D OBXCE2
 D OBXCE3
 D OBXCE4
 D OBXCE5
 D OBXCE11
 D OBXCE14
 D OBXCE17
 Q
 ;-----
OBXCE1 ;subid
 S INA("OBXCE1",INDA)="1"
 Q
 ;-----
OBXCE2 ;vt
 S INA("OBXCE2",INDA)="CE"
 Q
 ;-----
OBXCE3 ;od
 S INA("OBXCE3",INDA)="64994-7"_CS_"funding eligibility for immunization"_CS_"LN"
 Q
 ;-----
OBXCE4 ;osid
 S INA("OBXCE4",INDA)="1"
 Q
 ;-----
OBXCE5 ;ov
 S INA("OBXCE5",INDA)=$$IVFC^BYIMIMM3(INDA)
 Q
 ;-----
OBXCE11 ;abn
 S INA("OBXCE11",INDA)="F"
 Q
 ;-----
OBXCE14 ;edt
 S INA("OBXCE14",INDA)=""
 N X
 S X=$P(X12,U)
 S:'X X=$P(V0,U)
 Q:'X
 S INA("OBXCE14",INDA)=$E($$TIMEIO^INHUT10(X),1,8)
 Q
 ;-----
OBXCE17 ;METHOD OF CAPTURE
 S INA("OBXCE17",INDA)="VXC40"_CS_"per immunization"_CS_"CDCPHINVS"
OBXCEEND Q
 ;-----
 ;-----
OBXPR ;EP;VIS PRESENTED
 D VSET^BYIMSEGS(INDA)
 D OBXPR1
 D OBXPR2
 D OBXPR3
 D OBXPR4
 D OBXPR5
 Q
 ;-----
OBXPR1 ;subid
 S INA("OBXPR1",INDA)="5"
 Q
 ;-----
OBXPR2 ;vt
 S INA("OBXPR2",INDA)="TS"
 Q
 ;-----
OBXPR3 ;od
 S INA("OBXPR3",INDA)="29769-7"_CS_"Date vaccine information statement presented"_CS_"LN"
 Q
 ;-----
OBXPR4 ;osid
 S INA("OBXPR4",INDA)="2"
 Q
 ;-----
OBXPR5 ;ov
 N X
 S X=""
 S INA("OBXPR5",INDA)=""
 S X=$P(V0,".")
 S:X X=X+17000000
 S INA("OBXPR5",INDA)=X
OBXPREND Q
 ;-----
 ;-----
OBXPB ;EP;VIS PUBLISHED
 D VSET^BYIMSEGS(INDA)
 D OBXPB1
 D OBXPB2
 D OBXPB3
 D OBXPB4
 D OBXPB5
 Q
 ;-----
OBXPB1 ;subid
 S INA("OBXPB1",INDA)="4"
 Q
 ;-----
OBXPB2 ;vt
 S INA("OBXPB2",INDA)="TS"
 Q
 ;-----
OBXPB3 ;od
 S INA("OBXPB3",INDA)="29768-9"_CS_"Date vaccine information statement published"_CS_"LN"
 Q
 ;-----
OBXPB4 ;osid
 S INA("OBXPB4",INDA)="2"
 Q
 ;-----
OBXPB5 ;ov
 N X,Y,Z
 S PUB=""
 S INA("OBXPB5",INDA)=""
 D PUB(X0)
 S:$L(PUB)=7 INA("OBXPB5",INDA)=PUB+17000000
OBXPBEND Q
 ;-----
 ;-----
REFUSAL(DFN,UIF) ;EP;TO CREATE REFUSAL RELATED SEGMENTS
 ;DFN   = PATIENT DFN
 ;UIF   = IEN FOR ^INTHU
 Q:'$G(UIF)
 D:$G(DFN) R1(DFN,UIF)
 D:$G(DFN) V1(DFN,UIF)
 D COMP(UIF)
 Q
 ;-----
R1(DFN,UIF) ;EP;FIND PATIENT RELATED REFUSALS
 ;DFN   = PATIENT DFN
 ;UIF   = IEN FOR ^INTHU
 ;N X,Y,Z
 ;PATCH 7 - CHANGE VARIABLE 'X' TO 'REFX'
 N REFX,Y,Z
 S INDA=$O(INA("ORC1",9999999999),-1)
 S REFX=0
 F  S REFX=$O(^AUPNPREF("AC",DFN,REFX)) Q:'REFX  S X0=$G(^AUPNPREF(REFX,0)) D:+X0=3
 .;PATCH 7 EXPAND QUIT LOGIC SO DOES NOT QUIT IF 'ALL' IMM'S
 .;Q:$D(^BYIMEXP("REF",REFX))
 .I $G(^BYIMEXP("REF",REFX)),$G(BYIMALL)'=2 Q
 .Q:'$P(X0,U,6)
 .Q:'$D(^AUTTIMM($P(X0,U,6),0))
 .S INDA=INDA+1
 .S Y="ORC|RE||9999^CDC|CR|"
 .S LCT=+$O(^INTHU(UIF,3,9999999999),-1)+1
 .S ^INTHU(UIF,3,LCT,0)=Y
 .S V0=$P(X0,U,3)
 .N CS
 .S CS=U
 .;PATCH 7 GET PAT REFUSAL DATE DIRECTLY
 .S INA("RXA3",INDA)=$P($G(^AUPNPREF(REFX,0)),U,3)
 .S:INA("RXA3",INDA)]"" INA("RXA3",INDA)=INA("RXA3",INDA)+17000000
 .;D RXA3^BYIMSEGS
 .;END CHANGE
 .N IZDA
 .S IZDA=+$P(X0,U,6)
 .I '$D(^AUTTIMM(IZDA,0)) S IZDA=$P(X0,U,4) S:IZDA]"" IZDA=+$O(^AUTTIMM("B",IZDA,0))
 .S Z0=$G(^AUTTIMM(IZDA,0))
 .D RXA5^BYIMSEGS
 .S Z=$S($P($G(^DPT(DFN,0)),U,3)<(DT-180000):"03^Patient decision",1:"00^Parental decision")_CS_"NIP002"
 .S LCT=+$O(^INTHU(UIF,3,9999999999),-1)+1
 .S ^INTHU(UIF,3,LCT,0)="RXA|0|1|"_INA("RXA3",INDA)_"||"_INA("RXA5",INDA)_"|999|||01^HISTORICAL INFORMATION - SOURCE UNSPECIFIED^NIP001|||||||||"_Z_"||RE|CR|"
 .;PATCH 7 ADD IIS ID CODE FOR REFUSALS IF AVAILABLE
 .S X=$P($G(^BYIMPARA($$DUZ^BYIMIMM(),5,$$DUZ^BYIMIMM(),0)),U,2)
 .S:X="" X=$E($P($G(^DIC(4,+$G(^AUTTSITE(1,0)),0)),U),1,20)
 .S X="^^^"_X
 .S $P(^INTHU(UIF,3,LCT,0),"|",12)=X
 .S:'$G(BYIMMU2)&'$G(BYIMTEST) ^BYIMEXP("REF",REFX)=DT
 Q
 ;-----
V1(DFN,UIF) ;EP;DETERMINE VARICELLA EXPOSURE
 ;DFN   = PATIENT DFN
 ;UIF   = IEN FOR ^INTHU
 Q:'$D(^BIPC("B",+DFN))
 N VDAT,BIX,LCT,ORC,RXA,OBX
 S VDAT=""
 S BIX=0
 F  S BIX=$O(^BIPC("B",DFN,BIX)) Q:'BIX  D:$P($G(^BIPC(BIX,0)),U,2)
 .I $G(^BYIMEXP("HXV",BIX)),$G(BYIMALL)'=2 Q
 .;PATCH 7
 .;FILTER OUT NON-CONTRAINDICATION ENTRIES
 .Q:"^11^13^16^17^18^"[(U_$P($G(^BIPC(BIX,0)),U,3)_U)
 .S IMM=$P($G(^BIPC(BIX,0)),U,2)
 .S VDAT=$P(^BIPC(BIX,0),U,4)
 .Q:$L(VDAT)'=7
 .S:'$G(BYIMMU2) ^BYIMEXP("HXV",BIX)=VDAT
 .S LCT=+$O(^INTHU(UIF,3,9999999999),-1)+1
 .S VDAT=VDAT+17000000
 .S ORC="ORC|RE||9999^CDC|CR|"
 .S RXA="RXA|0|1|"_VDAT_"|"_VDAT_"|998^No vaccine administered^CVX|999|"
 .S $P(RXA,"|",21)="NA|CR|"
 .N X
 .S X=$G(^BYIMCON(IMM,0))
 .I X="" S OBX="OBX|1|CE|30945-0^Vaccination contraindication/precaution^LN|1|00000000^Reason not recorded^SCT||||||F|CR|"
 .I X]"" S OBX="OBX|1|CE|30945-0^Vaccination contraindication/precaution^LN|1|"_$P(X,U,2)_U_$P(X,U,3)_"^SCT||||||F|CR|"
 .S ^INTHU(UIF,3,LCT,0)=ORC
 .S LCT=+$O(^INTHU(UIF,3,9999999999),-1)+1
 .S ^INTHU(UIF,3,LCT,0)=RXA
 .S LCT=+$O(^INTHU(UIF,3,9999999999),-1)+1
 .S ^INTHU(UIF,3,LCT,0)=OBX
 Q
 ;-----
COMP(UIF) ;EP;REFORMAT MESSAGE PRIOR TO TRANSMISSION
 ;UIF   = IEN FOR ^INTHU
 N X,Y,Z,CNT
 K ^BYIMTMP("UIF",UIF)
 S CNT=0
 S XX=0
 F  S XX=$O(^INTHU(UIF,3,XX)) Q:'XX  S X=^(XX,0) D
 .S CNT=$O(^BYIMTMP("UIF",UIF,3,9999999999),-1)+1
 .S ^BYIMTMP("UIF",UIF,3,CNT,0)=X
 .Q:X'["ORC|"!($E(X,1,4)'?3U1"|")
 .D NORC(UIF)
 .D EVAL(UIF)
 K ^INTHU(UIF,3)
 S X=0
 F  S X=$O(^BYIMTMP("UIF",UIF,3,X)) Q:'X  S Y=^(X,0) S:Y]"" ^INTHU(UIF,3,X,0)=Y
 K ^BYIMTMP("UIF",UIF)
 Q
 ;-----
 ;-----
NORC(UIF) ;FIND NEXT ORC
 N X,Y,Z
 S J=XX+1
 S X=XX
 F  S X=$O(^INTHU(UIF,3,X)) Q:'X  I ^(X,0)["ORC|" S XX=X-1 Q
 S:J>XX XX=$O(^INTHU(UIF,3,9999999999),-1)
 Q
 ;-----
EVAL(UIF) ;EVAL FOR MULTIPLE VACCINE RXA'S
 N X,Y,Z,HIST,CNT,RXA,CVX,CVXDA,NAM,OBXPR,OBXPU
 S RXA=""
 S OBXPR=""
 S OBXPU=""
 S HIST=0
 F J=J:1:XX D
 .S X2="",X=$G(^INTHU(UIF,3,J,0))
 .I X'["|CR|",$G(^INTHU(UIF,3,J+1,0))["|CR|" S X2=^(0),J=J+1
 .S CNT=$O(^BYIMTMP("UIF",UIF,3,9999999999),-1)+1
 .D:$E(X,1,4)="RXA|"
 ..S RXA=X
 ..S HIST=+$P(RXA,"|",10)
 .I 'HIST,X'["vaccine info" D
 ..S ^BYIMTMP("UIF",UIF,3,CNT,0)=X
 ..S:X2]"" CNT=CNT+1,^BYIMTMP("UIF",UIF,3,CNT,0)=X2,X2=""
 .I HIST,"|MSH|PID|ORC|RXA|"[("|"_$E(X,1,3)_"|") D
 ..S ^BYIMTMP("UIF",UIF,3,CNT,0)=X
 ..S:X2]"" CNT=CNT+1,^BYIMTMP("UIF",UIF,3,CNT,0)=X2,X2=""
 .S:X["present" OBXPR=$G(^INTHU(UIF,3,J,0))
 .S:X["publish" OBXPU=$G(^INTHU(UIF,3,J,0))
 Q:RXA=""
 Q:HIST
 Q:$P(RXA,"|",19)]""
 S CVX=+$P(RXA,"|",6)
 S CVXDA=+$O(^AUTTIMM("C",CVX,0))
 S X=$G(^AUTTIMM(CVXDA,0))
 ;PATCH 7 GET DIRECT PUB DATE
 N ORPUB
 S ORPUB=$P(X,U,13)
 S CMP=$P($G(^AUTTIMM(CVXDA,0)),U,21,26)
 I $L(CMP)>5 D E1(RXA,CMP) Q
 S:$P($G(^BYIMNOS(CVXDA,0)),U,2) X=$G(^AUTTIMM(+$P(^(0),U,2),0))
 S NAM=$P(X,U)
 S CVX=+$P(X,U,3)
 S CVXDA=+$O(^AUTTIMM("C",CVX,0))
 S PUB=$P(X,U,13)
 S:'PUB PUB=$P($G(^BYIMNOS(CVXDA,0)),U,3)
 ;PATCH 7 USE DIRECT PUB DATE IF NOT GENERIC DEFAULT
 S:'PUB PUB=ORPUB
 D:$G(OBXPU)]""
 .S $P(OBXPU,"|",6)=PUB+17000000
 .S:OBXPU'["|CR|" OBXPU=OBXPU_"|CR|"
 .S CNT=$O(^BYIMTMP("UIF",UIF,3,9999999999),-1)+1
 .S ^BYIMTMP("UIF",UIF,3,CNT,0)=OBXPU
 D:$G(OBXPR)]""
 .S:OBXPR'["|CR|" OBXPR=OBXPR_"|CR|"
 .S CNT=$O(^BYIMTMP("UIF",UIF,3,9999999999),-1)+1
 .S ^BYIMTMP("UIF",UIF,3,CNT,0)=OBXPR
 Q
 ;-----
E1(RXA,CMP) ;
 N J,K,L,X,Y,Z,XX
 S CNT=$O(^BYIMTMP("UIF",UIF,3,9999999999),-1)
 S X=$G(^BYIMTMP("UIF",UIF,3,CNT,0))
 I $E(X,1,9)="OBX|3|CE|" K ^BYIMTMP("UIF",UIF,3,CNT)
 S K=2
 S L=1
 F J=1:1:6 S X=$P(CMP,U,J) D:X
 .S:$P($G(^BYIMNOS(X,0)),U,2) X=$P(^(0),U,2),NOSPUB=$P(^(0),U,3)
 .S X=$G(^AUTTIMM(X,0))
 .S NAM=$P(X,U)
 .S CVX=$P(X,U,3)
 .S PUB=$P(X,U,13)
 .I 'PUB,NOSPUB S PUB=NOSPUB
 .S K=K+1
 .S L=L+1
 .S X="OBX|"_K_"|"
 .S $P(X,"|",3)="CE"
 .S $P(X,"|",4)="30956-7"_U_"vaccine type"_U_"LN"
 .S $P(X,"|",5)=L
 .S $P(X,"|",6)=(CVX_U_NAM_U_"CVX")
 .S $P(X,"|",12)="F"
 .S CNT=$O(^BYIMTMP("UIF",UIF,3,9999999999),-1)+1
 .S ^BYIMTMP("UIF",UIF,3,CNT,0)=X_"|CR|"
 .S K=K+1
 .S $P(OBXPU,"|",2)=K
 .S $P(OBXPU,"|",5)=L
 .S $P(OBXPU,"|",6)=PUB+17000000
 .S $P(OBXPU,"|",12)="F"
 .S CNT=$O(^BYIMTMP("UIF",UIF,3,9999999999),-1)+1
 .S ^BYIMTMP("UIF",UIF,3,CNT,0)=OBXPU
 .S K=K+1
 .S $P(OBXPR,"|",2)=K
 .S $P(OBXPR,"|",5)=L
 .S $P(OBXPR,"|",12)="F"
 .S CNT=$O(^BYIMTMP("UIF",UIF,3,9999999999),-1)+1
 .S ^BYIMTMP("UIF",UIF,3,CNT,0)=OBXPR
 Q
 ;-----
 ;-----
OBXTY ;EP;
 D VSET^BYIMSEGS(INDA)
 D OBXTY1
 D OBXTY2
 D OBXTY3
 D OBXTY4
 D OBXTY5
 D OBXTY11
 Q
 ;-----
OBXTY1 ;subid
 S INA("OBXTY1",INDA)="3"
 Q
 ;-----
OBXTY2 ;vt
 S INA("OBXTY2",INDA)="CE"
 Q
 ;-----
OBXTY3 ;od
 S INA("OBXTY3",INDA)="30956-7"_CS_"vaccine type"_CS_"LN"
 Q
 ;-----
OBXTY4 ;osid
 S INA("OBXTY4",INDA)="2"
 Q
 ;-----
OBXTY5 ;ov
 N X
 S CVX=$P(Z0,U,3)
 S IDA=+$O(^AUTTIMM("C",+CVX,0))
 S:$P($G(^BYIMNOS(IDA,0)),U,2) IDA=$P(^(0),U,2)
 S X=$G(^AUTTIMM(IDA,0))
 S CVX=$P(X,U,3)
 S:$L(CVX)=1 CVX="0"_CVX
 S INA("OBXTY5",INDA)=CVX_CS_$P(X,U)_CS_"CVX"
 Q
 ;-----
OBXTY11 ;abn
 S INA("OBXTY11",INDA)="F"
 Q
 ;-----
OBXTYEND Q
 ;-----
 ;-----
QRF ;EP;main QRF routine driver
 S INA("INQWHICH")="ANY"
 D QRF1
 D QRF2
 D QRF3
 D QRF5
 Q
 ;-----
QRF1 ;
 S INA("QRF1")=$P($G(^DIC(4,$$DUZ^BYIMIMM(),0)),U)
 Q
QRF2 ;
 S INA("QRF2")=""
 Q
 ;-----
QRF3 ;
 ;S INA("INQEDTM")=$G(INA("QEDT"))
 S INA("QRF3")=""
 Q
 ;-----
QRF5 ;build the other query subject filter
 N BYIMDA,BYIMSSN,BYIMDOB,BYIMBST,BYIMBCN,BYIMMCN,BYIMMNM,BYIMMMN,BYIMMSSN,BYIMFNM
 S BYIMDA=$O(INA("QNM",0))
 Q:'BYIMDA
 N X,Y,Z,X0,X24
 S X0=$G(^DPT(BYIMDA,0))
 Q:X0=""
 S BYIMSSN=$TR($P(X0,U,9),"-")
 S BYIMDOB=$P(X0,U,3)+17000000
 S BYIMBST=$P($G(^DIC(5,+$P(X0,U,12),0)),U,2)
 S BYIMBCN=$P($G(^AUPNPAT(BYIMDA,11)),U,5)
 S BYIMMCN=""
 S BYIMMNM=""
 S BYIMMMN=""
 S BYIMMSSN=""
 S BYIMFNM=""
 S X24=$G(^DPT(BYIMDA,.24))
 S X=$P(X24,U,2)
 S:X]"" BYIMMNM=$$QRFNAME(X)
 S X=$P(X24,U,3)
 S:X]"" BYIMMMN=$$QRFNAME(X)
 S X=$P(X24,U)
 S:X]"" BYIMFNM=$$QRFNAME(X)
 S BYIMFSSN=""
 S INA("QRF5")=BYIMSSN_RS_BYIMDOB_RS_BYIMBST_RS_BYIMBCN_RS_BYIMMCN_RS_BYIMMNM_RS_BYIMMMN_RS_BYIMMSSN_RS_BYIMFNM_RS_BYIMFSSN
 Q
 ;-----
QRFNAME(NAME) ;FORMAT NAME
 Q:NAME="" ""
 S X=$P(NAME,",")_U_$P($P(NAME,",",2)," ")
 S:NAME[" " X=X_U_$P(NAME," ",2)
 Q X
QRFEND Q
 ;-----
 ;-----
FHS ;EP;
 Q
 ;-----
PUB(X0) ;FIND PUB DATE
 S PUB=$P(X0,U,12)
 Q:$L(PUB)=7
 S IDA=+X0
 Q:'IDA
 S BYIMNOS=$G(^BYIMNOS(IDA,0))
 ;PATCH 7 GET DIRECT PUB DATE IF NOS NOT DEFINED
 ;Q:'BYIMNOS
 I 'BYIMNOS S PUB=$P($G(^AUTTIMM(IDA,0)),U,13) Q
 S NOSDA=+$P(BYIMNOS,U,2)
 S PUB=$P(BYIMNOS,U,3)
 ;S:NOSDA=IDA PUB=$P(X0,U,12)
 I 'PUB,NOSDA S PUB=$P($G(^AUTTIMM(NOSDA,0)),U,13)
 ;I 'PUB,NOSPUB S PUB=NOSPUB
 Q
OBXFS ;EP;
 ;PATCH 6 TO INCLUDE FUNDING SOURCE OBX SEGMENT
 D VSET^BYIMSEGS(INDA)
 D OBXFS1
 D OBXFS2
 D OBXFS3
 D OBXFS4
 D OBXFS5
 D OBXFS11
 D OBXFS14
 Q
 ;-----
OBXFS1 ;subid
 S INA("OBXFS1",INDA)="2"
 Q
 ;-----
OBXFS2 ;vt
 S INA("OBXFS2",INDA)="CE"
 Q
 ;-----
OBXFS3 ;od
 S INA("OBXFS3",INDA)="30963-3"_CS_"funding source for immunization"_CS_"LN"
 Q
 ;-----
OBXFS4 ;osid
 S INA("OBXFS4",INDA)="1"
 Q
 ;-----
OBXFS5 ;ov
 S INA("OBXFS5",INDA)=$$IVFS^BYIMIMM3(INDA)
 Q
 ;-----
OBXFS11 ;abn
 S INA("OBXFS11",INDA)="F"
 Q
 ;-----
OBXFS14 ;edt
 S INA("OBXFS14",INDA)=""
 N X
 S X=$P(X12,U)
 S:'X X=$P(V0,U)
 Q:'X
 S INA("OBXFS14",INDA)=$E($$TIMEIO^INHUT10(X),1,8)
 Q
 ;-----
OBXFSEND Q
 ;-----
 ;-----
RXR ;EP;
 D RXR1
 D RXR2
 Q
 ;-----
RXR1 ;
 S INA("RXR1",INDA)=""
 N X,R
 D VSET^BYIMSEGS(INDA)
 S X=$P(X0,U,9)
 Q:X=""
 S R=$E(X,$L(X))
 ;PATCH 7 CORRECT IN TO NASAL
 ;S:X="O" R="O"
 S:X="IN" R="N"
 Q:"IDNOS"'[R
 S:R="I" X="IM"_CS_"Intramuscular"
 S:R="D" X="ID"_CS_"Intradermal"
 S:R="N" X="NS"_CS_"Nasal"
 S:R="O" X="PO"_CS_"Oral"
 S:R="S" X="SC"_CS_"Subcutaneous"
 S INA("RXR1",INDA)=X_CS_"HL70162"
 Q
 ;-----
RXR2 ;
 S INA("RXR2",INDA)=""
 N X,R
 D VSET^BYIMSEGS(INDA)
 S X=$P(X0,U,9)
 Q:X=""
 S R=$E(X,1,2)
 ;PATCH 7 CORRECT SHIFT OF LI AND RI
 ;S:R="LI" R="LA"
 ;S:R="RI" R="RA"
 Q:R="O"!(R="IN")
 S:R="LT" X=R_CS_"Left Thigh"
 S:R="LA" X=R_CS_"Left Arm"
 S:R="LD" X=R_CS_"Left Deltoid"
 S:R="LG" X=R_CS_"Left Gluteus Medius"
 S:R="LL" X="LVL"_CS_"Left Vastus Lateralis"
 S:R="LV" X="LVL"_CS_"Left Vastus Lateralis"
 S:R="LI" X="LLFA"_CS_"Left Lower Forearm"
 S:R="LL" X="LLFA"_CS_"Left Lower Forearm"
 S:R="RA" X=R_CS_"Right Arm"
 S:R="RT" X=R_CS_"Right Thigh"
 S:R="RV" X="RVL"_CS_"Right Vastus Lateralis"
 S:R="RG" X=R_CS_"Right Gluteous Medius"
 S:R="RD" X=R_CS_"Right Deltoid"
 S:R="RI" X="RLFA"_CS_"Right Lower Forearm"
 S:R="RL" X="RLFA"_CS_"Right Lower Forearm"
 S INA("RXR2",INDA)=X_CS_"HL70163"
RXREND Q
 ;-----
PD1 ;EP;
 D PD13
 D PD111
 D PD112
 D PD113
 D PD116
 D PD117
 D PD118
 Q
 ;-----
PD13 ;PD1-3 variable - location
 S INA("PD13",1)=$G(BYIM("PD13.1"))_CS_$G(BYIM("PD13.2"))_CS_$G(BYIM("PD13.3"))
 Q
 ;-----
PD111 ;PD1-11 PUBLICITY
 S INA("PD111",1)=$$PUB^BYIMIMM3(INDA)
 Q
 ;-----
PD112 ;PD1-12
 S INA("PD112",1)=$$PROT^BYIMIMM3(INDA)
 Q
 ;-----
PD113 ;PD1-13
 S INA("PD113",1)=$$PROTDT^BYIMIMM3(INDA)
 S:INA("PD112",1)="" INA("PD113",1)=""
 I INA("PD112",1)]"",INA("PD113",1)="" S INA("PD113",1)=DT+17000000
 Q
 ;-----
PD116 ;PD1-16
 ;PATCH 6 INCLUDE ACTIVE/INACTIVE STATUS
 S X=$P($G(^BIP(INDA,0)),U,8)
 S INA("PD116",1)=$S('X:"A",1:"I")
 ;PATCH 6 INCLUDE ACTIVE/INACTIVE STATUS
 Q
 ;-----
PD117 ;PD1-17
 ;PATCH 6 INCLUDE ACTIVE/INACTIVE STATUS
 S INA("PD117",1)=$$ACTDT^BYIMIMM3(INDA)
 ;S:INA("PD117",1)="" INA("PD113",1)=DT+17000000
 S:INA("PD117",1)="" INA("PD117",1)=DT+17000000
 ;PATCH 6 INCLUDE ACTIVE/INACTIVE STATUS
 Q
 ;-----
PD118 ;PD1-18
 I INA("PD111",1)="" S INA("PD118",1)="" Q
 S INA("PD118",1)=$$PUBDT^BYIMIMM3(INDA)
 S:INA("PD118",1)="" INA("PD118",1)=DT+17000000
 Q
 ;-----
PD1END Q