FSCLMPMQ ;SLC/STAFF-NOIS List Manager Protocol Modify Query ;4/22/94 11:04
;;1.1;NOIS;;Sep 06, 1998
;
QDESC(ARRAY,DESC,CRITERIA) ; from FSCLDU, FSCLMPMS
N COND,DEFINE,DESCNT,EXT,FCOND,FLD,FLDNAME,LCOND,LINE,OPER,PAREN,STEP,VALNAME,VALUE,X K CRITERIA,DESC
S DEFINE=0,DESC(0)="List: "_FSCLNAME
S PAREN="closed",(DESCNT,FCOND,LINE)=0,STEP=1 F S LINE=$O(ARRAY(LINE)) Q:LINE<1 D
.S X=ARRAY(LINE),OPER=$P(X,U,2),EXT=$P(X,U,3),FLD=$P(X,U,4),COND=$P(X,U,5),VALUE=$P(X,U,6)
.S OPER=$S(OPER="A":"Add",OPER="R":"Remove",OPER="S":"Select",1:"")
.S EXT=$S(EXT="A":"and",EXT="O":"or",1:"")
.S FLDNAME=$P(^FSC("FLD",+FLD,0),U)
.S COND=$P(^FSC("COND",+COND,0),U,2)
.S VALNAME=VALUE I $P(^FSC("FLD",+FLD,0),U,8),"DNP"[$E($P(^(0),U,3)) S VALNAME=$$VALUE^FSCGET(VALUE,7100,+$P(^(0),U,8))
.I $L(VALUE),"FW"[$E($P(^FSC("FLD",+FLD,0),U,3)) S VALNAME=""""_VALUE_""""
.I $L(OPER),$D(CRITERIA) D
..S $P(CRITERIA(0),U,2)=STEP
..I PAREN="open" S CRITERIA(STEP,FCOND,0)=CRITERIA(STEP,FCOND,0)_")"
..D DESC^FSCQD(.DESCNT,.CRITERIA)
..K CRITERIA
..S CRITERIA(0)=OPER_"^^0"
..S FCOND=0,PAREN="closed",STEP=1
.I $L(OPER),'$D(CRITERIA) S CRITERIA(0)=OPER_"^^0"
.I EXT="or" D
..S STEP=STEP+1,FCOND=0
..I PAREN="closed" S PAREN="ready"
..I PAREN="open" S PAREN="closed",LCOND=CRITERIA(STEP-1),CRITERIA(STEP-1,LCOND,1)=CRITERIA(STEP-1,LCOND,1)_")"
.I EXT="and",PAREN="ready" S PAREN="open",CRITERIA(STEP,FCOND,0)="("_CRITERIA(STEP,FCOND,0)
.S FCOND=FCOND+1
.S CRITERIA(STEP)=FCOND
.S CRITERIA(STEP,FCOND)=FLD_U_COND_U_VALUE
.S CRITERIA(STEP,FCOND,0)=FLDNAME_" "_COND_$S($L(VALNAME):" "_VALNAME,1:"")
.S CRITERIA(STEP,FCOND,1)=EXT
I PAREN="open" S CRITERIA(STEP,FCOND,0)=CRITERIA(STEP,FCOND,0)_")"
S $P(CRITERIA(0),U,2)=STEP
I $D(CRITERIA) D DESC^FSCQD(.DESCNT,.CRITERIA)
S DESC(0)=$P(DESC(0)," (MODIFIED)")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFSCLMPMQ 1848 printed Oct 16, 2024@18:18:56 Page 2
FSCLMPMQ ;SLC/STAFF-NOIS List Manager Protocol Modify Query ;4/22/94 11:04
+1 ;;1.1;NOIS;;Sep 06, 1998
+2 ;
QDESC(ARRAY,DESC,CRITERIA) ; from FSCLDU, FSCLMPMS
+1 NEW COND,DEFINE,DESCNT,EXT,FCOND,FLD,FLDNAME,LCOND,LINE,OPER,PAREN,STEP,VALNAME,VALUE,X
KILL CRITERIA,DESC
+2 SET DEFINE=0
SET DESC(0)="List: "_FSCLNAME
+3 SET PAREN="closed"
SET (DESCNT,FCOND,LINE)=0
SET STEP=1
FOR
SET LINE=$ORDER(ARRAY(LINE))
if LINE<1
QUIT
Begin DoDot:1
+4 SET X=ARRAY(LINE)
SET OPER=$PIECE(X,U,2)
SET EXT=$PIECE(X,U,3)
SET FLD=$PIECE(X,U,4)
SET COND=$PIECE(X,U,5)
SET VALUE=$PIECE(X,U,6)
+5 SET OPER=$SELECT(OPER="A":"Add",OPER="R":"Remove",OPER="S":"Select",1:"")
+6 SET EXT=$SELECT(EXT="A":"and",EXT="O":"or",1:"")
+7 SET FLDNAME=$PIECE(^FSC("FLD",+FLD,0),U)
+8 SET COND=$PIECE(^FSC("COND",+COND,0),U,2)
+9 SET VALNAME=VALUE
IF $PIECE(^FSC("FLD",+FLD,0),U,8)
IF "DNP"[$EXTRACT($PIECE(^(0),U,3))
SET VALNAME=$$VALUE^FSCGET(VALUE,7100,+$PIECE(^(0),U,8))
+10 IF $LENGTH(VALUE)
IF "FW"[$EXTRACT($PIECE(^FSC("FLD",+FLD,0),U,3))
SET VALNAME=""""_VALUE_""""
+11 IF $LENGTH(OPER)
IF $DATA(CRITERIA)
Begin DoDot:2
+12 SET $PIECE(CRITERIA(0),U,2)=STEP
+13 IF PAREN="open"
SET CRITERIA(STEP,FCOND,0)=CRITERIA(STEP,FCOND,0)_")"
+14 DO DESC^FSCQD(.DESCNT,.CRITERIA)
+15 KILL CRITERIA
+16 SET CRITERIA(0)=OPER_"^^0"
+17 SET FCOND=0
SET PAREN="closed"
SET STEP=1
End DoDot:2
+18 IF $LENGTH(OPER)
IF '$DATA(CRITERIA)
SET CRITERIA(0)=OPER_"^^0"
+19 IF EXT="or"
Begin DoDot:2
+20 SET STEP=STEP+1
SET FCOND=0
+21 IF PAREN="closed"
SET PAREN="ready"
+22 IF PAREN="open"
SET PAREN="closed"
SET LCOND=CRITERIA(STEP-1)
SET CRITERIA(STEP-1,LCOND,1)=CRITERIA(STEP-1,LCOND,1)_")"
End DoDot:2
+23 IF EXT="and"
IF PAREN="ready"
SET PAREN="open"
SET CRITERIA(STEP,FCOND,0)="("_CRITERIA(STEP,FCOND,0)
+24 SET FCOND=FCOND+1
+25 SET CRITERIA(STEP)=FCOND
+26 SET CRITERIA(STEP,FCOND)=FLD_U_COND_U_VALUE
+27 SET CRITERIA(STEP,FCOND,0)=FLDNAME_" "_COND_$SELECT($LENGTH(VALNAME):" "_VALNAME,1:"")
+28 SET CRITERIA(STEP,FCOND,1)=EXT
End DoDot:1
+29 IF PAREN="open"
SET CRITERIA(STEP,FCOND,0)=CRITERIA(STEP,FCOND,0)_")"
+30 SET $PIECE(CRITERIA(0),U,2)=STEP
+31 IF $DATA(CRITERIA)
DO DESC^FSCQD(.DESCNT,.CRITERIA)
+32 SET DESC(0)=$PIECE(DESC(0)," (MODIFIED)")
+33 QUIT