GMRGRUT1 ;CISC/RM-ROUTINE UTILITIES (cont.) ;2/21/89
;;3.0;Text Generator;;Jan 24, 1996
FITLINE ; THIS UTILITY TAKES A LINE OF TEXT IN GMRGPLN AND A LENGTH IN
; GMRGLEN, AND SETS GMRGPLN(0)=THE FIRST N-WORDS OF GMRGPLN THAT
; WILL FIT IN LENGTH GMRGLEN, AND GMRGPLN(1)=REST OF GMRGPLN
; KILLS GMRGLEN AND RETURNS GMRGPLN,GMRGPLN(0),GMRGPLN(1).
S GMRG100=0,GMRGPLN(0)="",GMRGPLN(1)=GMRGPLN
I $L(GMRGPLN)>GMRGLEN F GMRG101=0:0 S GMRG102=$F(GMRGPLN," ",GMRG100) Q:GMRG102'>0!(GMRG102>GMRGLEN) S GMRG100=GMRG102
S GMRGPLN(0)=$E(GMRGPLN,1,$S(GMRG100>0:GMRG100-1,1:GMRGLEN)),GMRGPLN(1)=$E(GMRGPLN,$S(GMRG100>0:GMRG100,1:GMRGLEN+1),$L(GMRGPLN))
I GMRGPLN(0)?1." ",$L(GMRGPLN)>GMRGLEN S GMRGPLN(0)=$E(GMRGPLN,1,GMRGLEN),GMRGPLN(1)=$E(GMRGPLN,GMRGLEN+1,$L(GMRGPLN))
K GMRG100,GMRG101,GMRG102,GMRGLEN
Q
STORETXT ; THIS UTILITY TAKES THE FOLLOWING ELEMENTS OF THE GMRGNAR ARRAY
; GMRGNAR=AGGY IEN^O/P FORM.^SPACES LT MARG.^CHILD?^SPACES RT. MARG.
; GMRGNAR(0) = TEXT OF AGGY TERM ^ PATIENT TEXT (IF EXISTS)
; GMRGNAR("LEAD") = LEAD TEXT FOR AGGY TERM
; GMRGNAR("TRAIL") = TRAIL TEXT FOR AGGY TERM
; AND STORES THE APPROPRIATE INFORMATION IN THE APPROPRIATE FORMAT
; INTO THE UTILITY($J,"GMRGNAR",AGGY CLASS,AGGY IEN,LINE) GLOBAL
Q:'$D(GMRGNAR) Q:'$D(^TMP($J,"GMRGNAR",GMRGCLAS,$P(GMRGNAR,"^"),0)) S GMRG01=$P(^(0),"^",2),GMRG14=$P(GMRGNAR,"^",3),GMRG15="" F GMRG02=1:1:GMRG14 S GMRG15=GMRG15_" "
S GMRGXPRT(0)=$P(GMRGNAR(0),"^",2),GMRGXPRT=$P(GMRGNAR(0),"^"),GMRGXPRT(1)="^^^^1^1" D EN1^GMRGRUT2 S GMRG11=GMRGXPRT K GMRGXPRT
S GMRG17=$P(GMRGNAR,"^",5),GMRG16=$S((IOM-GMRG14)>0:IOM-GMRG14,1:IOM),GMRG10=$P(GMRGNAR,"^",4),GMRG18=0
I GMRG10 S GMRG08=" "_$S(GMRG10=1:"",GMRG10=2:"and ",1:""),GMRG04=$S(GMRG10=1:",",1:"."),GMRG05=$S(GMRG01:GMRG01,1:1),GMRG06=$L(^TMP($J,"GMRGNAR",GMRGCLAS,$P(GMRGNAR,"^"),GMRG01)),GMRGPLN=$E(^(GMRG01),GMRGSPC,GMRG06)
I S GMRG18=$S($E(GMRGPLN)'="-":0,1:1),GMRGPLN=$E(GMRGPLN,$S(GMRG18!($E(GMRGPLN)=" "):2,1:1),$L(GMRGPLN)) D NOB^GMRGRUT4 G QS
S:$P(GMRGNAR,"^",2)="B" (GMRGNAR("LEAD"),GMRGNAR("TRAIL"))="" S GMRG18=1
S (GMRG08,GMRGPLN)="" I 'GMRGSSW,($P(GMRGNAR,"^",2)="B"!($P(GMRGNAR,"^",2)="T")) S GMRG05=GMRG01+1
E S:GMRGSSW GMRG08=" ",GMRGPLN=$S(GMRGSSW:$E(^TMP($J,"GMRGNAR",GMRGCLAS,$P(GMRGNAR,"^"),GMRG01),GMRGSPC+1,$L(^TMP($J,"GMRGNAR",GMRGCLAS,$P(GMRGNAR,"^"),GMRG01))),1:""),GMRG18=0 S GMRG05=$S('GMRGSSW:GMRG01+1,GMRG01:GMRG01,1:1)
S GMRG04="" D NOB^GMRGRUT4
QS K GMRG01,GMRG02,GMRG03,GMRG04,GMRG05,GMRG06,GMRG08,GMRG10,GMRG11,GMRG12,GMRG13,GMRG14,GMRG15,GMRG16,GMRG17,GMRG18,GMRGNAR,GMRGPLN
Q
GMRGRUT1 ;CISC/RM-ROUTINE UTILITIES (cont.) ;2/21/89
+1 ;;3.0;Text Generator;;Jan 24, 1996
FITLINE ; THIS UTILITY TAKES A LINE OF TEXT IN GMRGPLN AND A LENGTH IN
+1 ; GMRGLEN, AND SETS GMRGPLN(0)=THE FIRST N-WORDS OF GMRGPLN THAT
+2 ; WILL FIT IN LENGTH GMRGLEN, AND GMRGPLN(1)=REST OF GMRGPLN
+3 ; KILLS GMRGLEN AND RETURNS GMRGPLN,GMRGPLN(0),GMRGPLN(1).
+4 SET GMRG100=0
SET GMRGPLN(0)=""
SET GMRGPLN(1)=GMRGPLN
+5 IF $LENGTH(GMRGPLN)>GMRGLEN
FOR GMRG101=0:0
SET GMRG102=$FIND(GMRGPLN," ",GMRG100)
IF GMRG102'>0!(GMRG102>GMRGLEN)
QUIT
SET GMRG100=GMRG102
+6 SET GMRGPLN(0)=$EXTRACT(GMRGPLN,1,$SELECT(GMRG100>0:GMRG100-1,1:GMRGLEN))
SET GMRGPLN(1)=$EXTRACT(GMRGPLN,$SELECT(GMRG100>0:GMRG100,1:GMRGLEN+1),$LENGTH(GMRGPLN))
+7 IF GMRGPLN(0)?1." "
IF $LENGTH(GMRGPLN)>GMRGLEN
SET GMRGPLN(0)=$EXTRACT(GMRGPLN,1,GMRGLEN)
SET GMRGPLN(1)=$EXTRACT(GMRGPLN,GMRGLEN+1,$LENGTH(GMRGPLN))
+8 KILL GMRG100,GMRG101,GMRG102,GMRGLEN
+9 QUIT
STORETXT ; THIS UTILITY TAKES THE FOLLOWING ELEMENTS OF THE GMRGNAR ARRAY
+1 ; GMRGNAR=AGGY IEN^O/P FORM.^SPACES LT MARG.^CHILD?^SPACES RT. MARG.
+2 ; GMRGNAR(0) = TEXT OF AGGY TERM ^ PATIENT TEXT (IF EXISTS)
+3 ; GMRGNAR("LEAD") = LEAD TEXT FOR AGGY TERM
+4 ; GMRGNAR("TRAIL") = TRAIL TEXT FOR AGGY TERM
+5 ; AND STORES THE APPROPRIATE INFORMATION IN THE APPROPRIATE FORMAT
+6 ; INTO THE UTILITY($J,"GMRGNAR",AGGY CLASS,AGGY IEN,LINE) GLOBAL
+7 IF '$DATA(GMRGNAR)
QUIT
IF '$DATA(^TMP($JOB,"GMRGNAR",GMRGCLAS,$PIECE(GMRGNAR,"^"),0))
QUIT
SET GMRG01=$PIECE(^(0),"^",2)
SET GMRG14=$PIECE(GMRGNAR,"^",3)
SET GMRG15=""
FOR GMRG02=1:1:GMRG14
SET GMRG15=GMRG15_" "
+8 SET GMRGXPRT(0)=$PIECE(GMRGNAR(0),"^",2)
SET GMRGXPRT=$PIECE(GMRGNAR(0),"^")
SET GMRGXPRT(1)="^^^^1^1"
DO EN1^GMRGRUT2
SET GMRG11=GMRGXPRT
KILL GMRGXPRT
+9 SET GMRG17=$PIECE(GMRGNAR,"^",5)
SET GMRG16=$SELECT((IOM-GMRG14)>0:IOM-GMRG14,1:IOM)
SET GMRG10=$PIECE(GMRGNAR,"^",4)
SET GMRG18=0
+10 IF GMRG10
SET GMRG08=" "_$SELECT(GMRG10=1:"",GMRG10=2:"and ",1:"")
SET GMRG04=$SELECT(GMRG10=1:",",1:".")
SET GMRG05=$SELECT(GMRG01:GMRG01,1:1)
SET GMRG06=$LENGTH(^TMP($JOB,"GMRGNAR",GMRGCLAS,$PIECE(GMRGNAR,"^"),GMRG01))
SET GMRGPLN=$EXTRACT(^(GMRG01),GMRGSPC,GMRG06)
+11 IF $TEST
SET GMRG18=$SELECT($EXTRACT(GMRGPLN)'="-":0,1:1)
SET GMRGPLN=$EXTRACT(GMRGPLN,$SELECT(GMRG18!($EXTRACT(GMRGPLN)=" "):2,1:1),$LENGTH(GMRGPLN))
DO NOB^GMRGRUT4
GOTO QS
+12 IF $PIECE(GMRGNAR,"^",2)="B"
SET (GMRGNAR("LEAD"),GMRGNAR("TRAIL"))=""
SET GMRG18=1
+13 SET (GMRG08,GMRGPLN)=""
IF 'GMRGSSW
IF ($PIECE(GMRGNAR,"^",2)="B"!($PIECE(GMRGNAR,"^",2)="T"))
SET GMRG05=GMRG01+1
+14 IF '$TEST
IF GMRGSSW
SET GMRG08=" "
SET GMRGPLN=$SELECT(GMRGSSW:$EXTRACT(^TMP($JOB,"GMRGNAR",GMRGCLAS,$PIECE(GMRGNAR,"^"),GMRG01),GMRGSPC+1,$LENGTH(^TMP($JOB,"GMRGNAR",GMRGCLAS,$PIECE(GMRGNAR,"^"),GMRG01))),1:"")
SET GMRG18=0
SET GMRG05=$SELECT('GMRGSSW:GMRG01+1,GMRG01:GMRG01,1:1)
+15 SET GMRG04=""
DO NOB^GMRGRUT4
QS KILL GMRG01,GMRG02,GMRG03,GMRG04,GMRG05,GMRG06,GMRG08,GMRG10,GMRG11,GMRG12,GMRG13,GMRG14,GMRG15,GMRG16,GMRG17,GMRG18,GMRGNAR,GMRGPLN
+1 QUIT