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

BHSPED.m

Go to the documentation of this file.
BHSPED ;IHS/MSC/MGH - Health Summary for patient education;22-Apr-2014 09:31;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**1,2,3,4,9**;March 17,2006;Build 16
 ;===================================================================
 ; Copied from PART 10 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;  [ 05/04/04  2:12 PM ]
 ;;2.0;IHS RPMS/PCC Health Summary;**5,6,9,11,15**;JUN 24, 1997
 ;IHS/CMI/LAB - took screen out of education topics service cat
 ;IHS/CMI/LAB - patch 11 added behavior code and obj to pt ed display
 ;IHS/CMI/LAB - added dental ada codes for education to pt ed display (1310, 1320, 1330)
 ;Changes for patch 17 added on
 ;Changes added in patch 3 for date on historical education
PTED ; ********** PATIENT EDUCATION * 9000010.16 **********
 ; <SETUP>
 N BHSPAT
 S BHSPAT=DFN
 ;Q:'$D(^AUPNVPED("AA",BHSPAT))
 K BHSDEN D DENTED
 I '$D(^AUPNVPED("AA",BHSPAT)),'$D(BHSDEN) Q  ;no ada or v pt ed
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <DISPLAY>
 S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVPED("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D ONEDATE
 S BHSIVD=0 F  S BHSIVD=$O(BHSDEN(BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)!('GMTSNDM)  S X=(-BHSIVD+9999999)\1 D REGDT4^GMTSU S BHSDAT=X S BHSDTU=0 D
 .S BHSDFN=0 F  S BHSDFN=$O(BHSDEN(BHSIVD,"PED",BHSDFN)) Q:BHSDFN'=+BHSDFN!($D(GMTSQIT))!('GMTSNDM)  D PEDCHK S GMTSNDM=GMTSNDM-BHSDTU
 .S BHSDFN=0,BHSCNT=0 F  S BHSDFN=$O(BHSDEN(BHSIVD,"DEN",BHSDFN)) Q:BHSDFN'=+BHSDFN!($D(GMTSQIT))!('GMTSNDM)  D
 ..S APCHX=BHSDEN(BHSIVD,"DEN",BHSDFN)
 ..D CKP^GMTSUP Q:$D(GMTSQIT)
 ..W ! S BHSVDF=$P(^AUPNVDEN(BHSDFN,0),U,3) D GETSITEV^BHSUTL W:'BHSCNT BHSDAT,?12,BHSNSH W ?25,"ADA: ",$P(^AUTTADA(APCHX,0),U)," - ",$E($P(^AUTTADA(APCHX,0),U,2),1,40),! S BHSCNT=BHSCNT+1
 ..D GETSITEV^BHSUTL W:'BHSCNT BHSDAT,?10,BHSNSH W ?23,"ADA: ",$P(^AUTTADA(APCHX,0),U)," - ",$E($P(^AUTTADA(APCHX,0),U,2),1,40),! S BHSCNT=BHSCNT+1
 ..Q
 ; <CLEANUP>
 ;now display PTED refusals
 S BHST="EDUCATION",BHSFN=9999999.09 D DISPREF^BHSRAD
 K BHST,BHSFN
PTEDX K BHSIVD,BHSDAT,BHSDFN,BHSFO,BHSFAC,BHSN,BHSDTU,BHSLVL,BHSLVT,BHSPED,BHSPTB,BHSQ,BHSPEM,Y,X
 K BHSNFL,BHSNSH,BHSNAB,BHSTYP,BHSVDT,BHSVSC,BHSVDF,BHSDEN,BHSDE1,BHSDE2,BHSDE3,APCHX,BHSICL,BHSNRQ,BHSCNT,BHSTXT
 Q
ONEDATE N BHSDATE,BHSVST,BHSVTYP
 S BHSDFN=""
 F BHSQ=0:0 S BHSDFN=$O(^AUPNVPED("AA",BHSPAT,BHSIVD,BHSDFN)) Q:BHSDFN=""  D
 .;Find the entry date.  Store this here first
 .I $P($G(^AUPNVPED(BHSDFN,12)),U,1)'=""  D
 ..S BHSDATE=$P($G(^AUPNVPED(BHSDFN,12)),U,1)
 ..;IHS/MSC/MGH updated patch 3 to find visit date for historical education
 ..S BHSVST=$P($G(^AUPNVPED(BHSDFN,0)),U,3)
 ..S BHSTYP=$P($G(^AUPNVSIT(BHSVST,0)),U,7)
 ..I BHSTYP="E" S BHSDATE=$P($G(^AUPNVSIT(BHSVST,0)),U,1)
 ..S BHSDATE=9999999-BHSDATE
 ..S BHSDEN(BHSDATE,"PED",BHSDFN)=""
 .E  S BHSDEN(BHSIVD,"PED",BHSDFN)=""
 Q
PEDCHK S BHSN=^AUPNVPED(BHSDFN,0)
 S BHSVDF=$P(BHSN,U,3) D GETSITEV^BHSUTL
 D CKP^GMTSUP Q:$D(GMTSQIT)  S:GMTSNPG BHSDTU=0
 I 'BHSDTU W BHSDAT S BHSFO=""
 I BHSNSH=BHSFO S BHSFAC=""
 E  S (BHSFAC,BHSFO)=BHSNSH
 S BHSDTU=1
 S BHSPED=$P(BHSN,U,1),BHSPEM=$P(^AUTTEDT(BHSPED,0),U,2),BHSPED=$P(^AUTTEDT(BHSPED,0),U,1)
 S BHSLVL=$P(BHSN,U,6),BHSLVT=""
 I BHSLVL]"" D
 .  S BHSLVT=$P(^DD(9000010.16,.06,0),U,3)
 .  S BHSLVT=$P(BHSLVT,BHSLVL_":",2)
 .  S BHSLVT=$P(BHSLVT,";",1)
 .  S:"^GOOD^FAIR^POOR^"[("^"_BHSLVT_"^") BHSLVT=BHSLVT_" UNDERSTANDING"
 .  ;S BHSLVT="- "_BHSLVT
 .  Q
 D CKP^GMTSUP Q:$D(GMTSQIT)  W:GMTSNPG BHSDAT W ?12,BHSFAC,?25,$E(BHSPEM,1,12),?37,$E(BHSPED,1,35),$S($P(BHSN,U,7)="":"",$P(BHSN,U,7)="I":" - (IND)",$P(BHSN,U,7)="G":" - (GRP)",1:""),!
 I BHSLVT]"" W ?37,BHSLVT,!
 I $P(BHSN,U,13)]""!($P(BHSN,U,14)]"") D
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W ?23,"Behavior Code: ",$$VAL^XBDIQ1(9000010.16,BHSDFN,.13),?51,"Objectives Met: ",$P(BHSN,U,14),!
 ;IHS/MSC/MGH Patch 17 changes added here
 ;I $P($G(^AUPNVPED(BHSDFN,11)),U)]"" S BHSTXT=$P(^AUPNVPED(BHSDFN,11),U),BHSNRQ="",BHSICL=23 D PRTTXT^BHSUTL
 N BHDVDT
 S BHSVDT=$P($P($G(^AUPNVSIT(BHSVDF,0)),U),".")  ;get visit date
 I $P($G(^AUPNVPED(BHSDFN,11)),U)="",$P(BHSN,U,4)]"" D
 .;Patch 9 change for ICD-10
 .I $$AICD^BHSUTL  S BHSTXT=$P($$ICDDX^ICDEX($P(BHSN,U,4),BHSVDT,"","I"),U,4),BHSNRQ="",BHSICL=23 D PRTTXT^BHSUTL
 .E  S BHSTXT=$P($$ICDDX^ICDCODE($P(BHSN,U,4),BHSVDT),U,4),BHSNRQ="",BHSICL=23 D PRTTXT^BHSUTL
 I $P(BHSN,U,11)]"" S BHSTXT=$P(BHSN,U,11),BHSNRQ="",BHSICL=23 D PRTTXT^BHSUTL Q
 Q
 ;
