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

BGP8D24A.m

Go to the documentation of this file.
BGP8D24A ;IHS/CMI/LAB - sti measure;
 ;;18.1;IHS CLINICAL REPORTING;;MAY 25, 2018;Build 66
 ;
KEYSTI(P,BDATE,EDATE) ;EP - return key sti's
 NEW X,Y,Z,A,B,C,D,R,N,BD,ED,BGPD,BGPRES,BGPCNTI,BGPCNTN,BGPCNTH,BGPCNTR,BGPRESD,BGPRESN,BGPY
 S BD=$$FMADD^XLFDT(BDATE,-60)
 S ED=$$FMADD^XLFDT(BDATE,300)
 ;S ED=EDATE ;LORI
 S (BGPRESD,BGPRESN,BGPCNTI,BGPCNTN,BGPCNTH,BGPCNTR,BGPHIV)=""  ;RETURN VALUE
HIV ;get first HIV dx, if in time window count as an incident, if not don't
 S BGPHIV=$$HIVDX(P,$$DOB^AUPNPAT(P),ED)
 I BGPHIV,$P(BGPHIV,U,1)'<BD S BGPCNTI=BGPCNTI+1,BGPCNTI($P(BGPHIV,U,1),BGPCNTI)=BGPHIV,$P(BGPCNTI($P(BGPHIV,U),BGPCNTI),U,9)="HIV" ;,BGPRES=BGPRES_$S(BGPRES="":"",1:", ")_$$DATE^BGP8UTL($P($P(^AUPNVSIT($P(BGPG(1),U,5),0),U),"."))_" (HIV)"
CHL ;chlamydia
 NEW BGPG
 S BGPD=BD
 S C=0,R=""
 F  D  Q:'$D(BGPG(1))
 .K BGPG
 .S X=P_"^FIRST DX [BKM CHLAMYDIA DXS;DURING "_$$FMTE^XLFDT(BGPD)_"-"_$$FMTE^XLFDT(ED) S E=$$START1^APCLDF(X,"BGPG(")
 .Q:'$D(BGPG(1))
 .S BGPD=$$FMADD^XLFDT($P(BGPG(1),U,1),61)
 .;S BGPRES=BGPRES_$S(BGPRES="":"",1:", ")_$$DATE^BGP8UTL($P($P(^AUPNVSIT($P(BGPG(1),U,5),0),U),"."))_" (CHL)"
 .S BGPCNTI=BGPCNTI+1
 .S BGPCNTI($P(BGPG(1),U,1),BGPCNTI)=BGPG(1),$P(BGPCNTI($P(BGPG(1),U),BGPCNTI),U,9)="CHL"
 .D NEED
GON ;
 K BGPG
 S BGPD=BD
 F  D  Q:'$D(BGPG(1))
 .K BGPG
 .S X=P_"^FIRST DX [BKM GONORRHEA DXS;DURING "_$$FMTE^XLFDT(BGPD)_"-"_$$FMTE^XLFDT(ED) S E=$$START1^APCLDF(X,"BGPG(")
 .Q:'$D(BGPG(1))
 .S BGPD=$$FMADD^XLFDT($P(BGPG(1),U,1),61)
 .;S BGPRES=BGPRES_$S(BGPRES="":"",1:", ")_$$DATE^BGP8UTL($P($P(^AUPNVSIT($P(BGPG(1),U,5),0),U),"."))_" (GON)"
 .S BGPCNTI=BGPCNTI+1
 .S BGPCNTI($P(BGPG(1),U,1),BGPCNTI)=BGPG(1),$P(BGPCNTI($P(BGPG(1),U),BGPCNTI),U,9)="GON"
 .D NEED
