source: ccr/trunk/p/C0CMXML.m@ 615

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

update to CCD parsing

File size: 13.5 KB
RevLine 
[575]1C0CMXML ; ERX/GPL - MXML based XPath utilities;10/13/09 17:05
2 ;;0.1;C0P;nopatch;noreleasedate
3 ;Copyright 2009 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 ;
22TEST ;
23 S C0CXMLIN=$NA(^TMP("C0CMXML",$J))
24 K GARY
25 W $$FTG^%ZISH("/home/vademo2/EHR/p/","mxml-test.xml",$NA(@C0CXMLIN@(1)),3)
26 S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DocID: ",C0CDOCID
27 S REDUX="//ContinuityOfCareRecord/Body"
28 D XPATH(1,"/","GIDX","GARY",,REDUX)
29 Q
30 ;
[606]31TEST4 ; TEST OF OUTPUTING AN XML FILE FROM THE DOM .. this one is the CCR
32 ;
33 D TEST ; SET UP THE DOM
34 D START^C0CMXMLB($$TAG(1),,"G")
35 D NDOUT($$FIRST(1))
36 D END^C0CMXMLB ;END THE DOCUMENT
37 M ZCCR=^TMP("MXMLBLD",$J)
38 ZWR ZCCR
39 Q
40 ;
41TEST5 ; SAME AS TEST4, BUT THIS TIME THE CCD
42 S C0CXMLIN=$NA(^TMP("C0CMXML",$J))
43 K GARY,GTMP,GIDX
44 K @C0CXMLIN
45 W $$FTG^%ZISH("/home/vademo2/CCR/","SampleCCDDocument.xml",$NA(@C0CXMLIN@(1)),3)
46 D CLEANARY("GTMP",C0CXMLIN) ; REMOVE CONTROL CHARACTERS
47 K @C0CXMLIN
48 M @C0CXMLIN=GTMP
49 K GTMP
50 D STRIPTXT("GTMP",C0CXMLIN)
51 K @C0CXMLIN
52 M @C0CXMLIN=GTMP
53 K GTMP
54 S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DOCID: ",C0CDOCID ;CALL REGULAR PARSER
55 ;D XPATH(1,"/","GIDX2","GARY2",,REDUX)
56 D OUTXML("ZCCD",C0CDOCID)
57 ;D START^C0CMXMLB($$TAG(1),,"G")
58 ;D NDOUT($$FIRST(1))
59 ;D END^C0CMXMLB ;END THE DOCUMENT
60 ;M ZCCD=^TMP("MXMLBLD",$J)
61 ZWR ZCCD(1:30)
62 Q
63 ;
[575]64TEST2 ;
65 S REDUX="//soap:Envelope/soap:Body/GetPatientFullMedicationHistory5Response/GetPatientFullMedicationHistory5Result/patientDrugDetail"
66 D XPATH(1,"/","GIDX","GARY","",REDUX)
67 Q
68 ;
[601]69TEST3
70 S C0CXMLIN=$NA(^TMP("C0CMXML",$J))
71 K GARY,GTMP,GIDX
72 K @C0CXMLIN
73 W $$FTG^%ZISH("/home/vademo2/CCR/","SampleCCDDocument.xml",$NA(@C0CXMLIN@(1)),3)
74 D CLEANARY("GTMP",C0CXMLIN) ; REMOVE CONTROL CHARACTERS
75 K @C0CXMLIN
76 M @C0CXMLIN=GTMP
77 K GTMP
78 D STRIPTXT("GTMP",C0CXMLIN)
79 K @C0CXMLIN
80 M @C0CXMLIN=GTMP
81 K GTMP
82 S C0CDOCID=$$PARSCCD(C0CXMLIN,"W") W !,"DocID: ",C0CDOCID
83 S REDUX="//ClinicalDocument/component/structuredBody"
[605]84 D FINDTID ; FIND THE TEMPLATE IDS
85 D FINDALT ; FIND ALTERNATE TAGS
86 D SETCBK ; SET THE CALLBACK ROUTINE FOR TAGS
[601]87 D XPATH(1,"/","GIDX","GARY",,REDUX)
[606]88 K C0CCBK("TAG")
[605]89 D SEPARATE("GARY2","GARY") ; SEPARATE FOR EASIER BROWSING
90 ;S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DOCID: ",C0CDOCID ;CALL REGULAR PARSER
91 ;D XPATH(1,"/","GIDX2","GARY2",,REDUX)
[601]92 Q
93 ;
[575]94XPATH(ZOID,ZPATH,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; RECURSIVE ROUTINE TO POPULATE
95 ; THE XPATH INDEX ZXIDX, PASSED BY NAME
96 ; THE XPATH ARRAY XPARY, PASSED BY NAME
97 ; ZOID IS THE STARTING OID
98 ; ZPATH IS THE STARTING XPATH, USUALLY "/"
99 ; ZNUM IS THE MULTIPLE NUMBER [x], USUALLY NULL WHEN ON THE TOP NODE
100 ; ZREDUX IS THE XPATH REDUCTION STRING, TAKEN OUT OF EACH XPATH IF PRESENT
101 I $G(ZREDUX)="" S ZREDUX=""
102 N NEWPATH
103 N NEWNUM S NEWNUM=""
104 I $G(ZNUM)>0 S NEWNUM="["_ZNUM_"]"
105 S NEWPATH=ZPATH_"/"_$$TAG(ZOID)_NEWNUM ; CREATE THE XPATH FOR THIS NODE
106 I $G(ZREDUX)'="" D ; REDUX PROVIDED?
107 . N GT S GT=$P(NEWPATH,ZREDUX,2)
108 . I GT'="" S NEWPATH=GT
109 S @ZXIDX@(NEWPATH)=ZOID ; ADD THE XPATH FOR THIS NODE TO THE XPATH INDEX
110 N GD D DATA("GD",ZOID) ; SEE IF THERE IS DATA FOR THIS NODE
111 I $D(GD(2)) M @ZXPARY@(NEWPATH)=GD ; IF MULITPLE DATA MERGE TO THE ARRAY
112 E I $D(GD(1)) S @ZXPARY@(NEWPATH)=GD(1) ; IF SINGLE VALUE, ADD TO ARRAY
113 N ZFRST S ZFRST=$$FIRST(ZOID) ; SET FIRST CHILD
114 I ZFRST'=0 D ; THERE IS A CHILD
[605]115 . N ZNUM
[575]116 . N ZMULT S ZMULT=$$ISMULT(ZFRST) ; IS FIRST CHILD A MULTIPLE
117 . D XPATH(ZFRST,NEWPATH,ZXIDX,ZXPARY,$S(ZMULT:1,1:""),ZREDUX) ; DO THE CHILD
118 N GNXT S GNXT=$$NXTSIB(ZOID)
[605]119 I $$TAG(GNXT)'=$$TAG(ZOID) S ZNUM="" ; RESET COUNTING AFTER MULTIPLES
[575]120 I GNXT'=0 D ;
[601]121 . N ZMULT S ZMULT=$$ISMULT(GNXT) ; IS THE SIBLING A MULTIPLE?
122 . I (ZNUM="")&(ZMULT) D ; SIBLING IS FIRST OF MULTIPLES
[605]123 . . N ZNUM S ZNUM=1 ;
[601]124 . . D XPATH(GNXT,ZPATH,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; DO NEXT SIB
125 . E D XPATH(GNXT,ZPATH,ZXIDX,ZXPARY,$S(ZNUM>0:ZNUM+1,1:""),ZREDUX) ; DO NEXT SIB
[575]126 Q
127 ;
128PARSE(INXML,INDOC) ;CALL THE MXML PARSER ON INXML, PASSED BY NAME
129 ; INDOC IS PASSED AS THE DOCUMENT NAME - DON'T KNOW WHERE TO STORE THIS NOW
130 ; EXTRINSIC WHICH RETURNS THE DOCID ASSIGNED BY MXML
131 ;Q $$EN^MXMLDOM(INXML)
132 Q $$EN^MXMLDOM(INXML,"W")
133 ;
134ISMULT(ZOID) ; RETURN TRUE IF ZOID IS ONE OF A MULTIPLE
135 N ZN
[601]136 ;I $$TAG(ZOID)["entry" B
[575]137 S ZN=$$NXTSIB(ZOID)
138 I ZN'="" Q $$TAG(ZOID)=$$TAG(ZN) ; IF TAG IS THE SAME AS NEXT SIB TAG
139 Q 0
140 ;
141FIRST(ZOID) ;RETURNS THE OID OF THE FIRST CHILD OF ZOID
142 Q $$CHILD^MXMLDOM(C0CDOCID,ZOID)
143 ;
[601]144PARENT(ZOID) ;RETURNS THE OID OF THE PARENT OF ZOID
145 Q $$PARENT^MXMLDOM(C0CDOCID,ZOID)
146 ;
[606]147ATT(RTN,NODE) ;GET ATTRIBUTES FOR ZOID
148 S HANDLE=C0CDOCID
149 K @RTN
150 D GETTXT^MXMLDOM("A")
151 Q
152 ;
[575]153TAG(ZOID) ; RETURNS THE XML TAG FOR THE NODE
[605]154 ;I ZOID=149 B ;GPLTEST
155 N X,Y
156 S Y=""
157 S X=$G(C0CCBK("TAG")) ;IS THERE A CALLBACK FOR THIS ROUTINE
158 I X'="" X X ; EXECUTE THE CALLBACK, SHOULD SET Y
159 I Y="" S Y=$$NAME^MXMLDOM(C0CDOCID,ZOID)
160 Q Y
[575]161 ;
162NXTSIB(ZOID) ; RETURNS THE NEXT SIBLING
163 Q $$SIBLING^MXMLDOM(C0CDOCID,ZOID)
164 ;
165DATA(ZT,ZOID) ; RETURNS DATA FOR THE NODE
166 ;N ZT,ZN S ZT=""
167 ;S C0CDOM=$NA(^TMP("MXMLDOM",$J,C0CDOCID))
168 ;Q $G(@C0CDOM@(ZOID,"T",1))
169 S ZN=$$TEXT^MXMLDOM(C0CDOCID,ZOID,ZT)
170 Q
171 ;
[606]172OUTXML(ZRTN,INID) ; USES C0CMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM
173 ;
174 S C0CDOCID=INID
175 D START^C0CMXMLB($$TAG(1),,"G")
176 D NDOUT($$FIRST(1))
177 D END^C0CMXMLB ;END THE DOCUMENT
178 M @ZRTN=^TMP("MXMLBLD",$J)
179 K ^TMP("MXMLBLD",$J),^TMP("MXMLDOM",$J)
180 Q
181 ;
182NDOUT(ZOID) ;CALLBACK ROUTINE - IT IS RECURSIVE
183 I $$FIRST(ZOID)'=0 D ; THERE IS A CHILD
184 . N ZI S ZI=$$FIRST(ZOID)
185 . N ZATT D ATT("ZATT",ZOID)
186 . D MULTI^C0CMXMLB("",$$TAG(ZOID),.ZATT,"NDOUT^C0CMXML(ZI)")
187 E D ; NO CHILD
188 . ;W "DOING",ZOID,!
189 . N ZD D DATA("ZD",ZOID)
190 . N ZATT D ATT("ZATT",ZOID)
191 . D ITEM^C0CMXMLB("",$$TAG(ZOID),.ZATT,$G(ZD(1)))
192 I $$NXTSIB(ZOID)'=0 D ; THERE IS A SIBLING
193 . D NDOUT($$NXTSIB(ZOID)) ;RECURSE FOR SIBLINGS
194 Q
195 ;
[601]196PARSCCD(DOC,OPTION) ; THIS WAS COPIED FROM EN^MXMLDOM TO CUSTIMIZE FOR
197 ; PROCESSING CCDS
198 N CBK,SUCCESS,LEVEL,NODE,HANDLE
199 K ^TMP("MXMLERR",$J)
200 L +^TMP("MXMLDOM",$J):5
201 E Q 0
202 S HANDLE=$O(^TMP("MXMLDOM",$J,""),-1)+1,^(HANDLE)=""
203 L -^TMP("MXMLDOM",$J)
204 S CBK("STARTELEMENT")="STARTELE^C0CMXML" ; ONLY THIS ONE IS CHANGED ;GPL
205 S CBK("ENDELEMENT")="ENDELE^MXMLDOM"
206 S CBK("COMMENT")="COMMENT^MXMLDOM"
207 S CBK("CHARACTERS")="CHAR^MXMLDOM"
208 S CBK("ENDDOCUMENT")="ENDDOC^MXMLDOM"
209 S CBK("ERROR")="ERROR^MXMLDOM"
210 S (SUCCESS,LEVEL,LEVEL(0),NODE)=0,OPTION=$G(OPTION,"V1")
211 D EN^MXMLPRSE(DOC,.CBK,OPTION)
212 D:'SUCCESS DELETE^MXMLDOM(HANDLE)
213 Q $S(SUCCESS:HANDLE,1:0)
214 ; Start element
215 ; Create new child node and push info on stack
216STARTELE(ELE,ATTR) ; COPIED FROM STARTELE^MXMLDOM AND MODIFIED TO TREAT
217 ; ATTRIBUTES AS SUBELEMENTS TO MAKE CCD XPATH PROCESSING EASIER
218 N PARENT
219 S PARENT=LEVEL(LEVEL),NODE=NODE+1
220 S:PARENT ^TMP("MXMLDOM",$J,HANDLE,PARENT,"C",NODE)=ELE
221 S LEVEL=LEVEL+1,LEVEL(LEVEL)=NODE,LEVEL(LEVEL,0)=ELE
222 S ^TMP("MXMLDOM",$J,HANDLE,NODE)=ELE,^(NODE,"P")=PARENT
223 ;M ^("A")=ATTR
224 N ZI S ZI="" ; INDEX FOR ATTR
225 F S ZI=$O(ATTR(ZI)) Q:ZI="" D ; FOR EACH ATTRIBUTE
226 . N ELE,TXT ; ABOUT TO RECURSE
227 . S ELE=ZI ; TAG
228 . S TXT=ATTR(ZI) ; DATA
229 . D STARTELE(ELE,"") ; CREATE A NEW SUBNODE
230 . D TXT^MXMLDOM("T") ; INSERT DATA TO TAG
231 . D ENDELE^MXMLDOM(ELE) ; POP BACK UP A LEVEL
232 Q
233 ;
234CLEANARY(OUTARY,INARY) ; GOES THROUGH AN ARRAY AND CALLS CLEAN ON EACH NODE
235 ; INARY AND OUTARY PASSED BY NAME
236 N ZI S ZI=""
237 F S ZI=$O(@INARY@(ZI)) Q:ZI="" D ; FOR EACH NODE
238 . S @OUTARY@(ZI)=$$CLEAN(@INARY@(ZI)) ; CLEAN THE NODE
239 Q
240 ;
241CLEAN(STR) ; extrinsic function; returns string
242 ;; Removes all non printable characters from a string.
243 ;; STR by Value
244 N TR,I
245 F I=0:1:31 S TR=$G(TR)_$C(I)
246 S TR=TR_$C(127)
247 QUIT $TR(STR,TR)
248 ;
249STRIPTXT(OUTARY,ZARY) ; STRIPS THE "TEXT" PORTION OUT OF AN XML FILE
250 ; THIS IS USED TO DELETE THE NARATIVE HTML OUT OF THE CCD XML FILES BECAUSE
251 ; THEY DO NOT WORK RIGHT WITH THE PARSER
252 ;N ZWRK,ZBLD,ZI ; WORK ARRAY,BUILD ARRAY, AND COUNTER
253 S ZI=$O(@ZARY@("")) ; GET FIRST LINE NUMBER
254 D C0CBEGIN("ZWRK",ZI) ; INSERT FIRST LINE IN WORK ARRAY
255 F S ZI=$O(@ZARY@(ZI)) Q:ZI="" D ; FOR EACH LINE OF THE ARRAY
256 . I $O(@ZARY@(ZI))="" D Q ; AT THE END
257 . . D C0CEND("ZWRK",ZI) ; INCLUDE LAST LINE IN WORK ARRAY
258 . I ZI=1 D C0CBEGIN("ZWRK",ZI) ; START WITH FIRST LINE
259 . I @ZARY@(ZI)["<text" D C0CEND("ZWRK",ZI-1) ;PREV LINE IS AN END
260 . I @ZARY@(ZI)["</text>" D C0CBEGIN("ZWRK",ZI+1) ;NEXT LINE IS A BEGIN
261 S ZI=""
262 F S ZI=$O(ZWRK(ZI)) Q:ZI="" D ; MAKE A BUILD LIST FROM THE WORK ARRAY
263 . D QUEUE^C0CXPATH("ZBLD",ZARY,$P(ZWRK(ZI),"^",1),$P(ZWRK(ZI),"^",2))
264 D BUILD^C0CXPATH("ZBLD",OUTARY) ; BUILD NEW ARRAY WITHOUT TEXT SECTIONS
265 K @OUTARY@(0) ; GET RID OF THE LINE COUNT
266 Q
267 ;
268C0CBEGIN(ZA,LN) ; INSERTS A BEGIN LINE LN INTO ARRAY ZWRK, PASSED BY NAME
269 N ZI
270 S ZI=$O(@ZA@(""),-1)
271 I ZI="" S ZI=1
272 E S ZI=ZI+1 ; INCREMENT COUNT IN WORK ARRAY
273 S $P(@ZA@(ZI),"^",1)=LN
274 Q
275 ;
276C0CEND(ZB,LN) ; INSERTS AN END LINE LN INTO ARRAY ZWRK, PASSED BY NAME
277 N ZI
278 S ZI=$O(@ZB@(""),-1)
279 I ZI="" S ZI=1
280 S $P(@ZB@(ZI),"^",2)=LN
281 Q
282 ;
[605]283SEPARATE(OUTARY,INARY) ; SEPARATES XPATH VARIABLES ACCORDING TO THEIR
284 ; ROOT ; /Problems/etc/etc goes to @OUTARY@("Problems","/Problems/etc/etc")
285 S ZI=""
286 F S ZI=$O(@INARY@(ZI)) Q:ZI="" D ; FOR EACH ELEMENT OF THE ARRAY
287 . S ZJ=$P(ZI,"/",2) ;
[608]288 . I ZJ="" S ZJ=$P(ZI,"/",3) ;
[605]289 . S @OUTARY@(ZJ,ZI)=@INARY@(ZI)
290 Q
291 ;
[601]292FINDTID ; FIND TEMPLATE IDS IN DOM 1
293 S C0CDOCID=1
294 S ZD=$NA(^TMP("MXMLDOM",$J,C0CDOCID))
295 S ZN=""
296 S CURSEC=""
297 S TID=""
298 F S ZN=$O(@ZD@(ZN)) Q:ZN="" D ;
299 . I $$TAG(ZN)="root" D ;
300 . . I $$TAG($$PARENT(ZN))="templateId" D ; ONLY LOOKING FOR TEMPLATES
301 . . . S ZG=$$PARENT($$PARENT(ZN))
[605]302 . . . S ZG2=$$PARENT(ZG) ;COMPONENT THAT HOLDS THIS SECTION
[601]303 . . . S CMT=$G(@ZD@(ZG,"X",1))
[605]304 . . . I CMT="" S CMT="?"
[601]305 . . . I $$TAG(ZG)="section" D ;START OF A SECTION
[605]306 . . . . S CURSEC=$$PARENT(ZG)
[601]307 . . . . S SECCMT=$G(@ZD@(CURSEC,"X",1))
[605]308 . . . . I SECCMT="" S SECCMT="?"
309 . . . . S SECTID=$G(@ZD@(ZN,"T",1)) ;SECTION TEMPLATE ID
[601]310 . . . S TID=$G(@ZD@(ZN,"T",1)) ;TEMPLATE ID
311 . . . I CURSEC'="" D ; IF WE ARE IN A SECTION
[605]312 . . . . S CCDDIR(ZG2,CURSEC,$$TAG(ZG2),CMT,SECCMT)=TID
313 . . . . S DOMMAP(ZG2)=CURSEC_U_$$TAG(ZG2)_U_TID_U_SECTID
314 . . . W !,$$TAG(ZG2)," ",$G(@ZD@(ZG,"X",1))
[601]315 . . . W " root ",ZN," ",@ZD@(ZN,"T",1)
316 Q
317 ;
[605]318FINDALT ; PROCESS THE DOMMAP AND FIND THE ALT TAGS FOR COMPONENTS
319 ;
320 S ZI=""
321 F S ZI=$O(DOMMAP(ZI)) Q:ZI="" D ; FOR EACH NODE IN THE MAP
322 . S ZJ=DOMMAP(ZI) ;
323 . S PARNODE=$P(ZJ,U,1) ;PARENT NODE
324 . S TAG=$P(ZJ,U,2) ;THIS TAG
325 . S TID=$P(ZJ,U,3) ;THIS TEMPLATE ID
326 . S PARTID=$P(ZJ,U,4) ;PARENT TEMPLATE ID
327 . S ZIEN=$O(^C0CXDS(178.101,"TID",TID,"")) ;THIS NODE IEN
328 . S PARIEN=$O(^C0CXDS(178.101,"TID",PARTID,"")) ;PARENT NODE IEN
329 . I ZI=PARNODE D ; IF THIS IS A SECTION NODE
330 . . S ALTTAG=$$GET1^DIQ(178.101,PARIEN_",",.03) ;ALT TAG FIELD FOR PARENT
331 . . S NAME=$$GET1^DIQ(178.101,ZIEN_",",.01) ;NAME OF THIS NODE'S TEMPLATE
332 . . W ZI," ",TAG," ",ALTTAG," ",NAME,!
333 . . S C0CTAGS(ZI)=ALTTAG
334 Q
335 ;
336ALTTAG(NODE) ; SET Y EQUAL TO THE ALT TAG FOUND IN C0CTAGS IF NODE IF FOUND
337 ;
338 S Y=$G(C0CTAGS(NODE))
339 Q
340 ;
341SETCBK ; SET THE TAG CALLBACK FOR XPATH PROCESSSING OF THE CCD
342 S C0CCBK("TAG")="D ALTTAG(ZOID)"
343 Q
344 ;
[601]345GENXDS(ZD) ; GENERATE THE XDS PROTOTYPE RECORDS FROM A CCDDIR ARRAY
346 ; ARRAY ELEMENTS LOOK LIKE:
[605]347 ; CCDDIR(1659,1634,"observation"," Result observaion template "," Vital signs section template ")="2.16.840.1.113883.10.20.1.31"
348 ;or CCDDIR(cur node,section node,cur tag,cur name,sec name)=templateId
[601]349 S ZF=178.101 ; FILE NUMBER FOR THE C0C XDS PROTOTYPE FILE
350 S ZI=$Q(@ZD@("")) ;FIRST ARRAY ELEMENT
351 S DONE=0
352 F Q:DONE D ;
353 . W @ZI,!
354 . S ZJ=$QS(ZI,5)
355 . S ZJ=$E(ZJ,2,$L(ZJ)) ;STRIP THE LEADING SPACE
356 . S C0CFDA(ZF,"?+1,",.01)=ZJ
357 . S C0CFDA(ZF,"?+1,",.02)=$QS(ZI,4) ; TAG FOR THIS TEMPLATE
358 . S C0CFDA(ZF,"?+1,",1)=@ZI
359 . D UPDIE
360 . S ZI=$Q(@ZI)
361 . I ZI="" S DONE=1
362 Q
363 ;
[605]364WHRUSD(ZD) ; UPDATE THE C0C XDS FILE WITH WHERE USED DATA FROM
365 ; CCDDIR PASS BY NAME
366 ; ARRAY ELEMENTS LOOK LIKE:
367 ; CCDDIR(1634," Vital signs section template ",1659,"observation"," Result observaion template ")="2.16.840.1.113883.10.20.1.31"
368 ;or CCDDIR(section node,sec name, cur node,cur tag,cur name)=templateId
369 S ZF=178.101 ; FILE NUMBER FOR THE C0C XDS PROTOTYPE FILE
370 S ZSF=178.111 ; WHERE USED SUBFILE OF C0C XDS PROTOTYPE FILE
371 S ZI=$Q(@ZD@("")) ;FIRST ARRAY ELEMENT
372 S DONE=0
373 F Q:DONE D ;
374 . W @ZI
375 . S ZIEN=$O(^C0CXDS(178.101,"TID",@ZI,"")) ; IEN FOR THIS NODE'S TEMPLATE
376 . W " IEN:",ZIEN
377 . S ZJ=$QS(ZI,2)
378 . S ZJ=$E(ZJ,2,$L(ZJ)) ;STRIP THE LEADING SPACE
379 . S ZPIEN=$O(^C0CXDS(178.101,"B",ZJ,"")) ; PARENT IEN
380 . W " PARENT IEN:",ZPIEN
381 . S ZTAG=$QS(ZI,4) ; TAG FOR THIS TEMPLATE
382 . W " TAG:",ZTAG,!
383 . I ZIEN'=ZPIEN D ; ONLY FOR CHILD TEMPLATES
384 . . S C0CFDA(ZSF,"?+1,"_ZIEN_",",.01)=ZPIEN ; NEW SUBFILE ENTRY WITH PAR PTR
385 . . S C0CFDA(ZSF,"?+1,"_ZIEN_",",1)=ZTAG ; TAG FOR NEW ENTRY
386 . . D UPDIE
387 . ;S C0CFDA(ZF,"?+1,",1)=@ZI
388 . ;D UPDIE
389 . S ZI=$Q(@ZI)
390 . I ZI="" S DONE=1
391 Q
392 ;
[601]393UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
394 K ZERR
395 D CLEAN^DILF
396 D UPDATE^DIE("","C0CFDA","","ZERR")
397 I $D(ZERR) D ;
398 . W "ERROR",!
399 . ZWR ZERR
400 . B
401 K C0CFDA
402 Q
403 ;
Note: See TracBrowser for help on using the repository browser.