From d0f16e03ebb4ce26f50aaede8be97805d8f093a9 Mon Sep 17 00:00:00 2001 From: george Date: Tue, 8 Dec 2009 22:29:27 +0000 Subject: [PATCH] improved xpath handling --- p/C0CIN.m | 20 +------------------- p/C0CMXML.m | 2 +- p/C0CMXP.m | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/p/C0CIN.m b/p/C0CIN.m index f103714..640726a 100644 --- a/p/C0CIN.m +++ b/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) diff --git a/p/C0CMXML.m b/p/C0CMXML.m index 411a813..8fbfe3f 100644 --- a/p/C0CMXML.m +++ b/p/C0CMXML.m @@ -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 diff --git a/p/C0CMXP.m b/p/C0CMXP.m index 8a40da4..b90de87 100644 --- a/p/C0CMXP.m +++ b/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