MRPTED ; ********** MOST RECENT PATIENT EDUCATION * 9000010.16 **********
 ; <SETUP>
 ;Q:'$D(^AUPNVPED("AA",BHSPAT))
 K BHSDEN D DENTEDL
 I '$D(^AUPNVPED("AA",BHSPAT)),'$D(BHSDEN) Q  ;no ada or v pt ed
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <DISPLAY>
 K BHSPTB
 ;S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVPED("AA",BHSPAT,BHSIVD)) Q:'BHSIVD  S X=-BHSIVD\1+9999999 D REGDT4^GMTSU S BHSDAT=X D ONEDAY Q:$D(GMTSSQIT)
 ;IHS/CMI/LAB - PATCH 9 modified this to look at date range and max visit limits
 S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVPED("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D ONEDAY
 S BHSIVD=0 F  S BHSIVD=$O(BHSDEN(BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)!('GMTSNDM)  S X=(-BHSIVD+9999999)\1 D REGDT4^GMTSU S BHSDAT=X S BHSDTU=0 D
 .S BHSDFN=0 F  S BHSDFN=$O(BHSDEN(BHSIVD,"PED",BHSDFN)) Q:BHSDFN'=+BHSDFN!($D(GMTSQIT))!('GMTSNDM)  D PEDCHK S GMTSNDM=GMTSNDM-BHSDTU
 .S BHSDFN=0,BHSCNT=0 F  S BHSDFN=$O(BHSDEN(BHSIVD,"DEN",BHSDFN)) Q:BHSDFN'=+BHSDFN!($D(GMTSQIT))!('GMTSNDM)  D
 ..S APCHX=BHSDEN(BHSIVD,"DEN",BHSDFN)
 ..D CKP^GMTSUP Q:$D(GMTSQIT)
 ..W ! S BHSVDF=$P(^AUPNVDEN(BHSDFN,0),U,3) D GETSITEV^BHSUTL W:'BHSCNT BHSDAT,?10,BHSNSH W ?23,"ADA: ",$P(^AUTTADA(APCHX,0),U)," - ",$E($P(^AUTTADA(APCHX,0),U,2),1,40),! S BHSCNT=BHSCNT+1
 ..Q
 ; <CLEANUP>
 ;patch 4 now display PTED refusals
 S BHST="EDUCATION",BHSFN=9999999.09 D DISPREF^BHSRAD
 K BHST,BHSFN
MRPTEDX K BHSPTB,BHSEVT
 K BHSIVD,BHSDAT,BHSDFN,BHSFO,BHSFAC,BHSN,BHSDTU,BHSLVL,BHSLVT,BHSPED
 K BHSNFL,BHSNSH,BHSNAB,BHSVSC,BHSVDF
 Q
 ;
ONEDAY ;
 N X
 S BHSDFN="" F BHSQ=0:0 S BHSDFN=$O(^AUPNVPED("AA",BHSPAT,BHSIVD,BHSDFN)) Q:'BHSDFN  D
 .S X=$P($G(^AUPNVPED(BHSDFN,0)),U)
 .Q:X=""
 .Q:'$D(^AUTTEDT(X,0))
 .S BHSEVT=+^AUPNVPED(BHSDFN,0) I '$D(BHSPTB(BHSEVT)) S BHSPTB(BHSEVT)="",BHSDEN(BHSIVD,"PED",BHSDFN)=""
 Q
MRPE ;EP - called from component
 ; <SETUP>
 ;Q:'$D(^AUPNVPED("AA",BHSPAT))
 K BHSDEN D DENTAL
 I '$D(^AUPNVPED("AA",BHSPAT)),'$D(BHSDEN) Q  ;no ada or v pt ed
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <DISPLAY>
 K BHSPTB
 ;S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVPED("AA",BHSPAT,BHSIVD)) Q:'BHSIVD  S X=(-BHSIVD+9999999)\1 D REGDT4^GMTSU S BHSDAT=X D ONEDAY Q:$D(GMTSQIT)
 ;IHS/CMI/LAB - PATCH 9 modified this to look at date range and max visit limits
 S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVPED("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)!('GMTSNDM)  D
 .S X=(-BHSIVD+9999999)\1 D REGDT4^GMTSU S BHSDAT=X  S BHSDTU=0 D MRPEOD Q:$D(GMTSQIT)  S GMTSNDM=GMTSNDM-BHSDTU Q:'GMTSNDM
 D REORDER
 ; <CLEANUP>
 ;now display PTED refusals
 S BHST="EDUCATION",BHSFN=9999999.09 D DISPREF^BHSRAD
 K BHST,BHSFN
MRPEX K BHSPTB,BHSEVT,BHSDSP,BHSX
 K BHSIVD,BHSDAT,BHSDFN,BHSFO,BHSFAC,BHSN,BHSDTU,BHSLVL,BHSLVT,BHSPED
 K BHSNFL,BHSNSH,BHSNAB,BHSVSC,BHSVDF
 Q
 ;
MRPEOD ;
 S BHSDFN="" F BHSQ=0:0 S BHSDFN=$O(^AUPNVPED("AA",BHSPAT,BHSIVD,BHSDFN)) Q:'BHSDFN  S BHSEVT=+^AUPNVPED(BHSDFN,0) I '$D(BHSPTB(BHSEVT)) S BHSPTB(BHSEVT)=BHSIVD_U_BHSDFN,BHSDTU=1
 Q
REORDER ;reorder by name and print
 S BHSEVT=0 F  S BHSEVT=$O(BHSPTB(BHSEVT)) Q:BHSEVT'=+BHSEVT  I $D(^AUTTEDT(BHSEVT,0)) S BHSDSP($P(^AUTTEDT(BHSEVT,0),U))=BHSPTB(BHSEVT)
 S BHSX="" F  S BHSX=$O(BHSDSP(BHSX)) Q:BHSX=""!($D(GMTSQIT))  D
 .S BHSDFN=$P(BHSDSP(BHSX),U,2)
 .S BHSIVD=$P(BHSDSP(BHSX),U) S X=(-BHSIVD+9999999)\1 D REGDT4^GMTSU S BHSDAT=X
 .I $P(BHSDSP(BHSX),U,3)="D" S BHSN=^AUPNVDEN(BHSDFN,0)
 .E  S BHSN=^AUPNVPED(BHSDFN,0)
 .S BHSVDF=$P(BHSN,U,3) D GETSITEV^BHSUTL
 .I $P(BHSDSP(BHSX),U,3)="D" D  Q
 ..D CKP^GMTSUP Q:$D(GMTSQIT)
 ..W $E(BHSX,1,43),"  ADA Code: ",$P(^AUTTADA($P(^AUPNVDEN(BHSDFN,0),U),0),U),?57,BHSDAT,?67,BHSNSH,! Q
 .S BHSLVL=$P(BHSN,U,6),BHSLVT=""
 .I BHSLVL]"" D
 ..  S BHSLVT=$P(^DD(9000010.16,.06,0),U,3)
 ..  S BHSLVT=$P(BHSLVT,BHSLVL_":",2)
 ..  S BHSLVT=$P(BHSLVT,";",1)
 ..  S:"^GOOD^FAIR^POOR^"[("^"_BHSLVT_"^") BHSLVT=BHSLVT_" UNDERSTANDING"
 ..  S BHSLVT="- "_BHSLVT
 .D CKP^GMTSUP Q:$D(GMTSQIT)  W BHSX,"  ",$S($P(BHSN,U,7)="":"",$P(BHSN,U,7)="I":" - (IND)",$P(BHSN,U,7)="G":" - (GRP)",1:""),"  ",BHSLVT,?57,BHSDAT,?67,BHSNSH,!
 .I $P(BHSN,U,13)]""!($P(BHSN,U,14)]"") D
 ..D CKP^GMTSUP Q:$D(GMTSQIT)
 ..W ?23,"Behavior Code: ",$$VAL^XBDIQ1(9000010.16,BHSDFN,.13),?51,"Objectives Met: ",$P(BHSN,U,14),!
 .I $P($G(^AUPNVPED(BHSDFN,11)),U)]"" S BHSTXT=$P(^AUPNVPED(BHSDFN,11),U),BHSNRQ="",BHSICL=5 D PRTTXT^BHSUTL
 .;IHS/MSC/MGH Changes added for patch 17
 .N BHDVDT
 .S BHSVDT=$P($P($G(^AUPNVSIT(BHSVDF,0)),U),".")  ;get visit date
 .I $P($G(^AUPNVPED(BHSDFN,11)),U)="",$P(BHSN,U,4)]""
 .;Patch 9 change for ICD-10
 .I $$AICD^BHSUTL  S BHSTXT=$P($$ICDDX^ICDEX($P(BHSN,U,4),BHSVDT,"","I"),U,4),BHSNRQ="",BHSICL=23 D PRTTXT^BHSUTL
 .E  S BHSTXT=$P($$ICDDX^ICDCODE($P(BHSN,U,4),BHSVDT),U,4),BHSNRQ="",BHSICL=5 D PRTTXT^BHSUTL
 .I $P(BHSN,U,11)]"" S BHSTXT=$P(BHSN,U,11),BHSNRQ="",BHSICL=5 D PRTTXT^BHSUTL Q
 ;now print all dental ADA
 Q
