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

BGP3D64.m

Go to the documentation of this file.
BGP3D64 ; IHS/CMI/LAB - measure 31 01 Jul 2010 7:47 PM ;
 ;;13.0;IHS CLINICAL REPORTING;;NOV 20, 2012;Build 81
 ;
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(DFN,BGPAGEB,BGPAGEE,BGPSEX,BGPEDATE)
 S BGPBREAS=$$DEN8^BGP3D4(DFN,BGPAGEB,BGPAGEE,BGPSEX,BGPEDATE)
 S BGPCRCS="" I BGPAGEB>49,BGPAGEB<76,'$$CRC^BGP3D62(DFN,BGPEDATE) S BGPCRCS=1
 ;if cervical cancer, did they have a pap
 S BGPPAP="" I BGPCERV S BGPPAP=$$PAP^BGP3D3(DFN,BGPEDATE,4,1)
 S BGPMAM="" I BGPBREAS S BGPMAM=$$MAM^BGP3D4(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=""
 I BGPCERV S BGPDV=BGPDV_$S(BGPDV]"":",PAP",1:"PAP")
 I BGPBREAS S BGPDV=BGPDV_$S(BGPDV]"":",MAM",1:"MAM")
 I BGPCRCS S BGPDV=BGPDV_$S(BGPDV]"":",CRCS",1:"CRCS")
 S BGPVALUE=$S(BGPPAP]"":"PAP: "_$$DATE^BGP3UTL($P(BGPPAP,U,2))_" "_$P(BGPPAP,U,3),1:"")
 I BGPMAM]"" S:BGPVALUE]"" BGPVALUE=BGPVALUE_"; " S BGPVALUE=BGPVALUE_$S(BGPMAM]"":"MAM: "_$$DATE^BGP3UTL($P(BGPMAM,U,2))_" "_$P(BGPMAM,U,3),1:"")
 I BGPCRC]"" S:BGPVALUE]"" BGPVALUE=BGPVALUE_"; " S BGPVALUE=BGPVALUE_$S(BGPCRC]"":"CRCS: "_$P(BGPCRC,U,2)_" "_$P(BGPCRC,U,1),1:"")
 S BGPVALUE=BGPDV_"|||"_BGPVALUE
 K X,Y,Z,%,A,B,C,D,E,H,BDATE,EDATE,P
 Q
DEN7(P,AGEB,AGEE,SEX,EDATE) ;EP
 I SEX'="F" Q 0
 I AGEB<25 Q 0
 I AGEE>64 Q 0
 I $$HYSTER^BGP3D3(P,EDATE) Q 0
 Q 1
CRCS(P,BDATE,EDATE) ;
 NEW VALUE
 S VALUE=""
 S VALUE=$$SIG^BGP3D62(P,EDATE)
 I VALUE]"" Q VALUE
 S VALUE=$$COLO^BGP3D62(P,EDATE)
 I VALUE]"" Q VALUE
 S VALUE=$$FOB^BGP3D62(P,BDATE,EDATE)
 I VALUE]"" Q $P(VALUE,U,1)_"^"_$$DATE^BGP3UTL($P(VALUE,U,2))_"^"_VALUE
 Q ""
SIG(P,EDATE,BDATE) ;EP
 NEW BGPLSIG
 S BGPLSIG=""
 I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,5*(-365))
 S BGPG=$$LASTPRC^BGP3UTL1(P,"BGP SIG PROCS",BDATE,EDATE)
 I $P(BGPG,U)=1 S BGPLSIG="SIG "_$P(BGPG,U,2)_"^"_$$DATE^BGP3UTL($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^BGP3UTL($P(X,U,1))_U_$P(X,U,1)
 .S X=$$CPT^BGP3DU(P,BDATE,EDATE,T,5) I X]"" Q
 .S X=$$TRAN^BGP3DU(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^BGP3UTL1(P,"BGP COLO PROCS",BDATE,EDATE)
 I $P(BGPG,U)=1 S BGPLCOLO="COLO "_$P(BGPG,U,2)_"^"_$$DATE^BGP3UTL($P(BGPG,U,3))_U_$P(BGPG,U,3)
 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^BGP3UTL($P(X,U,1))_U_$P(X,U,1)
 .S X=$$CPT^BGP3DU(P,BDATE,EDATE,T,5) I X]"" Q
 .S X=$$TRAN^BGP3DU(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^BGP3DU(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 "_$P(BGPG(1),U,2)_"^"_$P(BGPG(1),U)
 I BGPLFOB="" Q ""
 Q $P(BGPLFOB,U,1)_U_$$DATE^BGP3UTL($P(BGPLFOB,U,2))
 ;
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 ""