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

BHSEXAM.m

Go to the documentation of this file.
BHSEXAM ;IHS/CIA/MGH - Health Summary for V EXAM file ;10-Dec-2010 17:44;MGH
 ;;1.0;HEALTH SUMMARY COMPONENTS;**2,4**;March 17, 2006;Build 13
 ;===================================================================
 ;Taken from APCH3C
 ; IHS/TUCSON/LAB - PART 3C OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;  [ 01/20/04  8:04 PM ]
 ;;2.0;IHS RPMS/PCC Health Summary;**11,12**;JUN 24, 1997
 ;IHS/MSC/MGH Patch 2 update to patch 17
 ; MOST RECENT EXAMINATION OF EACH TYPE WITHIN DATE RANGE
 ;
MRE ; ******************** EP MOST RECENT EXAMINATION * 9000010.13 *******
 N BHSPAT,BHSICD,BHSICL,BHSQ,X
 S BHSPAT=DFN
 ;Q:'$D(^AUPNVXAM("AA",BHSPAT))
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <SETUP>
 ; <PROCESS>
 D EBLDNEW,EPRTNEW
 ;Now display refusals (patch 2)
 Q:'$D(^AUPNPREF("AA",BHSPAT,9999999.15))
 S BHSFN=9999999.15,BHST="EXAM"
 D DISPREF
 ; <CLEANUP>
MREX K %,BHSET,BHSER,BHSEIEN,BHSECOD,BHSETX,BHSERT,BHSMXL,BHSRL,BHSRW,BHSNMX,BHSDFN,BHSIVD,BHSETD,BHSN,Y
 Q
DISPREF ;EP added in patch 2
 D CKP^GMTSUP Q:$D(GMTSQIT)
 S BHSRC=0
 S BHSX="" F  S BHSX=$O(^AUPNPREF("AA",BHSPAT,BHSFN,BHSX)) Q:BHSX=""!($D(GMTSQIT))  D
 .S BHSD=0 F  S BHSD=$O(^AUPNPREF("AA",BHSPAT,BHSFN,BHSX,BHSD)) Q:BHSD=""!(BHSD>GMTSDLM)!($D(GMTSQIT))  D
 ..S BHSI=0 F  S BHSI=$O(^AUPNPREF("AA",BHSPAT,BHSFN,BHSX,BHSD,BHSI)) Q:BHSI=""!($D(GMTSQIT))  D
 ...I $D(BHSS) X BHSS Q:'%
 ...S BHSRC=BHSRC+1
 ...I BHSRC=1 I BHST]"" W !,BHST," Refusals "
 ...D CKP^GMTSUP Q:$D(GMTSQIT)
 ...W !,$$VAL^XBDIQ1(9000022,BHSI,.04)," -- ",$$VAL^XBDIQ1(9000022,BHSI,.07),?60,"(",$$DATE^APCHSMU(9999999-BHSD),")"
 ..Q
 .Q
 W !
 K BHST,BHSX,BHSD,BHSS,BHSFN,BHSI,BHSRC
 Q
 ; <BUILD>