DENTEDL ;gather up last of each
 K BHSDEN S BHSDTU=0
 S BHSDE1=$O(^AUTTADA("B",1310,0))
 S BHSDE2=$O(^AUTTADA("B",1320,0))
 S BHSDE3=$O(^AUTTADA("B",1330,0))
 S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVDEN("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D
 .S BHSDFN="" F  S BHSDFN=$O(^AUPNVDEN("AA",BHSPAT,BHSIVD,BHSDFN)) Q:'BHSDFN  D
 ..S X=$P($G(^AUPNVDEN(BHSDFN,0)),U) I X=BHSDE1!(X=BHSDE2)!(X=BHSDE3) I '$D(BHSDEN("DEN",X)) S BHSDEN(BHSIVD,"DEN",BHSDFN)=$P(^AUPNVDEN(BHSDFN,0),U),BHSDEN("DEN",X)=""
 .Q
 Q
DENTED ;gather up all 1310, 1320, 1330
 K BHSDEN S BHSDTU=0
 S BHSDE1=$O(^AUTTADA("B",1310,0))
 S BHSDE2=$O(^AUTTADA("B",1320,0))
 S BHSDE3=$O(^AUTTADA("B",1330,0))
 S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVDEN("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D
 .S BHSDFN="" F  S BHSDFN=$O(^AUPNVDEN("AA",BHSPAT,BHSIVD,BHSDFN)) Q:'BHSDFN  D
 ..S X=$P($G(^AUPNVDEN(BHSDFN,0)),U) I X=BHSDE1!(X=BHSDE2)!(X=BHSDE3) S BHSDEN(BHSIVD,"DEN",BHSDFN)=$P(^AUPNVDEN(BHSDFN,0),U),BHSDTU=BHSDTU+1
 .Q
 Q
DENTAL ;
 K BHSDEN,BHSDSP
 K BHSDEN S BHSDTU=0
 S BHSDE1=$O(^AUTTADA("B",1310,0))
 S BHSDE2=$O(^AUTTADA("B",1320,0))
 S BHSDE3=$O(^AUTTADA("B",1330,0))
 S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVDEN("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D
 .S BHSDFN="" F  S BHSDFN=$O(^AUPNVDEN("AA",BHSPAT,BHSIVD,BHSDFN)) Q:'BHSDFN  D
 ..S X=$P($G(^AUPNVDEN(BHSDFN,0)),U) I X=BHSDE1!(X=BHSDE2)!(X=BHSDE3) I '$D(BHSDEN("DEN",X)) S BHSDSP($P(^AUTTADA(X,0),U,2))=BHSIVD_U_BHSDFN_U_"D",BHSDEN("DEN",X)=""
 .Q