source: FOIAVistA/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YTQPXRM4.m@ 635

Last change on this file since 635 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 4.3 KB
Line 
1YTQPXRM4 ;ASF/ALB CLINICAL REMINDERS CONT ; 10/29/07 3:06pm
2 ;;5.01;MENTAL HEALTH;**85**;DEC 30,1994;Build 48
3 ;
4 Q
5CHECKCR(YSDATA,YS) ;ckeck out cr dialog is ok
6 ; input: CODE,DFN,^TMP($J,AARAY,sequential)=ITEM#^RESPONSE
7 ;output [DATA] VS [ERROR]
8 ;scoring in ^TMP($J,"YSCOR"
9 N DA,DFN,N,YSV,YSCODE,YSQNUMB,YSADDER,YSNEWA,YSADDER,YSDATAZ,YSANS,YSX,YSBOP1
10 N YSERR,YSLEGA,YSRR,YSCHOT,YSCHOICE,G,YSLN,YSIC,YSQN,YSF,YSCODE,J,N83,YSANSIV,YSIV,YSQ1,YSRG,YSRULE,YSRULID,DIK,YS84IEN,J1,YSTESTN
11 S DFN=$G(YS("DFN"),-1) I '$D(^DPT(DFN)) S YSDATA(1)="ERROR",YSDATA(2)="bad DFN" Q ;-->out
12 S YSDATA(1)="[DATA]"
13 D ALLIN
14 Q:(YSDATA(1)'="[DATA]") ;-->out
15 D SAVEOK
16 L +^YTT(601.84,YS84IEN):30
17 K YS D ANSSET
18 D GETSCORE^YTQAPI8(.YSV,.YS)
19 ; delete admin as it is not fully ok'd
20 S J=0 F S J=$O(^YTT(601.85,"AC",YS84IEN,J)) Q:J'>0 S J1=0 F S J1=$O(^YTT(601.85,"AC",YS84IEN,J,J1)) Q:J1'>0 D
21 . K DIK S DA=J1,DIK="^YTT(601.85," D ^DIK
22 K DIK S DA=YS84IEN,DIK="^YTT(601.84," D ^DIK ;moved 10/29/07 asf
23 L -^YTT(601.84,YS84IEN):30
24 K ^TMP($J,"YSQU")
25 Q
26SAVECR(YSDATA,YS) ;save cr entered instruments
27 ; input: CODE,DFN,^TMP($J,AARAY,sequential)=ITEM#^RESPONSE
28 ;output [DATA] VS [ERROR]
29 N DA,DFN,N,YSCODE,YSQNUMB,YSADDER,YSNEWA,YSADDER,YS84IEN,YSDATAZ,YSANS,YSX,YSBOP1,YSSTAFF,YSADATE
30 N YSERR,YSLEGA,YSRR,YSCHOT,YSCHOICE,G,YSLN,YSIC,YSQN,YSF,YSCODE,J,N83,YSANSIV,YSIV,YSQ1,YSRG,YSRULE,YSRULID,J1,YSTESTN
31 S DFN=$G(YS("DFN"),-1) I '$D(^DPT(DFN)) S YSDATA(1)="ERROR",YSDATA(2)="bad DFN" Q ;-->out
32 S YSADATE=$G(YS("ADATE"),"NOW")
33 S YSSTAFF=$G(YS("STAFF"),DUZ)
34 S YSDATA(1)="[DATA]"
35 D ALLIN
36 Q:(YSDATA(1)'="[DATA]") ;-->out
37 D SAVEOK
38 K YS D ANSSET
39 ;save results
40 K YS S YS("AD")=YS84IEN D SCORSAVE^YTQAPI11(.YSDATA,.YS)
41 ;send to nat db
42 K YS S YS("AD")=YS84IEN D HL7^YTQHL7(.YSDATA,.YS)
43 K ^TMP($J,"YSQU")
44 Q
45ALLIN ;check cr Entries ok
46 S YSCODE=$G(YS("CODE"),0)
47 S YSTESTN=$O(^YTT(601.71,"B",YSCODE,0))
48 I YSTESTN'>0 S YSDATA(1)="[ERROR]",YSDATA(2)="bad code" Q ;-->out
49 D QUESTALL^YTQPXRM3(.YSDATAZ,.YS)
50 I ^TMP($J,"YSQU",1)="[ERROR]" S YSDATA(1)="[ERROR]",YSDATA(2)="QUESTALL ERROR "_^TMP($J,"YSQU",2) Q ;-->out
51 ;set answers
52 S N=0 F S N=$O(YS(N)) Q:N'>0 S YSANS(+YS(N))=$P(YS(N),U,2)
53 ;Skip logic fire -only first condition-no consistency only checks
54 S N=0 F S N=$O(^TMP($J,"YSQU","YSCROSS",N)) Q:N'>0 D:$D(YSANS(N))
55 . S YSQN=^TMP($J,"YSQU","YSCROSS",N)
56 . Q:'$D(^YTT(601.83,"AD",YSTESTN,YSQN))
57 . S N83=0
58 . F S N83=$O(^YTT(601.83,"AD",YSTESTN,YSQN,N83)) Q:N83'>0 D
59 .. S YSRULID=$P(^YTT(601.83,N83,0),U,4)
60 .. S YSRG=^YTT(601.82,YSRULID,0)
61 .. S YSQ1=$P(YSRG,U,2),YSIV=$P(YSRG,U,3),YSBOP1=$$BOOL($P(YSRG,U,5))
62 .. S:YSBOP1="=<" YSBOP1="<",YSIV=YSIV+.1
63 .. S:YSBOP1="=>" YSBOP1=">",YSIV=YSIV-.1
64 .. S YSANSIV=$F(^TMP($J,"YSQU",N,"R",0),YSANS(N))-2
65 .. S YSX="S YSRULE=0 I ("_YSANSIV_YSBOP1_YSIV_") S YSRULE=1"
66 .. X YSX
67 .. I $G(YSRULE)=1 S J=0 F S J=$O(^YTT(601.79,"AE",YSRULID,J)) Q:J'>0 S ^TMP($J,"YSQU","YSKIP",$P($G(^YTT(601.79,J,0),0),U,4))=""
68 ; check all required answers present and legal
69 S YSERR=""
70 S N=0 F S N=$O(^TMP($J,"YSQU","YSCROSS",N)) Q:N'>0 D
71 . S YSQN=^TMP($J,"YSQU","YSCROSS",N)
72 . I $D(YSANS(N)) S:(^TMP($J,"YSQU",N,"R",0)'[YSANS(N)) YSERR="0^"_$P(YSERR,U,2)_N_"," ;answer not legal
73 . ;I $P(^YTT(601.72,YSQN,2),U,6)="N" Q ;-->out not a required ques
74 . I $D(^TMP($J,"YSQU","YSKIP",YSQN)) Q ;-->out skip rule
75 . I '$D(YSANS(N)) S YSERR="0^"_$P(YSERR,U,2)_N_"," ; error set req answer not present
76 I $L(YSERR)>1 S YSDATA(1)="[ERROR]" S YSDATA(2)=YSERR K ^TMP($J,"YSQU") Q ;-->out houston we have a problem
77 Q
78SAVEOK ; checks out so save admin
79 S:'$D(YSADATE) YSADATE="NOW"
80 S:'$D(YSSTAFF) YSSTAFF=DUZ
81 S YSNEWA("FILEN")=601.84,YSNEWA(1)=".01^NEW^1",YSNEWA(2)="1^`"_DFN
82 S YSNEWA(3)="2^"_YSCODE,YSNEWA(4)="3^"_YSADATE,YSNEWA(5)="4^NOW"
83 S YSNEWA(6)="5^`"_YSSTAFF,YSNEWA(7)="6^`"_DUZ,YSNEWA(8)="7^N",YSNEWA(9)="8^Y"
84 ;ASF 8/13 staff and orderer passing
85 D EDAD^YTQAPI1(.YSADDER,.YSNEWA)
86 S YS84IEN=$P(YSADDER(2),U,2)
87 Q
88ANSSET ;save answers
89 S N=0 F S N=$O(^TMP($J,"YSQU","YSCROSS",N)) Q:N'>0 D
90 . Q:'$D(YSANS(N))
91 . S YS("AD")=YS84IEN
92 . S YS("QN")=^TMP($J,"YSQU","YSCROSS",N)
93 . S YS("CHOICE")=^TMP($J,"YSQU","YSCA",YS("QN"),YSANS(N)) ;ASF 10/19
94 . ;S YS(1)=YSANS(N)
95 . D SETANS^YTQAPI2(.YSDATA,.YS)
96 Q
97BOOL(YSOP) ;
98 S YSOP=$S(YSOP="Equals":"=",YSOP="Is greater than":">",YSOP="Is less than":"<",YSOP="Equals or is less than":"=<",YSOP="Equals or is greater than":"=>",1:"")
99 Q YSOP
Note: See TracBrowser for help on using the repository browser.