SCRPBK5 ;MJK/ALB - RPC Broker Utilities ; 27 FEB 96
;;5.3;Scheduling;**41**;AUG 13, 1993
;
PARSE(SCQDEF,SCQREC) ; -- parse incoming raw broker array
; -- return formatted query record
;
; -- SEE BOTTOM OF SCRPBK FOR VARIABLE DEFINITIONS
;
N SCINC,X
;
; -- build internal formatted variables
S SCINC=1,X=SCQDEF(SCINC)
S SCQREC("NAME")=$P(X,U)
S SCQREC("CREATORID")=+$P(X,U,2)
S SCQREC("ACCESSID")=+$P(X,U,3)
S SCQREC("REPORTID")=+$P(X,U,4)
;
; -- build external formatted variables
S SCINC=2,X=SCQDEF(SCINC)
S SCQREC("QUERYID")=$P(X,U)
S SCQREC("CREATOR")=$P(X,U,2)
S SCQREC("ACCESS")=$P(X,U,3)
S SCQREC("REPORT")=$P(X,U,4)
;
F S SCINC=$O(SCQDEF(SCINC)) Q:'SCINC S X=$G(SCQDEF(SCINC)) D
. IF X="[Description]" D DESC(.SCINC,.SCQDEF,.SCQREC)
. ; -- get fields
. IF X="[Fields]" D FIELDS(.SCINC,.SCQDEF,.SCQREC)
. ; -- get files
. IF X="[Selections]" D SELECT(.SCINC,.SCQDEF,.SCQREC)
Q
;
DESC(SCINC,SCQDEF,SCQREC) ; -- build query description
N I,X
S I=0
F S SCINC=$O(SCQDEF(SCINC)) Q:'SCINC S X=$G(SCQDEF(+SCINC)) Q:X="$$END" D
. S I=I+1,SCQREC("DESCRIPTION",I,0)=X
Q
;
FIELDS(SCINC,SCQRY,SCQREC) ; -- build field answeredk
N X
F S SCINC=$O(SCQDEF(SCINC)) Q:'SCINC S X=$G(SCQDEF(+SCINC)) Q:X="$$END" D
. S SCQREC("FIELDS",$P(X,U))=$P(X,U,2)
Q
;
SELECT(SCINC,SCQRY,SCQREC) ; -- build file entries selected
N X
F S SCINC=$O(SCQDEF(SCINC)) Q:'SCINC S X=$G(SCQDEF(+SCINC)) Q:X="$$END" D
. S SCQREC("SELECTIONS",$P(X,U,2),$$SEL(X))=""
Q
;
SEL(SEL) ; -- set vp for selection
N Y,IEN,SCTYPE
S SCTYPE=$P(SEL,U,2),IEN=+$P(SEL,U,3),Y="NOT VALID: "_SCTYPE
IF SCTYPE="DIVISION" S Y="DIC(4," G SELQ
IF SCTYPE="TEAM" S Y="SCTM(404.51," G SELQ
IF SCTYPE="PRACTITIONER" S Y="VA(200," G SELQ
IF SCTYPE="ROLE" S Y="SD(403.46," G SELQ
IF SCTYPE="CLINIC" S Y="SC(" G SELQ
IF SCTYPE="USERCLASS" S Y="USR(8930," G SELQ
SELQ Q IEN_";"_Y
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCRPBK5 1942 printed Dec 13, 2024@02:42:25 Page 2
SCRPBK5 ;MJK/ALB - RPC Broker Utilities ; 27 FEB 96
+1 ;;5.3;Scheduling;**41**;AUG 13, 1993
+2 ;
PARSE(SCQDEF,SCQREC) ; -- parse incoming raw broker array
+1 ; -- return formatted query record
+2 ;
+3 ; -- SEE BOTTOM OF SCRPBK FOR VARIABLE DEFINITIONS
+4 ;
+5 NEW SCINC,X
+6 ;
+7 ; -- build internal formatted variables
+8 SET SCINC=1
SET X=SCQDEF(SCINC)
+9 SET SCQREC("NAME")=$PIECE(X,U)
+10 SET SCQREC("CREATORID")=+$PIECE(X,U,2)
+11 SET SCQREC("ACCESSID")=+$PIECE(X,U,3)
+12 SET SCQREC("REPORTID")=+$PIECE(X,U,4)
+13 ;
+14 ; -- build external formatted variables
+15 SET SCINC=2
SET X=SCQDEF(SCINC)
+16 SET SCQREC("QUERYID")=$PIECE(X,U)
+17 SET SCQREC("CREATOR")=$PIECE(X,U,2)
+18 SET SCQREC("ACCESS")=$PIECE(X,U,3)
+19 SET SCQREC("REPORT")=$PIECE(X,U,4)
+20 ;
+21 FOR
SET SCINC=$ORDER(SCQDEF(SCINC))
if 'SCINC
QUIT
SET X=$GET(SCQDEF(SCINC))
Begin DoDot:1
+22 IF X="[Description]"
DO DESC(.SCINC,.SCQDEF,.SCQREC)
+23 ; -- get fields
+24 IF X="[Fields]"
DO FIELDS(.SCINC,.SCQDEF,.SCQREC)
+25 ; -- get files
+26 IF X="[Selections]"
DO SELECT(.SCINC,.SCQDEF,.SCQREC)
End DoDot:1
+27 QUIT
+28 ;
DESC(SCINC,SCQDEF,SCQREC) ; -- build query description
+1 NEW I,X
+2 SET I=0
+3 FOR
SET SCINC=$ORDER(SCQDEF(SCINC))
if 'SCINC
QUIT
SET X=$GET(SCQDEF(+SCINC))
if X="$$END"
QUIT
Begin DoDot:1
+4 SET I=I+1
SET SCQREC("DESCRIPTION",I,0)=X
End DoDot:1
+5 QUIT
+6 ;
FIELDS(SCINC,SCQRY,SCQREC) ; -- build field answeredk
+1 NEW X
+2 FOR
SET SCINC=$ORDER(SCQDEF(SCINC))
if 'SCINC
QUIT
SET X=$GET(SCQDEF(+SCINC))
if X="$$END"
QUIT
Begin DoDot:1
+3 SET SCQREC("FIELDS",$PIECE(X,U))=$PIECE(X,U,2)
End DoDot:1
+4 QUIT
+5 ;
SELECT(SCINC,SCQRY,SCQREC) ; -- build file entries selected
+1 NEW X
+2 FOR
SET SCINC=$ORDER(SCQDEF(SCINC))
if 'SCINC
QUIT
SET X=$GET(SCQDEF(+SCINC))
if X="$$END"
QUIT
Begin DoDot:1
+3 SET SCQREC("SELECTIONS",$PIECE(X,U,2),$$SEL(X))=""
End DoDot:1
+4 QUIT
+5 ;
SEL(SEL) ; -- set vp for selection
+1 NEW Y,IEN,SCTYPE
+2 SET SCTYPE=$PIECE(SEL,U,2)
SET IEN=+$PIECE(SEL,U,3)
SET Y="NOT VALID: "_SCTYPE
+3 IF SCTYPE="DIVISION"
SET Y="DIC(4,"
GOTO SELQ
+4 IF SCTYPE="TEAM"
SET Y="SCTM(404.51,"
GOTO SELQ
+5 IF SCTYPE="PRACTITIONER"
SET Y="VA(200,"
GOTO SELQ
+6 IF SCTYPE="ROLE"
SET Y="SD(403.46,"
GOTO SELQ
+7 IF SCTYPE="CLINIC"
SET Y="SC("
GOTO SELQ
+8 IF SCTYPE="USERCLASS"
SET Y="USR(8930,"
GOTO SELQ
SELQ QUIT IEN_";"_Y
+1 ;