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

AMHLESF1.m

Go to the documentation of this file.
AMHLESF1 ; IHS/CMI/LAB - ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**6**;JUN 02, 2010;Build 10
 ;
EN ;
 W:$D(IOF) @IOF
 W !!,$$CTR("*** Print Suicide Reporting Form ***"),!!
 S DIC="^AUPNPAT(",DIC(0)="AEMQ" D ^DIC
 I Y=-1 D EXIT Q
 I $G(AUPNDOD)]"" W !!?10,"***** PATIENT'S DATE OF DEATH IS ",$$FMTE^XLFDT(AUPNDOD),!! H 2
 S DFN=+Y
 W !
 D EP(DFN)
 D EXIT
 Q
EP(AMHSF) ;EP - when form is known
ZIS ;
 W ! S DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen",DIR("A")="Do you wish to",DIR("B")="P" K DA D ^DIR K DIR
 I $D(DIRUT) D EXIT Q
 S AMHOPT=Y
 I Y="B" D BROWSE,EXIT Q
 S XBRP="PRINT^AMHLESF1",XBRC="",XBRX="EXIT^AMHLESF1",XBNS="AMH*;DFN"
 D ^XBDBQUE
 D EXIT
 Q
BROWSE ;
 S XBRP="VIEWR^XBLM(""PRINT^AMHLESF1"")"
 S XBRC="",XBRX="EXIT^AMHLESF1",XBIOP=0 D ^XBDBQUE
 Q
EXIT ;
 K AMHOPT,AMHSF,AMHX,AMHOD,AMHSQIT,AMHQUIT
 ;D EN^XBVK("AMH")
 D ^XBFMK
 Q
EP2(AMHSF) ;
 S DFN=$P(^AMHPSUIC(AMHSF,0),U,4)
 K ^TMP("AMHS",$J,"DCS")
 S ^TMP("AMHS",$J,"DCS",0)=0
 D SETARRAY
 Q
SETARRAY ;set up array containing suicide form
 S X="Suicide Reporting Form                       Date Printed:  "_$$FMTE^XLFDT(DT) D S(X)
 S X="1. Case #: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.01),$E(X,40)="Local Case #: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.02) D S(X,1)
 S X="2. PROVIDER INITIALS: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.031),$E(X,40)="3. PROVIDER DISCIPLINE: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.032) D S(X,1)
 S X="4. SEX: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.041),$E(X,25)="5. DOB: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.042),$E(X,58)="6. AGE: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.043) D S(X)
 S X="7. EMPLOYMENT STATUS: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.05) D S(X)
 S X="8. DATE OF ACT: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.06) D S(X)
 S X="9. TRIBE: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.044) D S(X)
 S X="10. COMMUNITY OF RESIDENCE: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.045) D S(X)
 S X="11. COMMUNITY WHERE ACT OCCURRED: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.07) D S(X)
 S X="12. RELATIONSHIP STATUS: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.08) D S(X,1)
 ;I $P(^AMHPSUIC(AMHSF,0),U,9)]"" S X="    RELATIONSHIP IF OTHER: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.09) D S(X)
 S X="13. EDUCATION: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.11) D S(X,1)
 I $P(^AMHPSUIC(AMHSF,0),U,12)]"" S X="    IF LESS THAN 12 YEARS, HIGHEST GRADE COMPLETED: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.12) D S(X)
 S X="14. SUICIDAL BEHAVIOR: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.131) D S(X,1)
MET ;
 K AMHOD,AMHO S Y="",Z=0 F  S Z=$O(^AMHPSUIC(AMHSF,11,Z)) Q:Z'=+Z  S Y=Y_$$EXTSET^XBFUNC(9002011.6511,.01,$P(^AMHPSUIC(AMHSF,11,Z,0),U))_"  " D
 .I $P(^AMHPSUIC(AMHSF,11,Z,0),U,2)]"" S AMHO(Z)=$P(^AMHPSUIC(AMHSF,11,Z,0),U,2)
 .S A=0 F  S A=$O(^AMHPSUIC(AMHSF,11,Z,11,A)) Q:A'=+A  D
 ..S AMHOD(Z,A)=$P(^AMHTSDRG($P(^AMHPSUIC(AMHSF,11,Z,11,A,0),U),0),U) S %=$P(^AMHPSUIC(AMHSF,11,Z,11,A,0),U,2) I %]"" S AMHOD(Z,A)=AMHOD(Z,A)_" - "_%
 ..Q
 S X="15. METHOD: "_Y D
 .K ^UTILITY($J,"W") S DIWL=0,DIWR=65 D ^DIWP
 .D S($G(^UTILITY($J,"W",0,1,0)))
 .S AMHX=1 F  S AMHX=$O(^UTILITY($J,"W",0,AMHX)) Q:AMHX'=+AMHX  D S("    "_$G(^UTILITY($J,"W",0,AMHX,0)))
 .K ^UTILITY($J,"W")
 I $D(AMHO) S X="    OTHER METHOD: " D
 .S A=0 F  S A=$O(AMHO(A)) Q:A'=+A  S X=X_AMHO(A)_" "
 .D S(X)
 I $D(AMHOD) D
 .S X="    DRUGS W/OVERDOSE: " D S(X)
 .S Y=0 F  S Y=$O(AMHOD(Y)) Q:Y'=+Y  D
 ..S A=0 F  S A=$O(AMHOD(Y,A)) Q:A'=+A  S X="     "_AMHOD(Y,A) D
 ...K ^UTILITY($J,"W") S DIWL=0,DIWR=72 D ^DIWP
 ...D S($G(^UTILITY($J,"W",0,1,0)))
 ...S AMHX=1 F  S AMHX=$O(^UTILITY($J,"W",0,AMHX)) Q:AMHX'=+AMHX  D S("     "_$G(^UTILITY($J,"W",0,AMHX,0)))
 ...K ^UTILITY($J,"W")
 S X="16. PREVIOUS ATTEMPTS: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.14) D S(X,1)
