Changeset 1612
- Timestamp:
- Mar 7, 2013, 7:20:32 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fmts/trunk/p/C0XOTLN.m
r1611 r1612 95 95 q 96 96 ; 97 tree2(where,prefix) ; show a tree starting at a node in MXML. node is passed by name 98 ; tree2 handles ConceptLists as tables 99 i $g(prefix)="" s prefix="|--" ; starting prefix 100 i '$d(C0XJOB) s C0XJOB=$J 101 n node s node=$na(^TMP("MXMLDOM",C0XJOB,1,where)) 102 ;n txt s txt=$$CLEAN($$ALLTXT(node)) 103 n txt d alltxt(.txt,node) 104 ;w !,prefix_@node_" "_txt 105 n zk s zk="" 106 f s zk=$o(txt(zk)) q:zk="" d ; 107 . i zk=1 d out(prefix_@node_" "_txt(zk)) q ; 108 . d out(prefix_txt(zk)) 109 i @node["ns0:ConceptList" d q ; 110 . d clist(where,prefix) 111 n zi s zi="" 112 f s zi=$o(@node@("A",zi)) q:zi="" d ; 113 . ;w !,prefix_" : "_zi_"^"_$g(@node@("A",zi)) 114 . d out(prefix_" : "_zi_"^"_$g(@node@("A",zi))) 115 n grpstart s grpstart=0 116 f s zi=$o(@node@("C",zi)) q:zi="" d ; 117 . i @node@("C",zi)="ns0:RevisionDate" d newgrp 118 . i @node@("C",zi)="ns0:Group" d group(zi) q ; 119 . d tree2(zi,"| "_prefix) 120 d:grpstart grpout 121 q 122 ; 123 newgrp ; kill the group array for a new group 124 ;W !,"NEW GROUP" 125 k ^TMP("C0XNLMVS",$J,"GROUP") 126 q 127 ; 128 group(where) ; add a group node to the group array 129 s grpstart=1 130 n gn s gn=$na(^TMP("C0XNLMVS",$J,"GROUP")) 131 n node s node=$na(^TMP("MXMLDOM",C0XJOB,1)) 132 n gnum s gnum=$g(@node@(where,"A","ID")) 133 i gnum="" d q ; 134 . w !,"error finding group number ",where 135 n var s var=@node@(where,"A","displayName") 136 n valref s valref=$o(@node@(where,"C","")) 137 i valref="" d q ; 138 . w !,"error finding value reference ",where 139 n val s val=@node@(valref,"T",1) 140 s @gn@(gnum,var)=val 141 q 142 ; 143 grpout ; output the group array 144 ;zwr ^TMP("C0XNLMVS",$J,*) 145 ;b 146 n gn s gn=$na(^TMP("C0XNLMVS",$J,"GROUP")) 147 n grp s grp="" 148 f s grp=$o(@gn@(grp)) q:grp="" d ; 149 . d out("--------------------------------------------------------------") 150 . n attr s attr="" 151 . f s attr=$o(@gn@(grp,attr)) q:attr="" d ; 152 . . d out(attr_": "_@gn@(grp,attr)) 153 q 154 ; 155 out(txt) ; add line to output array 156 s c0xout=$na(^TMP("C0XOUT",$J)) 157 n cnt 158 s cnt=$o(@c0xout@(""),-1) 159 i cnt="" s cnt=0 160 s @c0xout@(cnt+1)=txt 161 q 162 ; 163 clist(where,prefix,nohead) 164 n nd s nd=$na(^TMP("MXMLDOM",C0XJOB,1)) 165 ;i '$d(nohead) s nohead=0 166 ;i 'nohead d ; 167 d out($j("Code",20)_$j("System",10)_$j("Description",20)) 168 n zzi s zzi="" 169 f s zzi=$o(@nd@(where,"C",zzi)) q:zzi="" d ; 170 . n code,system,desc 171 . s code=$g(@nd@(zzi,"A","code")) 172 . s system=$g(@nd@(zzi,"A","codeSystemName")) 173 . s desc=$g(@nd@(zzi,"A","displayName")) 174 . d out($j(code,20)_$j(system,10)_" "_desc) 175 ;w @nd,":",@nd@("T",1) 176 q 177 ; 178 alltxt(rtn,node) ; handle arrays of text 179 m rtn=@node@("T") 180 n zj s zj="" 181 f s zj=$o(rtn(zj)) q:zj="" d ; 182 . s rtn(zj)=$$CLEAN(rtn(zj)) 183 . s rtn(zj)=$$LDBLNKS(rtn(zj)) 184 . i rtn(zj)="" k rtn(zj) 185 . i (rtn(zj)=" ")&(zj>1) k rtn(zj) 186 q 187 ; 97 188 ALLTXT(where) ; extrinsic which returns all text lines from the node .. concatinated 98 189 ; together … … 125 216 Q 126 217 ; 127 agenda(zrtn,docId) ; produce an agenda for the docIdin the MXML dom218 contents(zrtn,ids) ; produce an agenda for the docId 1 in the MXML dom 128 219 ; generally, a first level index to the document 129 220 ; set C0XJOB if you want to use a different $J to locate the dom 130 221 ; zrtn passed by name 131 ; 222 ; ids=1 names them by number ids=0 or null names them by displayname 132 223 ;s C0XJOB=26295 224 D NLMVS 133 225 n zi s zi="" 134 226 i '$d(docId) s docId=1 … … 136 228 n dom s dom=$na(^TMP("MXMLDOM",C0XJOB,docId)) 137 229 f s zi=$o(@dom@(1,"C",zi)) q:zi="" d ; 138 . n zn s zn=@dom@(1,"C",zi) 139 . s zn=zn_" "_$g(@dom@(zi,"A","displayName")) 140 . s @zrtn@(zn,zi)="" 141 q 142 ; 230 . n zn ; 231 . d:$g(ids) ; 232 . . s zn=$tr($g(@dom@(zi,"A","ID")),".","-")_".txt" 233 . . s @zrtn@(zn,zi)="" 234 . d:'$g(ids) ; 235 . . s zn=$tr($g(@dom@(zi,"A","displayName"))," ","_")_".txt" 236 . . s zn=$tr(zn,"()","") ; get rid of parens for valid filename 237 . . s zn=$tr(zn,"/","-") ; get rid of slash for valid filename 238 . . s @zrtn@(zn,zi)="" 239 q 240 ; 241 export ; exports separate files for each value set 242 ; one copy in a file with a text name based on the displayName 243 n g,zi,fname,where,dirname,gn 244 s gn=$na(^TMP("C0XOUT",$J)) 245 s dirname="/home/wvehr2/valuesets/by-name/" 246 s zi="" 247 d contents("g") ; first with text names 248 f s zi=$o(g(zi)) q:zi="" d ; 249 . s fname=zi 250 . s where=$o(g(zi,"")) 251 . k @gn 252 . d tree2(where,"| ") 253 . n gn2 s gn2=$na(@gn@(1)) ; name for gtf 254 . s ok=$$GTF^%ZISH(gn2,3,dirname,fname) 255 q 256 ; 257 export2 ; exports separate files for each value set 258 ; one copy in a file with a numeric file name based on ID 259 n g,zi,fname,where,dirname,gn 260 s gn=$na(^TMP("C0XOUT",$J)) 261 s dirname="/home/wvehr2/valuesets/by-id/" 262 s zi="" 263 d contents("g",1) ; with id names 264 f s zi=$o(g(zi)) q:zi="" d ; 265 . s fname=zi 266 . s where=$o(g(zi,"")) 267 . k @gn 268 . d tree2(where,"| ") 269 . n gn2 s gn2=$na(@gn@(1)) ; name for gtf 270 . s ok=$$GTF^%ZISH(gn2,3,dirname,fname) 271 q 272 ;
Note:
See TracChangeset
for help on using the changeset viewer.