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

BGP8D715.m

Go to the documentation of this file.
BGP8D715 ; IHS/CMI/LAB - measure 6 ;
 ;;18.1;IHS CLINICAL REPORTING;;MAY 25, 2018;Build 66
 ;
PREG(P,BDATE,EDATE,NOCHR,NORX,FORM,CPBD,CPED,TCNT) ;EP
 I $P($G(^DPT(P,0)),U,2)'="F" Q ""
 NEW B,E,A,CNT,BGPD,BGPG,X,Y,BGPDX,C,D,G,T,%,CTR,VIEN,DXT,PXT,CPTT,BGPV,H,BGP20M,T1,T2,MADX,APC,MCPT,ACPT
 I '$G(FORM) S FORM=""
 I $G(CPBD)="" S CPBD=$$FMADD^XLFDT(BDATE,-365)
 I $G(CPED)="" S CPED=EDATE
 I '$G(TCNT) S TCNT=1
 S D=$$RF(P,BDATE,EDATE) I D Q $S(FORM="":1,1:$$DATE^BGP8UTL(D))  ;REPRODUCTIVE FACTORS
 ;check problem list next
PL ;must be modified in the past 20 months from EDATE
 S BGP20M=$$FMADD^XLFDT(EDATE,-608)
 S T=$O(^ATXAX("B","BGP PREGNANCY DIAGNOSES 2",0))
 S T1=$O(^ATXAX("B","BGP MISCARRIAGE/ABORTION DXS",0))
 S (X,G,A)=0 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"
 .S A=0
 .;S D=$P(^AUPNPROB(X,0),U,3)
 .;I D'<BGP20M,D'>EDATE S A=1
 .;S D=$P(^AUPNPROB(X,0),U,8)
 .;I D'<BGP20M,D'>EDATE S A=1
 .;S D=$P(^AUPNPROB(X,0),U,13)
 .;I D'<BGP20M,D'>EDATE S A=1
 .Q:$P(^AUPNPROB(X,0),U,8)>EDATE
 .Q:$P(^AUPNPROB(X,0),U,8)<BGP20M
 .;Q:'A
 .S Y=$P(^AUPNPROB(X,0),U)
 .I '$$ICD^BGP8UTL2(Y,T,9),'$$ICD^BGP8UTL2(Y,T1,9) Q  ;must be one of these
 .S G=$P(^AUPNPROB(X,0),U,8)
 I G Q $S(FORM="":1,1:$$DATE^BGP8UTL(G))
V ;now visits
 D ALLV^APCLAPIU(P,BDATE,EDATE,"BGPV")
 I '$D(BGPV) Q ""
 S CNT=0,BGPD=""
 S NOCHR=$G(NOCHR)
 S NORX=$G(NORX)
 K BGPG
 S DXT=$O(^ATXAX("B","BGP PREGNANCY DIAGNOSES 2",0))
 S PXT=$O(^ATXAX("B","BGP PREGNANCY ICD PROCEDURES",0))
 S CPTT=$O(^ATXAX("B","BGP PREGNANCY CPT CODES",0))
 S MADX=$O(^ATXAX("B","BGP MISCARRIAGE/ABORTION DXS",0))
 S APC=$O(^ATXAX("B","BGP ABORTION PROCEDURES",0))
 S MCPT=$O(^ATXAX("B","BGP CPT MISCARRIAGE",0))
 S ACPT=$O(^ATXAX("B","BGP CPT ABORTION",0))
 ;CHECK DX, PROCS, CPTS for CNT separate visits
 S B=0,CTR=0 F  S CTR=$O(BGPV(CTR)) Q:CTR'=+CTR!(CNT>(TCNT-1))  D
 .;get visit into VIEN
 .S VIEN=$P(BGPV(CTR),U,5)
 .S D=$$VD^APCLV(VIEN)
 .S C=$$CLINIC^APCLV(VIEN,"C")
 .I NORX,C=39 Q
 .S C=$$PRIMPROV^APCLV(VIEN,"D")
 .I NOCHR,C=53 Q  ;no chr as primary provider
 .;now check for dx
 .S Y=0,H="" F  S Y=$O(^AUPNVPOV("AD",VIEN,Y)) Q:Y'=+Y  D
 ..S %=+^AUPNVPOV(Y,0)
 ..I $$ICD^BGP8UTL2(%,DXT,9)!($$ICD^BGP8UTL2(%,MADX,9)) S BGPDX(D)="",CNT=CNT+1,H=1
 .Q:H
 .;NOW GO THROUGH CPTS
 .S Y=0,H="" F  S Y=$O(^AUPNVCPT("AD",VIEN,Y)) Q:Y'=+Y  D
 ..S %=+^AUPNVCPT(Y,0)
 ..I $$ICD^BGP8UTL2(%,CPTT,1)!($$ICD^BGP8UTL2(%,MCPT,1))!($$ICD^BGP8UTL2(%,ACPT,1)) I '$D(BGPDX(D)) S BGPDX(D)="",CNT=CNT+1,H=1
 .Q:H
 .;NOW PROCEDURES
 .S Y=0,H="" F  S Y=$O(^AUPNVPRC("AD",VIEN,Y)) Q:Y'=+Y  D
 ..S %=+^AUPNVPRC(Y,0)
 ..I $$ICD^BGP8UTL2(%,PXT,0)!($$ICD^BGP8UTL2(%,APC,0)) I '$D(BGPDX(D)) S BGPDX(D)="",CNT=CNT+1,H=1
 .Q:H
 .Q
 I CNT>(TCNT-1) S D=$O(BGPDX(0)) Q $S(FORM="":1,1:$$DATE^BGP8UTL(D))
 Q ""
RF(P,CPBD,CPED) ;CHECK REPRODUCTIVE FACTORS
 NEW A,B
 I $P($G(^AUPNREP(P,11)),U,1)'="Y" Q ""
 S A=""
 S B=$P($G(^AUPNREP(P,11)),U,2)
 I B="" Q ""
 I B<CPBD Q ""
 I B>CPED Q ""
 Q B