diff --git a/p/C0CMXML.m b/p/C0CMXML.m index 6c8cae4..67a2143 100644 --- a/p/C0CMXML.m +++ b/p/C0CMXML.m @@ -28,6 +28,39 @@ TEST ; D XPATH(1,"/","GIDX","GARY",,REDUX) Q ; +TEST4 ; TEST OF OUTPUTING AN XML FILE FROM THE DOM .. this one is the CCR + ; + D TEST ; SET UP THE DOM + D START^C0CMXMLB($$TAG(1),,"G") + D NDOUT($$FIRST(1)) + D END^C0CMXMLB ;END THE DOCUMENT + M ZCCR=^TMP("MXMLBLD",$J) + ZWR ZCCR + Q + ; +TEST5 ; SAME AS TEST4, BUT THIS TIME THE CCD + S C0CXMLIN=$NA(^TMP("C0CMXML",$J)) + K GARY,GTMP,GIDX + K @C0CXMLIN + W $$FTG^%ZISH("/home/vademo2/CCR/","SampleCCDDocument.xml",$NA(@C0CXMLIN@(1)),3) + D CLEANARY("GTMP",C0CXMLIN) ; REMOVE CONTROL CHARACTERS + K @C0CXMLIN + M @C0CXMLIN=GTMP + K GTMP + D STRIPTXT("GTMP",C0CXMLIN) + K @C0CXMLIN + M @C0CXMLIN=GTMP + K GTMP + S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DOCID: ",C0CDOCID ;CALL REGULAR PARSER + ;D XPATH(1,"/","GIDX2","GARY2",,REDUX) + D OUTXML("ZCCD",C0CDOCID) + ;D START^C0CMXMLB($$TAG(1),,"G") + ;D NDOUT($$FIRST(1)) + ;D END^C0CMXMLB ;END THE DOCUMENT + ;M ZCCD=^TMP("MXMLBLD",$J) + ZWR ZCCD(1:30) + Q + ; TEST2 ; S REDUX="//soap:Envelope/soap:Body/GetPatientFullMedicationHistory5Response/GetPatientFullMedicationHistory5Result/patientDrugDetail" D XPATH(1,"/","GIDX","GARY","",REDUX) @@ -52,6 +85,7 @@ TEST3 D FINDALT ; FIND ALTERNATE TAGS D SETCBK ; SET THE CALLBACK ROUTINE FOR TAGS D XPATH(1,"/","GIDX","GARY",,REDUX) + K C0CCBK("TAG") D SEPARATE("GARY2","GARY") ; SEPARATE FOR EASIER BROWSING ;S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DOCID: ",C0CDOCID ;CALL REGULAR PARSER ;D XPATH(1,"/","GIDX2","GARY2",,REDUX) @@ -110,6 +144,12 @@ FIRST(ZOID) ;RETURNS THE OID OF THE FIRST CHILD OF ZOID PARENT(ZOID) ;RETURNS THE OID OF THE PARENT OF ZOID Q $$PARENT^MXMLDOM(C0CDOCID,ZOID) ; +ATT(RTN,NODE) ;GET ATTRIBUTES FOR ZOID + S HANDLE=C0CDOCID + K @RTN + D GETTXT^MXMLDOM("A") + Q + ; TAG(ZOID) ; RETURNS THE XML TAG FOR THE NODE ;I ZOID=149 B ;GPLTEST N X,Y @@ -129,6 +169,30 @@ DATA(ZT,ZOID) ; RETURNS DATA FOR THE NODE S ZN=$$TEXT^MXMLDOM(C0CDOCID,ZOID,ZT) Q ; +OUTXML(ZRTN,INID) ; USES C0CMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM + ; + S C0CDOCID=INID + D START^C0CMXMLB($$TAG(1),,"G") + D NDOUT($$FIRST(1)) + D END^C0CMXMLB ;END THE DOCUMENT + M @ZRTN=^TMP("MXMLBLD",$J) + K ^TMP("MXMLBLD",$J),^TMP("MXMLDOM",$J) + Q + ; +NDOUT(ZOID) ;CALLBACK ROUTINE - IT IS RECURSIVE + I $$FIRST(ZOID)'=0 D ; THERE IS A CHILD + . N ZI S ZI=$$FIRST(ZOID) + . N ZATT D ATT("ZATT",ZOID) + . D MULTI^C0CMXMLB("",$$TAG(ZOID),.ZATT,"NDOUT^C0CMXML(ZI)") + E D ; NO CHILD + . ;W "DOING",ZOID,! + . N ZD D DATA("ZD",ZOID) + . N ZATT D ATT("ZATT",ZOID) + . D ITEM^C0CMXMLB("",$$TAG(ZOID),.ZATT,$G(ZD(1))) + I $$NXTSIB(ZOID)'=0 D ; THERE IS A SIBLING + . D NDOUT($$NXTSIB(ZOID)) ;RECURSE FOR SIBLINGS + Q + ; PARSCCD(DOC,OPTION) ; THIS WAS COPIED FROM EN^MXMLDOM TO CUSTIMIZE FOR ; PROCESSING CCDS N CBK,SUCCESS,LEVEL,NODE,HANDLE