EBLDNEW ;new exam section that looks at dx, procedures,cpts in addition to exams
 K BHSERT S BHSMXL=0
 S BHSEIEN=0 F  S BHSEIEN=$O(^AUTTEXAM(BHSEIEN)) Q:BHSEIEN'=+BHSEIEN  D
 .S BHSECOD=$P(^AUTTEXAM(BHSEIEN,0),U,2)
 .I BHSECOD="" S Y=$$VXAM(BHSPAT,(9999999-GMTSDLM),DT,BHSEIEN) D SEXAM Q  ;just V EXAM
 .;now see if there is a special routine to get the last of this code
 .I BHSECOD="01" S Y=$$LASTEX01(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="02" S Y=$$LASTEX02(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="04" S Y=$$LASTEX04(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="06" S Y=$$LASTEX06(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="07" S Y=$$LASTEX07(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="08" S Y=$$LASTEX08(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="11" S Y=$$LASTEX11(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="12" S Y=$$LASTEX12(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="14" S Y=$$LASTEX14(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="15" S Y=$$LASTEX15(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="16" S Y=$$LASTEX16(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="17" S Y=$$LASTEX17(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="19" S Y=$$LASTEX19(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="21" S Y=$$LASTEX21(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .I BHSECOD="23" S Y=$$LASTEX23(BHSPAT,(9999999-GMTSDLM),DT) D SEXAM Q
 .S Y=$$VXAM(BHSPAT,(9999999-GMTSDLM),DT,BHSEIEN) D SEXAM
 .Q
 Q
EPRTNEW ;<PRINT>
 N BHSEXT,BHSER,BHS,BHSN,BHSD,BHSHP
 W "Exam",?32,"Date",?45,"Result",?65,"Provider",!
 S BHSEXT=0 F  S BHSEXT=$O(BHSERT(BHSEXT)) Q:BHSEXT=""!($D(GMTSQIT))  D
 .S BHSN=$S($P($G(^AUTTEXAM(BHSEXT,0)),U,2)=34:"DOMESTIC VIOLENCE SCREENING",1:$E($P($G(^AUTTEXAM(BHSEXT,0)),U),1,28))
 .I $P(BHSERT(BHSEXT),U,2)'["Exam" S BHSN=$E(BHSN,1,22)_"["_$P(BHSERT(BHSEXT),U,2)_"]"
 .S X=$P(BHSERT(BHSEXT),U,1) D REGDT4^GMTSU S BHSD=X
 .S BHSER=$P(BHSERT(BHSEXT),U,3)
 .S BHSHP=$E($P(BHSERT(BHSEXT),U,4),1,15)
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W $E(BHSN,1,30),?32,BHSD,?45,$E(BHSER,1,15),?65,BHSHP,!
 .Q
 Q
VXAM(P,BD,ED,E) ;
 S ED=$G(ED)
 NEW D,I
 S D=$O(^AUPNVXAM("AA",P,E,0))
 I D="" Q ""
 I (9999999-D)<BD Q ""  ;before date limits
 S I=$O(^AUPNVXAM("AA",P,E,D,0))
 Q (9999999-D)_"^"_"Exam code "_$P(^AUTTEXAM(E,0),U,2)_"^"_$$VAL^XBDIQ1(9000010.13,I,.04)_"^"_$$VAL^XBDIQ1(9000010.13,I,1204)_"^"_$$VAL^XBDIQ1(9000010.13,I,81101)
SEXAM ;
 I Y="" Q
 S BHSERT(BHSEIEN)=Y
 Q
 ;
LASTEX01(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,"01",BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 01^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V70.0",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V70.0"
 S D=$$LASTDXI^APCHSMU2(P,"V70.3")
 I D S LBE(9999999-$P(D,U,3))="Dx: V70.3"
 S D=$$LASTDXI^APCHSMU2(P,"V70.9")
 I D S LBE(9999999-$P(D,U,3))="Dx: V70.9"
 S D=$$CPT^APCHSMU2(P,BD,DT,$O(^ATXAX("B","APCH GENERAL EXAM CPTS",0)),5)
 I D S LBE(9999999-$P(D,U,1))="CPT: "_$P(D,U,2)
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
 ;
LASTEX02(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,"02",BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 02^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V72.1",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.1"
 S D=$$LASTDXI^APCHSMU2(P,"V72.19")
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.19"
 S D=$$LASTDXI^APCHSMU2(P,"V80.3")
 I D S LBE(9999999-$P(D,U,3))="Dx: V80.3"
 S D=$$LASTPRCI^APCHSMU2(P,"18.11")
 I D S LBE(9999999-$P(D,U,3))="ICD: 18.11"
 S D=$$LASTCPTI^APCHSMU2(P,92700)
 I D S LBE(9999999-$P(D,U,3))="CPT: 92700"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
 ;
LASTEX04(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,"04",BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 04^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V76.42",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V76.42"
 S D=$$LASTPRCI^APCHSMU2(P,"89.31")
 I D S LBE(9999999-$P(D,U,3))="ICD: 89.31"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
 ;
LASTEX06(P,BD,ED) ;
 NEW Y
 S Y=$$LASTBRST^APCLAPI3(P)
 I $P(Y,U)<BD S Y=""
 Q Y
 ;
LASTEX07(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,"07",BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 07^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V72.82",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.82"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
 ;
LASTEX08(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,"08",BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 08^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V72.81",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.81"
 S D=$$LASTDXI^APCHSMU2(P,"V81.0")
 I D S LBE(9999999-$P(D,U,3))="Dx: V81.0"
 S D=$$LASTDXI^APCHSMU2(P,"V81.2")
 I D S LBE(9999999-$P(D,U,3))="Dx: V81.2"
 S D=$$LASTCPTI^APCHSMU2(P,"G0367")
 I D S LBE(9999999-$P(D,U,3))="CPT: G0367"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
 ;
LASTEX11(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,"11",BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 11^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V80.0",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V80.0"
 S D=$$LASTPRCI^APCHSMU2(P,"89.13")
 I D S LBE(9999999-$P(D,U,3))="ICD: 89.13"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
LASTEX12(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,"12",BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 12^"_$P(D,U,2,99)
 S D=$$LASTPRCI^APCHSMU2(P,"89,39")
 I D S LBE(9999999-$P(D,U,3))="ICD: 89.39"
 S D=$$LASTCPTI^APCHSMU2(P,95851)
 I D S LBE(9999999-$P(D,U,3))="CPT: 95851"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
LASTEX14(P,BD,ED) ;
 NEW Y
 S Y=$$LASTRECT^APCLAPI2(P)
 I $P(Y,U)<BD S Y=""
 Q Y
 ;
LASTEX15(P,BD,ED) ;
 NEW Y
 S Y=$$LASTPELV^APCLAPI2(P)
 I $P(Y,U)<BD S Y=""
 Q Y
 ;
LASTEX16(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,16,BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 16^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V20.2",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V20.2"
 S D=$$LASTDXI^APCHSMU2(P,"V79.3",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V79.3"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
 ;
LASTEX17(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,17,BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 17^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V72.11",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.11"
 S D=$$LASTDXI^APCHSMU2(P,"V72.19",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.19"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
 ;
LASTEX19(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,19,BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 19^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V72.0",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.0"
 S D=$$LASTPRCI^APCHSMU2(P,"95.09")
 I D S LBE(9999999-$P(D,U,3))="ICD: 95.09"
 S D=$$LASTPRCI^APCHSMU2(P,"95.05")
 I D S LBE(9999999-$P(D,U,3))="ICD: 95.05"
 S D=$$LASTCPTI^APCHSMU2(P,99172)
 I D S LBE(9999999-$P(D,U,3))="CPT: 99172"
 S D=$$LASTCPTI^APCHSMU2(P,99173)
 I D S LBE(9999999-$P(D,U,3))="CPT: 99173"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
LASTEX21(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,21,BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 21^"_$P(D,U,2,99)
 S D=$$LASTDXI^APCHSMU2(P,"V72.1",BD,DT)
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.1"
 S D=$$LASTDXI^APCHSMU2(P,"V72.19")
 I D S LBE(9999999-$P(D,U,3))="Dx: V72.19"
 S D=$$LASTDXI^APCHSMU2(P,"V80.3")
 I D S LBE(9999999-$P(D,U,3))="Dx: V80.3"
 S D=$$LASTPRCI^APCHSMU2(P,"18.11")
 I D S LBE(9999999-$P(D,U,3))="ICD: 18.11"
 S D=$$LASTCPTI^APCHSMU2(P,92700)
 I D S LBE(9999999-$P(D,U,3))="CPT: 92700"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
LASTEX23(P,BD,ED) ;
 NEW LBE,D
 K LBE
 S ED=$G(ED)
 S D=$$LASTEXAM(P,23,BD,ED)
 I D]"" S LBE(9999999-$P(D,U,1))="Exam code 23^"_$P(D,U,2,99)
 S D=$$LASTCPTI^APCHSMU2(P,92551)
 I D S LBE(9999999-$P(D,U,3))="CPT: 92551"
 I '$D(LBE) Q ""
 S D=$O(LBE(0))
 Q (9999999-D)_"^"_LBE(D)
 ;
LASTEXAM(P,C,B,E) ;
 I '$G(P) Q ""
 I $G(C)="" Q ""
 S B=$G(B)
 S E=$G(E)
 NEW D,I
 S C=$O(^AUTTEXAM("C",C,0))
 I C="" Q ""
 S D=$O(^AUPNVXAM("AA",P,C,0))
 I D="" Q ""
 I (9999999-D)<B Q ""  ;before date limits
 S I=$O(^AUPNVXAM("AA",P,C,D,0))
 Q (9999999-D)_"^"_$$VAL^XBDIQ1(9000010.13,I,.04)_"^"_$$VAL^XBDIQ1(9000010.13,I,1204)_"^"_$$VAL^XBDIQ1(9000010.13,I,81101)