AMQQSQS ;IHS/CMI/THL - SETS INSTRUCTIONS FOR SUBQUERY ATTRIBUTES ;
;;2.0;IHS PCC SUITE;**6,7**;MAY 14, 2009
;-----
RUN I AMQQSQFN=1 D SET1
D FLAGS
I $G(AMQQSQNC) S AMQQNOCO=AMQQSQNC
I $D(AMQQSQNT) S AMQQNOT=""
I '$D(AMQQSQSC),$D(AMQQSQRC) S AMQQSQRC=AMQQSQNN
I '$D(AMQQSQSC),$D(AMQQSQAA) D SET2
I '$D(AMQQSQSC),"LVM"'[$E(AMQQSQCT) D SET3
D ^AMQQSQL
EXIT K AMQQSQSC,%
Q
;
SET1 ; ENTRY POINT FROM AMQQSQP
S AMQQUSQN=AMQQUSQN+1
S AMQQSQNN=AMQQUSQN
S AMQQFSQN=""
S %=AMQQSQAN
I $G(AMQQSQST)="I",$P($G(AMQQCOMP),";",4)'="" S %=%_" ("_$P(AMQQCOMP,";",4)_")"
I '$D(AMQQXX) S ^UTILITY("AMQQ",$J,"SQL",AMQQSQNN,.1)="W "_$S($D(AMQQGVF):"!!?3",1:("?"_(3*AMQQUSQL+6)))_",@AMQQRV,"""_$S($D(AMQQGVF):"Generic VISIT conditions",1:("Subject of subquery: "_%))_""",@AMQQNV"
I '$D(AMQQXX),AMQQLINK>764,AMQQLINK<768 S ^UTILITY("AMQQ",$J,"SQL",AMQQSQNN,.1)=^UTILITY("AMQQ",$J,"SQL",AMQQSQNN,.1)_" days"
I '$D(AMQQLSQF) S AMQQLSQF=AMQQSQNN
K ^UTILITY("AMQQ",$J,"SQ",AMQQSQNN)
Q
;
SET2 I AMQQUSQL>1 S ^UTILITY("AMQQ",$J,"SQXS",AMQQSQAA,AMQQSQNN)="",AMQQSQDF="" Q
S ^UTILITY("AMQQ",$J,"SQXQ",AMQQSQAA,AMQQSQNN)=""
K AMQQSQAA
Q
;
SET3 I AMQQSQCT'="B" G SETSQ
S %=^AMQQ(4,AMQQSQTP,0),%=$P(%,U)
I "EV"[% S AMQQSQF1="BP",AMQQSQF2="AMQQF1" G SETSQ
SETSQ S ^UTILITY("AMQQ",$J,"SQ",AMQQSQNN,AMQQSQFN)=AMQQSQN_U_AMQQSQNM_U_AMQQSQTP_U_AMQQSQF1_U_AMQQSQF2_U_AMQQSQCT_U_AMQQSQCV_U_$D(AMQQSQNT)
Q
;
FLAGS I AMQQSQCT="C" S (AMQQSQGF,AMQQSQCF)="" S:AMQQUSQL=1 AMQQFRED=1 Q
I AMQQSQCT="T" S (AMQQSQTF,AMQQSQGF)="" Q
I '$D(AMQQSQGF),AMQQSQCT="B",'$D(AMQQSQBF) D SETCOMPV Q
I (AMQQSQN=59!((AMQQSQN>315)&(AMQQSQN<319))),'$D(AMQQSQGF),'$D(AMQQSQDF) K AMQQSQQF D SETCOMPD Q
I '$D(AMQQSQGF),AMQQSQCT="D",'$D(AMQQSQDF) D SETCOMPD Q
I '$D(AMQQSQGF),AMQQSQCT="S",'$D(AMQQSQBF) D SETCOMPS Q
I '$D(AMQQSQGF),AMQQSQNM="LAST" S (AMQQSQGF,AMQQSQSC)="",$P(AMQQCOMP,";",3)=AMQQSQCV Q
I AMQQSQCT="N" S AMQQSQNF="" Q
I "MOL"[AMQQSQCT S AMQQSQGF="" Q
Q
;
SETCOMPV S AMQQSQBF=""
I $D(AMQQSQNT) S AMQQSQBS="'"_AMQQSQBS
I $P(AMQQCOMP,";",4)="" S AMQQSQSC=""
I $G(AMQQSQST)="E"!($G(AMQQSQST)="V") S $P(AMQQCOMP,";",4)=AMQQSQCV Q
I AMQQSQCV'[";" S $P(AMQQCOMP,";",4)=AMQQSQBS_":"_AMQQSQCV S:$D(AMQQRECV) $P(AMQQRECV,U,11)=$P(AMQQCOMP,";",4) Q
S $P(AMQQCOMP,";",4)="'<:"_$P(AMQQSQCV,";")_":'>:"_$P(AMQQSQCV,";",2)
Q
;
SETCOMPS S AMQQSQBF=""
I $D(AMQQSQNT) S AMQQSQBS="'"_AMQQSQBS
I $P(AMQQCOMP,";",4)="" S AMQQSQSC=""
S $P(AMQQCOMP,";",4)=AMQQSQBS_":"_AMQQSQCV
S $P(AMQQRECV,U,11)=$P(AMQQCOMP,";",4)
Q
;
SETCOMPD S AMQQSQDF=""
S:'$D(AMQQCOMP) AMQQCOMP=""
I $P(AMQQCOMP,";")="" S AMQQSQSC=""
I AMQQSQCV[";" F %=1,2 S $P(AMQQCOMP,";",%)=$P(AMQQSQCV,";",%) I %=2 G SETCEXIT
I AMQQSQBS="<" S $P(AMQQCOMP,";",1)=0,$P(AMQQCOMP,";",2)=AMQQSQCV Q
I AMQQSQBS="=" S $P(AMQQCOMP,";",1)=AMQQSQCV,$P(AMQQCOMP,";",2)=AMQQSQCV Q
S $P(AMQQCOMP,";",1)=AMQQSQCV
S $P(AMQQCOMP,";",2)=9999999
SETCEXIT Q
;
AMQQSQS ;IHS/CMI/THL - SETS INSTRUCTIONS FOR SUBQUERY ATTRIBUTES ;
+1 ;;2.0;IHS PCC SUITE;**6,7**;MAY 14, 2009
+2 ;-----
RUN IF AMQQSQFN=1
DO SET1
+1 DO FLAGS
+2 IF $GET(AMQQSQNC)
SET AMQQNOCO=AMQQSQNC
+3 IF $DATA(AMQQSQNT)
SET AMQQNOT=""
+4 IF '$DATA(AMQQSQSC)
IF $DATA(AMQQSQRC)
SET AMQQSQRC=AMQQSQNN
+5 IF '$DATA(AMQQSQSC)
IF $DATA(AMQQSQAA)
DO SET2
+6 IF '$DATA(AMQQSQSC)
IF "LVM"'[$EXTRACT(AMQQSQCT)
DO SET3
+7 DO ^AMQQSQL
EXIT KILL AMQQSQSC,%
+1 QUIT
+2 ;
SET1 ; ENTRY POINT FROM AMQQSQP
+1 SET AMQQUSQN=AMQQUSQN+1
+2 SET AMQQSQNN=AMQQUSQN
+3 SET AMQQFSQN=""
+4 SET %=AMQQSQAN
+5 IF $GET(AMQQSQST)="I"
IF $PIECE($GET(AMQQCOMP),";",4)'=""
SET %=%_" ("_$PIECE(AMQQCOMP,";",4)_")"
+6 IF '$DATA(AMQQXX)
SET ^UTILITY("AMQQ",$JOB,"SQL",AMQQSQNN,.1)="W "_$SELECT($DATA(AMQQGVF):"!!?3",1:("?"_(3*AMQQUSQL+6)))_",@AMQQRV,"""_$SELECT($DATA(AMQQGVF):"Generic VISIT conditions",1:("Subject of subquery: "_%))_""",@AMQQNV"
+7 IF '$DATA(AMQQXX)
IF AMQQLINK>764
IF AMQQLINK<768
SET ^UTILITY("AMQQ",$JOB,"SQL",AMQQSQNN,.1)=^UTILITY("AMQQ",$JOB,"SQL",AMQQSQNN,.1)_" days"
+8 IF '$DATA(AMQQLSQF)
SET AMQQLSQF=AMQQSQNN
+9 KILL ^UTILITY("AMQQ",$JOB,"SQ",AMQQSQNN)
+10 QUIT
+11 ;
SET2 IF AMQQUSQL>1
SET ^UTILITY("AMQQ",$JOB,"SQXS",AMQQSQAA,AMQQSQNN)=""
SET AMQQSQDF=""
QUIT
+1 SET ^UTILITY("AMQQ",$JOB,"SQXQ",AMQQSQAA,AMQQSQNN)=""
+2 KILL AMQQSQAA
+3 QUIT
+4 ;
SET3 IF AMQQSQCT'="B"
GOTO SETSQ
+1 SET %=^AMQQ(4,AMQQSQTP,0)
SET %=$PIECE(%,U)
+2 IF "EV"[%
SET AMQQSQF1="BP"
SET AMQQSQF2="AMQQF1"
GOTO SETSQ
SETSQ SET ^UTILITY("AMQQ",$JOB,"SQ",AMQQSQNN,AMQQSQFN)=AMQQSQN_U_AMQQSQNM_U_AMQQSQTP_U_AMQQSQF1_U_AMQQSQF2_U_AMQQSQCT_U_AMQQSQCV_U_$DATA(AMQQSQNT)
+1 QUIT
+2 ;
FLAGS IF AMQQSQCT="C"
SET (AMQQSQGF,AMQQSQCF)=""
IF AMQQUSQL=1
SET AMQQFRED=1
QUIT
+1 IF AMQQSQCT="T"
SET (AMQQSQTF,AMQQSQGF)=""
QUIT
+2 IF '$DATA(AMQQSQGF)
IF AMQQSQCT="B"
IF '$DATA(AMQQSQBF)
DO SETCOMPV
QUIT
+3 IF (AMQQSQN=59!((AMQQSQN>315)&(AMQQSQN<319)))
IF '$DATA(AMQQSQGF)
IF '$DATA(AMQQSQDF)
KILL AMQQSQQF
DO SETCOMPD
QUIT
+4 IF '$DATA(AMQQSQGF)
IF AMQQSQCT="D"
IF '$DATA(AMQQSQDF)
DO SETCOMPD
QUIT
+5 IF '$DATA(AMQQSQGF)
IF AMQQSQCT="S"
IF '$DATA(AMQQSQBF)
DO SETCOMPS
QUIT
+6 IF '$DATA(AMQQSQGF)
IF AMQQSQNM="LAST"
SET (AMQQSQGF,AMQQSQSC)=""
SET $PIECE(AMQQCOMP,";",3)=AMQQSQCV
QUIT
+7 IF AMQQSQCT="N"
SET AMQQSQNF=""
QUIT
+8 IF "MOL"[AMQQSQCT
SET AMQQSQGF=""
QUIT
+9 QUIT
+10 ;
SETCOMPV SET AMQQSQBF=""
+1 IF $DATA(AMQQSQNT)
SET AMQQSQBS="'"_AMQQSQBS
+2 IF $PIECE(AMQQCOMP,";",4)=""
SET AMQQSQSC=""
+3 IF $GET(AMQQSQST)="E"!($GET(AMQQSQST)="V")
SET $PIECE(AMQQCOMP,";",4)=AMQQSQCV
QUIT
+4 IF AMQQSQCV'[";"
SET $PIECE(AMQQCOMP,";",4)=AMQQSQBS_":"_AMQQSQCV
IF $DATA(AMQQRECV)
SET $PIECE(AMQQRECV,U,11)=$PIECE(AMQQCOMP,";",4)
QUIT
+5 SET $PIECE(AMQQCOMP,";",4)="'<:"_$PIECE(AMQQSQCV,";")_":'>:"_$PIECE(AMQQSQCV,";",2)
+6 QUIT
+7 ;
SETCOMPS SET AMQQSQBF=""
+1 IF $DATA(AMQQSQNT)
SET AMQQSQBS="'"_AMQQSQBS
+2 IF $PIECE(AMQQCOMP,";",4)=""
SET AMQQSQSC=""
+3 SET $PIECE(AMQQCOMP,";",4)=AMQQSQBS_":"_AMQQSQCV
+4 SET $PIECE(AMQQRECV,U,11)=$PIECE(AMQQCOMP,";",4)
+5 QUIT
+6 ;
SETCOMPD SET AMQQSQDF=""
+1 IF '$DATA(AMQQCOMP)
SET AMQQCOMP=""
+2 IF $PIECE(AMQQCOMP,";")=""
SET AMQQSQSC=""
+3 IF AMQQSQCV[";"
FOR %=1,2
SET $PIECE(AMQQCOMP,";",%)=$PIECE(AMQQSQCV,";",%)
IF %=2
GOTO SETCEXIT
+4 IF AMQQSQBS="<"
SET $PIECE(AMQQCOMP,";",1)=0
SET $PIECE(AMQQCOMP,";",2)=AMQQSQCV
QUIT
+5 IF AMQQSQBS="="
SET $PIECE(AMQQCOMP,";",1)=AMQQSQCV
SET $PIECE(AMQQCOMP,";",2)=AMQQSQCV
QUIT
+6 SET $PIECE(AMQQCOMP,";",1)=AMQQSQCV
+7 SET $PIECE(AMQQCOMP,";",2)=9999999
SETCEXIT QUIT
+1 ;