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

YTQAPI5.m

Go to the documentation of this file.
YTQAPI5 ;ALB/ASF - MHAX DISPLAYS ; 1/14/09 4:14pm
 ;;5.01;MENTAL HEALTH;**85,102,96,240**;Dec 30, 1994;Build 10
 ;
 ;
 ;Reference to ^DPT global (PATIENT - #2) supported by DBIA #10061
 ;Reference to XPDMENU API supported by DBIA #1157
 ;Reference to XQCHK API supported by DBIA #10078
 Q
SURVDAT(YSDATA,YS) ;output survey type data
 N %DT,X,Y,YSAD,YSANSID,YSBEG,YSB,YSEND,YSLIMIT,YSN,YSQI,YSQID,YSQS
 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
 S YSN=$O(^YTT(601.71,"B",YSCODE,0))
 S YSBEG=$G(YS("BEGIN")) S:YSBEG="" YSBEG="01/01/1970" S X=YSBEG,%DT="T" D ^%DT S YSBEG=Y
 S YSEND=$G(YS("END")) S:YSEND="" YSEND="01/01/2099" S X=YSEND,%DT="T" D ^%DT S YSEND=Y
 S YSLIMIT=$G(YS("LIMIT")) S:YSLIMIT="" YSLIMIT=999
 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
 . Q:$P(^YTT(601.84,YSAD,0),U,9)'="Y"  ;complete admins Only
 . W !,"AD= ",YSAD
 . S YSQS=0 F  S YSQS=$O(^YTT(601.76,"AD",YSN,YSQS)) Q:YSQS'>0  D
 .. S YSQI=$O(^YTT(601.76,"AD",YSN,YSQS,0)) S YSQID=$P(^YTT(601.76,YSQI,0),U,4)
 .. W !,"QID= ",YSQID," QI= ",YSQI
 .. S YSANSID=$O(^YTT(601.85,"AC",YSAD,YSQID,0))
 .. Q:YSANSID=""
 .. W !,"Answer: ",^YTT(601.85,YSANSID,1,1,0)
 Q
DISPLAY(YSDATA,YS) ;RETURN Display Info
 N N,N1,YSID
 S YSDATA(1)="[DATA]"
 S N=1,N1=0 F  S N1=$O(YS(N1)) Q:N1'>0  D
 . S N=N+1
 . S YSID=YS(N1)
 . S YSDATA(N)=$$DISPEXT^YTQAPI5(YSID)
 . ;I '$D(^YTT(601.88,YSID,0)) S YSDATA(N)=YSID_U_"[ERROR] bad id" Q  ;-->out
 .;S YSDATA(N)=^YTT(601.88,YSID,0)
 Q
DISPEXT(YSID) ;EXTRINSIC 601.88
 N YSEX,I
 I '$D(^YTT(601.88,YSID,0)) S YSEX="[ERROR] BAD DISPLAY ID" Q YSEX
 S YSEX=YSID
 F I=1:1:11 S YSEX=YSEX_U_$$GET1^DIQ(601.88,YSID_",",I)
 Q YSEX
 ;
ADMINS(YSDATA,YS) ;administration retrieval
 ;input : DFN
 ;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^DAY RESTART^SOURCE
 N N,N4,G,DFN,YSIENS,YSDG,YSCODE,YSRPRIV,YSEXEMP,YSCODIEN,YSINC,YSISCOMP,YSX,YSX1,YSCODEN,YSANSN,YSLEG,YSLEGI,N1,N2,YSCOPY,YSLOCAT,YSREST,YSSRC
 S DFN=$G(YS("DFN"))
 I DFN'?1N.NP S YSDATA(1)="[ERROR]",YSDATA(2)="bad DFN" Q  ;-->out asf 2/22/08
 I '$D(^DPT(DFN,0)) S YSDATA(1)="[ERROR]",YSDATA(2)="no pt" Q  ;-->out
 S YSINC=$G(YS("COMPLETE")) I (YSINC'="Y")&(YSINC'="N") S YSDATA(1)="[ERROR]",YSDATA(2)="bad complete flag" Q  ;-->out
 S YSIENS=0,N=2
 S YSDATA(1)="[DATA]"
 F  S YSIENS=$O(^YTT(601.84,"C",DFN,YSIENS)) Q:YSIENS'>0  D
 . S G=$G(^YTT(601.84,YSIENS,0))
 . I G="" S YSDATA(1)="[ERROR]",YSDATA(2)=YSIENS_" bad ien in 84" Q  ;-->out
 . S YSISCOMP=$P(G,U,9)
 . Q:YSISCOMP'=YSINC
 . S YSDG=$P(G,U,4),YSCODE=$$GET1^DIQ(601.84,YSIENS_",",2)
 . Q:YSCODE=""
 . Q:'$D(^YTT(601.71,"B",YSCODE))
 . S YSCODIEN=$O(^YTT(601.71,"B",YSCODE,0))
 . S YSRPRIV=$$GET1^DIQ(601.71,YSCODIEN_",",9)
 . S YSREST=$$GET1^DIQ(601.71,YSCODIEN_",",27)
 . S YSCOPY=$P($G(^YTT(601.71,YSCODIEN,8)),U,5)
 . S YSLOCAT=$P($G(^YTT(601.84,YSIENS,0)),U,11)
 . S YSSRC=$P($G(^YTT(601.84,YSIENS,0)),U,13) I YSSRC S YSSRC=$P($G(^YTT(601.844,+YSSRC,0)),U)
 . S YSLEG=$P($G(^YTT(601.71,YSCODIEN,8)),U,3)
 . S YSLEGI="" S:YSLEG="Y" YSLEGI=$O(^YTT(601,"B",YSCODE,0))
 . 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_U_YSREST_U_YSSRC
 . F  Q:'$D(YSX(YSDG,YSCODE))  S YSDG=YSDG+.00000001 ;ASF 1/14/09
 . S YSX(YSDG,YSCODE)=YSX
 . S YSX1(YSCODE,YSDG)=""
 D:YSINC="Y" LISTALL
 D:YSINC="N" LISTINC
 D SET
 Q
SET ;
 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)
 S YSDATA(1)="[DATA]",YSDATA(2)=N-2_" administrations returned"
 Q
