template generation tools
This commit is contained in:
parent
d0f16e03eb
commit
86b5d4fbbf
|
@ -215,14 +215,14 @@ SETCBK ; SET THE TAG CALLBACK FOR XPATH PROCESSSING OF THE CCD
|
|||
S C0CCBK("TAG")="D ALTTAG^C0CMCCD(ZOID)"
|
||||
Q
|
||||
;
|
||||
OUTCCD ; OUTPUT THE PARSED CCD TO A TEXT FILE
|
||||
D TEST3^C0CMXML
|
||||
OUTCCD(GARYIN) ; OUTPUT THE PARSED CCD TO A TEXT FILE
|
||||
;D TEST3^C0CMXML
|
||||
N ZT S ZT=$NA(^TMP("CCDOUT",$J))
|
||||
N ZI,ZJ
|
||||
S ZI=1 S ZJ=""
|
||||
K @ZT
|
||||
F S ZJ=$O(GARY(ZJ)) Q:ZJ="" D ;
|
||||
. S @ZT@(ZI)=ZJ_"^"_GARY(ZJ)
|
||||
F S ZJ=$O(GARYIN(ZJ)) Q:ZJ="" D ;
|
||||
. S @ZT@(ZI)=ZJ_"^"_GARYIN(ZJ)
|
||||
. S ZI=ZI+1
|
||||
S ONAME=$NA(@ZT@(1))
|
||||
W $$OUTPUT^C0CXPATH(ONAME,"CCDOUT.txt","/home/vademo2/CCR")
|
||||
|
|
15
p/C0CMXML.m
15
p/C0CMXML.m
|
@ -30,6 +30,13 @@ TEST ;
|
|||
S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DocID: ",C0CDOCID
|
||||
S REDUX="//ContinuityOfCareRecord/Body"
|
||||
D XPATH(1,"/","GIDX","GARY",,REDUX)
|
||||
D SEPARATE^C0CMCCD("GARY2","GARY")
|
||||
S ZI=""
|
||||
F S ZI=$O(GARY2(ZI)) Q:ZI="" D ;
|
||||
. N GTMP,G2
|
||||
. M G2=GARY2(ZI)
|
||||
. D DEMUXARY^C0CMXP("GTMP","G2",2)
|
||||
. M GARY3(ZI)=GTMP
|
||||
Q
|
||||
;
|
||||
TEST2 ;
|
||||
|
@ -58,8 +65,12 @@ TEST3
|
|||
D XPATH(1,"/","GIDX","GARY",,REDUX)
|
||||
K C0CCBK("TAG")
|
||||
D SEPARATE^C0CMCCD("GARY2","GARY") ; SEPARATE FOR EASIER BROWSING
|
||||
;S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DOCID: ",C0CDOCID ;CALL REGULAR PARSER
|
||||
;D XPATH(1,"/","GIDX2","GARY2",,REDUX)
|
||||
S ZI=""
|
||||
F S ZI=$O(GARY2(ZI)) Q:ZI="" D ;
|
||||
. N GTMP,G2
|
||||
. M G2=GARY2(ZI)
|
||||
. D DEMUXARY^C0CMXP("GTMP","G2",2)
|
||||
. M GARY4(ZI)=GTMP
|
||||
Q
|
||||
;
|
||||
TEST4 ; TEST OF OUTPUTING AN XML FILE FROM THE DOM .. this one is the CCR
|
||||
|
|
74
p/C0CMXP.m
74
p/C0CMXP.m
|
@ -76,14 +76,31 @@ GETXML(OUTXML,TEMPID,FARY) ;GET THE XML FROM TEMPLATE TEMPID
|
|||
. W "ERROR RETRIEVING TEMPLATE",!
|
||||
Q
|
||||
;
|
||||
MKTPLATE(INXML,OUTT) ;MAKE A TEMPLATE FROM INXML, RETURNED IN OUTT
|
||||
MKTPLATE(OUTT,INXML,REDUX) ;MAKE A TEMPLATE FROM INXML, RETURNED IN OUTT
|
||||
; BOTH PASSED BY NAME
|
||||
;
|
||||
S C0CDOCID=$$PARSE^C0CMXML(INXML,"C0CMKT")
|
||||
S C0CDOM=$NA(^TMP("MXMLDOM",$J,C0CDOCID))
|
||||
N ZI S ZI=""
|
||||
;N GIDX,GIDX2,GARY,GARY2
|
||||
I '$D(REDUX) S REDUX=""
|
||||
D XPATH^C0CMXML(1,"/","GIDX","GARY",,REDUX)
|
||||
D INVERT("GIDX2","GIDX") ;MAKE ARRAY TO LOOK UP XPATH BY NODE
|
||||
N ZI,ZD S ZI=""
|
||||
F S ZI=$O(@C0CDOM@(ZI)) Q:ZI="" D ; FOR EACH NODE IN THE DOM
|
||||
. W !,ZI,$$TAG^C0CMXML(ZI)
|
||||
. K ZD ;FOR DATA
|
||||
. D DATA^C0CMXML("ZD",ZI) ;SEE IF THERE IS DATA FOR THIS NODE
|
||||
. I $D(ZD(1)) D ; IF YES
|
||||
. . W !,ZD(1)
|
||||
. . K @C0CDOM@(ZI,"T") ; KILL THE DATA
|
||||
. . S @C0CDOM@(ZI,"T",1)="@@"_$G(GIDX2(ZI))_"@@"
|
||||
D OUTXML^C0CMXML(OUTT,C0CDOCID)
|
||||
Q
|
||||
;
|
||||
INVERT(OUTX,INX) ;INVERTS AN XPATH INDEX RETURNING @OUTX@(x)=XPath from
|
||||
; @INX@(XPath)=x
|
||||
N ZI S ZI=""
|
||||
F S ZI=$O(@INX@(ZI)) Q:ZI="" D ;FOR EACH XPATH IN THE INPUT
|
||||
. S @OUTX@(@INX@(ZI))=ZI ; SET INVERTED ENTRY
|
||||
Q
|
||||
;
|
||||
DEMUX(OUTX,INX) ;PARSES XPATH PASSED BY VALUE IN INX TO REMOVE [x] MULTIPLES
|
||||
|
@ -104,6 +121,57 @@ DEMUX(OUTX,INX) ;PARSES XPATH PASSED BY VALUE IN INX TO REMOVE [x] MULTIPLES
|
|||
S @OUTX=ZMULT_"^"_ZSUB_"^"_ZX ;RETURN MULTIPLE^SUBMULTIPLE^XPATH
|
||||
Q
|
||||
;
|
||||
DEMUXARY(OARY,IARY,DEPTH) ;CONVERT AN XPATH ARRAY PASSED AS IARY TO
|
||||
; FORMAT @OARY@(x,variablename) where x is the first multiple
|
||||
; IF DEPTH=2, THE LAST 2 PARTS OF THE XPATH WILL BE USED
|
||||
N ZI,ZJ,ZK,ZL,ZM S ZI=""
|
||||
F S ZI=$O(@IARY@(ZI)) Q:ZI="" D ;
|
||||
. D DEMUX^C0CMXP("ZJ",ZI)
|
||||
. S ZK=$P(ZJ,"^",3)
|
||||
. S ZM=$RE($P($RE(ZK),"/",1))
|
||||
. I $G(DEPTH)=2 D ;LAST TWO PARTS OF XPATH USED FOR THE VARIABLE NAME
|
||||
. . S ZM=$RE($P($RE(ZK),"/",2))_ZM
|
||||
. S ZL=$P(ZJ,"^",1)
|
||||
. I ZL="" S ZL=0
|
||||
. I $D(@OARY@(ZL,ZM)) D ;IT'S A DUP
|
||||
. . S @OARY@(ZL,ZM_"[2]")=@IARY@(ZI)
|
||||
. E S @OARY@(ZL,ZM)=@IARY@(ZI)
|
||||
Q
|
||||
;
|
||||
DEMUXXP1(OARY,IARY) ;IARY IS INCOMING XPATH ARRAY
|
||||
; BOTH IARY AND OARY ARE PASSED BY NAME
|
||||
; RETURNS A SIMPLE XPATH ARRAY WITHOUT MULTIPLES. DUPLICATES ARE REMOVED
|
||||
N ZI,ZJ,ZK
|
||||
S ZI=""
|
||||
F S ZI=$O(@IARY@(ZI)) Q:ZI="" D ; FOR EACH XPATH IN IARY
|
||||
. D DEMUX^C0CMXP("ZJ",ZI)
|
||||
. S ZK=$P(ZJ,"^",3) ;THE XPATH
|
||||
. S @OARY@(ZK)=@IARY@(ZI) ;THE RESULT. DUPLICATES WILL NOT SHOW
|
||||
. ; CAUTION, IF THERE ARE MULTIPLES, ONLY THE DATA FOR THE LAST
|
||||
. ; MULTIPLE WILL BE INCLUDED IN THE OUTPUT ARRAY, ASSIGNED TO THE
|
||||
. ; COMMON XPATH
|
||||
Q
|
||||
;
|
||||
DEMUXXP2(OARY,IARY) ; IARY AND OARY ARE PASSED BY NAME
|
||||
; IARY IS AN XPATH ARRAY THAT MAY CONTAIN MULTIPLES
|
||||
; OARY IS THE OUTPUT ARRAY WHERE MULTIPLES ARE RETURNED IN THE FORM
|
||||
; @OARY@(x,Xpath)=data or @OARY@(x,y,Xpath)=data WHERE x AND y ARE
|
||||
; THE MULTIPLES AND Xpath IS THE BASE XPATH WITHOUT [x] AND [y]
|
||||
;
|
||||
N ZI,ZJ,ZK,ZX,ZY,ZP
|
||||
S ZI=""
|
||||
F S ZI=$O(@IARY@(ZI)) Q:ZI="" D ; FOR EACH INPUT XPATH
|
||||
. D DEMUX("ZJ",ZI) ; PULL OUT THE MULTIPLES
|
||||
. S ZX=$P(ZJ,"^",1) ;x
|
||||
. S ZY=$P(ZJ,"^",2) ;y
|
||||
. S ZP=$P(ZJ,"^",3) ;Xpath
|
||||
. I ZX="" S ZX=1 ; NO MULTIPLE WILL STORE IN x=1
|
||||
. I ZY'="" D ;IS THERE A y?
|
||||
. . S @OARY@(ZX,ZY,ZP)=@IARY@(ZI)
|
||||
. E D ;NO y
|
||||
. . S @OARY@(ZX,ZP)=@IARY@(ZI)
|
||||
Q
|
||||
;
|
||||
UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
|
||||
K ZERR
|
||||
D CLEAN^DILF
|
||||
|
|
Loading…
Reference in New Issue