source: FOIAVistA/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUFLLM1.m@ 1094

Last change on this file since 1094 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 5.1 KB
Line 
1TIUFLLM1 ; SLC/MAM - Library; LM Related: LINEUP(INFO,TEMPLATE), UPDATE(TMPLATE,SHIFT,LASTLIN,PINFO), AINUSE(LINENO), INUSEUP(FILEDA,LINENO) ;8/27/97 18:47
2 ;;1.0;TEXT INTEGRATION UTILITIES;**11**;Jun 20, 1997
3 ;
4LINEUP(INFO,TEMPLATE) ; Update Line +INFO. Line must be updated, NOT added or deleted.
5 ; Requires INFO,TEMPLATE
6 N NODE0
7 D:$D(INFO)<10 PARSE^TIUFLLM(.INFO) D:$D(NODE0)<10 NODE0ARR^TIUFLF($P(INFO,U,2),.NODE0) G:$D(DTOUT) LINEX
8 D BUFENTRY^TIUFLLM2(.INFO,.NODE0,TEMPLATE)
9 D UPDATE(TEMPLATE,0,INFO-1)
10LINEX Q
11 ;
12UPDATE(TMPLATE,SHIFT,LASTLIN,PINFO) ; Update LM TMPLATE using Buffer Array.
13 ; TMPLATE lines may be inserted, deleted, or reset. Resets 1 line;
14 ;inserts or deletes a continuous chunk of lines.
15 ; Lines to be inserted must be in buffer array ^TMP("TIUFB", starting
16 ;with line # LASTLIN+1 and running for SHIFT continuous lines.
17 ; Line to be reset must be in Buffer Array at line # LASTLIN+1,
18 ;with SHIFT = 0.
19 ; Lines to be deleted must be continuous lines starting with line #
20 ;LASTLIN+1 and running for -SHIFT lines, where SHIFT is negative.
21 ; Requires TMPLATE = LM Sub/Template H, A, I, T, D, O, or P; If TMPLATE
22 ; = H (Hierarchy), then lines to be added/deleted
23 ; must all be items under the same parent.
24 ; SHIFT is >0 for add; >0 for delete; =0 for reset.
25 ; |SHIFT| is Length of addition/deletion; a reset does not
26 ; add or delete, so SHIFT is 0 for reset.
27 ; LASTLIN = Line BEFORE Insertion/del/update point as above.
28 ;
29 ; Requires PINFO and PINFO array IF TMPLATE = "H" AND adding/deleting
30 ; (but NOT resetting) lines AND LASTLIN'=0 (Clinical Documents
31 ; HAS NO parent).
32 ; PINFO = ^TMP("TIUF1IDX,$J,LINENO), where LINENO is LM
33 ; Lineno of LM PARENT of lines added/deleted.
34 ; PINFO Array is as set in PARSE^TIUFLLM for PINFO.
35 ; PINFO is used to:
36 ; Update ^TMP("TIUF*IDX" for ancestors of lines
37 ; added/deleted (3rd piece, XPDLCNT);
38 ; Update the + preceeding Name of parent
39 ; of lines added/deleted.
40 ; If PINFO is received, routine returns updated PINFO array.
41 ; (Updates PINFO("XPDLCNT").
42 ; DOESN'T update VALMCNT. (Don't try it: may be updating template other than the one you're presently in.)
43 ;do I need "DAF" for all templates?;MAM
44 N LINENO,TIUI,TIUJ,OLDINFO,BEG,INC,END,BINFO,ARR,ARRIDX,ARRNO,VCNT
45 N INUSE,INUSE1,INUSECOL,PLINENO
46 S ARRNO=^TMP("TIUF",$J,"ARRNO"_TMPLATE)
47 S ARR="TIUF"_ARRNO,ARRIDX="TIUF"_ARRNO_"IDX"
48 I SHIFT'>0 D
49 . ;Delete lines to be deleted/updated
50 . S BEG=LASTLIN+1,END=$S(SHIFT=0:BEG,1:BEG-1-SHIFT)
51 . F TIUI=BEG:1:END D
52 . . S OLDINFO=^TMP(ARRIDX,$J,TIUI)
53 . . K ^TMP(ARR,$J,TIUI,0),^TMP(ARR,$J,"IDX",TIUI)
54 . . K ^TMP(ARRIDX,$J,"DAF",$P(OLDINFO,U,2),TIUI)
55 . . I TMPLATE="T" K ^TMP(ARRIDX,$J,"DA10",$P(OLDINFO,U,6),TIUI)
56 . . K ^TMP(ARRIDX,$J,TIUI)
57 . . Q
58 . Q
59 I SHIFT'=0 D
60 . ; Move lines starting w LASTLIN+1 down, creating gap to add entries
61 . ; OR Move lines after deleted lines up to fill in gap.
62 . S VCNT=$O(^TMP(ARR,$J,1000000),-1)
63 . I SHIFT>0 S BEG=VCNT,INC=-1,END=LASTLIN+1
64 . E S BEG=LASTLIN+1-SHIFT,INC=1,END=VCNT
65 . F LINENO=BEG:INC:END Q:INC>0&(BEG>END) Q:INC<0&(BEG<END) D
66 . . S ^TMP(ARR,$J,LINENO+SHIFT,0)=$$SETSTR^VALM1(LINENO+SHIFT,^TMP(ARR,$J,LINENO,0),1,5) ; SETFLD doesn't work since called by nontarget template.
67 . . I SHIFT>5!(SHIFT<-5) W "."
68 . . I ARR'="TIUF3" S ^TMP(ARR,$J,"IDX",LINENO+SHIFT,LINENO+SHIFT)=""
69 . . S OLDINFO=^TMP(ARRIDX,$J,LINENO)
70 . . S $P(OLDINFO,U)=LINENO+SHIFT
71 . . S PLINENO=$P(OLDINFO,U,5) I PLINENO>LASTLIN S $P(OLDINFO,U,5)=PLINENO+SHIFT
72 . . S ^TMP(ARRIDX,$J,"DAF",$P(OLDINFO,U,2),LINENO+SHIFT)=""
73 . . I TMPLATE="T" S ^TMP(ARRIDX,$J,"DA10",$P(OLDINFO,U,6),LINENO+SHIFT)=""
74 . . S ^TMP(ARRIDX,$J,LINENO+SHIFT)=OLDINFO
75 . . K ^TMP(ARR,$J,LINENO,0),^TMP(ARR,$J,"IDX",LINENO,LINENO)
76 . . K ^TMP(ARRIDX,$J,LINENO),^TMP(ARRIDX,$J,"DAF",$P(OLDINFO,U,2),LINENO)
77 . . I TMPLATE="T" K ^TMP(ARRIDX,$J,"DA10",$P(OLDINFO,U,6),LINENO)
78 . . Q
79 . Q
80 I SHIFT'<0 D
81 . ; Fill LM space with buffer array to add/update entries.
82 . S TIUJ=0 F S TIUJ=$O(^TMP("TIUFB",$J,TIUJ)) Q:'TIUJ D
83 . . S ^TMP(ARR,$J,TIUJ,0)=^TMP("TIUFB",$J,TIUJ,0)
84 . . I SHIFT>5 W "."
85 . . I ARR'="TIUF3" S ^TMP(ARR,$J,"IDX",TIUJ,TIUJ)=""
86 . . S BINFO=^TMP("TIUFBIDX",$J,TIUJ)
87 . . S ^TMP(ARRIDX,$J,"DAF",$P(BINFO,U,2),TIUJ)=""
88 . . I TMPLATE="T" S ^TMP(ARRIDX,$J,"DA10",$P(BINFO,U,6),TIUJ)=""
89 . . S ^TMP(ARRIDX,$J,TIUJ)=BINFO
90 . . Q
91 . K ^TMP("TIUFB",$J),^TMP("TIUFBIDX",$J)
92 . Q
93 I $G(PINFO),SHIFT,"HC"[TMPLATE D
94 . ; For Template H or C:
95 . ; Updates 3rd piece of ^TMP("TIUF1IDX",$J,LINENO) (XPDLCNT) for mutual
96 . ; parent and ancestors of entries to be added/deleted;
97 . ; Updates PINFO, array PINFO;
98 . ; Updates + in front of parent for template H
99 . N ANCLNO,XPDLCNT,AINFO
100 . S ANCLNO=+PINFO
101 . F S AINFO=$G(^TMP("TIUF1IDX",$J,ANCLNO)) Q:'AINFO D
102 . . S XPDLCNT=$P(AINFO,U,3)+SHIFT,$P(^TMP("TIUF1IDX",$J,ANCLNO),U,3)=XPDLCNT
103 . . S ANCLNO=+$P(AINFO,U,5)
104 . S PINFO("XPDLCNT")=$P(PINFO,U,3)+SHIFT
105 . S $P(PINFO,U,3)=PINFO("XPDLCNT")
106 . I TMPLATE="H" S ^TMP("TIUF1",$J,+PINFO,0)=$$PLUSUP^TIUFLLM(.PINFO,^TMP("TIUF1",$J,+PINFO,0))
107UPDAX Q
108 ;
Note: See TracBrowser for help on using the repository browser.