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

YTSBAMRC.m

Go to the documentation of this file.
YTSBAMRC ;SLC/PIJ/KCM - Score BAM-R-CSG-SUD ; 01/08/2016
 ;;5.01;MENTAL HEALTH;**234**;DEC 30,1994;Build 38
 ;
 Q
 ;
DATA1 ; display scores for administration
 N ANS,LEG,NODE,YSCDA,YSSEQ,YS
 N DATA,DES,SCORE,YSANS,YSQN,CID
 S SCORE=0
 S YSINSNAM=$P($G(YSDATA(2)),U,3)
 I $G(YSINSNAM)="" S YSINSNAM=$G(YS("CODE"),"NO NAME PASSED")
 S NODE=2 F  S NODE=$O(YSDATA(NODE)) Q:NODE=""  D  ; Start at YSDATA(3)
 .S DATA=YSDATA(NODE)
 .S YSQN=$P(DATA,U,1)
 .S YSSEQ=$P($P(DATA,U,2),";",1) ; Sequence Number
 .;if $P(YSSEQ,";",2)'"" then no Choice ID, piece 3 is data 
 .S YSANS=$P($P(DATA,U,2),";",2)
 .S ANS=$P(DATA,U,3),ANS=$S(ANS=1155:0,ANS=1156:0,1:ANS)
 .D DESGNTR^YTSCORE(YSQN,.DES)
 .S YSCDA=$P($G(DATA),U,3) ; Choice ID 
 .I $G(YSANS) S LEG=YSCDA
 .; legacy values are not correct for numerous CHOICE ID's, therefore set value from ID
 .I '$G(YSANS) S CID=YSCDA D
 ..S LEG=$S(CID=212:0,CID=1059:0,CID=1060:1,CID=1061:2,CID=1062:3,CID=1063:4,CID=717:1,CID=685:2,CID=2312:3,CID=687:4,CID=241:"Y",1:"")
 .I (DES="A")!(DES="B") Q
 .D SCORE
 Q
 ;
SCORE ;
 I DES=1 D
 .S HEALTH=HEALTH+LEG
 .S RISK=RISK+$$SCORADJ(LEG)
 I DES=2 D
 .S SLEEP=LEG
 .S RISK=RISK+LEG
 I DES=3 D
 .S DISTR=LEG
 .S RISK=RISK+LEG
 I DES=4 D
 .S DAYSAU=LEG
 .S USE=USE+LEG
 I DES="5A" D
 .S DAYSHA=LEG
 .S USE=USE+LEG
 I DES=6 D
 .S DAYSDRUG=LEG
 .S USE=USE+LEG
 I DES=8 D
 .S URGE=LEG
 .S RISK=RISK+$$SCORADJ(LEG)
 I DES=9 D
 .S CONFID=LEG
 .S PROTECT=PROTECT+$$SCORADJ(LEG)
 I DES=10 D
 .S SELF=LEG
 .S PROTECT=PROTECT+LEG
 I DES=11 D
 .S RISKY=LEG
 .S RISK=RISK+LEG
 I DES=12 D
 .S SPIRIT=LEG
 .S PROTECT=PROTECT+$$SCORADJ(LEG)
 I DES=13 D
 .S WORK=LEG
 .S PROTECT=PROTECT+LEG
 I DES=14 D
 .I LEG="Y" S INCME=4,PROTECT=PROTECT+30
 I DES=15 D
 .S RELAT=LEG
 .S RISK=RISK+$$SCORADJ(LEG)
 I DES=16 D
 .S SUPT=LEG
 .S PROTECT=PROTECT+LEG
 Q
 ;
SCORADJ(SCOR) ;
 S ANS=0
 I SCOR=1 S ANS=8
 I SCOR=2 S ANS=15
 I SCOR=3 S ANS=22
 I SCOR=4 S ANS=30
 Q ANS
 ; 
