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

BGP8D3C.m

Go to the documentation of this file.
BGP8D3C ; IHS/CMI/LAB - VARIOUS UTILS ;
 ;;18.1;IHS CLINICAL REPORTING;;MAY 25, 2018;Build 66
 ;
FIRSTPDX(P,BDATE,EDATE) ;EP
 NEW BGPG,G,Y,X,T,E,BGPR
 K BGPG
 S Y="BGPG("
 S BDATE=$G(BDATE)
 I BDATE="" S BDATE=$P(^DPT(P,0),U,3)
 S BGPR=""
 S X=P_"^FIRST DX [BGP PREGNANCY DIAGNOSES 2;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,Y)
 I $D(BGPG(1)) S BGPR=$P(BGPG(1),U)
 K BGPG
 S BGPG=$$FIRSTPRC^BGP8UTL1(P,"BGP PREGNANCY ICD PROCEDURES",BDATE,EDATE)
 I BGPG]"",$P(BGPG,U,3)<BGPR S BGPR=$P(BGPG,U,3)
 S X=$$FIRSTCPT^BGP8UTL1(P,"BGP PREGNANCY CPT CODES",BDATE,EDATE)
 I X,$P(X,U,1)<BGPR S BGPR=$P(X,U,1)
 Q BGPR
LASTVD(P,BDATE,EDATE) ;EP
 I '$D(^AUPNVSIT("AC",P)) Q ""
 NEW VISIT
 S A="VISIT(",B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(B,A)
 I '$D(VISIT(1)) Q ""
 S (X,G)=0 F  S X=$O(VISIT(X)) Q:X'=+X!(G)  S V=$P(VISIT(X),U,5) D
 .Q:'$D(^AUPNVSIT(V,0))
 .Q:'$P(^AUPNVSIT(V,0),U,9)
 .Q:$P(^AUPNVSIT(V,0),U,11)
 .Q:'$D(^AUPNVPRV("AD",V))
 .Q:"SAHO"'[$P(^AUPNVSIT(V,0),U,7)
 .Q:"V"[$P(^AUPNVSIT(V,0),U,3)
 .Q:$P(^AUPNVSIT(V,0),U,6)=""
 .S G=1
 .Q
 Q G
IZOSTER(P,BDATE,EDATE,FORE) ;EP
 NEW BGPLPNU,BGPG,X,E,R,BD,ED,G,%,BGPX,BGPSHIN,RED,RBD
 S BGPLPNU=""
 S BD=BDATE
 S ED=EDATE
 S EDATE=$$FMTE^XLFDT(EDATE)
 S BDATE=$$FMTE^XLFDT(BDATE)
 S X=P_"^LAST IMM 121;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BGPG(")
 I $D(BGPG(1)),$P(BGPLPNU,U,1)<$P(BGPG(1),U) S BGPLPNU=$P(BGPG(1),U,1)_U_"Imm 121"
 S X=P_"^LAST IMM 188;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BGPG(")
 I $D(BGPG(1)),$P(BGPLPNU,U,1)<$P(BGPG(1),U) S BGPLPNU=$P(BGPG(1),U,1)_U_"Imm 188"
 S %=$$CPT^BGP8DU(P,BD,ED,$O(^ATXAX("B","BGP ZOSTER IZ CPTS",0)),5)
 I $P(BGPLPNU,U,1)<$P(%,U,1) S BGPLPNU=$P(%,U,1)_U_"CPT "_$P(%,U,2)
 S %=$$TRAN^BGP8DU(P,BD,ED,$O(^ATXAX("B","BGP ZOSTER IZ CPTS",0)),5)
 I $P(BGPLPNU,U,1)<$P(%,U,1) S BGPLPNU=$P(%,U,1)_U_"CPT "_$P(%,U,2)
 I BGPLPNU]"" Q BGPLPNU_U_1
 ;
 K BGPSHIN,BGPX
 ;get all immunizations
 S C="187"
 D GETIMMS^BGP7D32(P,ED,C,.BGPX)
 ;go through and set into array if 10 days apart
 S X=0 F  S X=$O(BGPX(X)) Q:X'=+X  S BGPSHIN(X)=""
 ;now get cpts
 S RED=9999999-ED,RBD=9999999-$$DOB^AUPNPAT(P),G=0
 F  S RED=$O(^AUPNVSIT("AA",P,RED)) Q:RED=""!($P(RED,".")>RBD)  D
 .S V=0 F  S V=$O(^AUPNVSIT("AA",P,RED,V)) Q:V'=+V  D
 ..Q:'$D(^AUPNVSIT(V,0))
 ..S X=0 F  S X=$O(^AUPNVCPT("AD",V,X)) Q:X'=+X  D
 ...S Y=$P(^AUPNVCPT(X,0),U) I $$ICD^BGP8UTL2(Y,$O(^ATXAX("B","BGP ZOSTER SHINGRIX CPTS",0)),1) S BGPSHIN(9999999-$P(RED,"."))=""
 ..S X=0 F  S X=$O(^AUPNVTC("AD",V,X)) Q:X'=+X  D
 ...S Y=$P(^AUPNVTC(X,0),U,7) I $$ICD^BGP8UTL2(Y,$O(^ATXAX("B","BGP ZOSTER SHINGRIX CPTS",0)),1) S BGPSHIN(9999999-$P(RED,"."))=""
 ;now check to see if they are all spaced 10 days apart, if not, kill off the odd ones
 S X="",Y="",C=0 F  S X=$O(BGPSHIN(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BGPSHIN(X) Q
 .S Y=X
 ;now count them and see if there are 2 of them
 S BGPSHIN=0,X=0 F  S X=$O(BGPSHIN(X)) Q:X'=+X  S BGPSHIN=BGPSHIN+1
 I BGPSHIN>1 Q U_"2 Zoster/Shingrix"_U_1
 ;CONTRA
 ;
 F BGPZ=121,188,187 S X=$$ANIMCONT^BGP8D31(P,BGPZ,ED) Q:X]""
 I X]"" Q X_U_3
 ;NMI
 S G=$$NMIREF^BGP8UTL1(P,9999999.14,$O(^AUTTIMM("C",121,0)),$$DOB^AUPNPAT(P),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"NMI Refusal"_U_3
 S G=$$NMIREF^BGP8UTL1(P,9999999.14,$O(^AUTTIMM("C",188,0)),$$DOB^AUPNPAT(P),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"NMI Refusal"_U_3
 S G=$$NMIREF^BGP8UTL1(P,9999999.14,$O(^AUTTIMM("C",187,0)),$$DOB^AUPNPAT(P),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"NMI Refusal"_U_3
 S R=$$CPTREFT^BGP8UTL1(P,$$DOB^AUPNPAT(P),ED,$O(^ATXAX("B","BGP ZOSTER IZ CPTS",0)),"N")
 I R Q $P(R,U,2)_U_"NMI Refusal "_$P(R,U,4)_U_3
 S R=$$CPTREFT^BGP8UTL1(P,$$DOB^AUPNPAT(P),ED,$O(^ATXAX("B","BGP ZOSTER SHINGRIX CPTS",0)),"N")
 I R Q $P(R,U,2)_U_"NMI Refusal "_$P(R,U,4)_U_3
 Q ""
 ;
PPSV23(P,BDATE,EDATE,FORE) ;EP
 NEW BGPG,T1,BGPLPNU,I,X,CVX,T,D,BGPZ,G,B
 K BGPG
 S BGPLPNU=""
 S T1=$O(^ATXAX("B","BGP PPSV23 CVX CODES",0))
 S X=0 F  S X=$O(^AUPNVIMM("AC",P,X)) Q:X'=+X  D
 .S I=$P($G(^AUPNVIMM(X,0)),U,1)
 .I 'I Q
 .S CVX=$P($G(^AUTTIMM(I,0)),U,3)
 .Q:CVX=""
 .I '$D(^ATXAX(T1,21,"B",CVX)) Q  ;NOT IN TAXONOMY
 .S D=$P($$VALI^XBDIQ1(9000010.11,X,1201),".")
 .I D="" S D=$$VD^APCLV($P(^AUPNVIMM(X,0),U,3))
 .Q:D<BDATE
 .Q:D>EDATE
 .I $P(BGPLPNU,U,1)<D S BGPLPNU=D_U_"Imm "_CVX
 K BGPG S %=P_"^LAST DX [BGP PNEUMO IZ DXS;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)),$P(BGPLPNU,U,1)<$P(BGPG(1),U) S BGPLPNU=$P(BGPG(1),U,1)_U_"POV "_$P(BGPG(1),U,2)
 S %=$$CPT^BGP8DU(P,BDATE,EDATE,$O(^ATXAX("B","BGP PPSV23 CPT CODES",0)),5)
 I $P(BGPLPNU,U,1)<$P(%,U,1) S BGPLPNU=$P(%,U,1)_U_"CPT "_$P(%,U,2)
 S %=$$TRAN^BGP8DU(P,BDATE,EDATE,$O(^ATXAX("B","BGP PPSV23 CPT CODES",0)),5)
 I $P(BGPLPNU,U,1)<$P(%,U,1) S BGPLPNU=$P(%,U,1)_U_"CPT "_$P(%,U,2)
 I BGPLPNU]"" Q BGPLPNU_U_1
 Q ""
PCV13(P,BDATE,EDATE,FORE) ;EP
 NEW BGPG,T1,BGPLPNU,I,X,CVX,T,D,BGPZ,G,B
 K BGPG
 S BGPLPNU=""
 S T1=$O(^ATXAX("B","BGP PCV13 CVX CODES",0))
 S X=0 F  S X=$O(^AUPNVIMM("AC",P,X)) Q:X'=+X  D
 .S I=$P($G(^AUPNVIMM(X,0)),U,1)
 .I 'I Q
 .S CVX=$P($G(^AUTTIMM(I,0)),U,3)
 .Q:CVX=""
 .I '$D(^ATXAX(T1,21,"B",CVX)) Q  ;NOT IN TAXONOMY
 .S D=$P($$VALI^XBDIQ1(9000010.11,X,1201),".")
 .I D="" S D=$$VD^APCLV($P(^AUPNVIMM(X,0),U,3))
 .Q:D<BDATE
 .Q:D>EDATE
 .I $P(BGPLPNU,U,1)<D S BGPLPNU=D_U_"Imm "_CVX
 S %=$$CPT^BGP8DU(P,BDATE,EDATE,$O(^ATXAX("B","BGP PNEUMO CONJUGATE CPTS",0)),5)
 I $P(BGPLPNU,U,1)<$P(%,U,1) S BGPLPNU=$P(%,U,1)_U_"CPT "_$P(%,U,2)
 S %=$$TRAN^BGP8DU(P,BDATE,EDATE,$O(^ATXAX("B","BGP PNEUMO CONJUGATE CPTS",0)),5)
 I $P(BGPLPNU,U,1)<$P(%,U,1) S BGPLPNU=$P(%,U,1)_U_"CPT "_$P(%,U,2)
 I BGPLPNU]"" Q BGPLPNU_U_1
 Q ""