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

BHSBH.m

Go to the documentation of this file.
BHSBH ;IHS/CIA/MGH - Health Summary for Behavioral Health ;27-Aug-2014 14:15;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**2,4,9**;March 17, 2006;Build 16
 ;===================================================================
 ;Taken from AMHHS
 ; IHS/CMI/LAB - BH HEALTH SUMMARY COMPONENT ;
 ;;3.0;IHS BEHAVIORAL HEALTH;;JAN 27, 2003
 ;Conversion of behavioral health over to VA health summary
 ;=====================================================================
 ;
MH ;EP called from health summary
 NEW AMHPATH
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $P($G(^AMHPATR(BHSPAT,0)),U,9)]"" W ?23,"Patient Flag: ",?38,$P(^AMHPATR(BHSPAT,0),U,9),!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $P($G(^AMHPATR(BHSPAT,0)),U,11)]"" W ?21,"Flag Narrative: ",?38,$P(^AMHPATR(BHSPAT,0),U,11),!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $P($G(^AMHPATR(BHSPAT,0)),U,2)]"" W ?2,"Designated Mental Health Provider: ",?38,$P(^VA(200,$P(^AMHPATR(BHSPAT,0),U,2),0),U),!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $P($G(^AMHPATR(BHSPAT,0)),U,3)]"" W "Designated Social Services Provider: ",?38,$P(^VA(200,$P(^AMHPATR(BHSPAT,0),U,3),0),U),!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $P($G(^AMHPATR(BHSPAT,0)),U,4)]"" W ?10,"CD Designated Provider: ",?38,$P(^VA(200,$P(^AMHPATR(BHSPAT,0),U,4),0),U),!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $P($G(^AMHPATR(BHSPAT,0)),U,12)]"" W ?10,"Other Designated Provider: ",?38,$P(^VA(200,$P(^AMHPATR(BHSPAT,0),U,12),0),U),!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $P($G(^AMHPATR(BHSPAT,0)),U,13)]"" W ?10,"Other (2) Designated Provider: ",?38,$P(^VA(200,$P(^AMHPATR(BHSPAT,0),U,13),0),U),!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ;output personal history
 I $D(^AMHPPHX("AC",BHSPAT)) D
 .D CKP^GMTSUP Q:$D(GMTSQIT)  W !,"** Personal History of:",!
 .S AMHSX=0 F  S AMHSX=$O(^AMHPPHX("AC",BHSPAT,AMHSX)) Q:AMHSX'=+AMHSX  D
 ..S X=$P(^AMHPPHX(AMHSX,0),U,3) D REGDT4^GMTSU S AMHSDAT=X
 ..W !?5,$P(^AMHTPHF($P(^AMHPPHX(AMHSX,0),U),0),U),?30,"(noted: ",AMHSDAT,")"
 ..Q
 .W ! K AMHSX
 .Q
CASE ;output last 3 cases
 K AMHL S D=0,C=0 F  S D=$O(^AMHPCASE("AA",BHSPAT,D)) Q:D'=+D!(C>2)  D
 .S AMHL=0 F  S AMHL=$O(^AMHPCASE("AA",BHSPAT,D,AMHL)) Q:AMHL'=+AMHL!(C>2)  D
 ..S C=C+1
 ..S AMHL(C)=AMHL
 ..Q
 .Q
CASEOUT ;display last 3 cases found
 I $D(AMHL(1)) D
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .S K="21;41;61"
 .W ?4,"Case Open Date:"
 .F I=1:1:3 Q:'$D(AMHL(I))  S J=$P(K,";",I) W ?J,$$FMTE^XLFDT($P(^AMHPCASE(AMHL(I),0),U),"2E")
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !?3,"Case Admit Date:"
 .F I=1:1:3 Q:'$D(AMHL(I))  I $P(^AMHPCASE(AMHL(I),0),U,4)]"" S J=$P(K,";",I) W ?J,$$FMTE^XLFDT($P(^AMHPCASE(AMHL(I),0),U,4),"2E")
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !?3,"Case Close Date:"
 .F I=1:1:3 Q:'$D(AMHL(I))  I $P(^AMHPCASE(AMHL(I),0),U,5)]"" S J=$P(K,";",I) W ?J,$$FMTE^XLFDT($P(^AMHPCASE(AMHL(I),0),U,5),"2E")
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !?5,"Program Affil:"
 .F I=1:1:3 Q:'$D(AMHL(I))  I $P(^AMHPCASE(AMHL(I),0),U,3)]"" S J=$P(K,";",I) W ?J,$$VAL^XBDIQ1(9002011.58,AMHL(I),.03)
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !?7,"Disposition:"
 .F I=1:1:3 Q:'$D(AMHL(I))  I $P(^AMHPCASE(AMHL(I),0),U,6)]"" S J=$P(K,";",I) W ?J,$$VAL^XBDIQ1(9002011.58,AMHL(I),.06)
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !?2,"Next Review Date:"
 .F I=1:1:3 Q:'$D(AMHL(I))  I $P(^AMHPCASE(AMHL(I),0),U,12)]"" S J=$P(K,";",I) W ?J,$$FMTE^XLFDT($P(^AMHPCASE(AMHL(I),0),U,12),"2E")
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !?10,"Provider:"
 .F I=1:1:3 Q:'$D(AMHL(I))  I $P(^AMHPCASE(AMHL(I),0),U,8)]"" S J=$P(K,";",I) W ?J,$$VAL^XBDIQ1(9002011.58,AMHL(I),.08)
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !?11,"Problem:"
 .F I=1:1:3 Q:'$D(AMHL(I))  I $P(^AMHPCASE(AMHL(I),0),U,9)]"" S J=$P(K,";",I) W ?J,$$VAL^XBDIQ1(9002011.58,AMHL(I),.09)
 K AMHL,C,D,L,K
 D PROB^BHSBH1
