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

AMHRPSU2.m

Go to the documentation of this file.
AMHRPSU2 ; IHS/CMI/LAB - Suicide Form data element tally ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1,8**;JUN 02, 2010;Build 7
 ;
 ;
START ;
 D EN^XBVK("AMH")
 W:$D(IOF) @IOF
 W !!,"Aggregate Suicide Data Report - Selected Variables"
 W !!,"This report will tally the data items selected by the user for Suicide",!,"Forms in a date range.",!!
 ;D PAUSE
 ;GETDATES ;
 D DBHUSRP^AMHUTIL
BD ;
 S DIR(0)="D^::EP",DIR("A")="Enter Beginning Date of Suicide Act",DIR("?")="Enter the beginning date of suicide act for the search." D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 G:$D(DIRUT) EOJ
 S AMHBD=Y
ED ;
 S DIR(0)="DA^::EP",DIR("A")="Enter Ending Date of Suicide Act:  " D ^DIR K DIR,DA S:$D(DUOUT) DIRUT=1
 G:$D(DIRUT) EOJ
 I Y<AMHBD W !,"Ending date must be greater than or equal to beginning date!" G ED
 S AMHED=Y
 S X1=AMHBD,X2=-1 D C^%DTC S AMHSD=X
 I $D(AMHQUIT) D EOJ Q
 D ADD
 S AMHTCW=0,AMHPCNT=0
 S AMHPTVS="S",AMHXREF="SU"
 S AMHRPTC=7
SCREEN ;
 K ^AMHTRPT(AMHRPT,11) S AMHCNTL="S",AMHTYPE="SU",AMHPTTX="Suicide Form",AMHPTTS="Suicide Forms" D ^AMHRL4 K AMHRDTR,AMHCNTL I $D(AMHQUIT) D DEL^AMHRL G EOJ
DEMO ;
 D DEMOCHK^AMHUTIL1(.AMHDEMO)
 I AMHDEMO=-1 G BD
ZIS ;
 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) G EOJ
 I $G(Y)="B" D BROWSE,EOJ Q
 W !! S XBRP="PRINT^AMHRPSU2",XBRC="PROC^AMHRPSU2",XBNS="AMH",XBRX="EOJ^AMHRPSU2"
 D ^XBDBQUE
 D EOJ
 Q
BROWSE ;
 S XBRP="VIEWR^XBLM(""PRINT^AMHRPSU2"")"
 S XBNS="AMH",XBRC="PROC^AMHRPSU2",XBRX="EOJ^AMHRPSU2",XBIOP=0 D ^XBDBQUE
 Q
 ;
ADD ;EP
 S %H=$H D YX^%DTC S X=$P(^VA(200,DUZ,0),U)_"-"_Y,DIC(0)="L",DIC="^AMHTRPT(",DLAYGO=9002013.8,DIADD=1 D ^DIC K DIC,DA,DR,DIADD,DLAYGO I Y=-1 W !!,"UNABLE TO CREATE REPORT FILE ENTRY - NOTIFY SITE MANAGER!" S AMHQUIT=1 Q
 S AMHRPT=+Y
 K DIC,DIADD,DLAYGO,DR,DA,DD,X,Y,DINUM
 ;DELETE ALL 11 MULTIPLE HERE
 K ^AMHTRPT(AMHRPT,11)
 Q
PAUSE ; 
 S DIR(0)="E",DIR("A")="Press return to continue or '^' to quit" D ^DIR K DIR,DA
 S:$D(DIRUT) AMHQUIT=1
 W:$D(IOF) @IOF
 Q
EOJ ;
 D DEL^AMHRL
 D EN^XBVK("AMH")
 K L,M,S,T,X,X1,X2,Y,Z,B
 D KILL^AUPNPAT
 D ^XBFMK
 Q
PROC ;EP
 S AMHJ=$J,AMHH=$H
 K ^XTMP("AMHRPSU2",AMHJ,AMHH)
 D XTMP("AMHRPSU2","AMH - SUICIDE")
V ; Run by visit date
 K AMHTOT,AMHIA,AMHCS S AMHTOT=0,AMHIA=0,AMHCS=0
 ;S AMHR=0 F  S AMHR=$O(^AMHPSUIC(AMHR)) Q:AMHR'=+AMHR  D V1
  F  S AMHSD=$O(^AMHPSUIC("AD",AMHSD)) Q:AMHSD=""!((AMHSD\1)>AMHED)  D V1
 Q
 ;
V1 ;
 S AMHR="" F  S AMHR=$O(^AMHPSUIC("AD",AMHSD,AMHR)) Q:AMHR'=+AMHR  D V2
 Q
 ;
