improved xpath handling
This commit is contained in:
parent
fcfbaf9da8
commit
d0f16e03eb
20
p/C0CIN.m
20
p/C0CIN.m
|
@ -110,7 +110,7 @@ EN(INXML,SOURCE,C0CDFN) ; IMPORT A CCR, PASSED BY NAME INXML
|
|||
;N ZI,ZJ,ZK
|
||||
S ZI=""
|
||||
F S ZI=$O(C0CXP(ZI)) Q:ZI="" D ; FOR EACH XPATH
|
||||
. D DEMUX("ZJ",ZI) ;
|
||||
. D DEMUX^C0CMXP("ZJ",ZI) ;
|
||||
. W ZJ,!
|
||||
. S ZK=$P(ZJ,"^",3) ; PULL OUT THE XPATH
|
||||
. S ZM=$P(ZJ,"^",1) ; PULL OUT THE MULTIPLE
|
||||
|
@ -132,24 +132,6 @@ GETACCR(AOUT,C0CDFN) ; EXTRACT A CCR FOR PATIENT ADFN AND PUT IT IN ARRAY AOUT
|
|||
M @AOUT=ZT
|
||||
Q
|
||||
;
|
||||
DEMUX(OUTX,INX) ;PARSES XPATH PASSED BY VALUE IN INX TO REMOVE [x] MULTIPLES
|
||||
; RETURNS OUTX: MULTIPLE^SUBMULTIPLE^XPATH
|
||||
N ZX,ZY,ZZ,ZZ1,ZMULT,ZSUB
|
||||
S (ZMULT,ZSUB)=""
|
||||
S ZX=$P(INX,"[",2)
|
||||
I ZX'="" D ; THERE IS A [x] MULTIPLE
|
||||
. S ZY=$P(INX,"[",1) ;FIRST PART OF XPATH
|
||||
. S ZMULT=$P(ZX,"]",1) ; NUMBER OF THE MULTIPLE
|
||||
. S ZX=ZY_$P(ZX,"]",2) ; REST OF THE XPATH
|
||||
. I $P(ZX,"[",2)'="" D ; A SUB MULTIPLE EXISTS
|
||||
. . S ZZ=$P(ZX,"[",1) ; FIRST PART OF XPATH
|
||||
. . S ZX=$P(ZX,"[",2) ; DELETE THE [
|
||||
. . S ZSUB=$P(ZX,"]",1) ; NUMBER OF THE SUBMULTIPLE
|
||||
. . S ZX=ZZ_$P(ZX,"]",2) ; REST OF THE XPATH
|
||||
E S ZX=INX ;NO MULTIPLE HERE
|
||||
S @OUTX=ZMULT_"^"_ZSUB_"^"_ZX ;RETURN MULTIPLE^SUBMULTIPLE^XPATH
|
||||
Q
|
||||
;
|
||||
TEST64 ;TEST BASE64 DECODING FOR IMPORTING CCR FROM THE NHIN
|
||||
W $$FTG^%ZISH("/tmp/","base64_encoded_ccr.txt","G64(1)",1)
|
||||
S G=G64(1)
|
||||
|
|
|
@ -180,7 +180,7 @@ OUTXML(ZRTN,INID) ; USES C0CMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM
|
|||
D NDOUT($$FIRST(1))
|
||||
D END^C0CMXMLB ;END THE DOCUMENT
|
||||
M @ZRTN=^TMP("MXMLBLD",$J)
|
||||
K ^TMP("MXMLBLD",$J),^TMP("MXMLDOM",$J)
|
||||
K ^TMP("MXMLBLD",$J)
|
||||
Q
|
||||
;
|
||||
NDOUT(ZOID) ;CALLBACK ROUTINE - IT IS RECURSIVE
|
||||
|
|
18
p/C0CMXP.m
18
p/C0CMXP.m
|
@ -86,6 +86,24 @@ MKTPLATE(INXML,OUTT) ;MAKE A TEMPLATE FROM INXML, RETURNED IN OUTT
|
|||
. W !,ZI,$$TAG^C0CMXML(ZI)
|
||||
Q
|
||||
;
|
||||
DEMUX(OUTX,INX) ;PARSES XPATH PASSED BY VALUE IN INX TO REMOVE [x] MULTIPLES
|
||||
; RETURNS OUTX: MULTIPLE^SUBMULTIPLE^XPATH
|
||||
N ZX,ZY,ZZ,ZZ1,ZMULT,ZSUB
|
||||
S (ZMULT,ZSUB)=""
|
||||
S ZX=$P(INX,"[",2)
|
||||
I ZX'="" D ; THERE IS A [x] MULTIPLE
|
||||
. S ZY=$P(INX,"[",1) ;FIRST PART OF XPATH
|
||||
. S ZMULT=$P(ZX,"]",1) ; NUMBER OF THE MULTIPLE
|
||||
. S ZX=ZY_$P(ZX,"]",2) ; REST OF THE XPATH
|
||||
. I $P(ZX,"[",2)'="" D ; A SUB MULTIPLE EXISTS
|
||||
. . S ZZ=$P(ZX,"[",1) ; FIRST PART OF XPATH
|
||||
. . S ZX=$P(ZX,"[",2) ; DELETE THE [
|
||||
. . S ZSUB=$P(ZX,"]",1) ; NUMBER OF THE SUBMULTIPLE
|
||||
. . S ZX=ZZ_$P(ZX,"]",2) ; REST OF THE XPATH
|
||||
E S ZX=INX ;NO MULTIPLE HERE
|
||||
S @OUTX=ZMULT_"^"_ZSUB_"^"_ZX ;RETURN MULTIPLE^SUBMULTIPLE^XPATH
|
||||
Q
|
||||
;
|
||||
UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
|
||||
K ZERR
|
||||
D CLEAN^DILF
|
||||
|
|
Loading…
Reference in New Issue