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

BUDCRPC1.m

Go to the documentation of this file.
BUDCRPC1 ; IHS/CMI/LAB - UDS TABLE 6 ;
 ;;10.0;IHS/RPMS UNIFORM DATA SYSTEM;;FEB 04, 2016;Build 50
 ;
 ;
PT ;
 I $G(BUDT6L) S ^XTMP("BUDCRPT1",BUDJ,BUDH,"T6",BUDORD,BUDCOM,BUDAGE,BUDSEX,DFN,BUDV)=$G(^XTMP("BUDCRPT1",BUDJ,BUDH,"T6",BUDORD,BUDCOM,BUDAGE,BUDSEX,DFN,BUDV))_$E(BUDVAL,1,20)_U
PT1 S $P(BUDT6("V"),U,BUDORD)=$P(BUDT6("V"),U,BUDORD)+1
 I $D(^TMP($J,"PATIENTS",DFN,BUDORD)) Q
 S ^TMP($J,"PATIENTS",DFN,BUDORD)=""
 S $P(BUDT6("P"),U,BUDORD)=$P(BUDT6("P"),U,BUDORD)+1
 Q
OT ;
 I $D(^XTMP("BUDCRPT1",BUDJ,BUDH,"T6",BUDORD,BUDCOM,BUDAGE,BUDSEX,DFN)) Q  ;patient already a hit on this line
 S ^XTMP("BUDCRPT1",BUDJ,BUDH,"ORPHANS",BUDORD,BUDCOM,BUDAGE,BUDSEX,DFN,BUDV)=$E(BUDVAL,1,20)
 Q
T6 ;EP
 S BUDV=0 F  S BUDV=$O(^TMP($J,"VISITS356A",BUDV)) Q:BUDV'=+BUDV  D
 .S BUDP=$$PRIMPROV^APCLV(BUDV,"D") Q:BUDP=""
 .S BUDIEN=0 F  S BUDIEN=$O(^AUPNVPOV("AD",BUDV,BUDIEN)) Q:BUDIEN'=+BUDIEN  D
 ..S BUDPOV=$$VAL^XBDIQ1(9000010.07,BUDIEN,.01),BUDPOVP=$P(^AUPNVPOV(BUDIEN,0),U,1) ;$$PRIMPOV^APCLV(BUDV,"C") Q:BUDPOV=""  S BUDPOVP=$$PRIMPOV^APCLV(BUDV,"I")
 ..D PRIMDX
SERV1 ;NOW DO SERVICES ON FULL LIST
 S BUDV=0 F  S BUDV=$O(^TMP($J,"VISITSLIST",BUDV)) Q:BUDV'=+BUDV  D SERV
 Q
PRIMDX ;
 S BUDLINE=$O(^BUDCTSC("AC",BUDPOVP,0))
 I BUDLINE="" Q  ;Q  ;LORI FIX THIS LATER
 S BUDORD=$P(^BUDCTSC(BUDLINE,0),U,1)  ;order
 S BUDVAL=BUDPOV
 D PT
 Q
SERV ;
 S BUDORD=30 F  S BUDORD=$O(^BUDCTSC("B",BUDORD)) Q:BUDORD'=+BUDORD  S BUDY=0 F  S BUDY=$O(^BUDCTSC("B",BUDORD,BUDY)) Q:BUDY'=+BUDY  D
 .S BUDVAL=""
 .Q:$P(^BUDCTSC(BUDY,0),U,2)  ;header only
 .X ^BUDCTSC(BUDY,1)
 .Q:BUDVAL=""
 .D PT
 Q
MAM ;EP
 S BUDVAL=$$MAMM(BUDV) I BUDVAL]"" Q
 I BUDVAL="" D
 .S BUDW=0 F  S BUDW=$O(^TMP($J,"MAMMS",BUDW)) Q:BUDW'=+BUDW  D
 ..S D=$S($$VERSION^XPDUTL("BW")<3:$P($G(^BWPCD(BUDW,0)),U,12),1:$P(^TMP($J,"MAMMS",BUDW),U,3))
 ..Q:D'=$P($P($G(^AUPNVSIT(BUDV,0)),U),".")  ;pap not on this visit date
 ..Q:$D(^TMP($J,"MAMDATE",$P($P(^AUPNVSIT(BUDV,0),U),".")))  ;ALREADY HAVE A PAP ON THIS DATE
 ..D PT1 S ^XTMP("BUDCRPT1",BUDJ,BUDH,"T6",BUDORD,BUDCOM,BUDAGE,BUDSEX,DFN,"WH","MAM",BUDW)=^TMP($J,"MAMMS",BUDW)
 ..S ^TMP($J,"MAMDATE",$P($P($G(^AUPNVSIT(BUDV,0)),U),"."))=""
 Q