V2 ;
 S AMHR0=^AMHPSUIC(AMHR,0)
 S DFN=$P(AMHR0,U,4)
 ;I DFN,'$$ALLOWP^AMHUTIL(DUZ,DFN) Q
 Q:$$DEMO^AMHUTIL1(DFN,$G(AMHDEMO))
 D SCREENS
 Q:$D(AMHSKIP)
 S AMHTOT=AMHTOT+1
 S AMHSUC=$P(^AMHPSUIC(AMHR,0),U,7) I $D(AMHCOMM),'$D(AMHCOMM(AMHSUC)) Q
 S A=$$VAL^XBDIQ1(9002011.65,AMHR,.043)
 ;tally each date element
 S AMHC=0 F AMHX=.131,.032,.03,.041,.05,.044,.045,.08,.11 D
 .S AMHC=AMHC+1
 .S X=$$VAL^XBDIQ1(9002011.65,AMHR,AMHX),Y=$$VALI^XBDIQ1(9002011.65,AMHR,AMHX) I Y="" S Y=X
 .S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 ;method 10
 S AMHC=10 S Z=0 F  S Z=$O(^AMHPSUIC(AMHR,11,Z)) Q:Z'=+Z  D
 .S Y=$P(^AMHPSUIC(AMHR,11,Z,0),U),X=$$EXTSET^XBFUNC(9002011.6511,.01,Y)
 .S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 .;METHOD IF OTHER
 .I $P(^AMHPSUIC(AMHR,11,Z,0),U,2)]"" S (X,Y)=$P(^AMHPSUIC(AMHR,11,Z,0),U,2),^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",11,Y,X)):^(X)+1,1:1)
 S AMHC=12,X=$$VAL^XBDIQ1(9002011.65,AMHR,.14),Y=$$VALI^XBDIQ1(9002011.65,AMHR,.14)
 S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 ;sub use 11
 S AMHC=13 S Y=$P(^AMHPSUIC(AMHR,0),U,26),X=$$EXTSET^XBFUNC(9002011.65,.26,Y)
 S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 S AMHC=14,X=$$VAL^XBDIQ1(9002011.65,AMHR,.15),Y=$$VALI^XBDIQ1(9002011.65,AMHR,.15)
 S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 I $P($G(^AMHPSUIC(AMHR,14)),U)]"" D
 .S AMHC=15,X=$$VAL^XBDIQ1(9002011.65,AMHR,1401),Y=$$VALI^XBDIQ1(9002011.65,AMHR,1401)  ;OTHER LOC OF ACT VALUES
 .S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 ;cont fact 15
 S AMHC=19 S Z=0 F  S Z=$O(^AMHPSUIC(AMHR,13,Z)) Q:Z'=+Z  D
 .S Y=$P(^AMHPSUIC(AMHR,13,Z,0),U),Y=$P(^AMHTSCF(Y,0),U,2),X=$P(^AMHTSCF(Y,0),U,1)
 .S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 .;cf IF OTHER
 .I $P(^AMHPSUIC(AMHR,13,Z,0),U,2)]"" S (X,Y)=$P(^AMHPSUIC(AMHR,13,Z,0),U,2),^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",20,Y,X)):^(X)+1,1:1)
 S AMHC=17 S X=$$VAL^XBDIQ1(9002011.65,AMHR,.25),Y=$$VALI^XBDIQ1(9002011.65,AMHR,.25) D
 .S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 I $P($G(^AMHPSUIC(AMHR,14)),U,2)]"" D
 .S AMHC=18,X=$$VAL^XBDIQ1(9002011.65,AMHR,1402),Y=$$VALI^XBDIQ1(9002011.65,AMHR,1402)  ;OTHER LOC OF ACT VALUES
 .S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 I AMHBD<$$DV4^AMHUTIL S AMHC=16 S X=$$VAL^XBDIQ1(9002011.65,AMHR,.24),Y=$$VALI^XBDIQ1(9002011.65,AMHR,.24) D
 .S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 .Q
 S AMHC=21 S Z=0 F  S Z=$O(^AMHPSUIC(AMHR,15,Z)) Q:Z'=+Z  D
 .S Y=$P(^AMHPSUIC(AMHR,15,Z,0),U),X=$P(^AMHTSSU(Y,0),U,1)
 .S:Y="" Y="ZZZZZ" S:X="" X="DATA NOT ENTERED" S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 .;cf IF OTHER
 .I $P(^AMHPSUIC(AMHR,15,Z,0),U,2)]"" S (X,Y)=$P(^AMHPSUIC(AMHR,15,Z,0),U,2),^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",22,Y,X)):^(X)+1,1:1)
 S P=$P(^AMHPSUIC(AMHR,0),U,4)
 S AMHC=23,X=$$RACE^AGUTL(P)
 S (X,Y)=$P(X,U,2)
 I X="" S X="UNKNOWN",Y="ZZZZZ"
 S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 S AMHC=24,(X,Y)=$$ETHN^AMHRPSU1($P(^AMHPSUIC(AMHR,0),U,4),"E")
 I X="" S X="UNKNOWN",Y="ZZZZZ"
 S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 S AMHC=25,(X,Y)=$$VAL^XBDIQ1(2,P,1901)
 I X="" S X="UNKNOWN",Y="ZZZZZ"
 S ^(X)=$S($D(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHC,Y,X)):^(X)+1,1:1)
 Q