AXV ;trend and display last 7 AXIS V values
 K AMHAX5 S AMHCNT=0
 S AMHSIVD=0 F  S AMHSIVD=$O(^AMHREC("AE",BHSPAT,AMHSIVD)) Q:AMHSIVD=""!($D(GMTSQIT))!(AMHCNT>6)  D
 .S AMHSX=0 F  S AMHSX=$O(^AMHREC("AE",BHSPAT,AMHSIVD,AMHSX)) Q:AMHSX'=+AMHSX  D
 ..Q:$P($G(^AMHREC(AMHSX,0)),U,14)=""
 ..S AMHCNT=AMHCNT+1,AMHAX5(AMHCNT)=(9999999-AMHSIVD)_U_$P(^AMHREC(AMHSX,0),U,14)
 ..Q
 .Q
 I $D(AMHAX5) D  Q:$D(GMTSQIT)
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !!?4,"**********  LAST 6 AXIS V VALUES RECORDED.  (GAF SCORES)  **********",!!
 .S AMHJ=2 F AMHCNT=6:-1:1  I $D(AMHAX5(AMHCNT))  W ?AMHJ,$$DATE($P(AMHAX5(AMHCNT),U)) S AMHJ=AMHJ+12
 .W ! S AMHJ=6 F AMHCNT=6:-1:1 I $D(AMHAX5(AMHCNT)) W ?AMHJ,$P(AMHAX5(AMHCNT),U,2) S AMHJ=AMHJ+12
 .W !
OUTPT ; ********** MH PROBLEM CODES AND DESIGNATED PROVIDER
 ; <SETUP>
 D CKP^GMTSUP Q:$D(GMTSQIT)  S X="********************  BH ENCOUNTERS  ******************** ",AMHS="",$P(AMHS," ",IOM-1-$L(X)/2)="" W !,AMHS,X,AMHS,!!
 I '$D(^AMHREC("AE",BHSPAT)) D CKP^GMTSUP Q:$D(GMTSQIT)  W !,"No Behavioral Health Records on File.",! Q
 ; <DISPLAY>
 S AMHSPVD=0
 F AMHSIVD=0:0 S AMHSIVD=$O(^AMHREC("AE",BHSPAT,AMHSIVD)) Q:AMHSIVD=""!($P(AMHSIVD,".")>GMTSDLM)  D ONEDATE Q:$D(GMTSQIT)  S:(AMHSDAT'=AMHSPVD)&AMHSDTU GMTSNDM=GMTSNDM-AMHSDTU,AMHSPVD=AMHSDAT Q:GMTSNDM=0
PTED ;display all pt ed (last of each)
 I '$D(^AMHREDU("AC",BHSPAT)) G OUTPTX
 D CKP^GMTSUP Q:$D(GMTSQIT)  S X="********************  MH/SS PATIENT EDUCATION  ******************** ",AMHS="",$P(AMHS," ",IOM-1-$L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HSPVD)
 S AMHSVDF="" F AMHSQ=0:0 S AMHSVDF=$O(^AMHREC("AE",BHSPAT,AMHSIVD,AMHSVDF)) Q:AMHSVDF=""  S AMHSN=^AMHREC(AMHSVDF,0) D GETSITE,DSPVIS Q:$D(GMTSQIT)
 Q
 ;
GETSITE ;
 S AMHSFAC=$P(AMHSN,U,4) S AMHSFAC=$S(AMHSFAC:$E($P(^AUTTLOC(AMHSFAC,0),U,2),1,8),1:"<missing>")
 I AMHSFAC="" S AMHSFAC=$E($P(^DIC(4,$P(AMHSN,U,4),0),U),1,8)
 S AMHTOC=$P(AMHSN,U,7) I AMHTOC]"" S AMHTOC=$P(^AMHTSET(AMHTOC,0),U,4)
 Q