SYH ;
 K BGPG
 S BGPD=BD
 F  D  Q:'$D(BGPG(1))
 .K BGPG
 .S X=P_"^FIRST DX [BKM SYPHILIS DXS;DURING "_$$FMTE^XLFDT(BGPD)_"-"_$$FMTE^XLFDT(ED) S E=$$START1^APCLDF(X,"BGPG(")
 .Q:'$D(BGPG(1))
 .S BGPD=$$FMADD^XLFDT($P(BGPG(1),U,1),61)
 .;S BGPRES=BGPRES_$S(BGPRES="":"",1:", ")_$$DATE^BGP8UTL($P($P(^AUPNVSIT($P(BGPG(1),U,5),0),U),"."))_" (SYH)"
 .S BGPCNTI=BGPCNTI+1
 .S BGPCNTI($P(BGPG(1),U,1),BGPCNTI)=BGPG(1),$P(BGPCNTI($P(BGPG(1),U),BGPCNTI),U,9)="SYH"
 .D NEED
 ;NOW COUNT ALL SCREENINGS DONE FOR ALL INCIDENCES
 S BGPD=0 F  S BGPD=$O(BGPCNTI(BGPD)) Q:BGPD'=+BGPD  D
 .S BGPY=0 F  S BGPY=$O(BGPCNTI(BGPD,BGPY)) Q:BGPY'=+BGPY  D
 ..Q:'$P(BGPCNTI(BGPD,BGPY),U,10)  ;DOESN'T NEED A SCREEN
 ..S X=$$HIVTEST^BGP8D8(P,$$FMADD^XLFDT(BGPD,-30),$$FMADD^XLFDT(BGPD,60))
 ..I X S BGPCNTH=BGPCNTH+1,$P(BGPCNTI(BGPD,BGPY),U,11)=$P(X,U,2) Q
 ..S X=$$REFHIV(P,BDATE,EDATE)
 ..I X S BGPCNTR=BGPCNTR+1,$P(BGPCNTI(BGPD,BGPY),U,20)=$P(X,U,2)
 S D=0
 I 'BGPCNTI Q ""
 F  S D=$O(BGPCNTI(D)) Q:D'=+D  D
 .S Y=0 F  S Y=$O(BGPCNTI(D,Y)) Q:Y'=+Y  D
 ..S R=Y_") "_$$DATE^BGP8UTL($P(BGPCNTI(D,Y),U,1))_" "_$P(BGPCNTI(D,Y),U,9)_" "_$P(BGPCNTI(D,Y),U,2)
 ..S BGPRESD=BGPRESD_$S(BGPRESD]"":" ",1:"")_R
 ..I '$P(BGPCNTI(D,Y),U,10),$P(BGPCNTI(D,Y),U,9)'="HIV" S N=Y_") HIV-Contraind "_$$DATE^BGP8UTL($P(BGPHIV,U,1))_" Prior DX "_$P(BGPHIV,U,2) G R
 ..I '$P(BGPCNTI(D,Y),U,10),$P(BGPCNTI(D,Y),U,9)="HIV" S N=Y_") HIV-N/A" G R
 ..I $P(BGPCNTI(D,Y),U,10) S N=$P(BGPCNTI(D,Y),U,11) D
 ...I N]"" S N=Y_") HIV-Y "_N Q
 ...S N=$P(BGPCNTI(D,Y),U,20) I N]"" S N=Y_") HIV-"_N Q
 ...S N=Y_") HIV-N"
R ..S BGPRESN=BGPRESN_$S(BGPRESN]"":" ",1:"")_N
 ;ZW BGPCNTI
 Q BGPCNTI_U_BGPCNTN_U_BGPCNTH_U_BGPCNTR_U_BGPRESD_U_BGPRESN
NEED ;
 I BGPHIV,$P(BGPHIV,U,1)'>$P(BGPG(1),U,1) Q  ;DOESN'T NEED HIV SCREEN AS ALREADY HAS HIV
 S BGPCNTN=BGPCNTN+1  ;needs a screen
 S $P(BGPCNTI($P(BGPG(1),U),BGPCNTI),U,10)=1  ;needs a screen
 Q
REFHIV(P,BDATE,EDATE) ;
 NEW T,BGPT,G,BGPT1
 S T=""
 S T=$$CPTREFT^BGP8UTL1(P,BDATE,EDATE,$O(^ATXAX("B","BGP CPT HIV TESTS",0)),"R")
 I T S T=1_U_"Refused CPT "_$P(T,U,4)_U_$$DATE^BGP8UTL($P(T,U,2)) Q T
 S BGPT=$O(^ATXLAB("B","BGP HIV TEST TAX",0))
 I BGPT D  I $P(G,U) Q 1_U_"Refused Lab "_U_$$DATE^BGP8UTL($P(G,U,2))
 .S (G,BGPT1)=0 F  S BGPT1=$O(^ATXLAB(BGPT,21,"B",BGPT1)) Q:BGPT1=""!($P(G,U))  D
 ..S G=$$REFUSAL^BGP8UTL1(P,60,BGPT1,BDATE,EDATE)
 Q ""
HIVDX(P,BDATE,EDATE) ;EP - any HIV dx ever or PL
 NEW BGPG,G,Y,X,T,E
 K BGPG
 S Y="BGPG("
 S BDATE=$G(BDATE)
 I BDATE="" S BDATE=$P(^DPT(P,0),U,3)
 S X=P_"^FIRST DX [BGP HIV/AIDS DXS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 I $D(BGPG(1)) Q $P(BGPG(1),U)_U_"POV "_$P(BGPG(1),U,2)
 S T=$O(^ATXAX("B","BGP HIV/AIDS DXS",0))
 S X=0,G="" F  S X=$O(^AUPNPROB("AC",P,X)) Q:X'=+X!(G]"")  D
 .Q:$P(^AUPNPROB(X,0),U,12)="D"
 .;Q:$P(^AUPNPROB(X,0),U,12)="I"
 .Q:$P(^AUPNPROB(X,0),U,8)>EDATE
 .I $P(^AUPNPROB(X,0),U,13)]"",$P(^AUPNPROB(X,0),U,13)>EDATE Q  ;doo
 .S Y=$P(^AUPNPROB(X,0),U)
 .Q:'$$ICD^BGP8UTL2(Y,T,9)
 .S G=$P(^AUPNPROB(X,0),U,8) Q
 .S S=$$VAL^XBDIQ1(9000011,X,80001)
 .I S]"",$D(^XTMP("BGPSNOMEDSUBSET",$J,"PXRM HIV",S)) S G=$P(^AUPNPROB(X,0),U,8) Q
 .Q
 Q G