diff --git a/p/GPLCCR.m b/p/GPLCCR.m index 63e5237..9ce3e6d 100644 --- a/p/GPLCCR.m +++ b/p/GPLCCR.m @@ -70,6 +70,11 @@ CCRRPC(CCRGRTN,DFN,CCRPART,TIME1,TIME2,HDRARY) ;RPC ENTRY POINT FOR CCR OUTPUT D QUERY^GPLXPATH(TGLOBAL,"//ContinuityOfCareRecord/Actors","ACTT") D EXTRACT^GPLACTORS("ACTT",ACTGLO,"ACTT2") D INSINNER^GPLXPATH(CCRGLO,"ACTT2","//ContinuityOfCareRecord/Actors") + N I,J,DONE S DONE=0 + F I=0:0 D Q:DONE ; DELETE UNTIL ALL EMPTY ELEMENTS ARE GONE + . S J=$$TRIM^GPLXPATH(CCRGLO) ; DELETE EMPTY ELEMENTS + . W "TRIMMED",J,! + . I J=0 S DONE=1 ; DONE WHEN TRIM RETURNS FALSE Q ; INITSTPS(TAB) ; INITIALIZE CCR PROCESSING STEPS @@ -159,4 +164,7 @@ TLIST ; LIST THE TESTS ;;>>>D QUERY^GPLXPATH(TGLOBAL,"//ContinuityOfCareRecord/Actors","G2") ;;>>>D EXTRACT^GPLACTORS("G2","ACTTEST","G3") ;;>>?G3(G3(0))["" + ;;> + ;;>>>D ZTEST^GPLCCR("CCR") + ;;>>>W $$TRIM^GPLXPATH(CCRGLO) ;;> diff --git a/p/GPLXPATH.m b/p/GPLXPATH.m index 7fbd3bb..6559443 100644 --- a/p/GPLXPATH.m +++ b/p/GPLXPATH.m @@ -332,25 +332,39 @@ MAP(IXML,INARY,OXML) ; SUBSTITUTE @@X@@ VARS IN IXML WITH VALUES IN INARY ; TRIM(THEXML) ; TAKES OUT ALL NULL ELEMENTS ; THEXML IS PASSED BY NAME - N I,J,TMPXML,DEL - F I=1:1:@THEXML@(0) D ; LOOP THROUGH ENTIRE ARRAY - . I @THEXML@(I)'["><" D PUSH("TMPXML",@THEXML@(I)) - D INDEX("TMPXML") ; MAKE AN XPATH INDEX - S I="" S I=$O(TMPXML(I)) - F K=0:0 D Q:I="" ; NOW LOOK FOR EMPTY SECTIONS - . I I["//" D ; - . . W I,TMPXML(I),! - . . S J=$P(TMPXML(I),"^",1) - . . I J+1=$P(TMPXML(I),"^",2) D ; - . . . W I,! - . . . S DEL(J)="" - . . . S DEL(J+1)="" - . S I=$O(TMPXML(I)) - F I=1:1:TMPXML(0) D ; - . I '$D(DEL(I)) - . D PUSH("TMPXML2",TMPXML(I)) - D CP("TMPXML2",THEXML) - Q + N I,J,TMPXML,DEL,FOUND + S FOUND=0 + W "DELETING EMPTY ELEMENTS",! + F I=1:1:(@THEXML@(0)-1) D ; LOOP THROUGH ENTIRE ARRAY + . S J=@THEXML@(I) + . N JM,JP ; JMINUS AND JPLUS + . S JM=@THEXML@(I-1) ; LINE BEFORE + . S JP=@THEXML@(I+1) ; LINE AFTER + . S JPX=$TR(JP,"/","") ; REMOVE THE SLASH + . I J=JPX D ; AN EMPTY ELEMENT ON TWO LINES + . . W I,J,JP,! + . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED + . . S DEL(I)="" ; SET LINE TO DELETE + . . S DEL(I+1)="" ; SET NEXT LINE TO DELETE + . I J["><" D ; AN EMPTY ELEMENT ON ONE LINE + . . W I,J,! + . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED + . . S DEL(I)="" ; SET THE EMPTY LINE UP TO BE DELETED + . . I JM=JPX D ; + . . . W I,JM_J_JPX,! + . . . S DEL(I-1)="" + . . . S DEL(I+1)="" ; SET THE SURROUNDING LINES FOR DEL + ; . I J'["><" D PUSH("TMPXML",J) + I FOUND D ; NEED TO DELETE THINGS + . F I=1:1:@THEXML@(0) D ; COPY ARRAY LEAVING OUT DELELTED LINES + . . I '$D(DEL(I)) D ; IF THE LINE IS NOT DELETED + . . . D PUSH("TMPXML",@THEXML@(I)) ; COPY TO TMPXML ARRAY + . ZWR DEL + . D CP("TMPXML",THEXML) ; REPLACE THE XML WITH THE COPY + Q FOUND + ; +NXTCHLD(HANDLE,NODE,CUR) ; RETURNS THE NEXT CHILD OR "" IF NONE + Q $$CHILD^MXMLDOM(HANDLE,NODE,CUR) ; PARY(GLO) ;PRINT AN ARRAY N I