AMHSFR ; IHS/CMI/LAB - REVIEW SF BY DATE 28 Apr 2009 10:46 AM ;
;;4.0;IHS BEHAVIORAL HEALTH;**1,2**;JUN 18, 2010;Build 23
;
;
START ;
W:$D(IOF) @IOF
W $$CTR("Review/Update Suicide Forms by Date",80)
D DONE
;
D ;date range
K AMHED,AMHBD
K DIR W ! S DIR(0)="DO^::EXP",DIR("A")="Enter Beginning Suicide form date"
D ^DIR S:Y<1 AMHQUIT=1 Q:Y<1 S AMHBD=Y
K DIR S DIR(0)="DO^::EXP",DIR("A")="Enter Ending Suicide form date"
D ^DIR S:Y<1 AMHQUIT=1 Q:Y<1 S AMHED=Y
;
I AMHED<AMHBD D G D
. W !!,$C(7),"Sorry, Ending Date MUST not be earlier than Beginning Date."
DEMO ;
D DEMOCHK^AMHUTIL1(.AMHDEMO)
I AMHDEMO=-1 G D
D EN,FULL^VALM1,EXIT
Q
DONE ;
D EN^XBVK("AMH")
D ^XBFMK
D KILL^AUPNPAT
Q
EN ;
K AMHSFR
D GATHER
D EN^VALM("AMH SF BY DATE")
D CLEAR^VALM1
Q
GATHER ;
K AMHSFR
S AMHLINE=0
S AMHSD=$$FMADD^XLFDT(AMHED,1),AMHSD=9999999-AMHSD
F S AMHSD=$O(^AMHPSUIC("AB",AMHSD)) Q:AMHSD'=+AMHSD!(AMHSD>(9999999-AMHBD)) D
.S AMHX=0 F S AMHX=$O(^AMHPSUIC("AB",AMHSD,AMHX)) Q:AMHX'=+AMHX D
..S DFN=$P(^AMHPSUIC(AMHX,0),U,4),AMHDOB=$P(^DPT(DFN,0),U,3)
..Q:'$$ALLOW(DUZ,AMHX)
..Q:$$DEMO^AMHUTIL1(DFN,$G(AMHDEMO))
..S AMHD=$P(^AMHPSUIC(AMHX,0),U,6)
..S AMHLINE=AMHLINE+1,X=AMHLINE_")",$E(X,$S($L(AMHLINE)<3:5,1:6))=$S($$INCOMPSF^AMHLESF(AMHX):"I",1:"")
..S $E(X,8)=$E(AMHD,4,5)_"/"_$E(AMHD,6,7)_"/"_$E(AMHD,2,3),$E(X,17)=$E($P(^DPT(DFN,0),U),1,19),$E(X,37)=$$HRN^AUPNPAT(DFN,DUZ(2)),$E(X,44)=$E(AMHDOB,4,5)_"/"_$E(AMHDOB,6,7)_"/"_$E(AMHDOB,2,3)
..S $E(X,53)=$E($$VAL^XBDIQ1(9002011.65,AMHX,.131),1,20),$E(X,74)=$$VAL^XBDIQ1(9002011.65,AMHX,.031)
..S $E(X,78)=$$VAL^XBDIQ1(9002011.65,AMHX,.02),$E(X,96)=$$VAL^XBDIQ1(9002011.65,AMHX,.01)
..S AMHSFR(AMHLINE,0)=X,AMHSFR("IDX",AMHLINE,AMHLINE)=AMHX
Q
CTR(X,Y) ;EP - Center X in a field Y wide.
Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
;----------
HDR ; -- header code
S VALMHDR(1)="Suicide Form Review: "_$$FMTE^XLFDT(AMHBD)_" - "_$$FMTE^XLFDT(AMHED)
S VALMHDR(2)="I = Incomplete Form"
S X="",$E(X,8)="Date",$E(X,53)="" S VALMHDR(3)=X
S X="",X="No.",$E(X,8)="of Act",$E(X,17)="Patient",$E(X,37)="HRN",$E(X,44)="DOB",$E(X,53)="Suicidal Behavior",$E(X,74)="PRV",$E(X,78)="Local Case #",$E(X,96)="Case #",VALMHDR(4)=X
Q
;
INIT ; -- init variables and list array
D GATHER
S VALMCNT=AMHLINE
Q
;
HELP ; -- help code
S X="?" D DISP^XQORM1 W !!
Q
;
EXPND ; -- expand code
Q
EDIT ;EP - called from protocol
D EN^VALM2(XQORNOD(0),"OS")
I '$D(VALMY) W !,"No records selected." D EXIT Q
S R=$O(VALMY(0)) I 'R K R,VALMY,XQORNOD W !,"No record selected." D EXIT Q
S AMHSF=0 S AMHSF=AMHSFR("IDX",R,R)
I '$D(^AMHPSUIC(AMHSF,0)) W !,"Not a valid SUICIDE RECORD." K AMHRDEL,R,AMHSF,R1 D PAUSE D EXIT Q
D FULL^VALM1
DGSECE ;
I '$P(^AMHPSUIC(AMHSF,0),U,4) G EDITR9
S AMHPAT=$P(^AMHPSUIC(AMHSF,0),U,4)
D PTSEC^AMHUTIL2(.AMHRESU,AMHPAT,0)
I '$G(AMHRESU(1)) G EDITR9
D DISPDG^AMHLE
W ! K DIR S DIR(0)="Y",DIR("A")="Do you want to continue to edit this suicide form",DIR("B")="N" KILL DA D ^DIR KILL DIR
I 'Y D EXIT Q
K AMHRESU
D NOTICE^DGSEC4(.AMHRESU,AMHPAT,,3)
EDITR9 ;
S DA=AMHSF,DIE="^AMHPSUIC(",DR=".21////"_DT_";.22////"_DUZ_";.27////"_$$NOW^XLFDT D ^DIE
S (AMHPAT,DFN)=$P(^AMHPSUIC(AMHSF,0),U,4)
D ADDDS
D EXIT
Q
DISP ;EP - called from protocol
D EN^VALM2(XQORNOD(0),"OS")
I '$D(VALMY) W !,"No records selected." D EXIT Q
S R=$O(VALMY(0)) I 'R K R,VALMY,XQORNOD W !,"No record selected." D EXIT Q
S AMHSF=0 S AMHSF=AMHSFR("IDX",R,R)
I '$D(^AMHPSUIC(AMHSF,0)) W !,"Not a valid SUICIDE RECORD." K AMHRDEL,R,AMHSF,R1 D PAUSE D EXIT Q
D FULL^VALM1
DGSECD ;
I '$P(^AMHPSUIC(AMHSF,0),U,4) G EDITD9
S AMHPAT=$P(^AMHPSUIC(AMHSF,0),U,4)
D PTSEC^AMHUTIL2(.AMHRESU,AMHPAT,0)
I '$G(AMHRESU(1)) G EDITD9
D DISPDG^AMHLE
W ! K DIR S DIR(0)="Y",DIR("A")="Do you want to continue to display this suicide form",DIR("B")="N" KILL DA D ^DIR KILL DIR
I 'Y D EXIT Q
K AMHRESU
D NOTICE^DGSEC4(.AMHRESU,AMHPAT,,3)
EDITD9 ;
;NEW DFN,AMHPAT
D EP^AMHLESF1(AMHSF)
D EXIT
Q
DEL ;EP - called from protocol
;add code to not allow delete unless they have the key
I '$D(^XUSEC("AMHZ DELETE RECORD",DUZ)) W !!,"You do not have the security access to delete a Suicide Form.",!,"Please see your supervisor or program manager.",! D PAUSE,EXIT Q
D EN^VALM2(XQORNOD(0),"OS")
I '$D(VALMY) W !,"No records selected." D EXIT Q
S R=$O(VALMY(0)) I 'R K R,VALMY,XQORNOD W !,"No record selected." D EXIT Q
S AMHSF=0 S AMHSF=AMHSFR("IDX",R,R)
I '$D(^AMHPSUIC(AMHSF,0)) W !,"Not a valid SUICIDE RECORD." K AMHRDEL,R,AMHSF,R1 D PAUSE D EXIT Q
D FULL^VALM1
DGSECX ;
I '$P(^AMHPSUIC(AMHSF,0),U,4) G EDITX9
S AMHPAT=$P(^AMHPSUIC(AMHSF,0),U,4)
D PTSEC^AMHUTIL2(.AMHRESU,AMHPAT,0)
I '$G(AMHRESU(1)) G EDITX9
D DISPDG^AMHLE
W ! K DIR S DIR(0)="Y",DIR("A")="Do you want to continue to delete this suicide form",DIR("B")="N" KILL DA D ^DIR KILL DIR
I 'Y D EXIT Q
K AMHRESU
D NOTICE^DGSEC4(.AMHRESU,AMHPAT,,3)
EDITX9 ;
S DIR(0)="Y",DIR("A")="Are you sure you want to delete this suicide form",DIR("B")="N" KILL DA D ^DIR KILL DIR
I $D(DIRUT) D EXIT Q
I 'Y D EXIT Q
S DA=AMHSF,DIK="^AMHPSUIC(" D ^DIK
D EXIT
Q
BV ;
;S DFN=AMHPAT
NEW AMHPAT
D EP^AMHVD(DFN)
D EXIT
Q
HS ;EP called from protocol to generate hs
D FULL^VALM1
S Y=DFN D ^AUPNPAT
D GETTYPE
I '$G(APCHSTYP) D EN^XBVK("APCH") Q
S APCHSPAT=DFN
S %="PCC Health Summary for "_$P(^DPT(APCHSPAT,0),U)
NEW DFN,AMHPAT D VIEWR^XBLM("EN^APCHS",%)
D EN^XBVK("APCH") K AMCHDAYS,AMCHDOB,%
D EXIT
Q
GETTYPE ;
I $G(^AMHSITE(DUZ(2),0))="" D DEFAULT Q
S APCHSTYP=$P(^AMHSITE(DUZ(2),0),U,4) I APCHSTYP="" D DEFAULT Q
I '$D(^APCHSCTL(APCHSTYP)) W !,"Error in Site Parameter File!",$C(7),$C(7) S APCHSTYP="" Q
Q
DEFAULT ;
S APCHSTYP=""
S X="BEHAVIORAL HEALTH",DIC(0)="",DIC="^APCHSCTL(" D ^DIC K DIC,DA
I Y=-1 W !!,"PCC MENTAL HEALTH HEALTH SUMMARY TYPE IS MISSING!! NOTIFY YOUR SUPERVISOR OR SITE MANAGER.",!! Q
S APCHSTYP=+Y
Q
ADD ;EP
D FULL^VALM1
S AMHPAT=""
D GETPAT^AMHLEA
I 'AMHPAT W !!,"No patient entered..." D EXIT Q
S Y=AMHPAT D ^AUPNPAT
S DFN=AMHPAT
D ADDSF(AMHPAT)
D CLEAR^VALM1
D EXIT
Q
ADDSF(AMHPAT) ;EP called from protocol to add a new form
D FULL^VALM1
W:$D(IOF) @IOF
PROV ;
D ^XBFMK
S AMHDP=""
W !! S DIC("A")="Provider Completing the Form: ",DIC="^VA(200,",DIC(0)="AEMQ",DIC("B")=$P(^VA(200,DUZ,0),U) D ^DIC K DIC,DA,DR,DLAYGO,DIADD
I Y<0 W !,"No Provider Selected." D EXIT Q
S AMHPROV=+Y
GETDATE ;EP - GET DATE OF ENCOUNTER
W !!
S AMHDATE="",DIR(0)="DO^:"_DT_":EPTX",DIR("A")="Enter the DATE of the SUICIDE ACT" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) D EXIT G PROV
S AMHDATE=Y
S X=0,G=0,Y=0 F S X=$O(^AMHPSUIC("AC",AMHPAT,X)) Q:X'=+X!(G) I $P(^AMHPSUIC(X,0),U,6)=AMHDATE D
.S Y=1 W !!,"This patient already has a suicide form on file for this Date of Act."
.W !,"The form was filled out by: ",$$VAL^XBDIQ1(9002011.65,X,.03),!
.S DIR(0)="S^A:Continue to ADD a new form;Q:Quit - do not add a new form",DIR("A")="Do you wish to",DIR("B")="Q" KILL DA D ^DIR KILL DIR
.I $D(DIRUT) S Y="Q" Q
.I Y="Q" Q
.S G=1
I Y="Q" D PAUSE,EXIT Q
K DD,D0,DO,DINUM,DIC,DA,DR S DIC(0)="EL",DIC="^AMHPSUIC(",DLAYGO=9002011.65,DIADD=1,X=$$UPI(AMHPAT,AMHDATE)
S DIC("DR")=".06////"_AMHDATE_";.04////"_AMHPAT_";.03////"_AMHPROV_";.18////"_DT_";.19////"_DUZ_";.21////"_DT_";.22////"_DUZ_";.27////"_$$NOW^XLFDT
S DIC("DR")=DIC("DR")_";9901///1"
D FILE^DICN K DIC,DR,DIE,DIADD,DLAYGO,X,D0
I Y=-1 W !!,$C(7),$C(7),"Error creating Suicide form!! Deleting form.",! D PAUSE,EXIT Q
S AMHSF=+Y
D ADDDS
D EXIT
Q
ADDDS ;screenman call
S AMHIISFE=1
S DA=AMHSF,DDSFILE=9002011.65,DR="[AMH SUICIDE FORM UPDATE]" D ^DDS
I $D(DIMSG) W !!,"ERROR IN SCREENMAN FORM!! ***NOTIFY PROGRAMMER***" S AMHQUIT=1 K DIMSG D PAUSE,EXIT Q
D CHECK
Q
;
CHECK ; check record for completeness
S AMHC=0
F AMHF=.03:.01:.08 I $$VAL^XBDIQ1(9002011.65,AMHSF,AMHF)="" W !,$P(^DD(9002011.65,AMHF,0),U)," is a required data element." S AMHC=1
F AMHF=.11,.13:.01:.15,.25 I $$VAL^XBDIQ1(9002011.65,AMHSF,AMHF)="" W !,$P(^DD(9002011.65,AMHF,0),U)," is a required data element." S AMHC=1
I $$VAL^XBDIQ1(9002011.65,AMHSF,.25)="OTHER",$$VAL^XBDIQ1(9002011.65,AMHSF,1402)="" S AMHC=1 W !,"Location of Act is OTHER, OTHER description is required."
I $$VAL^XBDIQ1(9002011.65,AMHSF,.25)'="OTHER",$$VAL^XBDIQ1(9002011.65,AMHSF,1402)]"" S DA=AMHSF,DIE="^AMHPSUIC(",DR="1402///@" D ^DIE K DA,DIE,DR
;I $P(^AMHPSUIC(AMHSF,0),U,16)="",$P(^AMHPSUIC(AMHSF,0),U,17)="" W !,"INTERVENTION is a required data element." S AMHC=1
S (Z,X,G)=0 F S X=$O(^AMHPSUIC(AMHSF,11,X)) Q:X'=+X D
.I $P($G(^AMHPSUIC(AMHSF,11,X,0)),U)]"" S G=1
.I $P($G(^AMHPSUIC(AMHSF,11,X,0)),U)=8,$P(^AMHPSUIC(AMHSF,11,X,0),U,2)="" W !,"One of the Methods is OTHER. OTHER description is Required." S AMHC=1
.I $P(^AMHPSUIC(AMHSF,11,X,0),U,1)'=7 K ^AMHPSUIC(AMHSF,11,X,11)
.I $P(^AMHPSUIC(AMHSF,11,X,0),U,1)=7 D
..S Y=0 F S Y=$O(^AMHPSUIC(AMHSF,11,X,11,Y)) Q:Y'=+Y D
...S D=$P(^AMHPSUIC(AMHSF,11,X,11,Y,0),U,1)
...I $P(^AMHTSDRG(D,0),U,2),$P(^AMHPSUIC(AMHSF,11,X,11,Y,0),U,2)="" S AMHC=1 W !,"Method is Overdose, Drug type is Other, Other description is required."
.Q
I 'G W !!,"You must enter a METHOD." S AMHC=1
S G=$P(^AMHPSUIC(AMHSF,0),U,26)
I G="" W !!,"You must enter a value for SUBSTANCE Use. None or Unknown are valid values." S AMHC=1
I G=2 D
.S X=0 F S X=$O(^AMHPSUIC(AMHSF,15,X)) Q:X'=+X D
..S D=$P(^AMHPSUIC(AMHSF,15,X,0),U,1)
..I $P(^AMHTSSU(D,0),U,2),$P(^AMHPSUIC(AMHSF,15,X,0),U,2)="" S AMHC=1 W !,"Substance Involved is Alcohol/Drugs, Drug is Other, Other Description is Required."
S (Z,G,X)=0 F S X=$O(^AMHPSUIC(AMHSF,13,X)) Q:X'=+X D
.I $P($G(^AMHPSUIC(AMHSF,13,X,0)),U)]"" S G=1
.S D=$P(^AMHPSUIC(AMHSF,13,X,0),U,1)
.I $P(^AMHTSCF(D,0),U,1)="OTHER",$P(^AMHPSUIC(AMHSF,13,X,0),U,2)="" S AMHC=1 W !,"Contributing Factor is OTHER, OTHER description is required."
.Q
;NOW CHECK FOR OTHER
I 'G W !!,"You must enter a CONTRIBUTING FACTOR. Unknown is a valid value." S AMHC=1
I $P(^AMHPSUIC(AMHSF,0),U,15)=7,$$VAL^XBDIQ1(9002011.65,AMHSF,1401)="" S AMHC=1 W !,"Location of Act is OTHER, OTHER description is required."
I $P(^AMHPSUIC(AMHSF,0),U,15)'=7,$$VAL^XBDIQ1(9002011.65,AMHSF,1401)]"" S DIE="^AMHPSUIC(",DA=AMHSF,DR="1401///@" D ^DIE K DA,DIE,DR
I AMHC W !!,"One or more required data elements are missing.",!! D G:Y="E" ADDDS G:Y="L" EXIT W !,"Deleting form..." S DA=AMHSF,DIK="^AMHPSUIC(" D ^DIK D PAUSE
.S DIR(0)="S^E:Edit and Complete the Form;D:Delete the Incomplete Form;L:Leave the Incomplete Form as is and Finish it Later",DIR("A")="What do you want to do",DIR("B")="E" KILL DA D ^DIR KILL DIR
.I $D(DIRUT) S Y="L"
.Q
EXIT ; -- exit code
D TERM^VALM0
S VALMBCK="R"
D GATHER
S VALMCNT=AMHLINE
D HDR
K X,Y,Z,I,AMHPAT,DFN,AMHX,AMHLINE,AMHSF,AMHF,AMHC,AMHRESU
D KILL^AUPNPAT
Q
EOJ ;
D EN^XBVK("AMH")
K DFN
K DDSFILE,DIPGM,Y
K X,Y,%,DR,DDS,DA,DIC
D:$D(VALMWD) CLEAR^VALM1
K VALM,VALMHDR,VALMKEY,VALMMENU,VALMSGR,VALMUP,VALMWD,VALMLST,VALMVAR,VALMLFT,VALMBCK,VALMCC,VALMAR,VALMBG,VALMCAP,VALMCOFF,VALMCNT,VALMCON,BALMON,VALMEVL,VALMIOXY
D KILL^AUPNPAT
Q
;
;
PAUSE ;EP
S DIR(0)="EO",DIR("A")="Press enter to continue...." D ^DIR K DIR S:$D(DUOUT) DIRUT=1
Q
UPI(P,D) ;EP
I '$G(P) Q ""
I '$P($G(^AUTTSITE(1,1)),U,3) S $P(^AUTTSITE(1,1),U,3)=$P(^AUTTLOC($P(^AUTTSITE(1,0),U,1),0),U,10)
;
Q $P(^AUTTSITE(1,1),U,3)_$E(D,4,5)_$E(D,6,7)_(1700+$E(D,1,3))_$E("0000000000",1,10-$L(P))_P
;
ALLOW(S,R) ;EP - CAN THIS USER SEE THIS SUICIDE FORM?
;S is duz, R is suicide form ien
Q 1
I '$G(S) Q 0
I '$G(R) Q 0
I '$D(^AMHPSUIC(R,0)) Q 0
NEW P
S P=$P($G(^AMHPSUIC(R,0)),U,4)
I 'P Q 0
I $D(^AMHSITE(DUZ(2),16,S)) Q $$ALLOWP^AMHUTIL(S,P) ;allow all with access
I $P(^AMHPSUIC(R,0),U,3)=S Q $$ALLOWP^AMHUTIL(S,P) ;allow your own
Q 0
AMHSFR ; IHS/CMI/LAB - REVIEW SF BY DATE 28 Apr 2009 10:46 AM ;
+1 ;;4.0;IHS BEHAVIORAL HEALTH;**1,2**;JUN 18, 2010;Build 23
+2 ;
+3 ;
START ;
+1 IF $DATA(IOF)
WRITE @IOF
+2 WRITE $$CTR("Review/Update Suicide Forms by Date",80)
+3 DO DONE
+4 ;
D ;date range
+1 KILL AMHED,AMHBD
+2 KILL DIR
WRITE !
SET DIR(0)="DO^::EXP"
SET DIR("A")="Enter Beginning Suicide form date"
+3 DO ^DIR
IF Y<1
SET AMHQUIT=1
IF Y<1
QUIT
SET AMHBD=Y
+4 KILL DIR
SET DIR(0)="DO^::EXP"
SET DIR("A")="Enter Ending Suicide form date"
+5 DO ^DIR
IF Y<1
SET AMHQUIT=1
IF Y<1
QUIT
SET AMHED=Y
+6 ;
+7 IF AMHED<AMHBD
Begin DoDot:1
+8 WRITE !!,$CHAR(7),"Sorry, Ending Date MUST not be earlier than Beginning Date."
End DoDot:1
GOTO D
DEMO ;
+1 DO DEMOCHK^AMHUTIL1(.AMHDEMO)
+2 IF AMHDEMO=-1
GOTO D
+3 DO EN
DO FULL^VALM1
DO EXIT
+4 QUIT
DONE ;
+1 DO EN^XBVK("AMH")
+2 DO ^XBFMK
+3 DO KILL^AUPNPAT
+4 QUIT
EN ;
+1 KILL AMHSFR
+2 DO GATHER
+3 DO EN^VALM("AMH SF BY DATE")
+4 DO CLEAR^VALM1
+5 QUIT
GATHER ;
+1 KILL AMHSFR
+2 SET AMHLINE=0
+3 SET AMHSD=$$FMADD^XLFDT(AMHED,1)
SET AMHSD=9999999-AMHSD
+4 FOR
SET AMHSD=$ORDER(^AMHPSUIC("AB",AMHSD))
IF AMHSD'=+AMHSD!(AMHSD>(9999999-AMHBD))
QUIT
Begin DoDot:1
+5 SET AMHX=0
FOR
SET AMHX=$ORDER(^AMHPSUIC("AB",AMHSD,AMHX))
IF AMHX'=+AMHX
QUIT
Begin DoDot:2
+6 SET DFN=$PIECE(^AMHPSUIC(AMHX,0),U,4)
SET AMHDOB=$PIECE(^DPT(DFN,0),U,3)
+7 IF '$$ALLOW(DUZ,AMHX)
QUIT
+8 IF $$DEMO^AMHUTIL1(DFN,$GET(AMHDEMO))
QUIT
+9 SET AMHD=$PIECE(^AMHPSUIC(AMHX,0),U,6)
+10 SET AMHLINE=AMHLINE+1
SET X=AMHLINE_")"
SET $EXTRACT(X,$SELECT($LENGTH(AMHLINE)<3:5,1:6))=$SELECT($$INCOMPSF^AMHLESF(AMHX):"I",1:"")
+11 SET $EXTRACT(X,8)=$EXTRACT(AMHD,4,5)_"/"_$EXTRACT(AMHD,6,7)_"/"_$EXTRACT(AMHD,2,3)
SET $EXTRACT(X,17)=$EXTRACT($PIECE(^DPT(DFN,0),U),1,19)
SET $EXTRACT(X,37)=$$HRN^AUPNPAT(DFN,DUZ(2))
SET $EXTRACT(X,44)=$EXTRACT(AMHDOB,4,5)_"/"_$EXTRACT(AMHDOB,6,7)_"/"_$EXTRACT(AMHDOB,2,3)
+12 SET $EXTRACT(X,53)=$EXTRACT($$VAL^XBDIQ1(9002011.65,AMHX,.131),1,20)
SET $EXTRACT(X,74)=$$VAL^XBDIQ1(9002011.65,AMHX,.031)
+13 SET $EXTRACT(X,78)=$$VAL^XBDIQ1(9002011.65,AMHX,.02)
SET $EXTRACT(X,96)=$$VAL^XBDIQ1(9002011.65,AMHX,.01)
+14 SET AMHSFR(AMHLINE,0)=X
SET AMHSFR("IDX",AMHLINE,AMHLINE)=AMHX
End DoDot:2
End DoDot:1
+15 QUIT
CTR(X,Y) ;EP - Center X in a field Y wide.
+1 QUIT $JUSTIFY("",$SELECT($DATA(Y):Y,1:IOM)-$LENGTH(X)\2)_X
+2 ;----------
HDR ; -- header code
+1 SET VALMHDR(1)="Suicide Form Review: "_$$FMTE^XLFDT(AMHBD)_" - "_$$FMTE^XLFDT(AMHED)
+2 SET VALMHDR(2)="I = Incomplete Form"
+3 SET X=""
SET $EXTRACT(X,8)="Date"
SET $EXTRACT(X,53)=""
SET VALMHDR(3)=X
+4 SET X=""
SET X="No."
SET $EXTRACT(X,8)="of Act"
SET $EXTRACT(X,17)="Patient"
SET $EXTRACT(X,37)="HRN"
SET $EXTRACT(X,44)="DOB"
SET $EXTRACT(X,53)="Suicidal Behavior"
SET $EXTRACT(X,74)="PRV"
SET $EXTRACT(X,78)="Local Case #"
SET $EXTRACT(X,96)="Case #"
SET VALMHDR(4)=X
+5 QUIT
+6 ;
INIT ; -- init variables and list array
+1 DO GATHER
+2 SET VALMCNT=AMHLINE
+3 QUIT
+4 ;
HELP ; -- help code
+1 SET X="?"
DO DISP^XQORM1
WRITE !!
+2 QUIT
+3 ;
EXPND ; -- expand code
+1 QUIT
EDIT ;EP - called from protocol
+1 DO EN^VALM2(XQORNOD(0),"OS")
+2 IF '$DATA(VALMY)
WRITE !,"No records selected."
DO EXIT
QUIT
+3 SET R=$ORDER(VALMY(0))
IF 'R
KILL R,VALMY,XQORNOD
WRITE !,"No record selected."
DO EXIT
QUIT
+4 SET AMHSF=0
SET AMHSF=AMHSFR("IDX",R,R)
+5 IF '$DATA(^AMHPSUIC(AMHSF,0))
WRITE !,"Not a valid SUICIDE RECORD."
KILL AMHRDEL,R,AMHSF,R1
DO PAUSE
DO EXIT
QUIT
+6 DO FULL^VALM1
DGSECE ;
+1 IF '$PIECE(^AMHPSUIC(AMHSF,0),U,4)
GOTO EDITR9
+2 SET AMHPAT=$PIECE(^AMHPSUIC(AMHSF,0),U,4)
+3 DO PTSEC^AMHUTIL2(.AMHRESU,AMHPAT,0)
+4 IF '$GET(AMHRESU(1))
GOTO EDITR9
+5 DO DISPDG^AMHLE
+6 WRITE !
KILL DIR
SET DIR(0)="Y"
SET DIR("A")="Do you want to continue to edit this suicide form"
SET DIR("B")="N"
KILL DA
DO ^DIR
KILL DIR
+7 IF 'Y
DO EXIT
QUIT
+8 KILL AMHRESU
+9 DO NOTICE^DGSEC4(.AMHRESU,AMHPAT,,3)
EDITR9 ;
+1 SET DA=AMHSF
SET DIE="^AMHPSUIC("
SET DR=".21////"_DT_";.22////"_DUZ_";.27////"_$$NOW^XLFDT
DO ^DIE
+2 SET (AMHPAT,DFN)=$PIECE(^AMHPSUIC(AMHSF,0),U,4)
+3 DO ADDDS
+4 DO EXIT
+5 QUIT
DISP ;EP - called from protocol
+1 DO EN^VALM2(XQORNOD(0),"OS")
+2 IF '$DATA(VALMY)
WRITE !,"No records selected."
DO EXIT
QUIT
+3 SET R=$ORDER(VALMY(0))
IF 'R
KILL R,VALMY,XQORNOD
WRITE !,"No record selected."
DO EXIT
QUIT
+4 SET AMHSF=0
SET AMHSF=AMHSFR("IDX",R,R)
+5 IF '$DATA(^AMHPSUIC(AMHSF,0))
WRITE !,"Not a valid SUICIDE RECORD."
KILL AMHRDEL,R,AMHSF,R1
DO PAUSE
DO EXIT
QUIT
+6 DO FULL^VALM1
DGSECD ;
+1 IF '$PIECE(^AMHPSUIC(AMHSF,0),U,4)
GOTO EDITD9
+2 SET AMHPAT=$PIECE(^AMHPSUIC(AMHSF,0),U,4)
+3 DO PTSEC^AMHUTIL2(.AMHRESU,AMHPAT,0)
+4 IF '$GET(AMHRESU(1))
GOTO EDITD9
+5 DO DISPDG^AMHLE
+6 WRITE !
KILL DIR
SET DIR(0)="Y"
SET DIR("A")="Do you want to continue to display this suicide form"
SET DIR("B")="N"
KILL DA
DO ^DIR
KILL DIR
+7 IF 'Y
DO EXIT
QUIT
+8 KILL AMHRESU
+9 DO NOTICE^DGSEC4(.AMHRESU,AMHPAT,,3)
EDITD9 ;
+1 ;NEW DFN,AMHPAT
+2 DO EP^AMHLESF1(AMHSF)
+3 DO EXIT
+4 QUIT
DEL ;EP - called from protocol
+1 ;add code to not allow delete unless they have the key
+2 IF '$DATA(^XUSEC("AMHZ DELETE RECORD",DUZ))
WRITE !!,"You do not have the security access to delete a Suicide Form.",!,"Please see your supervisor or program manager.",!
DO PAUSE
DO EXIT
QUIT
+3 DO EN^VALM2(XQORNOD(0),"OS")
+4 IF '$DATA(VALMY)
WRITE !,"No records selected."
DO EXIT
QUIT
+5 SET R=$ORDER(VALMY(0))
IF 'R
KILL R,VALMY,XQORNOD
WRITE !,"No record selected."
DO EXIT
QUIT
+6 SET AMHSF=0
SET AMHSF=AMHSFR("IDX",R,R)
+7 IF '$DATA(^AMHPSUIC(AMHSF,0))
WRITE !,"Not a valid SUICIDE RECORD."
KILL AMHRDEL,R,AMHSF,R1
DO PAUSE
DO EXIT
QUIT
+8 DO FULL^VALM1
DGSECX ;
+1 IF '$PIECE(^AMHPSUIC(AMHSF,0),U,4)
GOTO EDITX9
+2 SET AMHPAT=$PIECE(^AMHPSUIC(AMHSF,0),U,4)
+3 DO PTSEC^AMHUTIL2(.AMHRESU,AMHPAT,0)
+4 IF '$GET(AMHRESU(1))
GOTO EDITX9
+5 DO DISPDG^AMHLE
+6 WRITE !
KILL DIR
SET DIR(0)="Y"
SET DIR("A")="Do you want to continue to delete this suicide form"
SET DIR("B")="N"
KILL DA
DO ^DIR
KILL DIR
+7 IF 'Y
DO EXIT
QUIT
+8 KILL AMHRESU
+9 DO NOTICE^DGSEC4(.AMHRESU,AMHPAT,,3)
EDITX9 ;
+1 SET DIR(0)="Y"
SET DIR("A")="Are you sure you want to delete this suicide form"
SET DIR("B")="N"
KILL DA
DO ^DIR
KILL DIR
+2 IF $DATA(DIRUT)
DO EXIT
QUIT
+3 IF 'Y
DO EXIT
QUIT
+4 SET DA=AMHSF
SET DIK="^AMHPSUIC("
DO ^DIK
+5 DO EXIT
+6 QUIT
BV ;
+1 ;S DFN=AMHPAT
+2 NEW AMHPAT
+3 DO EP^AMHVD(DFN)
+4 DO EXIT
+5 QUIT
HS ;EP called from protocol to generate hs
+1 DO FULL^VALM1
+2 SET Y=DFN
DO ^AUPNPAT
+3 DO GETTYPE
+4 IF '$GET(APCHSTYP)
DO EN^XBVK("APCH")
QUIT
+5 SET APCHSPAT=DFN
+6 SET %="PCC Health Summary for "_$PIECE(^DPT(APCHSPAT,0),U)
+7 NEW DFN,AMHPAT
DO VIEWR^XBLM("EN^APCHS",%)
+8 DO EN^XBVK("APCH")
KILL AMCHDAYS,AMCHDOB,%
+9 DO EXIT
+10 QUIT
GETTYPE ;
+1 IF $GET(^AMHSITE(DUZ(2),0))=""
DO DEFAULT
QUIT
+2 SET APCHSTYP=$PIECE(^AMHSITE(DUZ(2),0),U,4)
IF APCHSTYP=""
DO DEFAULT
QUIT
+3 IF '$DATA(^APCHSCTL(APCHSTYP))
WRITE !,"Error in Site Parameter File!",$CHAR(7),$CHAR(7)
SET APCHSTYP=""
QUIT
+4 QUIT
DEFAULT ;
+1 SET APCHSTYP=""
+2 SET X="BEHAVIORAL HEALTH"
SET DIC(0)=""
SET DIC="^APCHSCTL("
DO ^DIC
KILL DIC,DA
+3 IF Y=-1
WRITE !!,"PCC MENTAL HEALTH HEALTH SUMMARY TYPE IS MISSING!! NOTIFY YOUR SUPERVISOR OR SITE MANAGER.",!!
QUIT
+4 SET APCHSTYP=+Y
+5 QUIT
ADD ;EP
+1 DO FULL^VALM1
+2 SET AMHPAT=""
+3 DO GETPAT^AMHLEA
+4 IF 'AMHPAT
WRITE !!,"No patient entered..."
DO EXIT
QUIT
+5 SET Y=AMHPAT
DO ^AUPNPAT
+6 SET DFN=AMHPAT
+7 DO ADDSF(AMHPAT)
+8 DO CLEAR^VALM1
+9 DO EXIT
+10 QUIT
ADDSF(AMHPAT) ;EP called from protocol to add a new form
+1 DO FULL^VALM1
+2 IF $DATA(IOF)
WRITE @IOF
PROV ;
+1 DO ^XBFMK
+2 SET AMHDP=""
+3 WRITE !!
SET DIC("A")="Provider Completing the Form: "
SET DIC="^VA(200,"
SET DIC(0)="AEMQ"
SET DIC("B")=$PIECE(^VA(200,DUZ,0),U)
DO ^DIC
KILL DIC,DA,DR,DLAYGO,DIADD
+4 IF Y<0
WRITE !,"No Provider Selected."
DO EXIT
QUIT
+5 SET AMHPROV=+Y
GETDATE ;EP - GET DATE OF ENCOUNTER
+1 WRITE !!
+2 SET AMHDATE=""
SET DIR(0)="DO^:"_DT_":EPTX"
SET DIR("A")="Enter the DATE of the SUICIDE ACT"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+3 IF $DATA(DIRUT)
DO EXIT
GOTO PROV
+4 SET AMHDATE=Y
+5 SET X=0
SET G=0
SET Y=0
FOR
SET X=$ORDER(^AMHPSUIC("AC",AMHPAT,X))
IF X'=+X!(G)
QUIT
IF $PIECE(^AMHPSUIC(X,0),U,6)=AMHDATE
Begin DoDot:1
+6 SET Y=1
WRITE !!,"This patient already has a suicide form on file for this Date of Act."
+7 WRITE !,"The form was filled out by: ",$$VAL^XBDIQ1(9002011.65,X,.03),!
+8 SET DIR(0)="S^A:Continue to ADD a new form;Q:Quit - do not add a new form"
SET DIR("A")="Do you wish to"
SET DIR("B")="Q"
KILL DA
DO ^DIR
KILL DIR
+9 IF $DATA(DIRUT)
SET Y="Q"
QUIT
+10 IF Y="Q"
QUIT
+11 SET G=1
End DoDot:1
+12 IF Y="Q"
DO PAUSE
DO EXIT
QUIT
+13 KILL DD,D0,DO,DINUM,DIC,DA,DR
SET DIC(0)="EL"
SET DIC="^AMHPSUIC("
SET DLAYGO=9002011.65
SET DIADD=1
SET X=$$UPI(AMHPAT,AMHDATE)
+14 SET DIC("DR")=".06////"_AMHDATE_";.04////"_AMHPAT_";.03////"_AMHPROV_";.18////"_DT_";.19////"_DUZ_";.21////"_DT_";.22////"_DUZ_";.27////"_$$NOW^XLFDT
+15 SET DIC("DR")=DIC("DR")_";9901///1"
+16 DO FILE^DICN
KILL DIC,DR,DIE,DIADD,DLAYGO,X,D0
+17 IF Y=-1
WRITE !!,$CHAR(7),$CHAR(7),"Error creating Suicide form!! Deleting form.",!
DO PAUSE
DO EXIT
QUIT
+18 SET AMHSF=+Y
+19 DO ADDDS
+20 DO EXIT
+21 QUIT
ADDDS ;screenman call
+1 SET AMHIISFE=1
+2 SET DA=AMHSF
SET DDSFILE=9002011.65
SET DR="[AMH SUICIDE FORM UPDATE]"
DO ^DDS
+3 IF $DATA(DIMSG)
WRITE !!,"ERROR IN SCREENMAN FORM!! ***NOTIFY PROGRAMMER***"
SET AMHQUIT=1
KILL DIMSG
DO PAUSE
DO EXIT
QUIT
+4 DO CHECK
+5 QUIT
+6 ;
CHECK ; check record for completeness
+1 SET AMHC=0
+2 FOR AMHF=.03:.01:.08
IF $$VAL^XBDIQ1(9002011.65,AMHSF,AMHF)=""
WRITE !,$PIECE(^DD(9002011.65,AMHF,0),U)," is a required data element."
SET AMHC=1
+3 FOR AMHF=.11,.13:.01:.15,.25
IF $$VAL^XBDIQ1(9002011.65,AMHSF,AMHF)=""
WRITE !,$PIECE(^DD(9002011.65,AMHF,0),U)," is a required data element."
SET AMHC=1
+4 IF $$VAL^XBDIQ1(9002011.65,AMHSF,.25)="OTHER"
IF $$VAL^XBDIQ1(9002011.65,AMHSF,1402)=""
SET AMHC=1
WRITE !,"Location of Act is OTHER, OTHER description is required."
+5 IF $$VAL^XBDIQ1(9002011.65,AMHSF,.25)'="OTHER"
IF $$VAL^XBDIQ1(9002011.65,AMHSF,1402)]""
SET DA=AMHSF
SET DIE="^AMHPSUIC("
SET DR="1402///@"
DO ^DIE
KILL DA,DIE,DR
+6 ;I $P(^AMHPSUIC(AMHSF,0),U,16)="",$P(^AMHPSUIC(AMHSF,0),U,17)="" W !,"INTERVENTION is a required data element." S AMHC=1
+7 SET (Z,X,G)=0
FOR
SET X=$ORDER(^AMHPSUIC(AMHSF,11,X))
IF X'=+X
QUIT
Begin DoDot:1
+8 IF $PIECE($GET(^AMHPSUIC(AMHSF,11,X,0)),U)]""
SET G=1
+9 IF $PIECE($GET(^AMHPSUIC(AMHSF,11,X,0)),U)=8
IF $PIECE(^AMHPSUIC(AMHSF,11,X,0),U,2)=""
WRITE !,"One of the Methods is OTHER. OTHER description is Required."
SET AMHC=1
+10 IF $PIECE(^AMHPSUIC(AMHSF,11,X,0),U,1)'=7
KILL ^AMHPSUIC(AMHSF,11,X,11)
+11 IF $PIECE(^AMHPSUIC(AMHSF,11,X,0),U,1)=7
Begin DoDot:2
+12 SET Y=0
FOR
SET Y=$ORDER(^AMHPSUIC(AMHSF,11,X,11,Y))
IF Y'=+Y
QUIT
Begin DoDot:3
+13 SET D=$PIECE(^AMHPSUIC(AMHSF,11,X,11,Y,0),U,1)
+14 IF $PIECE(^AMHTSDRG(D,0),U,2)
IF $PIECE(^AMHPSUIC(AMHSF,11,X,11,Y,0),U,2)=""
SET AMHC=1
WRITE !,"Method is Overdose, Drug type is Other, Other description is required."
End DoDot:3
End DoDot:2
+15 QUIT
End DoDot:1
+16 IF 'G
WRITE !!,"You must enter a METHOD."
SET AMHC=1
+17 SET G=$PIECE(^AMHPSUIC(AMHSF,0),U,26)
+18 IF G=""
WRITE !!,"You must enter a value for SUBSTANCE Use. None or Unknown are valid values."
SET AMHC=1
+19 IF G=2
Begin DoDot:1
+20 SET X=0
FOR
SET X=$ORDER(^AMHPSUIC(AMHSF,15,X))
IF X'=+X
QUIT
Begin DoDot:2
+21 SET D=$PIECE(^AMHPSUIC(AMHSF,15,X,0),U,1)
+22 IF $PIECE(^AMHTSSU(D,0),U,2)
IF $PIECE(^AMHPSUIC(AMHSF,15,X,0),U,2)=""
SET AMHC=1
WRITE !,"Substance Involved is Alcohol/Drugs, Drug is Other, Other Description is Required."
End DoDot:2
End DoDot:1
+23 SET (Z,G,X)=0
FOR
SET X=$ORDER(^AMHPSUIC(AMHSF,13,X))
IF X'=+X
QUIT
Begin DoDot:1
+24 IF $PIECE($GET(^AMHPSUIC(AMHSF,13,X,0)),U)]""
SET G=1
+25 SET D=$PIECE(^AMHPSUIC(AMHSF,13,X,0),U,1)
+26 IF $PIECE(^AMHTSCF(D,0),U,1)="OTHER"
IF $PIECE(^AMHPSUIC(AMHSF,13,X,0),U,2)=""
SET AMHC=1
WRITE !,"Contributing Factor is OTHER, OTHER description is required."
+27 QUIT
End DoDot:1
+28 ;NOW CHECK FOR OTHER
+29 IF 'G
WRITE !!,"You must enter a CONTRIBUTING FACTOR. Unknown is a valid value."
SET AMHC=1
+30 IF $PIECE(^AMHPSUIC(AMHSF,0),U,15)=7
IF $$VAL^XBDIQ1(9002011.65,AMHSF,1401)=""
SET AMHC=1
WRITE !,"Location of Act is OTHER, OTHER description is required."
+31 IF $PIECE(^AMHPSUIC(AMHSF,0),U,15)'=7
IF $$VAL^XBDIQ1(9002011.65,AMHSF,1401)]""
SET DIE="^AMHPSUIC("
SET DA=AMHSF
SET DR="1401///@"
DO ^DIE
KILL DA,DIE,DR
+32 IF AMHC
WRITE !!,"One or more required data elements are missing.",!!
Begin DoDot:1
+33 SET DIR(0)="S^E:Edit and Complete the Form;D:Delete the Incomplete Form;L:Leave the Incomplete Form as is and Finish it Later"
SET DIR("A")="What do you want to do"
SET DIR("B")="E"
KILL DA
DO ^DIR
KILL DIR
+34 IF $DATA(DIRUT)
SET Y="L"
+35 QUIT
End DoDot:1
IF Y="E"
GOTO ADDDS
IF Y="L"
GOTO EXIT
WRITE !,"Deleting form..."
SET DA=AMHSF
SET DIK="^AMHPSUIC("
DO ^DIK
DO PAUSE
EXIT ; -- exit code
+1 DO TERM^VALM0
+2 SET VALMBCK="R"
+3 DO GATHER
+4 SET VALMCNT=AMHLINE
+5 DO HDR
+6 KILL X,Y,Z,I,AMHPAT,DFN,AMHX,AMHLINE,AMHSF,AMHF,AMHC,AMHRESU
+7 DO KILL^AUPNPAT
+8 QUIT
EOJ ;
+1 DO EN^XBVK("AMH")
+2 KILL DFN
+3 KILL DDSFILE,DIPGM,Y
+4 KILL X,Y,%,DR,DDS,DA,DIC
+5 IF $DATA(VALMWD)
DO CLEAR^VALM1
+6 KILL VALM,VALMHDR,VALMKEY,VALMMENU,VALMSGR,VALMUP,VALMWD,VALMLST,VALMVAR,VALMLFT,VALMBCK,VALMCC,VALMAR,VALMBG,VALMCAP,VALMCOFF,VALMCNT,VALMCON,BALMON,VALMEVL,VALMIOXY
+7 DO KILL^AUPNPAT
+8 QUIT
+9 ;
+10 ;
PAUSE ;EP
+1 SET DIR(0)="EO"
SET DIR("A")="Press enter to continue...."
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 QUIT
UPI(P,D) ;EP
+1 IF '$GET(P)
QUIT ""
+2 IF '$PIECE($GET(^AUTTSITE(1,1)),U,3)
SET $PIECE(^AUTTSITE(1,1),U,3)=$PIECE(^AUTTLOC($PIECE(^AUTTSITE(1,0),U,1),0),U,10)
+3 ;
+4 QUIT $PIECE(^AUTTSITE(1,1),U,3)_$EXTRACT(D,4,5)_$EXTRACT(D,6,7)_(1700+$EXTRACT(D,1,3))_$EXTRACT("0000000000",1,10-$LENGTH(P))_P
+5 ;
ALLOW(S,R) ;EP - CAN THIS USER SEE THIS SUICIDE FORM?
+1 ;S is duz, R is suicide form ien
+2 QUIT 1
+3 IF '$GET(S)
QUIT 0
+4 IF '$GET(R)
QUIT 0
+5 IF '$DATA(^AMHPSUIC(R,0))
QUIT 0
+6 NEW P
+7 SET P=$PIECE($GET(^AMHPSUIC(R,0)),U,4)
+8 IF 'P
QUIT 0
+9 ;allow all with access
IF $DATA(^AMHSITE(DUZ(2),16,S))
QUIT $$ALLOWP^AMHUTIL(S,P)
+10 ;allow your own
IF $PIECE(^AMHPSUIC(R,0),U,3)=S
QUIT $$ALLOWP^AMHUTIL(S,P)
+11 QUIT 0