FSCRPCQ ;SLC/STAFF-NOIS RPC Query ;4/24/98 16:02
;;1.1;NOIS;;Sep 06, 1998
;
QUERY(IN,OUT) ; from FSCRPX (RPCQuery)
N COUNT,CRITERIA,LISTCNT,MAX,NUM,OPNUM K CRITERIA
K ^TMP("FSC LIST",$J),^TMP("FSC NEWLIST",$J),^TMP("FSC USELIST",$J),^TMP("FSC CRITERIA",$J)
S (LISTCNT,CALL)=0 F S CALL=$O(^TMP("FSC CURRENT LIST",$J,"C",CALL)) Q:CALL<1 S ^TMP("FSC LIST",$J,CALL,0)=CALL,LISTCNT=LISTCNT+1
D PROCESS
S OPNUM=0 F S OPNUM=$O(^TMP("FSC CRITERIA",$J,OPNUM)) Q:OPNUM<1 D
.K CRITERIA M CRITERIA=^TMP("FSC CRITERIA",$J,OPNUM)
.D OPTIMIZE^FSCQO(.CRITERIA)
.D QUERY^FSCQR("",.LISTCNT,.CRITERIA)
K ^TMP("FSC CURRENT LIST",$J)
S COUNT=0,MAX=$$MAX^FSCRPCL
S NUM="A" F S NUM=$O(^TMP("FSC LIST",$J,NUM),-1) Q:NUM="" S CALL=+^(NUM,0) D SETUP^FSCRPCA(CALL,.COUNT) Q:COUNT>MAX
D OUTPUT^FSCRPCA
K ^TMP("FSC LIST",$J),^TMP("FSC NEWLIST",$J),^TMP("FSC USELIST",$J),^TMP("FSC CRITERIA",$J)
Q
;
PROCESS ;
N COND,EXT,FLD,FLDCNT,LINE,NUM,OP,OPCNT,STEPCNT,VALUE
S (OPCNT,STEPCNT,FLDCNT)=0
S NUM=0 F S NUM=$O(^TMP("FSCRPC",$J,"INPUT",NUM)) Q:NUM<1 S LINE=^(NUM) I $L(LINE) D
.S OP=$P(LINE,U),EXT=$P(LINE,U,2),FLD=$P(LINE,U,3),COND=$P(LINE,U,4),VALUE=$P(LINE,U,5,99)
.I COND="not exist" S COND="not exists" ;*** temp fix for gui
.I $L(OP) S OPCNT=OPCNT+1,STEPCNT=1,FLDCNT=0,^TMP("FSC CRITERIA",$J,OPCNT,0)=OP_"^1^0"
.I EXT="or" S STEPCNT=STEPCNT+1,FLDCNT=0,$P(^TMP("FSC CRITERIA",$J,OPCNT,0),U,2)=STEPCNT
.S FLDCNT=FLDCNT+1,^TMP("FSC CRITERIA",$J,OPCNT,STEPCNT)=FLDCNT
.S ^TMP("FSC CRITERIA",$J,OPCNT,STEPCNT,FLDCNT)=FLD_U_COND_U_VALUE
.S ^TMP("FSC CRITERIA",$J,OPCNT,STEPCNT,FLDCNT,1)=EXT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFSCRPCQ 1630 printed Oct 16, 2024@18:20:21 Page 2
FSCRPCQ ;SLC/STAFF-NOIS RPC Query ;4/24/98 16:02
+1 ;;1.1;NOIS;;Sep 06, 1998
+2 ;
QUERY(IN,OUT) ; from FSCRPX (RPCQuery)
+1 NEW COUNT,CRITERIA,LISTCNT,MAX,NUM,OPNUM
KILL CRITERIA
+2 KILL ^TMP("FSC LIST",$JOB),^TMP("FSC NEWLIST",$JOB),^TMP("FSC USELIST",$JOB),^TMP("FSC CRITERIA",$JOB)
+3 SET (LISTCNT,CALL)=0
FOR
SET CALL=$ORDER(^TMP("FSC CURRENT LIST",$JOB,"C",CALL))
if CALL<1
QUIT
SET ^TMP("FSC LIST",$JOB,CALL,0)=CALL
SET LISTCNT=LISTCNT+1
+4 DO PROCESS
+5 SET OPNUM=0
FOR
SET OPNUM=$ORDER(^TMP("FSC CRITERIA",$JOB,OPNUM))
if OPNUM<1
QUIT
Begin DoDot:1
+6 KILL CRITERIA
MERGE CRITERIA=^TMP("FSC CRITERIA",$JOB,OPNUM)
+7 DO OPTIMIZE^FSCQO(.CRITERIA)
+8 DO QUERY^FSCQR("",.LISTCNT,.CRITERIA)
End DoDot:1
+9 KILL ^TMP("FSC CURRENT LIST",$JOB)
+10 SET COUNT=0
SET MAX=$$MAX^FSCRPCL
+11 SET NUM="A"
FOR
SET NUM=$ORDER(^TMP("FSC LIST",$JOB,NUM),-1)
if NUM=""
QUIT
SET CALL=+^(NUM,0)
DO SETUP^FSCRPCA(CALL,.COUNT)
if COUNT>MAX
QUIT
+12 DO OUTPUT^FSCRPCA
+13 KILL ^TMP("FSC LIST",$JOB),^TMP("FSC NEWLIST",$JOB),^TMP("FSC USELIST",$JOB),^TMP("FSC CRITERIA",$JOB)
+14 QUIT
+15 ;
PROCESS ;
+1 NEW COND,EXT,FLD,FLDCNT,LINE,NUM,OP,OPCNT,STEPCNT,VALUE
+2 SET (OPCNT,STEPCNT,FLDCNT)=0
+3 SET NUM=0
FOR
SET NUM=$ORDER(^TMP("FSCRPC",$JOB,"INPUT",NUM))
if NUM<1
QUIT
SET LINE=^(NUM)
IF $LENGTH(LINE)
Begin DoDot:1
+4 SET OP=$PIECE(LINE,U)
SET EXT=$PIECE(LINE,U,2)
SET FLD=$PIECE(LINE,U,3)
SET COND=$PIECE(LINE,U,4)
SET VALUE=$PIECE(LINE,U,5,99)
+5 ;*** temp fix for gui
IF COND="not exist"
SET COND="not exists"
+6 IF $LENGTH(OP)
SET OPCNT=OPCNT+1
SET STEPCNT=1
SET FLDCNT=0
SET ^TMP("FSC CRITERIA",$JOB,OPCNT,0)=OP_"^1^0"
+7 IF EXT="or"
SET STEPCNT=STEPCNT+1
SET FLDCNT=0
SET $PIECE(^TMP("FSC CRITERIA",$JOB,OPCNT,0),U,2)=STEPCNT
+8 SET FLDCNT=FLDCNT+1
SET ^TMP("FSC CRITERIA",$JOB,OPCNT,STEPCNT)=FLDCNT
+9 SET ^TMP("FSC CRITERIA",$JOB,OPCNT,STEPCNT,FLDCNT)=FLD_U_COND_U_VALUE
+10 SET ^TMP("FSC CRITERIA",$JOB,OPCNT,STEPCNT,FLDCNT,1)=EXT
End DoDot:1
+11 QUIT