source: WorldVistAEHR/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YTQAPI5.m@ 949

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

initial load of WorldVistAEHR

File size: 4.7 KB
RevLine 
[613]1YTQAPI5 ;ALB/ASF- MHAX DISPLAYS ; 4/3/07 1:56pm
2 ;;5.01;MENTAL HEALTH;**85**;Dec 30, 1994;Build 49
3 Q
4SURVDAT(YSDATA,YS) ;ouput survey type data
5 N %DT,X,Y,YSAD,YSANSID,YSBEG,YSB,YSEND,YSLIMIT,YSN,YSQI,YSQID,YSQS
6 S YSCODE=$G(YS("CODE")) S:YSCODE="" YSCODE=0 I '$D(^YTT(601.71,"B",YSCODE)) S YSDATA(1)="[ERROR]",YSDATA(2)="bad tcode" Q ;-->out
7 S YSN=$O(^YTT(601.71,"B",YSCODE,0))
8 S YSBEG=$G(YS("BEGIN")) S:YSBEG="" YSBEG="01/01/1970" S X=YSBEG,%DT="T" D ^%DT S YSBEG=Y
9 S YSEND=$G(YS("END")) S:YSEND="" YSEND="01/01/2099" S X=YSEND,%DT="T" D ^%DT S YSEND=Y
10 S YSLIMIT=$G(YS("LIMIT")) S:YSLIMIT="" YSLIMIT=999
11 S YSB=0 F S YSB=$O(^YTT(601.84,"AC",YSN,YSB)) Q:YSB'>0 S YSAD=0 F S YSAD=$O(^YTT(601.84,"AC",YSN,YSB,YSAD)) Q:YSAD'>0 D
12 . Q:$P(^YTT(601.84,YSAD,0),U,9)'="Y" ;complete admins Only
13 . W !,"AD= ",YSAD
14 . S YSQS=0 F S YSQS=$O(^YTT(601.76,"AD",YSN,YSQS)) Q:YSQS'>0 D
15 .. S YSQI=$O(^YTT(601.76,"AD",YSN,YSQS,0)) S YSQID=$P(^YTT(601.76,YSQI,0),U,4)
16 .. W !,"QID= ",YSQID," QI= ",YSQI
17 .. S YSANSID=$O(^YTT(601.85,"AC",YSAD,YSQID,0))
18 .. Q:YSANSID=""
19 .. W !,"Answer: ",^YTT(601.85,YSANSID,1,1,0)
20 Q
21DISPLAY(YSDATA,YS) ;RETURN Dispaly Info
22 N N,N1,YSID
23 S YSDATA(1)="[DATA]"
24 S N=1,N1=0 F S N1=$O(YS(N1)) Q:N1'>0 D
25 . S N=N+1
26 . S YSID=YS(N1)
27 . S YSDATA(N)=$$DISPEXT^YTQAPI5(YSID)
28 . ;I '$D(^YTT(601.88,YSID,0)) S YSDATA(N)=YSID_U_"[ERROR] bad id" Q ;-->out
29 .;S YSDATA(N)=^YTT(601.88,YSID,0)
30 Q
31DISPEXT(YSID) ;EXTRINSIC 601.88
32 N YSEX,I
33 I '$D(^YTT(601.88,YSID,0)) S YSEX="[ERROR] BAD DISPLAY ID" Q YSEX
34 S YSEX=YSID
35 F I=1:1:11 S YSEX=YSEX_U_$$GET1^DIQ(601.88,YSID_",",I)
36 Q YSEX
37 ;
38ADMINS(YSDATA,YS) ;administration retrevial
39 ;input : DFN
40 ;output:Adm. ID^Inst. Name^Date Given^Date Saved^Orderer^Admin.By^Signed^# Answers^R_Privl^Is Legacy^INSTRUMENT id^Test IENS^copyright^location iens
41 N N,N4,G,DFN,YSIENS,YSDG,YSCODE,YSRPRIV,YSEXEMP,YSCODIEN,YSINC,YSISCOMP,YSX,YSX1,YSCODEN,YSANSN,YSLEG,YSLEGI,N1,N2,YSCOPY,YSLOCAT
42 S DFN=$G(YS("DFN"))
43 I DFN'?1N.N S YSDATA(1)="[ERROR]",YSDATA(2)="bad DFN" Q ;-->out
44 I '$D(^DPT(DFN,0)) S YSDATA(1)="[ERROR]",YSDATA(2)="nO pt" Q ;-->out
45 S YSINC=$G(YS("COMPLETE")) I (YSINC'="Y")&(YSINC'="N") S YSDATA(1)="[ERROR]",YSDATA(2)="bad complete flag" Q ;-->out
46 S YSIENS=0,N=2
47 S YSDATA(1)="[DATA]"
48 F S YSIENS=$O(^YTT(601.84,"C",DFN,YSIENS)) Q:YSIENS'>0 D
49 . S G=$G(^YTT(601.84,YSIENS,0))
50 . I G="" S YSDATA(1)="[ERROR]",YSDATA(2)=YSIENS_" bad ien in 84" Q ;-->out
51 . S YSISCOMP=$P(G,U,9)
52 . Q:YSISCOMP'=YSINC
53 . S YSDG=$P(G,U,4),YSCODE=$$GET1^DIQ(601.84,YSIENS_",",2)
54 . Q:YSCODE=""
55 . Q:'$D(^YTT(601.71,"B",YSCODE))
56 . S YSCODIEN=$O(^YTT(601.71,"B",YSCODE,0))
57 . S YSRPRIV=$$GET1^DIQ(601.71,YSCODIEN_",",9)
58 . S YSCOPY=$P($G(^YTT(601.71,YSCODIEN,8)),U,5)
59 . S YSLOCAT=$P($G(^YTT(601.84,YSIENS,0)),U,11)
60 . S YSLEG=$P($G(^YTT(601.71,YSCODIEN,8)),U,3)
61 . S YSLEGI="" S:YSLEG="Y" YSLEGI=$O(^YTT(601,"B",YSCODE,0))
62 . S YSX=YSIENS_U_YSCODE_U_YSDG_U_$P(G,U,5,8)_U_$P(G,U,10)_U_YSRPRIV_U_YSLEG_U_YSCODIEN_U_YSLEGI_U_YSCOPY_U_YSLOCAT
63 . S YSX(YSDG,YSCODE)=YSX
64 . S YSX1(YSCODE,YSDG)=""
65 D:YSINC="Y" LISTALL
66 D:YSINC="N" LISTINC
67 D SET
68 Q
69SET ;
70 S N=2,N1=9999999 F S N1=$O(YSX(N1),-1) Q:N1="" S YSCODE="" F S YSCODE=$O(YSX(N1,YSCODE)) Q:YSCODE="" S N=N+1,YSDATA(N)=YSX(N1,YSCODE)
71 S YSDATA(1)="[DATA]",YSDATA(2)=N-2_" administrations returned"
72 Q
73LISTALL ;
74 S N=0 F S N=$O(^YTD(601.2,DFN,1,N)) Q:N'>0 D
75 . ;I $P(^YTT(601,N,0),U,9)="I" QUIT
76 . I $D(^YTT(601,N)) S N2=0 F S N2=$O(^YTD(601.2,DFN,1,N,1,N2)) Q:N2'>0 D
77 .. S X=^YTT(601,N,0),N4=$P(X,U)
78 .. S YSCODIEN=$O(^YTT(601.71,"B",N4,0)) Q:YSCODIEN'>0 ;-->out
79 .. S YSRPRIV=$$GET1^DIQ(601.71,YSCODIEN_",",9)
80 .. S YSCOPY=$S($P(X,U,6)?1N.N:"Y",1:"N")
81 .. Q:$P(X,U,9)'="T"
82 .. Q:'$D(^YTD(601.2,DFN,1,N,1,N2,1))
83 .. S G=$G(^YTD(601.2,DFN,1,N,1,N2,0))
84 .. I N4="MMPI",$D(^YTD(601.2,DFN,1,N,1,N2,99)),^(99)="MMPIR" S N4="MMPR"
85 .. S YSX(N2,N4)=U_N4_U_$S($P(G,U,8)?7N.E:$P(G,U,8),1:N2)_U_N2_U_$P(G,U,3,4)_U_U_U_YSRPRIV_U_"Y"_U_U_N_U_YSCOPY_U ;ASF 12/19/06
86 .. Q
87 Q
88LISTINC ;list all incompletes for a pt
89 ;output:Adm. ID1^Inst. Name2^Date Given3^Date Saved4^Orderer5^Admin.By6^Signed7^# Answers8^R_Privl9^Is Legacy10^INSTRUMENT id11^Test IENS12^is COPY
90 S N1=0 F S N1=$O(^YTD(601.4,DFN,1,N1)) Q:N1'>0 D
91 . S G=$G(^YTD(601.4,DFN,1,N1,0))
92 . S YSCODE=$P($G(^YTT(601,N1,0)),U),YSDG=$P(G,U,2)
93 . S YSCODEN=N1
94 . S YSCOPY=$P(^YTT(601,N1,0),U,6) S YSCOPY=$S(+YSCOPY:"Y",1:"N")
95 . I YSCODE?1"CLERK".E S YSCODEN=$P(G,U,6) S:YSCODEN>0 YSCODE=$P(^YTT(601,YSCODEN,0),U)
96 . S YSCODIEN=$O(^YTT(601.71,"B",YSCODE,0)) Q:YSCODIEN'>0 ;-->out
97 . S YSRPRIV=$$GET1^DIQ(601.71,YSCODIEN_",",9)
98 . Q:$P(^YTT(601,YSCODEN,0),U,9)'="T"
99 . S YSANSN=$P(G,U,4) S:YSANSN?1N.E YSANSN=YSANSN-1
100 . S YSX(YSDG,YSCODE)=U_YSCODE_U_YSDG_U_$P(G,U,8)_U_$P(G,U,7)_U_U_U_YSANSN_U_YSRPRIV_U_"Y"_U_U_YSCODEN_U_YSCOPY_U
101 Q
Note: See TracBrowser for help on using the repository browser.