source: FOIAVistA/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUR2.m@ 1671

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

initial load of FOIAVistA 6/30/08 version

File size: 8.5 KB
Line 
1TIUR2 ; SLC/JER - Integrated Document Review ;1/29/04
2 ;;1.0;TEXT INTEGRATION UTILITIES;**100,113,208**;Jun 20, 1997
3 ; 12/12/00 new rtn, from splitting TIUR1
4REPLACE(TIUDA,SORTVAL,SORTFLD,DATTIM,EXPAND,FORGETAD) ; Fix ^TMP("TIUI",$J).
5 ;Remove ID kid or addm records from ^TMP("TIUI",$J), and replace
6 ;with parent record instead.
7 ; Requires TIUDA, SORTVAL, SORTFLD, DATTIM.
8 ; Passes back opt array EXPAND, where EXPAND(IFN)=""
9 ; opt flag FORGETAD: don't expand parent for sake of addm
10 N IDPRNT,ADDMPRNT,ADDMGPNT,PVAL,GPVAL,PDATTIM,GPDATTIM,NODE
11 S IDPRNT=+$G(^TIU(8925,TIUDA,21)) ; ID parent
12 I '$D(^TIU(8925,IDPRNT,0)) S IDPRNT=0
13 I IDPRNT D
14 . S PVAL=$$RESOLVE^TIUR1(IDPRNT,SORTFLD)
15 . S PDATTIM=$S(^TMP("TIUR",$J,"RTN")="TIURM":+$G(^TIU(8925,IDPRNT,12)),1:+$G(^TIU(8925,IDPRNT,13))) ; rtn TIURM uses "F" XREF, whose date is ENTRY DT.
16 . S PDATTIM=9999999-PDATTIM
17 S ADDMPRNT=+$P($G(^TIU(8925,TIUDA,0)),U,6) ; assume TIUDA is not component
18 I '$D(^TIU(8925,ADDMPRNT,0)) S ADDMPRNT=0
19 I ADDMPRNT D
20 . S PVAL=$$RESOLVE^TIUR1(ADDMPRNT,SORTFLD)
21 . S PDATTIM=$S(^TMP("TIUR",$J,"RTN")="TIUR":+$G(^TIU(8925,ADDMPRNT,13)),1:+$G(^TIU(8925,ADDMPRNT,12)))
22 . S PDATTIM=9999999-PDATTIM
23 S EXPAND=+$G(EXPAND)
24 ; -- If TIUDA is not an ID kid, not addm, just quit: --
25 I 'IDPRNT,'ADDMPRNT Q
26 ; -- Take kid or addm out of array:
27 S NODE=^TMP("TIUI",$J,SORTVAL,DATTIM,TIUDA)
28 K ^TMP("TIUI",$J,SORTVAL,DATTIM,TIUDA)
29 ; -- If TIUDA is an ID kid, put its parent in array:
30 I IDPRNT D Q
31 . I '$D(EXPAND(IDPRNT)) S EXPAND(IDPRNT)="",EXPAND=EXPAND+1
32 . Q:$$CHKPAR(IDPRNT)
33 . S ^TMP("TIUI",$J,PVAL,PDATTIM,IDPRNT)=NODE
34 ; -- If TIUDA is an addendum, put its (g)parent in array:
35 I ADDMPRNT D Q
36 . I '$G(FORGETAD),'$D(EXPAND(ADDMPRNT)) S EXPAND(ADDMPRNT)="",EXPAND=EXPAND+1
37 . S ADDMGPNT=+$G(^TIU(8925,ADDMPRNT,21))
38 . I '$D(^TIU(8925,ADDMGPNT,0)) S ADDMGPNT=0
39 . I ADDMGPNT D I 1
40 . . S GPVAL=$$RESOLVE^TIUR1(ADDMGPNT,SORTFLD)
41 . . S GPDATTIM=$S(^TMP("TIUR",$J,"RTN")="TIUR":+$G(^TIU(8925,ADDMGPNT,13)),1:+$G(^TIU(8925,ADDMGPNT,12)))
42 . . S GPDATTIM=9999999-GPDATTIM
43 . . I '$D(EXPAND(ADDMGPNT)) S EXPAND(ADDMGPNT)="",EXPAND=EXPAND+1
44 . . Q:$$CHKPAR(ADDMGPNT)
45 . . S ^TMP("TIUI",$J,GPVAL,GPDATTIM,ADDMGPNT)=NODE
46 . E D
47 . . Q:$$CHKPAR(ADDMPRNT)
48 . . S ^TMP("TIUI",$J,PVAL,PDATTIM,ADDMPRNT)=NODE
49 Q
50 ;
51CHKPAR(CHKDA) ;
52 N TIU1,TIU2,TIU3,TIURES
53 S TIU1="",TIURES=0
54 F S TIU1=$O(^TMP("TIUI",$J,TIU1)) Q:TIU1=""!(TIURES) D
55 . S TIU2=""
56 . F S TIU2=$O(^TMP("TIUI",$J,TIU1,TIU2)) Q:TIU2=""!(TIURES) D
57 . . S TIU3=""
58 . . F S TIU3=$O(^TMP("TIUI",$J,TIU1,TIU2,TIU3)) Q:TIU3=""!(TIURES) D
59 . . . I TIU3=ADDMPRNT S TIURES=1
60 Q TIURES
61 ;
62SETLIST(TIUORDER,VALMCNT,SCREEN) ; Set items from ^TMP("TIUI",$J) into
63 ;List Template list
64 N SORTVAL,TIUDTM,TIUDA
65 S SORTVAL=""
66 F S SORTVAL=$O(^TMP("TIUI",$J,SORTVAL),TIUORDER) Q:SORTVAL="" D
67 . S TIUDTM=0
68 . F S TIUDTM=$O(^TMP("TIUI",$J,SORTVAL,TIUDTM)) Q:'TIUDTM D
69 . . S TIUDA=0
70 . . F S TIUDA=$O(^TMP("TIUI",$J,SORTVAL,TIUDTM,TIUDA)) Q:'TIUDA D
71 . . . ; D ADDELMNT(TIUDA,.VALMCNT) ; P113
72 . . . I SCREEN=1!(SCREEN="ALL") D ADDELMNT(TIUDA,.VALMCNT)
73 . . . I SCREEN>1,$G(^TMP("TIUI",$J,SORTVAL,TIUDTM,TIUDA))=SCREEN D ADDELMNT(TIUDA,.VALMCNT)
74 Q
75 ;
76PUTLIST(TIUPREF,TIUCLASS,STATUS,SCREEN) ; Puts elements in List Template list
77 N TIUJ,TIUQ,TIUDA,TIUPICK,TIUORDER,TIUEXPKD,TIUSFLD
78 S VALMCNT=0
79 S TIUSFLD=$P(TIUPREF,U,3)
80 S TIUSFLD=$S(TIUSFLD="P":".02",TIUSFLD="D":".01",TIUSFLD="S":".05",TIUSFLD="C":"1507",TIUSFLD="A":"1202",TIUSFLD="E":"1208",1:"1301")
81 S TIUORDER=$S($P(TIUPREF,U,4)="A":1,1:-1) ;A for ascending
82 S TIUPICK=+$O(^ORD(101,"B","TIU ACTION SELECT LIST ELEMENT",0))
83 S TIUQ="" F S TIUQ=$O(^TMP("TIUI",$J,TIUQ)) Q:TIUQ']"" D
84 . S TIUJ=0 F S TIUJ=$O(^TMP("TIUI",$J,TIUQ,TIUJ)) Q:+TIUJ'>0 D
85 . . S TIUDA=0
86 . . F S TIUDA=$O(^TMP("TIUI",$J,TIUQ,TIUJ,TIUDA)) Q:+TIUDA'>0 D
87 . . . D REPLACE(TIUDA,TIUQ,TIUSFLD,TIUJ,.TIUEXPKD)
88 D SETLIST(TIUORDER,.VALMCNT,SCREEN)
89 S ^TMP("TIUR",$J,0)=+$G(VALMCNT)_U_STATUS("WORDS")
90 S TIUJ=0,SCREEN="" F S TIUJ=$O(SCREEN(TIUJ)) Q:+TIUJ'>0 D
91 . S SCREEN=$G(SCREEN)_$S(TIUJ>1:";",1:U)_SCREEN(TIUJ)
92 S ^TMP("TIUR",$J,0)=^TMP("TIUR",$J,0)_$G(SCREEN)
93 S ^TMP("TIUR",$J,"CLASS")=TIUCLASS
94 S ^TMP("TIUR",$J,"#")=TIUPICK_"^1:"_+$G(VALMCNT)
95 I $D(VALMHDR)>9 D HDR^TIURH
96 I +$G(VALMCNT)'>0 D
97 . S ^TMP("TIUR",$J,1,0)="",VALMCNT=2
98 . S ^TMP("TIUR",$J,2,0)=" No records found to satisfy search criteria."
99 . S ^TMP("TIUR",$J,"IDX",1,0)="" ; User can't select lines 1 or 2
100 . S ^TMP("TIUR",$J,"IDX",2,0)=""
101 I '$G(TIURBLD),$D(TIUEXPKD) D EXPANDKD(.TIUEXPKD,STATUS("WORDS"))
102 Q
103 ;
104EXPANDKD(TIUEXPKD,STATWORD,CONTEXT) ; Expand items to show kids that meet
105 ;search criteria.
106 ; Requires array TIUEXPKD, requires VALMCNT
107 ; Requires nonnull: STATWORD (from TIUR1) or CONTEXT (from TIUROR).
108 N TIUEXP2,YESEXPD,LINENO,HELP,TIUTWO
109 ; -- Expand only for status unsigned or uncosigned, & not for "ALL":
110 I STATWORD]"" Q:((STATWORD["ALL")!((STATWORD'["UNSIGNED")&(STATWORD'["UNCOSIGNED")))
111 I $G(CONTEXT) Q:((CONTEXT'=2)&(CONTEXT'=3)) ;unsigned, uncosigned
112 I (5*TIUEXPKD+$G(VALMCNT))>50 D Q:'YESEXPD
113 . W !!," There are ",TIUEXPKD," items (Interdisciplinary Notes, Addenda) to expand",!," in a list of ",VALMCNT," items."
114 . S HELP="NO saves time building the list, but 'hides' relevant items under their parent until you expand the parent yourself."
115 . S YESEXPD=$$READ^TIUU("Y"," Shall I take the extra time to expand them before I list them","NO",HELP)
116 D LOAD^TIUROR1(.TIUEXPKD,.TIUEXP2)
117 D BREATHE^TIUROR1(1)
118 ; Try again if not in list til expanded once:
119 ; (Can't use BREATHE^TIUROR1 again since it COLLAPSES now.)
120 Q:'$D(TIUEXP2)
121 S TIUDA=0
122 F S TIUDA=$O(TIUEXP2(TIUDA)) Q:'TIUDA D
123 . S LINENO=$O(^TMP("TIUR",$J,"IEN",TIUDA,0))
124 . Q:'LINENO
125 . S TIUTWO(LINENO)=""
126 S LINENO=VALMCNT+1
127 F S LINENO=$O(TIUTWO(LINENO),-1) Q:'LINENO D
128 . D BREATHE^TIURL1(LINENO,1)
129 Q
130 ;
131ADDELMNT(TIUDA,TIUCNT,APPEND) ; Add each element to the list
132 N PT,ADT,DDT,AUT,AMD,EDT,SDT,XDT,TIULST4,INSTA,TIUSTN
133 N TIUREC,TIUD0,TIUD12,TIUD13,TIUD15,TIULI,STATX,DOC
134 N PREFIX,TIUGDATA
135 I '$D(^TIU(8925,TIUDA,0)) Q
136 I $G(^TMP("TIUR",$J,2,0))=" No records found to satisfy search criteria." D
137 . K ^TMP("TIUR",$J,2),^TMP("TIUR",$J,"IDX",2),^TMP("TIUR",$J,"IDX",1)
138 . S TIUCNT=0
139 S TIUD0=$G(^TIU(8925,TIUDA,0)),TIUD12=$G(^TIU(8925,TIUDA,12))
140 S TIUD13=$G(^TIU(8925,TIUDA,13)),TIUD15=$G(^TIU(8925,TIUDA,15))
141 S DOC=$$PNAME^TIULC1(+TIUD0)
142 I DOC="Addendum" S DOC=DOC_" to "_$$PNAME^TIULC1(+$G(^TIU(8925,+$P(TIUD0,U,6),0)))
143 S PREFIX=$$PREFIX^TIULA2(TIUDA,0)
144 S PT=$$NAME^TIULS($$PTNAME^TIULC1($P(TIUD0,U,2)),"LAST,FI MI")
145 S TIULI=$E(PT)
146 S PT=PREFIX_PT
147 S TIULST4=$E($P($G(^DPT(+$P(TIUD0,U,2),0)),U,9),6,9)
148 S TIULST4="("_TIULI_TIULST4_")"
149 S ADT=$$DATE^TIULS($P(TIUD0,U,7),"MM/DD/YY")
150 S DDT=$$DATE^TIULS($P(TIUD0,U,8),"MM/DD/YY")
151 S AMD=$$PERSNAME^TIULC1($P(TIUD12,U,8)) S:AMD="UNKNOWN" AMD=""
152 S AUT=$$PERSNAME^TIULC1($P(TIUD12,U,2)) S:AUT="UNKNOWN" AUT=""
153 S AMD=$$NAME^TIULS(AMD,"LAST, FI MI")
154 S AUT=$$NAME^TIULS(AUT,"LAST, FI MI")
155 S EDT=$$DATE^TIULS($P(TIUD13,U),"MM/DD/YY")
156 S SDT=$S(+$P(TIUD15,U,7):+$P(TIUD15,U,7),+$P(TIUD0,U,5)'<7:+$P(TIUD15,U),1:"")
157 S SDT=$$DATE^TIULS(SDT,"MM/DD/YY")
158 S STATX=$P($G(^TIU(8925.6,+$P(TIUD0,U,5),0)),U)
159 S INSTA=""
160 I +$P(TIUD12,U,12)>0 D
161 . S TIUSTN=$$NS^XUAF4($P(TIUD12,U,12))
162 . I $P(TIUSTN,U,2)]"" S INSTA=$P(TIUSTN,U,2)
163 S INSTA=$E(INSTA,1,8)
164 S TIUCNT=+$G(TIUCNT)+1
165 S TIUREC=$$SETFLD^VALM1(TIUCNT,"","NUMBER")
166 S TIUREC=$$SETFLD^VALM1(PT,TIUREC,"PATIENT NAME")
167 S TIUREC=$$SETFLD^VALM1(TIULST4,TIUREC,"LAST I/LAST 4")
168 S TIUREC=$$SETFLD^VALM1(DOC,TIUREC,"DOCUMENT TYPE")
169 S TIUREC=$$SETFLD^VALM1(EDT,TIUREC,"REF DATE")
170 S TIUREC=$$SETFLD^VALM1($$LOWER^TIULS(STATX),TIUREC,"STATUS")
171 S TIUREC=$$SETFLD^VALM1(SDT,TIUREC,"SIG DATE")
172 S TIUREC=$$SETFLD^VALM1(AUT,TIUREC,"AUTHOR")
173 S TIUREC=$$SETFLD^VALM1(AMD,TIUREC,"EXPECTED COSIGNER")
174 S TIUREC=$$SETFLD^VALM1(INSTA,TIUREC,"DIVISION")
175 S ^TMP("TIUR",$J,TIUCNT,0)=TIUREC
176 S ^TMP("TIUR",$J,"IDX",TIUCNT,TIUCNT)="" W:TIUCNT#10'>0 "."
177 S ^TMP("TIURIDX",$J,TIUCNT)=TIUCNT_U_TIUDA_U_PREFIX
178 S ^TMP("TIUR",$J,"IEN",TIUDA,TIUCNT)="" ;MARGY 11/11/00
179 S TIUGDATA=$$IDDATA^TIURECL1(TIUDA,TIUD0)
180 I TIUGDATA S ^TMP("TIUR",$J,"IDDATA",TIUDA)=TIUGDATA
181 I +$G(APPEND) D
182 . D RESTORE^VALM10(TIUCNT)
183 . D CNTRL^VALM10(TIUCNT,1,$G(VALM("RM")),IOINHI,IOINORM),HDR^TIURH
184 . S VALMSG="** Item(s) #"_$$ITMLIST(TIUCNT,$G(VALMSG))_" Added **"
185 . S $P(^TMP("TIUR",$J,0),U)=TIUCNT
186 . S $P(^TMP("TIUR",$J,"#"),":",2)=TIUCNT
187 . S VALMCNT=TIUCNT
188 . I $D(VALMHDR)>9 D HDR^TIURH
189 Q
190ITMLIST(TIUITM,TIUMSG) ; Add Message
191 N TIULIST
192 I $E($G(TIUMSG),1,7)'="** Item" S TIULIST=TIUITM G ITMLISTX
193 S TIULIST=$P($P($G(TIUMSG)," Added **"),"#",2)_" & "_TIUITM
194ITMLISTX Q $G(TIULIST)
195 Q
Note: See TracBrowser for help on using the repository browser.