SCORESV ;
 I $D(^TMP($J,"YSG",1)),^TMP($J,"YSG",1)="[ERROR]" D  Q  ;-->out
 .K ^TMP($J,"YSCOR")
 .S ^TMP($J,"YSCOR",1)="[ERROR]"
 .S ^TMP($J,"YSCOR",2)="BAM-R-CSG-SUD Scale not found"
 ;
 K ^TMP($J,"YSCOR")
 S ^TMP($J,"YSCOR",1)="[DATA]"
 S ^TMP($J,"YSCOR",2)=$$GET1^DIQ(601.87,1506_",",3,"I")_"="_USE
 S ^TMP($J,"YSCOR",3)=$$GET1^DIQ(601.87,1507_",",3,"I")_"="_RISK
 S ^TMP($J,"YSCOR",4)=$$GET1^DIQ(601.87,1508_",",3,"I")_"="_PROTECT
 S ^TMP($J,"YSCOR",5)=$$GET1^DIQ(601.87,1509_",",3,"I")_"="_DAYSAU
 S ^TMP($J,"YSCOR",6)=$$GET1^DIQ(601.87,1510_",",3,"I")_"="_DAYSHA
 S ^TMP($J,"YSCOR",7)=$$GET1^DIQ(601.87,1511_",",3,"I")_"="_DAYSDRUG
 S ^TMP($J,"YSCOR",8)=$$GET1^DIQ(601.87,1512_",",3,"I")_"="_HEALTH
 S ^TMP($J,"YSCOR",9)=$$GET1^DIQ(601.87,1513_",",3,"I")_"="_SLEEP
 S ^TMP($J,"YSCOR",10)=$$GET1^DIQ(601.87,1514_",",3,"I")_"="_DISTR
 S ^TMP($J,"YSCOR",11)=$$GET1^DIQ(601.87,1515_",",3,"I")_"="_URGE
 S ^TMP($J,"YSCOR",12)=$$GET1^DIQ(601.87,1516_",",3,"I")_"="_RISKY
 S ^TMP($J,"YSCOR",13)=$$GET1^DIQ(601.87,1517_",",3,"I")_"="_RELAT
 S ^TMP($J,"YSCOR",14)=$$GET1^DIQ(601.87,1518_",",3,"I")_"="_CONFID
 S ^TMP($J,"YSCOR",15)=$$GET1^DIQ(601.87,1519_",",3,"I")_"="_SELF
 S ^TMP($J,"YSCOR",16)=$$GET1^DIQ(601.87,1520_",",3,"I")_"="_SPIRIT
 S ^TMP($J,"YSCOR",17)=$$GET1^DIQ(601.87,1521_",",3,"I")_"="_WORK
 S ^TMP($J,"YSCOR",18)=$$GET1^DIQ(601.87,1522_",",3,"I")_"="_INCME
 S ^TMP($J,"YSCOR",19)=$$GET1^DIQ(601.87,1523_",",3,"I")_"="_SUPT
 ;
 Q
DLLSTR(YSDATA,YS,YSTRNG) ;
 ;  YSTRNG = 1 Score Instrument
 ;  YSTRNG = 2 get Report Answers and Text
 N YSINSNAM
 N USE,RISK,PROTECT,DAYSAU,DAYSHA,DAYSDRUG,HEALTH,SLEEP
 N DISTR,URGE,RISKY,RELAT,CONFID,SELF,SPIRIT,WORK,INCME,SUPT
 ;
 S (USE,RISK,PROTECT,DAYSAU,DAYSHA,DAYSDRUG,HEALTH,SLEEP)=0
 S (DISTR,URGE,RISKY,RELAT,CONFID,SELF,SPIRIT,WORK,INCME,SUPT)=0
 ;
 I YSTRNG=2 Q  ; No special text, computations in the report. 
 ;
 D DATA1
 D SCORESV
 Q
 ;
VERIFY(ARGS,RESULTS) ; Add inconsistency messages based on set of answers in ARGS
 N MSGCNT S MSGCNT=0
 I $$LT("q9115","q9116") D MSG("more","4","5A")
 I $$LT("q9117","q9118") D MSG("less","7A","6")
 I $$LT("q9117","q9119") D MSG("less","7B","6")
 I $$LT("q9117","q9120") D MSG("less","7C","6")
 I $$LT("q9117","q9121") D MSG("less","7D","6")
 I $$LT("q9117","q9122") D MSG("less","7E","6")
 I $$LT("q9117","q9123") D MSG("less","7F","6")
 I $$LT("q9117","q9124") D MSG("less","7G","6")
 I $$GT("q9129","q9130") D MSG("more","5C","5B")
 S RESULTS("count")=MSGCNT
 Q
LT(ID1,ID2) ; returns 1 if ID1 is less than ID2
 ; expects ARGS from VERIFY
 N VAL1,VAL2
 S VAL1=$G(ARGS(ID1)) S:VAL1="c1156" VAL1=0  ; 1156 = skipped by rule
 S VAL2=$G(ARGS(ID2)) S:VAL2="c1156" VAL2=0
 I +VAL1<+VAL2 Q 1
 Q 0
 ;
GT(ID1,ID2) ; returns 1 if ID1 is more than ID2
 ; expects ARGS from VERIFY
 N VAL1,VAL2
 S VAL1=$G(ARGS(ID1)) S:VAL1="c1156" VAL1=0  ; 1156 = skipped by rule
 S VAL2=$G(ARGS(ID2)) S:VAL2="c1156" VAL2=0
 I +VAL1>+VAL2 Q 1
 Q 0
 ;
MSG(REL,Q1,Q2) ; Add text of message to RESULTS
 ; expects MSGCNT, RESULTS from VERIFY
 N X,NOUN
 S NOUN=$S(Q1="5C":"drinks",1:"days")
 S X="There is an inconsistency:  The number of "
 S X=X_NOUN_" entered in Question "_Q1
 S X=X_" should be equal to, or "_REL_" than,"
 S X=X_" the number of "_NOUN_" in Question "_Q2_"."
 S MSGCNT=MSGCNT+1,RESULTS("messages",MSGCNT)=X
 Q