Changeset 605 for ccr/trunk


Ignore:
Timestamp:
Nov 17, 2009, 6:14:09 PM (15 years ago)
Author:
George Lilly
Message:

CCD import processing

File:
1 edited

Legend:

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

    r601 r605  
    4949 S C0CDOCID=$$PARSCCD(C0CXMLIN,"W") W !,"DocID: ",C0CDOCID
    5050 S REDUX="//ClinicalDocument/component/structuredBody"
     51 D FINDTID ; FIND THE TEMPLATE IDS
     52 D FINDALT ; FIND ALTERNATE TAGS
     53 D SETCBK ; SET THE CALLBACK ROUTINE FOR TAGS
    5154 D XPATH(1,"/","GIDX","GARY",,REDUX)
    52  S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DOCID: ",C0CDOCID  ;CALL REGULAR PARSER
    53  D XPATH(1,"/","GIDX2","GARY2",,REDUX)
     55 D SEPARATE("GARY2","GARY") ; SEPARATE FOR EASIER BROWSING
     56 ;S C0CDOCID=$$PARSE(C0CXMLIN) W !,"DOCID: ",C0CDOCID  ;CALL REGULAR PARSER
     57 ;D XPATH(1,"/","GIDX2","GARY2",,REDUX)
    5458 Q
    5559 ;
     
    7579        N ZFRST S ZFRST=$$FIRST(ZOID) ; SET FIRST CHILD
    7680        I ZFRST'=0 D  ; THERE IS A CHILD
     81        . N ZNUM
    7782        . N ZMULT S ZMULT=$$ISMULT(ZFRST) ; IS FIRST CHILD A MULTIPLE
    7883        . D XPATH(ZFRST,NEWPATH,ZXIDX,ZXPARY,$S(ZMULT:1,1:""),ZREDUX) ; DO THE CHILD
    7984        N GNXT S GNXT=$$NXTSIB(ZOID)
     85        I $$TAG(GNXT)'=$$TAG(ZOID) S ZNUM="" ; RESET COUNTING AFTER MULTIPLES
    8086        I GNXT'=0 D  ;
    8187        . N ZMULT S ZMULT=$$ISMULT(GNXT) ; IS THE SIBLING A MULTIPLE?
    8288        . I (ZNUM="")&(ZMULT) D  ; SIBLING IS FIRST OF MULTIPLES
    83         . . S ZNUM=1 ;
     89        . . N ZNUM S ZNUM=1 ;
    8490        . . D XPATH(GNXT,ZPATH,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; DO NEXT SIB
    8591        . E  D XPATH(GNXT,ZPATH,ZXIDX,ZXPARY,$S(ZNUM>0:ZNUM+1,1:""),ZREDUX) ; DO NEXT SIB
     
    106112 ;
    107113TAG(ZOID)       ; RETURNS THE XML TAG FOR THE NODE
    108         Q $$NAME^MXMLDOM(C0CDOCID,ZOID)
     114        ;I ZOID=149 B ;GPLTEST
     115        N X,Y
     116        S Y=""
     117        S X=$G(C0CCBK("TAG")) ;IS THERE A CALLBACK FOR THIS ROUTINE
     118        I X'="" X X ; EXECUTE THE CALLBACK, SHOULD SET Y
     119        I Y="" S Y=$$NAME^MXMLDOM(C0CDOCID,ZOID)
     120        Q Y
    109121        ;
    110122NXTSIB(ZOID)    ; RETURNS THE NEXT SIBLING
     
    205217 Q
    206218 ;
     219SEPARATE(OUTARY,INARY) ; SEPARATES XPATH VARIABLES ACCORDING TO THEIR
     220 ; ROOT ; /Problems/etc/etc goes to @OUTARY@("Problems","/Problems/etc/etc")
     221 S ZI=""
     222 F  S ZI=$O(@INARY@(ZI)) Q:ZI=""  D  ; FOR EACH ELEMENT OF THE ARRAY
     223 . S ZJ=$P(ZI,"/",2) ;
     224 . S @OUTARY@(ZJ,ZI)=@INARY@(ZI)
     225 Q
     226 ;
    207227FINDTID ; FIND TEMPLATE IDS IN DOM 1
    208228 S C0CDOCID=1
     
    215235 . . I $$TAG($$PARENT(ZN))="templateId" D  ; ONLY LOOKING FOR TEMPLATES
    216236 . . . S ZG=$$PARENT($$PARENT(ZN))
     237 . . . S ZG2=$$PARENT(ZG) ;COMPONENT THAT HOLDS THIS SECTION
    217238 . . . S CMT=$G(@ZD@(ZG,"X",1))
     239 . . . I CMT="" S CMT="?"
    218240 . . . I $$TAG(ZG)="section" D  ;START OF A SECTION
    219  . . . . S CURSEC=ZG
     241 . . . . S CURSEC=$$PARENT(ZG)
    220242 . . . . S SECCMT=$G(@ZD@(CURSEC,"X",1))
     243 . . . . I SECCMT="" S SECCMT="?"
     244 . . . . S SECTID=$G(@ZD@(ZN,"T",1)) ;SECTION TEMPLATE ID
    221245 . . . S TID=$G(@ZD@(ZN,"T",1)) ;TEMPLATE ID
    222246 . . . I CURSEC'="" D  ; IF WE ARE IN A SECTION
    223  . . . . S CCDDIR(CURSEC,SECCMT,ZG,$$TAG(ZG),CMT)=TID
    224  . . . W !,$$TAG(ZG)," ",$G(@ZD@(ZG,"X",1))
     247 . . . . S CCDDIR(ZG2,CURSEC,$$TAG(ZG2),CMT,SECCMT)=TID
     248 . . . . S DOMMAP(ZG2)=CURSEC_U_$$TAG(ZG2)_U_TID_U_SECTID
     249 . . . W !,$$TAG(ZG2)," ",$G(@ZD@(ZG,"X",1))
    225250 . . . W " root ",ZN," ",@ZD@(ZN,"T",1)
     251 Q
     252 ;
     253FINDALT ; PROCESS THE DOMMAP AND FIND THE ALT TAGS FOR COMPONENTS
     254 ;
     255 S ZI=""
     256 F  S ZI=$O(DOMMAP(ZI)) Q:ZI=""  D  ; FOR EACH NODE IN THE MAP
     257 . S ZJ=DOMMAP(ZI) ;
     258 . S PARNODE=$P(ZJ,U,1) ;PARENT NODE
     259 . S TAG=$P(ZJ,U,2) ;THIS TAG
     260 . S TID=$P(ZJ,U,3) ;THIS TEMPLATE ID
     261 . S PARTID=$P(ZJ,U,4) ;PARENT TEMPLATE ID
     262 . S ZIEN=$O(^C0CXDS(178.101,"TID",TID,"")) ;THIS NODE IEN
     263 . S PARIEN=$O(^C0CXDS(178.101,"TID",PARTID,"")) ;PARENT NODE IEN
     264 . I ZI=PARNODE D  ; IF THIS IS A SECTION NODE
     265 . . S ALTTAG=$$GET1^DIQ(178.101,PARIEN_",",.03) ;ALT TAG FIELD FOR PARENT
     266 . . S NAME=$$GET1^DIQ(178.101,ZIEN_",",.01) ;NAME OF THIS NODE'S TEMPLATE
     267 . . W ZI," ",TAG," ",ALTTAG," ",NAME,!
     268 . . S C0CTAGS(ZI)=ALTTAG
     269 Q
     270 ;
     271ALTTAG(NODE) ; SET Y EQUAL TO THE ALT TAG FOUND IN C0CTAGS IF NODE IF FOUND
     272 ;
     273 S Y=$G(C0CTAGS(NODE))
     274 Q
     275 ;
     276SETCBK ; SET THE TAG CALLBACK FOR XPATH PROCESSSING OF THE CCD
     277 S C0CCBK("TAG")="D ALTTAG(ZOID)"
    226278 Q
    227279 ;
    228280GENXDS(ZD) ; GENERATE THE XDS PROTOTYPE RECORDS FROM A CCDDIR ARRAY
    229281 ; ARRAY ELEMENTS LOOK LIKE:
    230  ; CCDDIR(1634," Vital signs section template ",1659,"observation"," Result observaion template ")="2.16.840.1.113883.10.20.1.31"
    231  ;or CCDDIR(section node,sec name, cur node,cur tag,cur name)=templateId
     282 ; CCDDIR(1659,1634,"observation"," Result observaion template "," Vital signs section template ")="2.16.840.1.113883.10.20.1.31"
     283 ;or CCDDIR(cur node,section node,cur tag,cur name,sec name)=templateId
    232284 S ZF=178.101 ; FILE NUMBER FOR THE C0C XDS PROTOTYPE FILE
    233285 S ZI=$Q(@ZD@("")) ;FIRST ARRAY ELEMENT
     
    245297 Q
    246298 ;
     299WHRUSD(ZD) ; UPDATE THE C0C XDS FILE WITH WHERE USED DATA FROM
     300 ; CCDDIR PASS BY NAME
     301 ; ARRAY ELEMENTS LOOK LIKE:
     302 ; CCDDIR(1634," Vital signs section template ",1659,"observation"," Result observaion template ")="2.16.840.1.113883.10.20.1.31"
     303 ;or CCDDIR(section node,sec name, cur node,cur tag,cur name)=templateId
     304 S ZF=178.101 ; FILE NUMBER FOR THE C0C XDS PROTOTYPE FILE
     305 S ZSF=178.111 ; WHERE USED SUBFILE OF C0C XDS PROTOTYPE FILE
     306 S ZI=$Q(@ZD@("")) ;FIRST ARRAY ELEMENT
     307 S DONE=0
     308 F  Q:DONE  D  ;
     309 . W @ZI
     310 . S ZIEN=$O(^C0CXDS(178.101,"TID",@ZI,"")) ; IEN FOR THIS NODE'S TEMPLATE
     311 . W " IEN:",ZIEN
     312 . S ZJ=$QS(ZI,2)
     313 . S ZJ=$E(ZJ,2,$L(ZJ)) ;STRIP THE LEADING SPACE
     314 . S ZPIEN=$O(^C0CXDS(178.101,"B",ZJ,"")) ; PARENT IEN
     315 . W " PARENT IEN:",ZPIEN
     316 . S ZTAG=$QS(ZI,4) ; TAG FOR THIS TEMPLATE
     317 . W " TAG:",ZTAG,!
     318 . I ZIEN'=ZPIEN D  ; ONLY FOR CHILD TEMPLATES
     319 . . S C0CFDA(ZSF,"?+1,"_ZIEN_",",.01)=ZPIEN ; NEW SUBFILE ENTRY WITH PAR PTR
     320 . . S C0CFDA(ZSF,"?+1,"_ZIEN_",",1)=ZTAG ; TAG FOR NEW ENTRY
     321 . . D UPDIE
     322 . ;S C0CFDA(ZF,"?+1,",1)=@ZI
     323 . ;D UPDIE
     324 . S ZI=$Q(@ZI)
     325 . I ZI="" S DONE=1
     326 Q
     327 ;
    247328UPDIE   ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
    248329 K ZERR
Note: See TracChangeset for help on using the changeset viewer.