YS249PST ;BAL/KTL - Patch 249 Post-init ;May 10, 2024@13:55:37
;;5.01;MENTAL HEALTH;**249**;Dec 30, 1994;Build 30
;
;
; Reference to EN^XPAR in ICR #2263
; Reference to GETLST^XPAR in ICR #2263
; Reference to XLFSTR in ICR #10104
Q
;
EDTDATE ; date used to update 601.71:18
;;3240531.2159
Q
;
PRE ; nothing necessary
Q
;
POST ; post-init
D INSTALLQ^YTXCHG("XCHGLST","YS249PST")
D SETCAT("YMRS","Depression/Mood")
D SETCAT("MOCA_8.1","Cognitive/Learning")
D SETCAT("MOCA_8.2","Cognitive/Learning")
D SETCAT("MOCA_8.3","Cognitive/Learning")
D SETCAT("MOCA BLIND","Cognitive/Learning")
D SETCAT("PEG","Long COVID")
D SETCAT("MIDAS","Long COVID")
D DROPTST("MOCA")
D DROPTST("MOCA ALT 1")
D DROPTST("MOCA ALT 2")
D DROPTST("CEMI")
D DROPTST("GPCOG")
D DROPTST("ISMI")
D DROPTST("COPD")
D DROPTST("STAI")
D DROPTST("STMS")
D DROPTST("ATQ")
D DROPTST("IJSS")
D DROPTST("BBHI-2")
D DROPTST("CESD")
D BOMCREV
D UPDURL
Q
;
SETCAT(TEST,CATNM) ; add category to TEST if not already there
N CAT
I TEST'=+TEST S TEST=$O(^YTT(601.71,"B",TEST,0)) QUIT:'TEST
S CAT=$O(^YTT(601.97,"B",CATNM,0)) QUIT:'CAT
I $D(^YTT(601.71,TEST,10,"B",CAT))=10 QUIT ; already there
;
N YTFDA,YTIEN,DIERR
S YTFDA(601.71101,"+1,"_TEST_",",.01)=CATNM
D UPDATE^DIE("E","YTFDA","YTIEN")
I $D(DIERR) D MES^XPDUTL(CATNM_": "_$G(^TMP("DIERR",$J,1,"TEXT",1)))
D CLEAN^DILF
Q
;
DROPTST(NAME) ; Change OPERATIONAL to dropped
N IEN,REC
S IEN=$O(^YTT(601.71,"B",NAME,0))
I +IEN'=0 D
. S REC(10)="D"
. S REC(18)=$P($T(EDTDATE+1),";;",2)
. D FMUPD^YTXCHGU(601.71,.REC,IEN)
K REC,IEN
S IEN=$O(^YTT(601,"B",NAME,0))
I 'IEN QUIT
S REC(32)="N"
D FMUPD^YTXCHGU(601,.REC,IEN)
Q
;
BOMCREV ; Change old BOMC MH Answers (due to changes in Choices) and rescore for revision 2
N YSARR,YSBOMC
;
; YSARR(QUESTIONID,OLDCHOICEID)=NEWCHOICEID
S YSARR(4173,1834)=6093
S YSARR(4175,1838)=6094
S YSBOMC=$O(^YTT(601.71,"B","BOMC",0))
I YSBOMC D ANSREVQUE(YSBOMC,.YSARR,$H,2)
Q
;
UPDURL ; Update GUI TOOLS URL for MHA Web
;Z
N LIST,PARM,ERR,ENT,INST,VAL,TITL,CMD,SPEC,NEWVAL
K ^TMP($J,"XPAR")
S LIST=$NA(^TMP($J,"XPAR"))
S PARM="ORWT TOOLS MENU"
D ENVAL^XPAR(LIST,PARM,"",.ERR,1)
S ^XTMP("YS249-TOOLS",0)=$$FMADD^XLFDT(DT,7)_U_DT_U_"MH Backup Tools Menu"
M ^XTMP("YS249-TOOLS","XPAR")=^TMP($J,"XPAR")
S SPEC("/home?")="/home/p249/?",SPEC("/home/?")="/home/p249/?" ;In case URL entered home/? Patch 249
S SPEC("/home/p224/?")="/home/p249/?" ;Patch 249
S ENT="" F S ENT=$O(^TMP($J,"XPAR",ENT)) Q:ENT="" D
. S INST=0 F S INST=$O(^TMP($J,"XPAR",ENT,INST)) Q:+INST=0 D
.. S VAL=^TMP($J,"XPAR",ENT,INST)
.. I (VAL["mha.domain.ext/app/home?"!(VAL["mha.domain.ext/app/home/")) D
... S TITL=$P(VAL,"="),CMD=$P(VAL,"=",2,99)
... S CMD=$$REPLACE^XLFSTR(CMD,.SPEC)
... S NEWVAL=TITL_"="_CMD
... D BMES^XPDUTL("Updating "_CMD_" for "_ENT)
... D EN^XPAR(ENT,PARM,INST,NEWVAL,.ERR)
K ^TMP($J,"XPAR")
Q
;
SCREEN ; line to put in DATA SCREEN of KIDS build
; $$INCLUDE^YTXCHG(Y,"TAG","RTN") calls TAG^RTN to get an array of
; instrument exchange entries to include in the build. It sets Y
; to true if the entry should be included.
;
I $$INCLUDE^YTXCHG(Y,"XCHGLST","YS249PST")
Q
;
XCHGLST(ARRAY) ; return array of instrument exchange entries
; ARRAY(cnt,1)=instrument exchange entry name
; ARRAY(cnt,2)=instrument exchange entry creation date
;
N I,X
F I=1:1 S X=$P($T(ENTRIES+I),";;",2,99) Q:X="zzzzz" D
. S ARRAY(I,1)=$P(X,U)
. S ARRAY(I,2)=$P(X,U,2)
Q
;
ENTRIES ; New MHA instruments ^ Exchange Entry Date
;;YS*5.01*249 PEBS-20^04/11/2024@13:27:22
;;YS*5.01*249 BRADEN^04/11/2024@13:12:58
;;YS*5.01*249 YMRS^04/10/2024@15:20:31
;;YS*5.01*249 MOCA_8.1^04/17/2024@15:20:38
;;YS*5.01*249 MOCA_8.2^04/17/2024@15:21:06
;;YS*5.01*249 MOCA_8.3^04/18/2024@14:50:03
;;YS*5.01*249 MOCA BLIND^04/23/2024@13:52:01
;;YS*5.01*249 BOMC^04/24/2024@13:25:37
;;YS*5.01*249 Q-LES-Q-SF^05/03/2024@15:32:20
;;zzzzz
;
Q
;
;
ANSREVQUE(YSINS,YSARR,YSDTH,YSREV) ; Queue task to correct BOMC Answers and rescore
N ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTSAVE,ZTSK
;
I '$G(YSINS) QUIT
I '$D(YSARR) QUIT
D BMES^XPDUTL("Queueing task to Correct MH Instrument Answers")
I $G(YSDTH)="" S YSDTH=$H
S ZTIO=""
S ZTRTN="ANSREV^YS249PST"
S ZTDESC="Correct MH Instrument Answers"
S ZTDTH=YSDTH
S ZTSAVE("YSINS")=""
S ZTSAVE("YSARR(")=""
I $G(YSREV)>0 S ZTSAVE("YSREV")=""
D ^%ZTLOAD
I $G(ZTSK) D BMES^XPDUTL("DONE - Task #"_ZTSK)
I '$G(ZTSK) D BMES^XPDUTL("Unsuccessful queue of MH Instrument Answers job.")
S ^XTMP("YTS-ANSREV",0)=$$FMADD^XLFDT(DT,365)_U_DT_U_"MH Log Changed Answers"
Q
;
ANSREV ; correct BOMC Answers and rescore
; ZEXCEPT: YSARR,YSINS,YSREV,ZTQUEUED,ZTSTOP
N YSAD,YSADDT,YSCNT
;
S YSCNT=0
S ^XTMP("YTS-ANSREV",YSINS,"STARTED")=$$NOW^XLFDT
S YSADDT=+$G(^XTMP("YTS-ANSREV",YSINS,"LAST"))
F S YSADDT=$O(^YTT(601.84,"AC",YSINS,YSADDT)) Q:'YSADDT D Q:$G(ZTSTOP)
. S YSAD=0
. F S YSAD=$O(^YTT(601.84,"AC",YSINS,YSADDT,YSAD)) Q:'YSAD D Q:$G(ZTSTOP)
. . S YSCNT=YSCNT+1
. . ; take a "rest" - allow OS to swap out process
. . I '(YSCNT#1000) D I $D(ZTQUEUED),$$S^%ZTLOAD("Processing admin #"_YSAD) S ZTSTOP=1 QUIT
. . . S ^XTMP("YTS-ANSREV",YSINS,"LAST")=$O(^YTT(601.84,"AC",YSINS,YSADDT),-1)
. . . H 1
. . D CHK85(YSINS,YSAD,.YSARR)
;
S ^XTMP("YTS-ANSREV",YSINS,"ENDED")=$$NOW^XLFDT
;
; if revision # is passed in, kick off job to rescore old administrations
I $G(YSREV)>0 D QTASK^YTSCOREV(YSINS_"~"_YSREV,$H)
Q
;
CHK85(YSINS,YSAD,YSARR) ; See if any answers for this admin need to be changed
N YSANS,YSNEWCH,YSOLDCH,YSQID,YSREC
;
S YSQID=0
F S YSQID=$O(YSARR(YSQID)) Q:'YSQID D
. S YSANS=$O(^YTT(601.85,"AC",YSAD,YSQID,""))
. I 'YSANS QUIT
. S YSOLDCH=$P($G(^YTT(601.85,YSANS,0)),U,4)
. I 'YSOLDCH QUIT
. S YSNEWCH=$G(YSARR(YSQID,YSOLDCH))
. I YSNEWCH'>0 QUIT
. ;
. S ^XTMP("YTS-ANSREV",YSINS,YSANS)=YSOLDCH_U_YSNEWCH
. S YSREC(4)=YSNEWCH
. D FMUPD^YTXCHGU(601.85,.YSREC,YSANS)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYS249PST 6152 printed Oct 16, 2024@18:13:36 Page 2
YS249PST ;BAL/KTL - Patch 249 Post-init ;May 10, 2024@13:55:37
+1 ;;5.01;MENTAL HEALTH;**249**;Dec 30, 1994;Build 30
+2 ;
+3 ;
+4 ; Reference to EN^XPAR in ICR #2263
+5 ; Reference to GETLST^XPAR in ICR #2263
+6 ; Reference to XLFSTR in ICR #10104
+7 QUIT
+8 ;
EDTDATE ; date used to update 601.71:18
+1 ;;3240531.2159
+2 QUIT
+3 ;
PRE ; nothing necessary
+1 QUIT
+2 ;
POST ; post-init
+1 DO INSTALLQ^YTXCHG("XCHGLST","YS249PST")
+2 DO SETCAT("YMRS","Depression/Mood")
+3 DO SETCAT("MOCA_8.1","Cognitive/Learning")
+4 DO SETCAT("MOCA_8.2","Cognitive/Learning")
+5 DO SETCAT("MOCA_8.3","Cognitive/Learning")
+6 DO SETCAT("MOCA BLIND","Cognitive/Learning")
+7 DO SETCAT("PEG","Long COVID")
+8 DO SETCAT("MIDAS","Long COVID")
+9 DO DROPTST("MOCA")
+10 DO DROPTST("MOCA ALT 1")
+11 DO DROPTST("MOCA ALT 2")
+12 DO DROPTST("CEMI")
+13 DO DROPTST("GPCOG")
+14 DO DROPTST("ISMI")
+15 DO DROPTST("COPD")
+16 DO DROPTST("STAI")
+17 DO DROPTST("STMS")
+18 DO DROPTST("ATQ")
+19 DO DROPTST("IJSS")
+20 DO DROPTST("BBHI-2")
+21 DO DROPTST("CESD")
+22 DO BOMCREV
+23 DO UPDURL
+24 QUIT
+25 ;
SETCAT(TEST,CATNM) ; add category to TEST if not already there
+1 NEW CAT
+2 IF TEST'=+TEST
SET TEST=$ORDER(^YTT(601.71,"B",TEST,0))
if 'TEST
QUIT
+3 SET CAT=$ORDER(^YTT(601.97,"B",CATNM,0))
if 'CAT
QUIT
+4 ; already there
IF $DATA(^YTT(601.71,TEST,10,"B",CAT))=10
QUIT
+5 ;
+6 NEW YTFDA,YTIEN,DIERR
+7 SET YTFDA(601.71101,"+1,"_TEST_",",.01)=CATNM
+8 DO UPDATE^DIE("E","YTFDA","YTIEN")
+9 IF $DATA(DIERR)
DO MES^XPDUTL(CATNM_": "_$GET(^TMP("DIERR",$JOB,1,"TEXT",1)))
+10 DO CLEAN^DILF
+11 QUIT
+12 ;
DROPTST(NAME) ; Change OPERATIONAL to dropped
+1 NEW IEN,REC
+2 SET IEN=$ORDER(^YTT(601.71,"B",NAME,0))
+3 IF +IEN'=0
Begin DoDot:1
+4 SET REC(10)="D"
+5 SET REC(18)=$PIECE($TEXT(EDTDATE+1),";;",2)
+6 DO FMUPD^YTXCHGU(601.71,.REC,IEN)
End DoDot:1
+7 KILL REC,IEN
+8 SET IEN=$ORDER(^YTT(601,"B",NAME,0))
+9 IF 'IEN
QUIT
+10 SET REC(32)="N"
+11 DO FMUPD^YTXCHGU(601,.REC,IEN)
+12 QUIT
+13 ;
BOMCREV ; Change old BOMC MH Answers (due to changes in Choices) and rescore for revision 2
+1 NEW YSARR,YSBOMC
+2 ;
+3 ; YSARR(QUESTIONID,OLDCHOICEID)=NEWCHOICEID
+4 SET YSARR(4173,1834)=6093
+5 SET YSARR(4175,1838)=6094
+6 SET YSBOMC=$ORDER(^YTT(601.71,"B","BOMC",0))
+7 IF YSBOMC
DO ANSREVQUE(YSBOMC,.YSARR,$HOROLOG,2)
+8 QUIT
+9 ;
UPDURL ; Update GUI TOOLS URL for MHA Web
+1 ;Z
+2 NEW LIST,PARM,ERR,ENT,INST,VAL,TITL,CMD,SPEC,NEWVAL
+3 KILL ^TMP($JOB,"XPAR")
+4 SET LIST=$NAME(^TMP($JOB,"XPAR"))
+5 SET PARM="ORWT TOOLS MENU"
+6 DO ENVAL^XPAR(LIST,PARM,"",.ERR,1)
+7 SET ^XTMP("YS249-TOOLS",0)=$$FMADD^XLFDT(DT,7)_U_DT_U_"MH Backup Tools Menu"
+8 MERGE ^XTMP("YS249-TOOLS","XPAR")=^TMP($JOB,"XPAR")
+9 ;In case URL entered home/? Patch 249
SET SPEC("/home?")="/home/p249/?"
SET SPEC("/home/?")="/home/p249/?"
+10 ;Patch 249
SET SPEC("/home/p224/?")="/home/p249/?"
+11 SET ENT=""
FOR
SET ENT=$ORDER(^TMP($JOB,"XPAR",ENT))
if ENT=""
QUIT
Begin DoDot:1
+12 SET INST=0
FOR
SET INST=$ORDER(^TMP($JOB,"XPAR",ENT,INST))
if +INST=0
QUIT
Begin DoDot:2
+13 SET VAL=^TMP($JOB,"XPAR",ENT,INST)
+14 IF (VAL["mha.domain.ext/app/home?"!(VAL["mha.domain.ext/app/home/"))
Begin DoDot:3
+15 SET TITL=$PIECE(VAL,"=")
SET CMD=$PIECE(VAL,"=",2,99)
+16 SET CMD=$$REPLACE^XLFSTR(CMD,.SPEC)
+17 SET NEWVAL=TITL_"="_CMD
+18 DO BMES^XPDUTL("Updating "_CMD_" for "_ENT)
+19 DO EN^XPAR(ENT,PARM,INST,NEWVAL,.ERR)
End DoDot:3
End DoDot:2
End DoDot:1
+20 KILL ^TMP($JOB,"XPAR")
+21 QUIT
+22 ;
SCREEN ; line to put in DATA SCREEN of KIDS build
+1 ; $$INCLUDE^YTXCHG(Y,"TAG","RTN") calls TAG^RTN to get an array of
+2 ; instrument exchange entries to include in the build. It sets Y
+3 ; to true if the entry should be included.
+4 ;
+5 IF $$INCLUDE^YTXCHG(Y,"XCHGLST","YS249PST")
+6 QUIT
+7 ;
XCHGLST(ARRAY) ; return array of instrument exchange entries
+1 ; ARRAY(cnt,1)=instrument exchange entry name
+2 ; ARRAY(cnt,2)=instrument exchange entry creation date
+3 ;
+4 NEW I,X
+5 FOR I=1:1
SET X=$PIECE($TEXT(ENTRIES+I),";;",2,99)
if X="zzzzz"
QUIT
Begin DoDot:1
+6 SET ARRAY(I,1)=$PIECE(X,U)
+7 SET ARRAY(I,2)=$PIECE(X,U,2)
End DoDot:1
+8 QUIT
+9 ;
ENTRIES ; New MHA instruments ^ Exchange Entry Date
+1 ;;YS*5.01*249 PEBS-20^04/11/2024@13:27:22
+2 ;;YS*5.01*249 BRADEN^04/11/2024@13:12:58
+3 ;;YS*5.01*249 YMRS^04/10/2024@15:20:31
+4 ;;YS*5.01*249 MOCA_8.1^04/17/2024@15:20:38
+5 ;;YS*5.01*249 MOCA_8.2^04/17/2024@15:21:06
+6 ;;YS*5.01*249 MOCA_8.3^04/18/2024@14:50:03
+7 ;;YS*5.01*249 MOCA BLIND^04/23/2024@13:52:01
+8 ;;YS*5.01*249 BOMC^04/24/2024@13:25:37
+9 ;;YS*5.01*249 Q-LES-Q-SF^05/03/2024@15:32:20
+10 ;;zzzzz
+11 ;
+12 QUIT
+13 ;
+14 ;
ANSREVQUE(YSINS,YSARR,YSDTH,YSREV) ; Queue task to correct BOMC Answers and rescore
+1 NEW ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTSAVE,ZTSK
+2 ;
+3 IF '$GET(YSINS)
QUIT
+4 IF '$DATA(YSARR)
QUIT
+5 DO BMES^XPDUTL("Queueing task to Correct MH Instrument Answers")
+6 IF $GET(YSDTH)=""
SET YSDTH=$HOROLOG
+7 SET ZTIO=""
+8 SET ZTRTN="ANSREV^YS249PST"
+9 SET ZTDESC="Correct MH Instrument Answers"
+10 SET ZTDTH=YSDTH
+11 SET ZTSAVE("YSINS")=""
+12 SET ZTSAVE("YSARR(")=""
+13 IF $GET(YSREV)>0
SET ZTSAVE("YSREV")=""
+14 DO ^%ZTLOAD
+15 IF $GET(ZTSK)
DO BMES^XPDUTL("DONE - Task #"_ZTSK)
+16 IF '$GET(ZTSK)
DO BMES^XPDUTL("Unsuccessful queue of MH Instrument Answers job.")
+17 SET ^XTMP("YTS-ANSREV",0)=$$FMADD^XLFDT(DT,365)_U_DT_U_"MH Log Changed Answers"
+18 QUIT
+19 ;
ANSREV ; correct BOMC Answers and rescore
+1 ; ZEXCEPT: YSARR,YSINS,YSREV,ZTQUEUED,ZTSTOP
+2 NEW YSAD,YSADDT,YSCNT
+3 ;
+4 SET YSCNT=0
+5 SET ^XTMP("YTS-ANSREV",YSINS,"STARTED")=$$NOW^XLFDT
+6 SET YSADDT=+$GET(^XTMP("YTS-ANSREV",YSINS,"LAST"))
+7 FOR
SET YSADDT=$ORDER(^YTT(601.84,"AC",YSINS,YSADDT))
if 'YSADDT
QUIT
Begin DoDot:1
+8 SET YSAD=0
+9 FOR
SET YSAD=$ORDER(^YTT(601.84,"AC",YSINS,YSADDT,YSAD))
if 'YSAD
QUIT
Begin DoDot:2
+10 SET YSCNT=YSCNT+1
+11 ; take a "rest" - allow OS to swap out process
+12 IF '(YSCNT#1000)
Begin DoDot:3
+13 SET ^XTMP("YTS-ANSREV",YSINS,"LAST")=$ORDER(^YTT(601.84,"AC",YSINS,YSADDT),-1)
+14 HANG 1
End DoDot:3
IF $DATA(ZTQUEUED)
IF $$S^%ZTLOAD("Processing admin #"_YSAD)
SET ZTSTOP=1
QUIT
+15 DO CHK85(YSINS,YSAD,.YSARR)
End DoDot:2
if $GET(ZTSTOP)
QUIT
End DoDot:1
if $GET(ZTSTOP)
QUIT
+16 ;
+17 SET ^XTMP("YTS-ANSREV",YSINS,"ENDED")=$$NOW^XLFDT
+18 ;
+19 ; if revision # is passed in, kick off job to rescore old administrations
+20 IF $GET(YSREV)>0
DO QTASK^YTSCOREV(YSINS_"~"_YSREV,$HOROLOG)
+21 QUIT
+22 ;
CHK85(YSINS,YSAD,YSARR) ; See if any answers for this admin need to be changed
+1 NEW YSANS,YSNEWCH,YSOLDCH,YSQID,YSREC
+2 ;
+3 SET YSQID=0
+4 FOR
SET YSQID=$ORDER(YSARR(YSQID))
if 'YSQID
QUIT
Begin DoDot:1
+5 SET YSANS=$ORDER(^YTT(601.85,"AC",YSAD,YSQID,""))
+6 IF 'YSANS
QUIT
+7 SET YSOLDCH=$PIECE($GET(^YTT(601.85,YSANS,0)),U,4)
+8 IF 'YSOLDCH
QUIT
+9 SET YSNEWCH=$GET(YSARR(YSQID,YSOLDCH))
+10 IF YSNEWCH'>0
QUIT
+11 ;
+12 SET ^XTMP("YTS-ANSREV",YSINS,YSANS)=YSOLDCH_U_YSNEWCH
+13 SET YSREC(4)=YSNEWCH
+14 DO FMUPD^YTXCHGU(601.85,.YSREC,YSANS)
End DoDot:1
+15 QUIT
+16 ;