Changeset 52


Ignore:
Timestamp:
Jul 7, 2008, 1:12:04 PM (16 years ago)
Author:
George Lilly
Message:

Added TRIMGPLXPATH to delete empty elements from output

Location:
ccr/trunk/p
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/GPLCCR.m

    r51 r52  
    7171    D EXTRACT^GPLACTORS("ACTT",ACTGLO,"ACTT2")
    7272    D INSINNER^GPLXPATH(CCRGLO,"ACTT2","//ContinuityOfCareRecord/Actors")
     73    N I,J,DONE S DONE=0
     74    F I=0:0 D  Q:DONE ; DELETE UNTIL ALL EMPTY ELEMENTS ARE GONE
     75    . S J=$$TRIM^GPLXPATH(CCRGLO) ; DELETE EMPTY ELEMENTS
     76    . W "TRIMMED",J,!
     77    . I J=0 S DONE=1 ; DONE WHEN TRIM RETURNS FALSE
    7378    Q
    7479    ;
     
    160165 ;;>>>D EXTRACT^GPLACTORS("G2","ACTTEST","G3")
    161166 ;;>>?G3(G3(0))["</Actors>"
     167 ;;><TRIM>
     168 ;;>>>D ZTEST^GPLCCR("CCR")
     169 ;;>>>W $$TRIM^GPLXPATH(CCRGLO)
    162170 ;;></TEST>
  • ccr/trunk/p/GPLXPATH.m

    r50 r52  
    333333TRIM(THEXML) ; TAKES OUT ALL NULL ELEMENTS
    334334       ; THEXML IS PASSED BY NAME
    335        N I,J,TMPXML,DEL
    336        F I=1:1:@THEXML@(0) D  ; LOOP THROUGH ENTIRE ARRAY
    337        . I @THEXML@(I)'["><" D PUSH("TMPXML",@THEXML@(I))
    338        D INDEX("TMPXML") ; MAKE AN XPATH INDEX
    339        S I="" S I=$O(TMPXML(I))
    340        F K=0:0  D  Q:I="" ; NOW LOOK FOR EMPTY SECTIONS
    341        . I I["//" D  ;
    342        . . W I,TMPXML(I),!
    343        . . S J=$P(TMPXML(I),"^",1)
    344        . . I J+1=$P(TMPXML(I),"^",2) D  ;
    345        . . . W I,!
    346        . . . S DEL(J)=""
    347        . . . S DEL(J+1)=""
    348        . S I=$O(TMPXML(I))
    349        F I=1:1:TMPXML(0) D  ;
    350        . I '$D(DEL(I))
    351        . D PUSH("TMPXML2",TMPXML(I))
    352        D CP("TMPXML2",THEXML)
    353        Q
     335       N I,J,TMPXML,DEL,FOUND
     336       S FOUND=0
     337       W "DELETING EMPTY ELEMENTS",!
     338       F I=1:1:(@THEXML@(0)-1) D  ; LOOP THROUGH ENTIRE ARRAY
     339       . S J=@THEXML@(I)
     340       . N JM,JP ; JMINUS AND JPLUS
     341       . S JM=@THEXML@(I-1) ; LINE BEFORE
     342       . S JP=@THEXML@(I+1) ; LINE AFTER
     343       . S JPX=$TR(JP,"/","") ; REMOVE THE SLASH
     344       . I J=JPX D  ; AN EMPTY ELEMENT ON TWO LINES
     345       . . W I,J,JP,!
     346       . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED
     347       . . S DEL(I)="" ; SET LINE TO DELETE
     348       . . S DEL(I+1)="" ; SET NEXT LINE TO DELETE
     349       . I J["><" D  ; AN EMPTY ELEMENT ON ONE LINE
     350       . . W I,J,!
     351       . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED
     352       . . S DEL(I)="" ; SET THE EMPTY LINE UP TO BE DELETED
     353       . . I JM=JPX D  ;
     354       . . . W I,JM_J_JPX,!
     355       . . . S DEL(I-1)=""
     356       . . . S DEL(I+1)="" ; SET THE SURROUNDING LINES FOR DEL
     357       ; . I J'["><" D PUSH("TMPXML",J)
     358       I FOUND D  ; NEED TO DELETE THINGS
     359       . F I=1:1:@THEXML@(0) D  ; COPY ARRAY LEAVING OUT DELELTED LINES
     360       . . I '$D(DEL(I)) D  ; IF THE LINE IS NOT DELETED
     361       . . . D PUSH("TMPXML",@THEXML@(I)) ; COPY TO TMPXML ARRAY
     362       . ZWR DEL
     363       . D CP("TMPXML",THEXML) ; REPLACE THE XML WITH THE COPY
     364       Q FOUND
     365       ;
     366NXTCHLD(HANDLE,NODE,CUR) ; RETURNS THE NEXT CHILD OR "" IF NONE
     367       Q $$CHILD^MXMLDOM(HANDLE,NODE,CUR)
    354368       ;
    355369PARY(GLO)       ;PRINT AN ARRAY
Note: See TracChangeset for help on using the changeset viewer.