DSPVIS ;
 S AMHSDTU=1
 I $O(^AMHRPRO("AD",AMHSVDF,""))="" D NOPOV Q
 S AMHSPDN="" F AMHSQ=0:0 S AMHSPDN=$O(^AMHRPRO("AD",AMHSVDF,AMHSPDN)) Q:'AMHSPDN  S AMHSR=^AMHRPRO(AMHSPDN,0) D HASPOV
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ;I $P(AMHSN,U,13)]"" W ?25,"Axis IV (Stress): ",$P(^AMHTAXIV($P(AMHSN,U,13),0),U,2)," - ",$P(^AMHTAXIV($P(AMHSN,U,13),0),U) W:$P(AMHSN,U,14)="" !
 ;W:$P(AMHSN,U,14)]"" ?50,"Axis V (Function):  ",$P(AMHSN,U,14),!
 I $D(^AMHREC(AMHSVDF,61))!($P(^AMHREC(AMHSVDF,0),U,14)]"") D  Q:$D(GMTSQIT)
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W ?27,"AXIS IV:  " S Y=0 F  S Y=$O(^AMHREC(AMHSVDF,61,Y)) Q:Y'=+Y  S I=$P(^AMHREC(AMHSVDF,61,Y,0),U) W ?35,$P(^AMHTAXIV(I,0),U)_" - "_$P(^AMHTAXIV(I,0),U,2),!
 .I '$O(^AMHREC(AMHSVDF,61,0)) W !
 .W ?27,"AXIS V:  ",$P(^AMHREC(AMHSVDF,0),U,14),!
 .Q
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $P(AMHSN,U,17)]"" W ?27,"Inpatient Disp:  ",$$VAL^XBDIQ1(9002011,AMHSVDF,.17),!?27,"Referred To:  ",$P(AMHSN,U,18),!
 ;I $D(^AMHREC(AMHSVDF,12)) D CKP^GMTSUP Q:$D(GMTSQIT)  S BHSNRQ="COMMENT: "_^AMHREC(AMHSVDF,12),BHSICL=27,BHSTXT="" D PRTTXT^BHSUTL
 Q
 ;
NOPOV ;
 S BHSTXT="",(AMHSICD,BHSNRQ)="<BH problem codes not yet entered>"
 G COMMON
 ;
HASPOV ;
 N CODE,CODEIEN,CHK,FIRST,SEC,CHK,DESCT
 S CODE=$P(AMHSR,U)
 Q:CODE=""
 ;S CODEIEN="" S CODEIEN=$O(^AMHPROB("B",CODE,CODEIEN))
 S CODEIEN=CODE
 S BHSNRQ=$P($G(^AMHPROB(CODEIEN,0)),U)_" - "
 S AMHSICD=$E($P($G(^AMHPROB(CODEIEN,0)),U,2),1,45)
 S Y=$L(BHSNRQ) F X=Y:1:8 S BHSNRQ=BHSNRQ_" "
 S BHSNRQ=BHSNRQ_AMHSICD,BHSTXT="",BHSICL=27
 D COMMON
 S CHK=$P(^AUTNPOV($P(AMHSR,U,4),0),U)
 ;Patch  9 added changes for SNOMED POVs
 I CHK["|" D
 .S FIRST=$P(CHK,"|",1),SEC=$P(CHK,"|",2)
 .S DESCT=$$DESC^BSTSAPI(SEC_"^^1")
 .S CHK=$P(DESCT,U,2)
 .I FIRST'="" S CHK=CHK_" | "_FIRST
 S:$P(AMHSR,U,4) BHSNRQ=BHSNRQ_CHK S BHSTXT="",BHSICL=27 D PRTTXT^BHSUTL
 D CKP^GMTSUP Q:$D(GMTSQIT)
 Q
COMMON ;
 D CKP^GMTSUP Q:$D(GMTSQIT)  S:GMTSNPG AMHSNDT=1
 I AMHSNDT W AMHSDAT S AMHSPFN="",AMHSNDT=0
 W ?9,AMHSFAC,?18,$$PPINI^AMHUTIL(AMHSVDF),?22,AMHTOC S BHSICL=27 D PRTTXT^BHSUTL
 Q
DATE(D) ;
 I $G(D)="" Q ""
 Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_(1700+$E(D,1,3))