DRUG ;
 S X="17. SUBSTANCE USE INVOLVED: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.26) D S(X,1)
 I $P(^AMHPSUIC(AMHSF,0),U,26)=2 D
 .S X="    ALCOHOL OR DRUGS INVOLVED: "
 .S Y=0 F  S Y=$O(^AMHPSUIC(AMHSF,15,Y)) Q:Y'=+Y  D
 ..S A=$P(^AMHPSUIC(AMHSF,15,Y,0),U) I A S X="     "_$P($G(^AMHTSSU(A,0)),U) D S(X)
 ..S X=$P(^AMHPSUIC(AMHSF,15,Y,0),U,2) I X]"" S X="     OTHER DRUG: "_X D
 ...K ^UTILITY($J,"W") S DIWL=0,DIWR=72 D ^DIWP
 ...D S($G(^UTILITY($J,"W",0,1,0)))
 ...S AMHX=1 F  S AMHX=$O(^UTILITY($J,"W",0,AMHX)) Q:AMHX'=+AMHX  D S("     "_$G(^UTILITY($J,"W",0,AMHX,0)))
 ...K ^UTILITY($J,"W")
 S X="18. LOCATION OF ACT: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.15) D S(X,1)
 I $P($G(^AMHPSUIC(AMHSF,14)),U)]"" S X="18.1 LOCATION OF ACT, IF OTHER: "_$$VAL^XBDIQ1(9002011.65,AMHSF,1401) D
 .K ^UTILITY($J,"W") S DIWL=0,DIWR=70 D ^DIWP
 .D S($G(^UTILITY($J,"W",0,1,0)))
 .S AMHX=1 F  S AMHX=$O(^UTILITY($J,"W",0,AMHX)) Q:AMHX'=+AMHX  D S("     "_$G(^UTILITY($J,"W",0,AMHX,0)))
 .K ^UTILITY($J,"W")
 I $$VERSION^XPDUTL("AMH")<4 D  I 1
 .S X="19. LETHALITY: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.24) D S(X,1)
 .S X="20. CONTRIBUTING FACTORS: " D S(X,1)
 .S AMHZ=0 F  S AMHZ=$O(^AMHPSUIC(AMHSF,13,AMHZ)) Q:AMHZ'=+AMHZ  S X="      "_$P(^AMHTSCF($P(^AMHPSUIC(AMHSF,13,AMHZ,0),U),0),U) S:$P(^AMHPSUIC(AMHSF,13,Z,0),U,2)]"" X=X_" - "_$P(^AMHPSUIC(AMHSF,13,AMHZ,0),U,2) D S(X)
 .S X="21. DISPOSITION: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.25) D S(X,1)
 .I $P($G(^AMHPSUIC(AMHSF,14)),U,2)]"" S X="21.1 DISPOSITION, IF OTHER: "_$$VAL^XBDIQ1(9002011.65,AMHSF,1402) D S(X)
 .;S X="20b. INTERVENTION (COMPLETED): "_$$VAL^XBDIQ1(9002011.65,AMHSF,.17) D S(X,1)
 .;S X="  Describe in our own words what you believe contributed to this " D S(X,1)
 E  D
 .S X="19. CONTRIBUTING FACTORS: " D S(X,1)
 .S AMHZ=0 F  S AMHZ=$O(^AMHPSUIC(AMHSF,13,AMHZ)) Q:AMHZ'=+AMHZ  S X="      "_$P(^AMHTSCF($P(^AMHPSUIC(AMHSF,13,AMHZ,0),U),0),U) S:$P(^AMHPSUIC(AMHSF,13,AMHZ,0),U,2)]"" X=X_" - "_$P(^AMHPSUIC(AMHSF,13,AMHZ,0),U,2) D
 ..K ^UTILITY($J,"W") S DIWL=0,DIWR=70 D ^DIWP
 ..D S($G(^UTILITY($J,"W",0,1,0)))
 ..S AMHX=1 F  S AMHX=$O(^UTILITY($J,"W",0,AMHX)) Q:AMHX'=+AMHX  D S("     "_$G(^UTILITY($J,"W",0,AMHX,0)))
 ..K ^UTILITY($J,"W")
 .S X="20. DISPOSITION: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.25) D S(X,1)
 .I $P($G(^AMHPSUIC(AMHSF,14)),U,2)]"" S X="20.1 DISPOSITION, IF OTHER: "_$$VAL^XBDIQ1(9002011.65,AMHSF,1402) D
 ..K ^UTILITY($J,"W") S DIWL=0,DIWR=70 D ^DIWP
 ..D S($G(^UTILITY($J,"W",0,1,0)))
 ..S AMHX=1 F  S AMHX=$O(^UTILITY($J,"W",0,AMHX)) Q:AMHX'=+AMHX  D S("     "_$G(^UTILITY($J,"W",0,AMHX,0)))
 ..K ^UTILITY($J,"W")
 S X="  Other Relevant Information: (OPTIONAL)" D S(X,1)
 S X="  " D S(X,1)
