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

BGP0D64.m

Go to the documentation of this file.
BGP0D64 ; IHS/CMI/LAB - measure 31 01 Jul 2009 7:47 PM ;
 ;;10.0;IHS CLINICAL REPORTING;;JUN 18, 2010
 ;
ICCS ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
 I 'BGPACTCL S BGPSTOP=1 Q  ;not active clinical and must be
 ;
 S BGPCERV=$$DEN7^BGP0D3(DFN,BGPAGEB,BGPAGEE,BGPSEX,BGPEDATE)
 S BGPBREAS=$$DEN8^BGP0D4(DFN,BGPAGEB,BGPAGEE,BGPSEX,BGPEDATE)
 S BGPCRCS="" I BGPAGEB>49,BGPAGEB<76,'$$CRC^BGP0D61(DFN,BGPEDATE) S BGPCRCS=1
 ;if cervical cancer, did they have a pap
 S BGPPAP="" I BGPCERV S BGPPAP=$$PAP^BGP0D3(DFN,BGPEDATE,3,1)
 S BGPMAM="" I BGPBREAS S BGPMAM=$$MAM^BGP0D4(DFN,BGPEDATE,2,1)
 S BGPCRC="" I BGPCRCS S BGPCRC=$$CRCS(DFN,BGPBDATE,BGPEDATE)
 ;W !,BGPCRC
 ;BGPN1 will be set to 1 if the patient had all eligible screenings
 S BGPN1=1
 I BGPCERV,BGPPAP="" S BGPN1=0
 I BGPBREAS,BGPMAM="" S BGPN1=0
 I BGPCRCS,BGPCRC="" S BGPN1=0
 I (BGPCERV+BGPBREAS+BGPCRCS) S BGPD1=1
 I 'BGPD1 Q  ;not eligible for any
 S BGPDV="AC"
 I BGPCERV S BGPDV=BGPDV_";PAP DENOM"
 I BGPBREAS S BGPDV=BGPDV_";MAM DENOM"
 I BGPCRCS S BGPDV=BGPDV_";CRCS DENOM"
 S BGPVALUE=$S(BGPPAP]"":"Pap "_$P(BGPPAP,U,3)_" "_$$DATE^BGP0UTL($P(BGPPAP,U,2)),1:"")
 I BGPMAM]"" S:BGPVALUE]"" BGPVALUE=BGPVALUE_"; " S BGPVALUE=BGPVALUE_$S(BGPMAM]"":"Mamm "_$P(BGPMAM,U,3)_" "_$$DATE^BGP0UTL($P(BGPMAM,U,2)),1:"")
 I BGPCRC]"" S:BGPVALUE]"" BGPVALUE=BGPVALUE_"; " S BGPVALUE=BGPVALUE_$S(BGPCRC]"":"CRCS "_$P(BGPCRC,U,1)_" "_$$DATE^BGP0UTL($P(BGPCRC,U,3)),1:"")
 S BGPVALUE=BGPDV_"|||"_BGPVALUE
 K X,Y,Z,%,A,B,C,D,E,H,BDATE,EDATE,P
 Q
CRCS(P,BDATE,EDATE) ;
 NEW VALUE
 S VALUE=""
 S VALUE=$$SIG(P,EDATE)
 I VALUE]"" Q VALUE
 S VALUE=$$COLO(P,EDATE)
 I VALUE]"" Q VALUE
 S VALUE=$$FOB(P,BDATE,EDATE)
 I VALUE]"" Q VALUE
 Q ""
SIG(P,EDATE,BDATE) ;EP
 NEW BGPLSIG
 S BGPLSIG=""
 I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,5*(-365))
 ;S BGPG=$$LASTPRCI^BGP0UTL1(P,"45.24",BDATE,EDATE)
 S BGPG=$$LASTPRC^BGP0UTL1(P,"BGP SIG PROCS",BDATE,EDATE)
 I $P(BGPG,U)=1 S BGPLSIG="SIG "_$P(BGPG,U,2)_"^"_$$DATE^BGP0UTL($P(BGPG,U,3))_U_$P(BGPG,U,3)
 ;
 S T=$O(^ATXAX("B","BGP SIG CPTS",0))
 I T D  I X]"",$P(BGPLSIG,U,3)<$P(X,U,1) S BGPLSIG="CPT SIG "_$P(X,U,2)_U_$$DATE^BGP0UTL($P(X,U,1))_U_$P(X,U,1)
 .S X=$$CPT^BGP0DU(P,BDATE,EDATE,T,5) I X]"" Q
 .S X=$$TRAN^BGP0DU(P,BDATE,EDATE,T,5)
 Q BGPLSIG
