TIURECL2 ; SLC/MAM - Expand/collapse LM views ;1/22/01
;;1.0;TEXT INTEGRATION UTILITIES;**100**;Jun 20, 1997
; 7/6 Split TIURECL into TIURECL & TIURECL1, move RESOLVE to TIURECL1
; 7/10 Move INSID, INSADD, VEXREQ, ISSUB to TIURECL1
; 9/7 Move INSKIDS, INSADD & associated mods from TIURECL1 TO ECL2
;=======================================================================
INSKIDS(TSTART,TIUDA,PRNTPFIX,SORTBY) ;Insert ID kids
;of parent TIUDA into array ^TMP("TMPLIST",$J) in SORTBY order
; Receives TSTART, TIUDA, PRNTPFIX, SORTBY
; TIUDA = ID parent
; PRNTPFIX = prefix of parent, updated for current expand action.
; SORTBY = "REFDT" or "TITLE"
N KIDDATA,KIDDA,TEXT,FRSTPFIX,ORIGPFIX,NEWPFIX,KIDLIST,TIUK
; -- If ID parent has addenda at the parent level,
; as well as ID kids, then first insert addenda: --
I $$HASADDEN^TIULC1(TIUDA) S TSTART=$$INSADD(TSTART,TIUDA,PRNTPFIX)
; -- Get list of ID kids in ref date or title order: --
D GETIDKID(TIUDA,SORTBY)
; -- Set LIST(TSTART)=TEXT_U_KIDDA_U_NEWPFIX and
; ^TMP("TMPLIST",$J,"IDDATA",KIDDA)
S TIUK=0
F S TIUK=$O(^TMP("TIUIDKID",$J,TIUDA,TIUK)) Q:'TIUK D
. S KIDDA=^TMP("TIUIDKID",$J,TIUDA,TIUK)
. S TSTART=TSTART+1
. S ^TMP("TMPLIST",$J,TSTART)=$$GETLINE(KIDDA,PRNTPFIX,TSTART,.KIDDATA)
. S ^TMP("TMPLIST",$J,"IDDATA",KIDDA)=KIDDATA
K ^TMP("TIUIDKID",$J)
Q TSTART
;
GETIDKID(TIUDA,SORTBY) ; Set ^TMP("TIUIDKID",$J,TIUDA,TIUK) = KIDDA,
; array of ID kids of TIUDA, in SORTBY order
N KIDDA,REFDT,TITLE,TIUJ,LIST,TIUK
S KIDDA=0,TIUJ=0
F S KIDDA=$O(^TIU(8925,"GDAD",TIUDA,KIDDA)) Q:+KIDDA'>0 D
. S TIUJ=TIUJ+1
. S REFDT=$P(^TIU(8925,KIDDA,13),U)
. I SORTBY="REFDT" S LIST("HOLDER",REFDT,TIUJ)=KIDDA
. I SORTBY="TITLE" S TITLE=$$PNAME^TIULC1(+^TIU(8925,KIDDA,0)),LIST(TITLE,REFDT,TIUJ)=KIDDA
; -- Flatten the list: --
S TITLE="",REFDT=0,TIUJ=0,TIUK=0
F S TITLE=$O(LIST(TITLE)) Q:TITLE="" D
. F S REFDT=$O(LIST(TITLE,REFDT)) Q:'REFDT D
. . F S TIUJ=$O(LIST(TITLE,REFDT,TIUJ)) Q:'TIUJ D
. . . S TIUK=TIUK+1
. . . S ^TMP("TIUIDKID",$J,TIUDA,TIUK)=LIST(TITLE,REFDT,TIUJ)
Q
;
GETLINE(KIDDA,PRNTPFIX,LINENO,TIUGDATA) ; Return LINE=TEXT_U_KIDDA_U_NEWPFIX
; Find & pass back TIUGDATA
N LINE,ORIGPFIX,NEWPFIX,TEXT,FRSTPFIX
S ORIGPFIX=$$PREFIX^TIULA2(KIDDA)
S FRSTPFIX=$$FRSTPFIX(PRNTPFIX)
S TEXT=$$RESOLVE^TIURECL1(KIDDA,LINENO,FRSTPFIX,.TIUGDATA)
S NEWPFIX=FRSTPFIX_ORIGPFIX
S LINE=TEXT_U_KIDDA_U_NEWPFIX
Q LINE
;
FRSTPFIX(PRNTPFIX) ; Return first part of Prefix for Inserted addm
;or ID kid of parent.
; Receives PRNTPFIX; returns FRSTPFIX.
; PRNTPFIX = prefix of parent, updated for current expand action.
; -- Build first part of kid prefix using PRNTPFIX: --
; EX: if updated prefix of parent is " |_- ",
; then build FRSTPFIX from left to right:
; Take beginning spaces " ", keep the "|", replace the _
; with a space, replace INDicators (& the following space)
; with spaces, and tack on "|_" to get: " | |_"
; Prefix of kid is then FRSTPFIX_(Original prefix of kid).
N INDLNGTH,INDSPACE,FRSTPFIX
I PRNTPFIX["|_" S INDLNGTH=$L($P(PRNTPFIX,"|_",2)) I 1
E S INDLNGTH=$L(PRNTPFIX)
S INDSPACE="",$P(INDSPACE," ",INDLNGTH+1)=""
I PRNTPFIX["|_" S FRSTPFIX=$P(PRNTPFIX,"|_")_"| "_INDSPACE_"|_" I 1
E S FRSTPFIX=INDSPACE_"|_"
Q FRSTPFIX
;
INSADD(TSTART,TIUDA,PRNTPFIX) ;Insert addenda of parent TIUDA into ^TMP("TMPLIST",$J).
; Receives TSTART, TIUDA, PRNTPFIX
; PRNTPFIX = prefix of parent, updated for current expand action.
N KIDDA,TEXT,FIRSTPFX,ORIGPFIX,NEWPFIX
S KIDDA=0
F S KIDDA=$O(^TIU(8925,"DAD",TIUDA,KIDDA)) Q:+KIDDA'>0 D
. I '+$$ISADDNDM^TIULC1(+KIDDA) Q
. S TSTART=TSTART+1
. S ^TMP("TMPLIST",$J,TSTART)=$$GETLINE(KIDDA,PRNTPFIX,TSTART)
Q TSTART
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HTIURECL2 3849 printed Dec 13, 2024@02:45:16 Page 2
TIURECL2 ; SLC/MAM - Expand/collapse LM views ;1/22/01
+1 ;;1.0;TEXT INTEGRATION UTILITIES;**100**;Jun 20, 1997
+2 ; 7/6 Split TIURECL into TIURECL & TIURECL1, move RESOLVE to TIURECL1
+3 ; 7/10 Move INSID, INSADD, VEXREQ, ISSUB to TIURECL1
+4 ; 9/7 Move INSKIDS, INSADD & associated mods from TIURECL1 TO ECL2
+5 ;=======================================================================
INSKIDS(TSTART,TIUDA,PRNTPFIX,SORTBY) ;Insert ID kids
+1 ;of parent TIUDA into array ^TMP("TMPLIST",$J) in SORTBY order
+2 ; Receives TSTART, TIUDA, PRNTPFIX, SORTBY
+3 ; TIUDA = ID parent
+4 ; PRNTPFIX = prefix of parent, updated for current expand action.
+5 ; SORTBY = "REFDT" or "TITLE"
+6 NEW KIDDATA,KIDDA,TEXT,FRSTPFIX,ORIGPFIX,NEWPFIX,KIDLIST,TIUK
+7 ; -- If ID parent has addenda at the parent level,
+8 ; as well as ID kids, then first insert addenda: --
+9 IF $$HASADDEN^TIULC1(TIUDA)
SET TSTART=$$INSADD(TSTART,TIUDA,PRNTPFIX)
+10 ; -- Get list of ID kids in ref date or title order: --
+11 DO GETIDKID(TIUDA,SORTBY)
+12 ; -- Set LIST(TSTART)=TEXT_U_KIDDA_U_NEWPFIX and
+13 ; ^TMP("TMPLIST",$J,"IDDATA",KIDDA)
+14 SET TIUK=0
+15 FOR
SET TIUK=$ORDER(^TMP("TIUIDKID",$JOB,TIUDA,TIUK))
if 'TIUK
QUIT
Begin DoDot:1
+16 SET KIDDA=^TMP("TIUIDKID",$JOB,TIUDA,TIUK)
+17 SET TSTART=TSTART+1
+18 SET ^TMP("TMPLIST",$JOB,TSTART)=$$GETLINE(KIDDA,PRNTPFIX,TSTART,.KIDDATA)
+19 SET ^TMP("TMPLIST",$JOB,"IDDATA",KIDDA)=KIDDATA
End DoDot:1
+20 KILL ^TMP("TIUIDKID",$JOB)
+21 QUIT TSTART
+22 ;
GETIDKID(TIUDA,SORTBY) ; Set ^TMP("TIUIDKID",$J,TIUDA,TIUK) = KIDDA,
+1 ; array of ID kids of TIUDA, in SORTBY order
+2 NEW KIDDA,REFDT,TITLE,TIUJ,LIST,TIUK
+3 SET KIDDA=0
SET TIUJ=0
+4 FOR
SET KIDDA=$ORDER(^TIU(8925,"GDAD",TIUDA,KIDDA))
if +KIDDA'>0
QUIT
Begin DoDot:1
+5 SET TIUJ=TIUJ+1
+6 SET REFDT=$PIECE(^TIU(8925,KIDDA,13),U)
+7 IF SORTBY="REFDT"
SET LIST("HOLDER",REFDT,TIUJ)=KIDDA
+8 IF SORTBY="TITLE"
SET TITLE=$$PNAME^TIULC1(+^TIU(8925,KIDDA,0))
SET LIST(TITLE,REFDT,TIUJ)=KIDDA
End DoDot:1
+9 ; -- Flatten the list: --
+10 SET TITLE=""
SET REFDT=0
SET TIUJ=0
SET TIUK=0
+11 FOR
SET TITLE=$ORDER(LIST(TITLE))
if TITLE=""
QUIT
Begin DoDot:1
+12 FOR
SET REFDT=$ORDER(LIST(TITLE,REFDT))
if 'REFDT
QUIT
Begin DoDot:2
+13 FOR
SET TIUJ=$ORDER(LIST(TITLE,REFDT,TIUJ))
if 'TIUJ
QUIT
Begin DoDot:3
+14 SET TIUK=TIUK+1
+15 SET ^TMP("TIUIDKID",$JOB,TIUDA,TIUK)=LIST(TITLE,REFDT,TIUJ)
End DoDot:3
End DoDot:2
End DoDot:1
+16 QUIT
+17 ;
GETLINE(KIDDA,PRNTPFIX,LINENO,TIUGDATA) ; Return LINE=TEXT_U_KIDDA_U_NEWPFIX
+1 ; Find & pass back TIUGDATA
+2 NEW LINE,ORIGPFIX,NEWPFIX,TEXT,FRSTPFIX
+3 SET ORIGPFIX=$$PREFIX^TIULA2(KIDDA)
+4 SET FRSTPFIX=$$FRSTPFIX(PRNTPFIX)
+5 SET TEXT=$$RESOLVE^TIURECL1(KIDDA,LINENO,FRSTPFIX,.TIUGDATA)
+6 SET NEWPFIX=FRSTPFIX_ORIGPFIX
+7 SET LINE=TEXT_U_KIDDA_U_NEWPFIX
+8 QUIT LINE
+9 ;
FRSTPFIX(PRNTPFIX) ; Return first part of Prefix for Inserted addm
+1 ;or ID kid of parent.
+2 ; Receives PRNTPFIX; returns FRSTPFIX.
+3 ; PRNTPFIX = prefix of parent, updated for current expand action.
+4 ; -- Build first part of kid prefix using PRNTPFIX: --
+5 ; EX: if updated prefix of parent is " |_- ",
+6 ; then build FRSTPFIX from left to right:
+7 ; Take beginning spaces " ", keep the "|", replace the _
+8 ; with a space, replace INDicators (& the following space)
+9 ; with spaces, and tack on "|_" to get: " | |_"
+10 ; Prefix of kid is then FRSTPFIX_(Original prefix of kid).
+11 NEW INDLNGTH,INDSPACE,FRSTPFIX
+12 IF PRNTPFIX["|_"
SET INDLNGTH=$LENGTH($PIECE(PRNTPFIX,"|_",2))
IF 1
+13 IF '$TEST
SET INDLNGTH=$LENGTH(PRNTPFIX)
+14 SET INDSPACE=""
SET $PIECE(INDSPACE," ",INDLNGTH+1)=""
+15 IF PRNTPFIX["|_"
SET FRSTPFIX=$PIECE(PRNTPFIX,"|_")_"| "_INDSPACE_"|_"
IF 1
+16 IF '$TEST
SET FRSTPFIX=INDSPACE_"|_"
+17 QUIT FRSTPFIX
+18 ;
INSADD(TSTART,TIUDA,PRNTPFIX) ;Insert addenda of parent TIUDA into ^TMP("TMPLIST",$J).
+1 ; Receives TSTART, TIUDA, PRNTPFIX
+2 ; PRNTPFIX = prefix of parent, updated for current expand action.
+3 NEW KIDDA,TEXT,FIRSTPFX,ORIGPFIX,NEWPFIX
+4 SET KIDDA=0
+5 FOR
SET KIDDA=$ORDER(^TIU(8925,"DAD",TIUDA,KIDDA))
if +KIDDA'>0
QUIT
Begin DoDot:1
+6 IF '+$$ISADDNDM^TIULC1(+KIDDA)
QUIT
+7 SET TSTART=TSTART+1
+8 SET ^TMP("TMPLIST",$JOB,TSTART)=$$GETLINE(KIDDA,PRNTPFIX,TSTART)
End DoDot:1
+9 QUIT TSTART