GMRGPNB0 ;CISC/JH/RM-NARRATIVE BUILDER FOR TEXT GENERATOR (cont.) ;6/20/91
;;3.0;Text Generator;;Jan 24, 1996
TEXT ; ENTRY WITH GMRGA SET TO POINT AT WHICH WANT TO START BUILDING TEXT
S (GMRGE0,GMRGADD)=""
Q:'$D(^GMR(124.3,GMRGPDA,1,"ALIST",GMRGA0))&GMRGCSW Q:('$D(^GMR(124.3,"B",GMRGA0,GMRGPDA))&'$D(^GMR(124.3,GMRGPDA,1,"B",GMRGA0)))&'GMRGCSW D NOW^%DTC
S GMRGB0=$O(^GMR(124.3,GMRGPDA,1,"B",GMRGA0,0)) I GMRGB0>0 S GMRGST=GMRGB0,GMRGST(1)=GMRGPDA,GMRGST(2)=$S(GMRGCSW=1:%,1:GMRGPDT) D STAT^GMRGRUT0 S GMRGF0=GMRGSTAT,GMRGST=GMRGB0,GMRGST(1)=GMRGPDA,GMRGST(2)=GMRGPDT D STAT^GMRGRUT0
I GMRGB0>0 S GMRGE0=$S($P(GMRGSTAT,"^",3)=1:"",$P(GMRGSTAT,"^")=$P(GMRGF0,"^"):$S($D(^GMR(124.3,GMRGPDA,1,GMRGB0,0)):$P(^(0),"^",2),1:""),1:$S($D(^GMR(124.3,GMRGPDA,1,GMRGB0,2,+$P(GMRGSTAT,"^"),0)):$P(^(0),"^",4),1:""))
I S GMRGADD=$S($P(GMRGSTAT,"^",3)=1:"",$P(GMRGSTAT,"^")=$P(GMRGF0,"^"):$S($D(^GMR(124.3,GMRGPDA,1,GMRGB0,"ADD")):"1;"_GMRGB0_";0",1:""),1:$S($D(^GMR(124.3,GMRGPDA,1,GMRGB0,2,$P(GMRGSTAT,"^"),"ADD")):"1;"_GMRGB0_";2;"_$P(GMRGSTAT,"^"),1:""))
S GMRGE0(0)=$S($D(^GMRD(124.2,GMRGA0,0)):^(0),1:""),GMRGE0(4)=$S($D(^GMRD(124.2,GMRGA0,4)):^(4),1:""),GMRGE0(5)=$S($D(^GMRD(124.2,GMRGA0,5)):^(5),1:"") Q:$P(GMRGE0(0),"^",2)=3&GMRGSSW
I "S"[$P(GMRGE0(0),"^",8)!GMRGSSW D SNT^GMRGPNB1 Q
S GMRGNAR=GMRGPAR_"^"_$P(GMRGE0(0),"^",8)_"^"_GMRGSPC_"^^"_GMRGRM,GMRGNAR(0)=$P(GMRGE0(0),"^")_"^"_GMRGE0,GMRGNAR("LEAD")=GMRGE0(4),GMRGNAR("TRAIL")=GMRGE0(5) D STORETXT^GMRGRUT1
S GMRGSPC=GMRGSPC+3
F GMRGD0=0:0 S GMRGD0=$O(^GMRD(124.2,GMRGA0,1,GMRGD0)) Q:GMRGD0'>0 D RECUR
Q:'GMRGADD
S GMRGNAR=GMRGPAR_"^T^"_GMRGSPC_"^^"_GMRGRM,GMRGNAR("LEAD")="Additional Text: ",GMRGNAR("TRAIL")=""
S GMRGNAR(0)=$S('$P(GMRGADD,";",3):^GMR(124.3,GMRGPDA,1,$P(GMRGADD,";",2),"ADD"),1:^GMR(124.3,GMRGPDA,1,$P(GMRGADD,";",2),2,$P(GMRGADD,";",4),"ADD")) D STORETXT^GMRGRUT1
Q
RECUR ;
Q:'$$ALIST^GMRGRUT0(GMRGPDA,GMRGA0,+$G(^GMRD(124.2,+GMRGA0,1,+GMRGD0,0)))
S ^TMP($J,"GMRGPLVL",GMRGPLVL)=GMRGA0_"^"_GMRGD0_"^"_GMRGSPC_"^"_GMRGSSW_"^"_GMRGADD,GMRGPLVL=GMRGPLVL+1,GMRGA0=$S($D(^GMRD(124.2,GMRGA0,1,GMRGD0,0)):$P(^(0),"^"),1:"")
D TEXT
S GMRGPLVL=GMRGPLVL-1,GMRGI0=^TMP($J,"GMRGPLVL",GMRGPLVL),GMRGA0=$P(GMRGI0,"^"),GMRGD0=$P(GMRGI0,"^",2),GMRGSPC=$P(GMRGI0,"^",3),GMRGSSW=$P(GMRGI0,"^",4),GMRGADD=$P(GMRGI0,"^",5)
Q
GMRGPNB0 ;CISC/JH/RM-NARRATIVE BUILDER FOR TEXT GENERATOR (cont.) ;6/20/91
+1 ;;3.0;Text Generator;;Jan 24, 1996
TEXT ; ENTRY WITH GMRGA SET TO POINT AT WHICH WANT TO START BUILDING TEXT
+1 SET (GMRGE0,GMRGADD)=""
+2 IF '$DATA(^GMR(124.3,GMRGPDA,1,"ALIST",GMRGA0))&GMRGCSW
QUIT
IF ('$DATA(^GMR(124.3,"B",GMRGA0,GMRGPDA))&'$DATA(^GMR(124.3,GMRGPDA,1,"B",GMRGA0)))&'GMRGCSW
QUIT
DO NOW^%DTC
+3 SET GMRGB0=$ORDER(^GMR(124.3,GMRGPDA,1,"B",GMRGA0,0))
IF GMRGB0>0
SET GMRGST=GMRGB0
SET GMRGST(1)=GMRGPDA
SET GMRGST(2)=$SELECT(GMRGCSW=1:%,1:GMRGPDT)
DO STAT^GMRGRUT0
SET GMRGF0=GMRGSTAT
SET GMRGST=GMRGB0
SET GMRGST(1)=GMRGPDA
SET GMRGST(2)=GMRGPDT
DO STAT^GMRGRUT0
+4 IF GMRGB0>0
SET GMRGE0=$SELECT($PIECE(GMRGSTAT,"^",3)=1:"",$PIECE(GMRGSTAT,"^")=$PIECE(GMRGF0,"^"):$SELECT($DATA(^GMR(124.3,GMRGPDA,1,GMRGB0,0)):$PIECE(^(0),"^",2),1:""),1:$SELECT($DATA(^GMR(124.3,GMRGPDA,1,GMRGB0,2,+$PIECE(GMRGSTAT,"^"),0)):...
... $PIECE(^(0),"^",4),1:""))
+5 IF $TEST
SET GMRGADD=$SELECT($PIECE(GMRGSTAT,"^",3)=1:"",$PIECE(GMRGSTAT,"^")=...
... $PIECE(GMRGF0,"^"):$SELECT($DATA(^GMR(124.3,GMRGPDA,1,GMRGB0,"ADD")):"1;"_GMRGB0_";0",1:""),1:$SELECT($DATA(^GMR(124.3,GMRGPDA,1,GMRGB0,2,$PIECE(GMRGSTAT,"^"),"ADD")):"1;"_GMRGB0_";2;"_$PIECE(GMRGSTAT,"^"),1:""))
+6 SET GMRGE0(0)=$SELECT($DATA(^GMRD(124.2,GMRGA0,0)):^(0),1:"")
SET GMRGE0(4)=$SELECT($DATA(^GMRD(124.2,GMRGA0,4)):^(4),1:"")
SET GMRGE0(5)=$SELECT($DATA(^GMRD(124.2,GMRGA0,5)):^(5),1:"")
IF $PIECE(GMRGE0(0),"^",2)=3&GMRGSSW
QUIT
+7 IF "S"[$PIECE(GMRGE0(0),"^",8)!GMRGSSW
DO SNT^GMRGPNB1
QUIT
+8 SET GMRGNAR=GMRGPAR_"^"_$PIECE(GMRGE0(0),"^",8)_"^"_GMRGSPC_"^^"_GMRGRM
SET GMRGNAR(0)=$PIECE(GMRGE0(0),"^")_"^"_GMRGE0
SET GMRGNAR("LEAD")=GMRGE0(4)
SET GMRGNAR("TRAIL")=GMRGE0(5)
DO STORETXT^GMRGRUT1
+9 SET GMRGSPC=GMRGSPC+3
+10 FOR GMRGD0=0:0
SET GMRGD0=$ORDER(^GMRD(124.2,GMRGA0,1,GMRGD0))
IF GMRGD0'>0
QUIT
DO RECUR
+11 IF 'GMRGADD
QUIT
+12 SET GMRGNAR=GMRGPAR_"^T^"_GMRGSPC_"^^"_GMRGRM
SET GMRGNAR("LEAD")="Additional Text: "
SET GMRGNAR("TRAIL")=""
+13 SET GMRGNAR(0)=$SELECT('$PIECE(GMRGADD,";",3):^GMR(124.3,GMRGPDA,1,$PIECE(GMRGADD,";",2),"ADD"),1:^GMR(124.3,GMRGPDA,1,$PIECE(GMRGADD,";",2),2,$PIECE(GMRGADD,";",4),"ADD"))
DO STORETXT^GMRGRUT1
+14 QUIT
RECUR ;
+1 IF '$$ALIST^GMRGRUT0(GMRGPDA,GMRGA0,+$GET(^GMRD(124.2,+GMRGA0,1,+GMRGD0,0)))
QUIT
+2 SET ^TMP($JOB,"GMRGPLVL",GMRGPLVL)=GMRGA0_"^"_GMRGD0_"^"_GMRGSPC_"^"_GMRGSSW_"^"_GMRGADD
SET GMRGPLVL=GMRGPLVL+1
SET GMRGA0=$SELECT($DATA(^GMRD(124.2,GMRGA0,1,GMRGD0,0)):$PIECE(^(0),"^"),1:"")
+3 DO TEXT
+4 SET GMRGPLVL=GMRGPLVL-1
SET GMRGI0=^TMP($JOB,"GMRGPLVL",GMRGPLVL)
SET GMRGA0=$PIECE(GMRGI0,"^")
SET GMRGD0=$PIECE(GMRGI0,"^",2)
SET GMRGSPC=$PIECE(GMRGI0,"^",3)
SET GMRGSSW=$PIECE(GMRGI0,"^",4)
SET GMRGADD=$PIECE(GMRGI0,"^",5)
+5 QUIT