COLO(P,EDATE,BDATE) ;EP
 K BGPG
 S BGPLCOLO=""
 I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,10*(-365))
 S BGPG=$$LASTPRC^BGP0UTL1(P,"BGP COLO PROCS",BDATE,EDATE)
 I $P(BGPG,U)=1 S BGPLCOLO="COLO "_$P(BGPG,U,2)_"^"_$$DATE^BGP0UTL($P(BGPG,U,3))_U_$P(BGPG,U,3)
 ;S %=P_"^LAST DIAGNOSIS [BGP COLO DXS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 ;I $D(BGPG(1)),$P(BGPLCOLO,U,3)<$P(BGPG(1),U,1) S BGPLCOLO="COLO DX V76.51"_"^"_$$DATE^BGP0UTL($P(BGPG(1),U))
 S T=$O(^ATXAX("B","BGP COLO CPTS",0))
 I T D  I X]"",$P(BGPLCOLO,U,3)<$P(X,U,1) S BGPLCOLO="CPT COLO "_$P(X,U,2)_U_$$DATE^BGP0UTL($P(X,U,1))_U_$P(X,U,1)
 .S X=$$CPT^BGP0DU(P,BDATE,EDATE,T,5) I X]"" Q
 .S X=$$TRAN^BGP0DU(P,BDATE,EDATE,T,5)
 Q BGPLCOLO
FOB(P,BDATE,EDATE) ;EP
 I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,2*(-365))
 S BGPC="",BGPLFOB=""
 S T=$O(^ATXAX("B","BGP FOBT LOINC CODES",0))
 S BGPLT=$O(^ATXLAB("B","BGP GPRA FOB TESTS",0))
 S B=9999999-BDATE,E=9999999-EDATE S D=E-1 F  S D=$O(^AUPNVLAB("AE",P,D)) Q:D'=+D!(D>B)!(BGPC]"")  D
 .S L=0 F  S L=$O(^AUPNVLAB("AE",P,D,L)) Q:L'=+L!(BGPC]"")  D
 ..S X=0 F  S X=$O(^AUPNVLAB("AE",P,D,L,X)) Q:X'=+X!(BGPC]"")  D
 ...Q:'$D(^AUPNVLAB(X,0))
 ...I BGPLT,$P(^AUPNVLAB(X,0),U),$D(^ATXLAB(BGPLT,21,"B",$P(^AUPNVLAB(X,0),U))) S BGPC="V LAB"_U_(9999999-D) Q
 ...Q:'T
 ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
 ...Q:'$$LOINC(J,T)
 ...S BGPC="LOINC"_U_(9999999-D) Q
 ...Q
 S BGPLFOB=BGPC
 S T=$O(^ATXAX("B","BGP FOBT CPTS",0))
 I T D  I X]"",$P(BGPLFOB,U,2)<$P(X,U,1) S BGPLFOB="CPT "_$P(X,"^",2)_"^"_$P(X,U,1)
 .S X=$$CPT^BGP0DU(P,BDATE,EDATE,T,5) I X]"" Q
 S %=P_"^LAST DIAGNOSIS [BGP COLO DXS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)),$P(BGPLFOB,U,2)<$P(BGPG(1),U,1) S BGPLFOB="FOB DX V76.51"_"^"_$P(BGPG(1),U)
 Q BGPLFOB
 ;
LOINC(A,B) ;
 NEW %
 S %=$P($G(^LAB(95.3,A,9999999)),U,2)
 I %]"",$D(^ATXAX(B,21,"B",%)) Q 1
 S %=$P($G(^LAB(95.3,A,0)),U)_"-"_$P($G(^LAB(95.3,A,0)),U,15)
 I $D(^ATXAX(B,21,"B",%)) Q 1
 Q ""