source: fmts/trunk/p/C0XCDA.m@ 1644

Last change on this file since 1644 was 1611, checked in by George Lilly, 12 years ago

moving on

File size: 3.3 KB
RevLine 
[1610]1C0XCDA ; GPL - Fileman Triples CDA Processing ;2/20/13 17:05
2 ;;0.1;C0X;nopatch;noreleasedate;Build 7
3 ;Copyright 2013 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 Q
21 ;
22 ;
23 ; -- some python that does a tree
24 ;def tree(node, prefix='|--'):
25 ; txt=('' if (node.text is None) or (len(node.text) == 0) else node.text);
26 ; txt2 = txt.replace('\n','');
27 ; print prefix+cdautil.clean(node.tag)+' '+txt2;
28 ; for att in node.attrib:
29 ; print prefix+' : '+cdautil.clean2(att)+'^'+node.attrib[att];
30 ; for child in node:
31 ; tree(child,'| '+prefix );
32 ;
[1611]33tree(where,prefix) ; show a tree starting at a node in MXML. where is passed by value
[1610]34 ;
35 i $g(prefix)="" s prefix="|--" ; starting prefix
36 i '$d(C0XJOB) s C0XJOB=$J
37 n node s node=$na(^TMP("MXMLDOM",C0XJOB,1,where))
38 n txt s txt=$$CLEAN($$ALLTXT(node))
39 w !,prefix_@node_" "_txt
40 n zi s zi=""
41 f s zi=$o(@node@("A",zi)) q:zi="" d ;
42 . w !,prefix_" : "_zi_"^"_$g(@node@("A",zi))
43 f s zi=$o(@node@("C",zi)) q:zi="" d ;
44 . d tree(zi,"| "_prefix)
45 q
46 ;
47show(what) ;
48 ;S C0XJOB=26295
49 I '$D(C0XJOB) S C0XJOB=$J
50 d tree(what)
51 q
52 ;
53ALLTXT(where) ; extrinsic which returns all text lines from the node .. concatinated
54 ; together
55 n zti s zti=""
56 n ztr s ztr=""
57 f s zti=$o(@where@("T",zti)) q:zti="" d ;
58 . s ztr=ztr_$g(@where@("T",zti))
59 q ztr
60 ;
61CLEAN(STR) ; extrinsic function; returns string - gpl borrowed from the CCR package
62 ;; Removes all non printable characters from a string.
63 ;; STR by Value
64 N TR,I
65 F I=0:1:31 S TR=$G(TR)_$C(I)
66 S TR=TR_$C(127)
67 N ZR S ZR=$TR(STR,TR)
[1611]68 S ZR=$$LTRIM(ZR) ; get rid of leading blanks
[1610]69 QUIT ZR
70 ;
[1611]71LDBLNKS(st) ; extrinsic which removes leading blanks from a string - deprecated see LTRIM
[1610]72 n zr s zr=st
73 f q:$e(zr,1)'=" " s zr=$e(zr,2,$l(zr))
74 q zr
75 ;
[1611]76 ; copied from VPRJT - thanks.
77UP(X) ; return uppercase for X
78 Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
79 ;
80LTRIM(X) ; remove spaces from left side
81 N POS F POS=1:1:$L(X) Q:$E(X,POS)'=" "
82 Q $E(X,POS,$L(X))
83 ;
[1610]84VACCD ; set C0XJOB to the VA CCD
85 s C0XJOB=14921
86 q
87 ;
88NLMVS ; set C0XJOB to the NLM Values Set xml
89 s C0XJOB=26295
90 Q
91 ;
92agenda(zrtn,docId) ; produce an agenda for the docId in the MXML dom
93 ; generally, a first level index to the document
94 ; set C0XJOB if you want to use a different $J to locate the dom
95 ; zrtn passed by name
96 ;
97 ;s C0XJOB=26295
98 n zi s zi=""
99 i '$d(docId) s docId=1
100 i '$D(C0XJOB) s C0XJOB=$J
101 n dom s dom=$na(^TMP("MXMLDOM",C0XJOB,docId))
102 f s zi=$o(@dom@(1,"C",zi)) q:zi="" d ;
103 . n zn s zn=@dom@(1,"C",zi)
104 . s zn=zn_" "_$g(@dom@(zi,"A","displayName"))
105 . s @zrtn@(zn,zi)=""
106 q
107 ;
Note: See TracBrowser for help on using the repository browser.