PAP1 ;
 S BUDVAL=$$PAP(BUDV) I BUDVAL]"" Q
 I BUDVAL="" D
 .S BUDW=0 F  S BUDW=$O(^TMP($J,"PAPS",BUDW)) Q:BUDW'=+BUDW  D
 ..S D=$S($$VERSION^XPDUTL("BW")<3:$P($G(^BWPCD(BUDW,0)),U,12),1:$P(^TMP($J,"PAPS",BUDW),U,3))
 ..Q:D'=$P($P($G(^AUPNVSIT(BUDV,0)),U),".")
 ..Q:$D(^TMP($J,"PAPDATE",$P($P(^AUPNVSIT(BUDV,0),U),".")))  ;ALREADY HAVE A PAP ON THIS DATE
 ..D PT1 S ^XTMP("BUDCRPT1",BUDJ,BUDH,"T6",BUDORD,BUDCOM,BUDAGE,BUDSEX,DFN,"WH","PAP",BUDW)=^TMP($J,"PAPS",BUDW)
 ..S ^TMP($J,"PAPDATE",$P($P($G(^AUPNVSIT(BUDV,0)),U),"."))=""
 Q
CONTRA(BUDV) ;
 S G="",X=0 F  S X=$O(^AUPNVPOV("AD",BUDV,X)) Q:X'=+X!(G]"")  S R=$P(^AUPNVPOV(X,0),U),R=$P($$ICDDX^ICDEX(R,$$VD^APCLV(BUDV)),U,2) I $E(R,1,3)="V25"!($E(R,1,3)="Z30") S G=R
 Q G