SCREENS ;
 K AMHSKIP
 S AMHI=0 F  S AMHI=$O(^AMHTRPT(AMHRPT,11,AMHI)) Q:AMHI'=+AMHI!($D(AMHSKIP))  D
 .I '$P(^AMHSORT(AMHI,0),U,8) D SINGLE Q
 .D MULT
 .Q
 Q
SINGLE ;
 K AMHSPEC
 S X="",AMHX=0
 X:$D(^AMHSORT(AMHI,1)) ^(1)
 I X="" S AMHSKIP="" Q
 I '$D(AMHSPEC),'$D(^AMHTRPT(AMHRPT,11,AMHI,11,"B",X)) S AMHSKIP="" Q
 Q
MULT ;
 K AMHFOUN,AMHSKIP,X S AMHX=0,X=""
 X:$D(^AMHSORT(AMHI,1)) ^(1)
 I '$L($O(X)) S AMHSKIP="" Q
 S Y="" F  S Y=$O(X(Y)) Q:Y=""  I $D(^AMHTRPT(AMHRPT,11,AMHI,11,"B",Y)) S AMHFOUN="" Q
 S:'$D(AMHFOUN) AMHSKIP=""
 Q
PRINT ;EP called from xbdbque
 S AMHPG=0
 K AMHQUIT
 S AMHSUIC=1
 D COVPAGE^AMHRPTCP
 I 'AMHTOT D HEAD W !!,"No Suicide Forms to Report"  G DONE
 I $D(AMHQUIT) G DONE
 D HEAD Q:$D(AMHQUIT)
 W !,"Total # of Suicide Forms: ",AMHTOT,!?63,"REPORT TOTALS"
 S AMHV="" F  S AMHV=$O(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHV)) Q:AMHV=""!($D(AMHQUIT))  D
 .I $Y>(IOSL-6) D HEAD Q:$D(AMHQUIT)
 .S AMHL=$P($T(@AMHV),";;",2) W !?1,$$LBLK(AMHL,28)
 .S AMHY="" F  S AMHY=$O(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHV,AMHY)) Q:AMHY=""!($D(AMHQUIT))  D
 ..S AMHX="" S AMHX=$O(^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHV,AMHY,AMHX)) Q:AMHX=""!($D(AMHQUIT))  D
 ...S X=^XTMP("AMHRPSU2",AMHJ,AMHH,"TALLY","TOTAL",AMHV,AMHY,AMHX)
 ...W ?31,$E(AMHX,1,30),?63,$J(X,4) S T=AMHTOT W ?72,$J(((X/T)*100),3,0)_"%",!
 ..Q
 .Q
DONE ;
 I $E(IOST)="C",IO=IO(0) S DIR(0)="EO",DIR("A")="End of report.  PRESS RETURN" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 K ^XTMP("AMHRPSU2",AMHJ,AMHH)
 Q
 G:'AMHPG HEAD1
 K DIR 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 S AMHPG=AMHPG+1
 W !,$$LOC,?35,$$FMTE^XLFDT(DT),?70,"Page ",AMHPG,!
 S X="***** AGGREGATED SUICIDE DATA *****" W !,?((80-$L(X))/2),X,!
 S X="Act Occurred: "_$$FMTE^XLFDT(AMHBD)_" - "_$$FMTE^XLFDT(AMHED) W $$CTR(X),!
 W $TR($J("",80)," ","-"),!
 Q
LBLK(V,L) ;left blank fill
 NEW %,I
 S %=$L(V),Z=L-% F I=1:1:Z S V=" "_V
 Q V
RBLK(V,L) ;EP right blank fill
 NEW %,I
 S %=$L(V),Z=L-% F I=1:1:Z S V=V_" "
 Q V
CTR(X,Y) ;EP - Center X in a field Y wide.
 Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
 ;----------
EOP ;EP - End of page.
 Q:$E(IOST)'="C"
 Q:$D(ZTQUEUED)!'(IOT="TRM")!$D(IO("S"))
 NEW DIR
 K DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
 S DIR(0)="E" D ^DIR
 Q
 ;----------
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")
 ;----------
XTMP(N,D) ;EP - set xtmp 0 node
 Q:$G(N)=""
 S ^XTMP(N,0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^"_$G(D)
 Q
 ;
LABEL ;
1 ;;Suicidal Behavior:
2 ;;Event logged by Discipline:
3 ;;Event logged by Provider:
4 ;;Sex:
5 ;;Employed:
6 ;;Tribe of Enrollment:
7 ;;Community of Residence:
8 ;;Relationship:
9 ;;Education:
10 ;;Method:
11 ;;Method if Other:
12 ;;Previous Attempts:
13 ;;Substance Use Involved:
14 ;;Location of Act:
15 ;;Other location of Act:
16 ;;Lethality:
17 ;;Disposition:
18 ;;Disposition if OTHER:
19 ;;Contributing Factors:
20 ;;Contributing Factor if OTHER:
21 ;;Substance Drugs:
22 ;;Substance Drugs if OTHER:
23 ;;Race:
24 ;;Ethnicity:
25 ;;Veteran's Status