LISTALL ;
 S N=0 F  S N=$O(^YTD(601.2,DFN,1,N)) Q:N'>0  D
 . ;I $P(^YTT(601,N,0),U,9)="I"  QUIT
 . I $D(^YTT(601,N)) S N2=0 F  S N2=$O(^YTD(601.2,DFN,1,N,1,N2)) Q:N2'>0  D
 .. S X=^YTT(601,N,0),N4=$P(X,U)
 .. S YSCODIEN=$O(^YTT(601.71,"B",N4,0)) Q:YSCODIEN'>0  ;-->out
 .. S YSRPRIV=$$GET1^DIQ(601.71,YSCODIEN_",",9)
 .. S YSCOPY=$S($P(X,U,6)?1N.N:"Y",1:"N")
 .. Q:$P(X,U,9)'="T"
 .. Q:'$D(^YTD(601.2,DFN,1,N,1,N2,1))
 .. S G=$G(^YTD(601.2,DFN,1,N,1,N2,0))
 .. I N4="MMPI",$D(^YTD(601.2,DFN,1,N,1,N2,99)),^(99)="MMPIR" S N4="MMPR"
 .. 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
 .. Q
 Q
LISTINC ;list all incompletes for a pt
 ;output:Adm. ID1^Inst. Name2^Date Given3^Date Saved4^Orderer5^Admin.By6^Signed7^# Answers8^R_Privl9^Is Legacy10^INSTRUMENT id11^Test IENS12^is COPY
 S N1=0 F  S N1=$O(^YTD(601.4,DFN,1,N1)) Q:N1'>0  D
 . S G=$G(^YTD(601.4,DFN,1,N1,0))
 . S YSCODE=$P($G(^YTT(601,N1,0)),U),YSDG=$P(G,U,2)
 . S YSCODEN=N1
 . S YSCOPY=$P(^YTT(601,N1,0),U,6) S YSCOPY=$S(+YSCOPY:"Y",1:"N")
 . I YSCODE?1"CLERK".E S YSCODEN=$P(G,U,6) S:YSCODEN>0 YSCODE=$P(^YTT(601,YSCODEN,0),U)
 . S YSCODIEN=$O(^YTT(601.71,"B",YSCODE,0)) Q:YSCODIEN'>0  ;-->out
 . S YSRPRIV=$$GET1^DIQ(601.71,YSCODIEN_",",9)
 . Q:$P(^YTT(601,YSCODEN,0),U,9)'="T"
 . S YSANSN=$P(G,U,4) S:YSANSN?1N.E YSANSN=YSANSN-1
 . 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
 Q
DELADMIN(YSDATA,YS) ;delete an administration of a test ASF 1/14/09
 N DIK,YSAD,YSANS,YSRESUL,YSMENU,YSPRIV,YSEVDFN,YSEVTST,YSEVCPLT
 N DA
 S YSAD=$G(YS("AD"))
 I YSAD'?1N.N S YSDATA(1)="[ERROR]",YSDATA(2)="bad 601.84 IEN" Q  ;-->out
 S YSMENU=$$LKOPT^XPDMENU("YSMANAGER")
 I YSMENU'>0 S YSDATA(1)="[ERROR]",YSDATA(2)="no ysmanager MENU" Q  ;-->out
 S YSPRIV=$$ACCESS^XQCHK(DUZ,YSMENU)
 I YSPRIV'>0 S YSDATA(1)="[ERROR]",YSDATA(2)="no privilege" Q  ;-->out
 S YSEVDFN=+$P($G(^YTT(601.84,+YSAD,0)),U,2)
 S YSEVTST=+$P($G(^YTT(601.84,+YSAD,0)),U,3)
 S YSEVTST=$P($G(^YTT(601.71,YSEVTST,0)),U)
 S YSEVCPLT=($P($G(^YTT(601.84,+YSAD,0)),U,9)="Y")
 S DIK="^YTT(601.84,",DA=YSAD D ^DIK
 S YSANS=0 F  S YSANS=$O(^YTT(601.85,"AD",YSAD,YSANS)) Q:YSANS'>0  D
 . S DIK="^YTT(601.85,",DA=YSANS D ^DIK
 S YSRESUL=0 F  S YSRESUL=$O(^YTT(601.92,"AC",YSAD,YSRESUL)) Q:YSRESUL'>0  D
 . S DIK="^YTT(601.92,",DA=YSRESUL D ^DIK
 S YSDATA(1)="[DATA]",YSDATA(2)=YSAD_" deleted"
 ; publish delete event for admin if it was completed
 I YSEVCPLT D DELETE^YTQEVNT(YSAD,YSEVDFN,YSEVTST,"windel")
 Q