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

BUDDRP7B.m

Go to the documentation of this file.
BUDDRP7B ; IHS/CMI/LAB - UDS REPORT PROCESSOR ;
 ;;11.0;IHS/RPMS UNIFORM DATA SYSTEM;;JAN 18, 2017;Build 66
 ;
HTN ;EP - list of HTN
 ;is patient pregnant during the time period BUDDD and BUDED
 S BUDDOB=$P(^DPT(DFN,0),U,3)
 S BUDDDB=($E(BUDBD,1,3)-85)_"0101"
 S BUDDDE=($E(BUDBD,1,3)-18)_"1231"
 Q:BUDDOB>BUDDDE
 Q:BUDDOB<BUDDDB
 Q:BUDMEDV<1
 ;
 S BUDP=$$HTNDX(DFN,$$DOB^AUPNPAT(DFN),BUDCCAD)
 I '$P(BUDP,U) Q  ;not dx'ed before june 30
 ;PREGNANCY
 Q:$$PREG^BUDDRP6B(DFN,BUDBD,BUDED,BUDBD)
 Q:$$EXCL(DFN,BUDDOB,BUDED)
 S BUDP=$$HTNDX(DFN,$$DOB^AUPNPAT(DFN),BUDED,1)
 S BUDRACEX=$$RACE^BUDDRPTC(DFN),BUDRACE=$P(BUDRACEX,U,2),BUDRACEP=$P(BUDRACEX,U,5)
 S BUDRACEE=$$RACE^BUDDRP7I(BUDRACE)
 S BUDR=""
 S BUDETHN=$P($$HISP^BUDDRPTC(DFN),U,1)
 I +BUDETHN=1 S BUDETHNN="Hispanic or Latino"
 I +BUDETHN=2 S BUDETHNN="Non-Hispanic/Latino"
 I +BUDETHN=3 S BUDETHNN="Unreported/Refused to Report"
 I BUDRACEP=8,+BUDETHN=3 S BUDR=1 G SETSECTB
 I +BUDETHN=1 S BUDR=BUDRACEP G SETSECTB
 I +BUDETHN=2 S BUDR=BUDRACEP G SETSECTB
 ;I +BUDETHN=3,BUDRACEP=8 S BUDR=1
SETSECTB ;
 S $P(BUDSECTB(+BUDETHN,BUDR),U,1)=$P($G(BUDSECTB(+BUDETHN,BUDR)),U,1)+1  ;COL 1
 S $P(BUDSECTB(+BUDETHN,BUDR),U,2)=$P($G(BUDSECTB(+BUDETHN,BUDR)),U,2)+1  ;COL 2
 ;TOTAL LINE
 S $P(BUDSECTB(4),U,1)=$P($G(BUDSECTB(4)),U,1)+1
 S $P(BUDSECTB(4),U,2)=$P($G(BUDSECTB(4)),U,2)+1
 ;SUBTOTAL LINE
 S $P(BUDSECTB(+BUDETHN),U,1)=$P($G(BUDSECTB(+BUDETHN)),U,1)+1
 S $P(BUDSECTB(+BUDETHN),U,2)=$P($G(BUDSECTB(+BUDETHN)),U,2)+1
 I $G(BUDHTRL) S ^XTMP("BUDDRP7",BUDJ,BUDH,"HTR",BUDRACEP,+BUDETHN,BUDCCOM,BUDAGE,$P(^DPT(DFN,0),U),DFN)=$P(BUDP,"^",2)
 ;I $G(BUDHTEL) S ^XTMP("BUDDRP7",BUDJ,BUDH,"HTE",BUDETHNN,BUDCCOM,BUDAGE,$P(^DPT(DFN,0),U),DFN)=$P(BUDP,"^",2)
 ;now check BP
 S BUDDP=$$LASTITEM^BUDDDU(DFN,BUDBD,BUDED,"MEASUREMENT","BP")
 I BUDDP]"" S BUDV=$$BPCHK(BUDDP) G SET
 ;now check cpts
 S T=$O(^ATXAX("B","BUD SYSTOLIC BP CPTS",0))
 S BUDS=$$CPT^BUDDDU(DFN,BUDBD,BUDED,T,6)
 S T=$O(^ATXAX("B","BUD DIASTOLIC BP CPTS",0))
 S BUDD=$$CPT^BUDDDU(DFN,BUDBD,BUDED,T,6)
 I 'BUDS,'BUDD S BUDV=0_U_"NO BP TAKEN DURING THE REPORT PERIOD" G SET  ;DIDN'T HAVE BOTH IN TIME PERIOD
 S S=$P(BUDS,U,3)
 S D=$P(BUDD,U,3)
 S G=0
 I S="3074F",D="3078F" S G=1
 I S="3074F",D="3079F" S G=1
 I S="3075F",D="3078F" S G=1
 I S="3075F",D="3079F" S G=1
 S BUDV=G_U_"CPTs: "_$P(BUDS,U,3)_" on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;
 NEW S,D
 S S=$P($P(BP,U,4),"/")
 S D=$P($P(BP,U,4),"/",2)
 I S>139 Q 0_U_$P(BP,U,4)_"  "_$$FMTE^XLFDT($P(BP,U,2))
 I D>89 Q 0_U_$P(BP,U,4)_"  "_$$FMTE^XLFDT($P(BP,U,2))
 Q 1_U_$P(BP,U,4)_"  "_$$FMTE^XLFDT($P(BP,U,2))
RACE(R) ;EP
 I R="Unreported" Q 8
 I R="Asian" Q 1
 I R="Native Hawaiian" Q 2
 I R="Other Pacific Islander" Q 3
 I R="Black/African American" Q 4
 I R="American Indian/Alaska Native" Q 5
 I R="White" Q 6
 Q ""
HTNDX(P,BDATE,EDATE,STOP) ;EP
 NEW BUDDX,B,CNT,BUDD,BUDG,BUDALL
 S STOP=$G(STOP)
 S B=0,CNT=0,BUDD="",BUDALL=""  ;if there is one before time frame set this to 1
 ;
 ;V10.0 ICD10
 K BUDG S %=P_"^ALL DX;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
 S T=$O(^BUDDTSSC("B","T7 HTN DIAGNOSES",0))
 S X=0,G="" F  S X=$O(BUDG(X)) Q:X'=+X!(G)  D
 .S Y=+$P(BUDG(X),U,4)
 .S Z=$P($G(^AUPNVPOV(Y,0)),U,1)
 .S V=$P(BUDG(X),U,5)
 .S C=$$PRIMPROV^APCLV(V,"D")
 .Q:C=53
 .Q:$P(^AUPNVSIT(V,0),U,7)="C"
 .I $D(^BUDDTSSC("AD",Z,T)) S G=1_"^"_$P(BUDG(X),U,5)_"|"_$P(BUDG(X),U,2) Q
 .S S=$$VAL^XBDIQ1(9000010.07,Y,1101) I S]"",$D(^BUDDTSSC("AS",S,T)) S G=1_"^"_$P(BUDG(X),U,5)_"|"_S Q
 I G]"" Q G
PROBDX ;
 S G=$$PLCL^BUDDDU(P,"T7 HTN DIAGNOSES",EDATE,0)
 I G Q 1_U_"Problem List: "_$P(G,U,2)_" on "_$$DATE^BUDDUTL1($P(G,U,3))
 Q ""