FSCQO ;SLC/STAFF-NOIS Query Optimize ;1/11/98 18:46
;;1.1;NOIS;;Sep 06, 1998
;
OPTIMIZE(CRITERIA) ; from FSCQS, FSCRPCQ
; ***needs algorithm to assign order to steps in fconds
N STEP,FCOND,FIELD,SOPT,FOPT
S STEP=0 F S STEP=$O(CRITERIA(STEP)) Q:STEP<1 D
.S SOPT=STEP,CRITERIA("O",SOPT)=STEP
.S FCOND="" F S FCOND=$O(CRITERIA(STEP,FCOND)) Q:FCOND="" S FIELD=$P(CRITERIA(STEP,FCOND),U) D
..S FOPT=FCOND
..S CRITERIA("F",FIELD)=$P(^FSC("FLD",FIELD,0),U,3,6)
..S CRITERIA("O",SOPT,FOPT)=FCOND_U_$G(^FSC("FLD",FIELD,2))
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFSCQO 545 printed Oct 16, 2024@18:19:33 Page 2
FSCQO ;SLC/STAFF-NOIS Query Optimize ;1/11/98 18:46
+1 ;;1.1;NOIS;;Sep 06, 1998
+2 ;
OPTIMIZE(CRITERIA) ; from FSCQS, FSCRPCQ
+1 ; ***needs algorithm to assign order to steps in fconds
+2 NEW STEP,FCOND,FIELD,SOPT,FOPT
+3 SET STEP=0
FOR
SET STEP=$ORDER(CRITERIA(STEP))
if STEP<1
QUIT
Begin DoDot:1
+4 SET SOPT=STEP
SET CRITERIA("O",SOPT)=STEP
+5 SET FCOND=""
FOR
SET FCOND=$ORDER(CRITERIA(STEP,FCOND))
if FCOND=""
QUIT
SET FIELD=$PIECE(CRITERIA(STEP,FCOND),U)
Begin DoDot:2
+6 SET FOPT=FCOND
+7 SET CRITERIA("F",FIELD)=$PIECE(^FSC("FLD",FIELD,0),U,3,6)
+8 SET CRITERIA("O",SOPT,FOPT)=FCOND_U_$GET(^FSC("FLD",FIELD,2))
End DoDot:2
End DoDot:1
+9 QUIT