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

BUDERPC1.m

Go to the documentation of this file.
BUDERPC1 ; IHS/CMI/LAB - UDS TABLE 6 ;
 ;;12.0;IHS/RPMS UNIFORM DATA SYSTEM;;NOV 22, 2017;Build 75
 ;
 ;
PT ;
 I $G(BUDT6L) S ^XTMP("BUDERPT1",BUDJ,BUDH,"T6",BUDORD,BUDCCOM,BUDAGE,BUDSEX,DFN,BUDV)=$G(^XTMP("BUDERPT1",BUDJ,BUDH,"T6",BUDORD,BUDCCOM,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
T6 ;EP
 S BUDV=0 F  S BUDV=$O(^TMP($J,"VISITSTABLE6A",BUDV)) Q:BUDV'=+BUDV  D
 .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)
 ..D DX
SERV1 ;NOW DO SERVICES ON FULL LIST
 S BUDV=0 F  S BUDV=$O(^TMP($J,"VISITSTABLE6A",BUDV)) Q:BUDV'=+BUDV  D SERV
 Q
DX ;
 S BUD1="",BUDGOT="" F  S BUD1=$O(^BUDETSC("AD",BUD1)) Q:BUD1=""!(BUDGOT)  D
 .S X=$O(^BUDETSC("AD",BUD1,0))
 .Q:$G(^BUDETSC(X,1))]""
 .I $$ICD^ATXCHK(BUDPOVP,$O(^ATXAX("B",BUD1,0)),9) S BUDLINE=$O(^BUDETSC("AD",BUD1,0)),BUDORD=$P(^BUDETSC(BUDLINE,0),U,1),BUDGOT=1
 .Q:'BUDGOT
 .Q:BUDLINE=""
 .;
 .S P=$$VALI^XBDIQ1(9000010,BUDV,.05)
 .Q:P=""
 .Q:$D(^TMP($J,"VISITS6DX",$$VD^APCLV(BUDV),P,BUDORD))  ;already have this dx line for this date
 .S ^TMP($J,"VISITS6DX",$$VD^APCLV(BUDV),P,BUDORD)=""
 .S BUDVAL=BUDPOV
 .D PT
 Q
SERV ;
 S BUDORD=30 F  S BUDORD=$O(^BUDETSC("B",BUDORD)) Q:BUDORD'=+BUDORD  S BUDY=0 F  S BUDY=$O(^BUDETSC("B",BUDORD,BUDY)) Q:BUDY'=+BUDY  D
 .S BUDVAL=""
 .Q:$P(^BUDETSC(BUDY,0),U,2)  ;header only
 .X ^BUDETSC(BUDY,1)
 .Q:BUDVAL=""
 .;ALREADY HAVE THIS SERVICE FOR THIS PT ON THIS DAY?
 .S P=$$VALI^XBDIQ1(9000010,BUDV,.05)
 .Q:P=""
 .Q:$D(^TMP($J,"VISITS6DX",$$VD^APCLV(BUDV),P,BUDORD))  ;already have this dx line for this date
 .S ^TMP($J,"VISITS6DX",$$VD^APCLV(BUDV),P,BUDORD)=""
 .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("BUDERPT1",BUDJ,BUDH,"T6",BUDORD,BUDCCOM,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("BUDERPT1",BUDJ,BUDH,"T6",BUDORD,BUDCCOM,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,I)=$P(^AUPNVPOV(X,0),U),R=$P($$ICDDX^ICDEX(R,$$VD^APCLV(BUDV)),U,2) I $$ICD^ATXCHK(I,$O(^ATXAX("B","BUD 17 T6A LINE 25",0)),9) 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 $D(^BUDETSC(BUDY,8,"B",Z)) S G=Z
 .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 $D(^BUDETSC(BUDY,9,"B",Z)) 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 G="" I T S X=0 F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$$VAL^XBDIQ1(9000010.18,X,.01)
 .I $D(^BUDETSC(BUDY,8,"B",Z)) S G=Z
 .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=+^AUPNVPOV(X,0) I $$ICD^ATXCHK(Z,$O(^ATXAX("B","BUD 17 T6A LINE 23",0)),9) S G=$P($$ICDDX^ICDEX(Z),U,2)
 I G]"" Q "V POV: "_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=$$VAL^XBDIQ1(9000010.18,X,.01)
 .I $D(^BUDETSC(BUDY,8,"B",Z)) S G=Z
 .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 $D(^BUDETSC(BUDY,9,"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 $D(^BUDETSC(BUDY,8,"B",%)) 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,$D(^BUDETSC(BUDY,8,"B",Y)) 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)
 .I $$ICD^ATXCHK(Z,$O(^ATXAX("B","BUD 17 T6A LINE 22",0)),9) S G=$P(^ICD9(Z,0),U,1)
 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,$D(^BUDETSC(BUDY,8,"B",Y)) 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 G="" I T S X=0 F  S X=$O(^AUPNVCPT("AD",BUDV,X)) Q:X'=+X!(G]"")  D
 .S Z=$$VAL^XBDIQ1(9000010.18,X,.01)
 .I $D(^BUDETSC(BUDY,8,"B",Z)) 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=$$VAL^XBDIQ1(9000010.18,X,.01)
 .I $D(^BUDETSC(BUDY,8,"B",Z)) S G=$P($$CPT^ICPTCOD(Z),U,2)
 .Q
 I G]"" Q "V CPT: "_G
 Q ""