SEASFLU(BUDV) ;
 S G="" S X=0 F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVCPT(X,0),U)
 .S Z=$P($$CPT^ICPTCOD(Z),U,2)
 .I Z>90653,Z<90663 S G=Z Q
 .I Z>90671,Z<90674 S G=Z Q
 .I Z>90684,Z<90689 S G=Z Q
 .Q
 I G]"" Q "V CPT: "_G
 S G="",X=0 F  S X=$O(^AUPNVIMM("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVIMM(X,0),U),Z=+$P(^AUTTIMM(Z,0),U,3)
 .I Z=15!(Z=16)!(Z=111)!(Z=88)!(Z=135)!(Z=140)!(Z=141)!(Z=144)!(Z=149)!(Z=150)!(Z=151)!(Z=153)!(Z=155)!(Z=158)!(Z=161)!(Z=166) S G=Z_" imm"
 .Q
 Q G
 ;
 ;
PAP(BUDV) ;
 S T=$O(^ATXLAB("B","BGP PAP SMEAR TAX",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVLAB("AD",BUDV,X)) Q:X'=+X!(G]"")  S R=$P($G(^AUPNVLAB(X,0)),U) I R,$D(^ATXLAB(T,21,"B",R)) S G=$P(^LAB(60,R,0),U)
 I G]"" Q "V LAB: "_G
 S X=0 F  S X=$O(^AUPNVLAB("AD",BUDV,X)) Q:X'=+X!(G]"")  S R=$P(^AUPNVLAB(X,0),U),R=$P(^LAB(60,R,0),U) I R="PAP SMEAR" S G=R
 I G]"" Q "V LAB: "_G
 S T=$O(^ATXAX("B","BUD CPT PAP 10",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVCPT(X,0),U)
 .I $$ICD^ATXCHK(Z,T,1) S G=$P($$CPT^ICPTCOD(Z),U,2)
 .Q
 I G]"" Q "V CPT: "_G
 S X=0,G="" F  S X=$O(^AUPNVPOV("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVPOV(X,0),U),Z=$P($$ICDDX^ICDEX(Z,$$VD^APCLV(BUDV)),U,2)
 .I Z="V76.2"!(Z="V72.3")!(Z="V72.31")!(Z="V72.32")!($E(Z,1,6)="Z01.41")!($E(Z,1,6)="Z01.42")!($E(Z,1,5)="Z12.4") S G=Z  ;!(Z="V72.32")!(Z="V76.47")!(Z="V67.01")!($E(Z,1,5)="795.0") S G=Z
 I G]"" Q "V POV: "_G
 S X=0,G="" F  S X=$O(^AUPNVPRC("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$$GET1^DIQ(9000010.08,X,.01)
 .I Z="91.46" S G=Z
 I G]"" Q "V PROCEDURE: "_G
 S T=$O(^ATXAX("B","BGP PAP LOINC CODES",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVLAB("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S J=$P($G(^AUPNVLAB(X,11)),U,13)
 .Q:J=""
 .Q:'$$LOINC(J,T)
 .S G=J
 I G]"" Q "V LAB LOINC: "_G
 Q ""
IMM(BUDV) ;
 S T=$O(^ATXAX("B","BUD 12 CPT IMM LINE 24",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVCPT(X,0),U)
 .I $$ICD^ATXCHK(Z,T,1) S G=$P($$CPT^ICPTCOD(Z),U,2)
 .Q
 I G]"" Q "V CPT: "_G
 S G="",X=0 F  S X=$O(^AUPNVIMM("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVIMM(X,0),U),Z=+$P(^AUTTIMM(Z,0),U,3)
 .S BUDTIEN=$O(^BUDCCNTL("B","IMMUNIZATIONS LINE 24",0))
 .I $D(^BUDCCNTL(BUDTIEN,11,"B",Z)) S G=Z_" imm"
 .Q
 Q G
HIV(BUDV) ;EP
 S T=$O(^ATXLAB("B","BGP HIV TEST TAX",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVLAB("AD",BUDV,X)) Q:X'=+X!(G]"")  S R=$P($G(^AUPNVLAB(X,0)),U) I R,$D(^ATXLAB(T,21,"B",R)) S G=$P(^LAB(60,R,0),U)
 I G]"" Q "V LAB: "_G
 ;S T=$O(^ATXAX("B","BUD CPT HIV TESTS",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVCPT(X,0),U)
 .S %=$$VAL^XBDIQ1(9000010.18,X,.01)
 .I %=86689!(%=86701)!(%=86702)!(%=86703)!(%=87390)!(%=87391) S G=$P($$CPT^ICPTCOD(Z),U,2)
 .Q
 I G]"" Q "V CPT: "_G
 S T=$O(^ATXAX("B","BGP HIV TEST LOINC CODES",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVLAB("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S J=$P($G(^AUPNVLAB(X,11)),U,13)
 .Q:J=""
 .Q:'$$LOINC(J,T)
 .S G=J
 I G]"" Q "V LAB LOINC: "_G
 Q ""
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 ""
MAMM(BUDV) ;
 S X=0,G="" F  S X=$O(^AUPNVRAD("AD",BUDV,X)) Q:X'=+X  D
 .S Z=$P(^AUPNVRAD(X,0),U),Z=$P(^RAMIS(71,Z,0),U,9) I Z S Y=$P($$CPT^ICPTCOD(Z),U,2)
 .I Y=77057!(Y=77052) S G=Y
 I G]"" Q "V RAD: "_G
 S X=0,G="" F  S X=$O(^AUPNVPOV("AD",BUDV,X)) Q:X'=+X  D
 .S Z=$P(^AUPNVPOV(X,0),U),Z=$P($$ICDDX^ICDEX(Z,$$VD^APCLV(BUDV)),U,2)
 .I Z="V76.11"!(Z="V76.12")!($E(Z,1,6)="Z12.31") S G=Z
 I G]"" Q "V POV: "_G
 S X=0,G="" F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X  D
 .S Z=$P(^AUPNVCPT(X,0),U),Y=$P($$CPT^ICPTCOD(Z),U,2)
 .I Y=77057!(Y=77052) S G="V CPT: "_Y
 I G]"" Q "V CPT: "_Y
 Q ""
HEPB(BUDV) ;
 S T=$O(^ATXLAB("B","BUD HEPATITIS B TESTS",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVLAB("AD",BUDV,X)) Q:X'=+X!(G]"")  S R=$P($G(^AUPNVLAB(X,0)),U) I R,$D(^ATXLAB(T,21,"B",R)) S G=$P(^LAB(60,R,0),U)
 I G]"" Q "V LAB: "_G
 S T=$O(^ATXAX("B","BUD CPT HEPATITIS B TESTS",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVCPT(X,0),U)
 .I $$ICD^ATXCHK(Z,T,1) S G=$P($$CPT^ICPTCOD(Z),U,2)
 .Q
 I G]"" Q "V CPT: "_G
 Q ""
HEPC(BUDV) ;
 S T=$O(^ATXLAB("B","BUD HEPATITIS C TESTS",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVLAB("AD",BUDV,X)) Q:X'=+X!(G]"")  S R=$P($G(^AUPNVLAB(X,0)),U) I R,$D(^ATXLAB(T,21,"B",R)) S G=$P(^LAB(60,R,0),U)
 I G]"" Q "V LAB: "_G
 S T=$O(^ATXAX("B","BUD CPT HEPATITIS C TESTS",0))
 S G="" I T S X=0 F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$P(^AUPNVCPT(X,0),U)
 .I $$ICD^ATXCHK(Z,T,1) S G=$P($$CPT^ICPTCOD(Z),U,2)
 .Q
 I G]"" Q "V CPT: "_G
 Q ""