WP ;
 K ^UTILITY($J,"W")
 S AMHX=0
 S DIWL=5,DIWR=75 F  S AMHX=$O(^AMHPSUIC(AMHSF,41,AMHX)) Q:AMHX'=+AMHX  D
 .S X=$TR(^AMHPSUIC(AMHSF,41,AMHX,0),$C(10)) D ^DIWP
 .Q
WPS ;
 S Z=0 F  S Z=$O(^UTILITY($J,"W",DIWL,Z)) Q:Z'=+Z  S X="",$E(X,5)=^UTILITY($J,"W",DIWL,Z,0) D S(X)
 K DIWL,DIWR,DIWF,Z
 K ^UTILITY($J,"W"),AMHX
 S X="DIVISION: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.28) D S(X,1)
 S X="DATE LAST MODIFIED: "_$$VAL^XBDIQ1(9002011.65,AMHSF,.21) D S(X,1)
 S X="USER LAST UPDATED:  "_$$VAL^XBDIQ1(9002011.65,AMHSF,.22) D S(X)
 S X="EDIT HISTORY: " D S(X)
 S F=0 F  S F=$O(^AMHPSUIC(AMHSF,51,F)) Q:F'=+F  D
 .Q:'$D(^AMHPSUIC(AMHSF,51,F,0))
 .Q:$P(^AMHPSUIC(AMHSF,51,F,0),U)=""
 .Q:$P(^AMHPSUIC(AMHSF,51,F,0),U,2)=""
 .S X="  "_$$FMTE^XLFDT($P(^AMHPSUIC(AMHSF,51,F,0),U),"1P"),$E(X,30)=$P($G(^VA(200,$P(^AMHPSUIC(AMHSF,51,F,0),U,2),0)),U) D S(X)
 Q
S(Y,F,C,T) ;set up array
 I '$G(F) S F=0
 I '$G(T) S T=0
 ;blank lines
 F F=1:1:F S X="" D S1
 S X=Y
 I $G(C) S L=$L(Y),T=(80-L)/2 D  D S1 Q
 .F %=1:1:(T-1) S X=" "_X
 F %=1:1:T S X=" "_Y
 D S1
 Q
S1 ;
 S %=$P(^TMP("AMHS",$J,"DCS",0),U)+1,$P(^TMP("AMHS",$J,"DCS",0),U)=%
 S ^TMP("AMHS",$J,"DCS",%)=X
 Q
PRINT ;
 K ^TMP("AMHS",$J)
 D EP2(AMHSF) ;gather up data
W ;write out array
 W:$D(IOF) @IOF
 K AMHQUIT
 W !,"********** CONFIDENTIAL PATIENT INFORMATION ["_$P(^VA(200,DUZ,0),U,2)_"]  "_$$FMTE^XLFDT(DT)_" **********"
 S AMHX=0 F  S AMHX=$O(^TMP("AMHS",$J,"DCS",AMHX)) Q:AMHX'=+AMHX!($D(AMHQUIT))  D
 .I $Y>(IOSL-3) D HEADER Q:$D(AMHQUIT)
 .W !,^TMP("AMHS",$J,"DCS",AMHX)
 .Q
 I $D(AMHQUIT) S AMHSQIT=1
 D EOJ
 Q
 ;
EOJ ;
 K ^TMP("AMHS",$J)
 K AMHX,AMHQUIT,AMHY,AMHSBEG,AMHSTOB,AMHSUPI,AMHSED,AMHTOBN,AMHTOB,AMHOD,AMHO,X,Y,Z,AMHOPT,AMHSF,AMHSQIT,AMHOD
 K N,%,T,F,X,Y,B,C,E,F,H,L,N,P,T,W
 Q
 I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S AMHQUIT="" Q
HEAD1 ;
 W:$D(IOF) @IOF
 W !,"********** CONFIDENTIAL PATIENT INFORMATION ["_$P(^VA(200,DUZ,0),U,2)_"]  "_$$FMTE^XLFDT(DT)_" **********",!!
 Q
CTR(X,Y) ;EP - Center X in a field Y wide.
 Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
 ;----------
USR() ;EP - Return name of current user from ^VA(200.
 Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
 ;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
 Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
 ;----------