2016-10-01 3 views
0

는 부모 아이 아이 세그먼트를 통해 루프 필요하지만, "연구소"에 대한 변수는 그러나 "장"과 "헤더"작동하지 않습니다 :결합 중첩 된 foreach 루프는 실험실에 대한 CCDA을 통해 근무

var file=""; var header=""; var Lab=""; var section=""; 


header=msg['recordTarget']['patientRole']['patient']['name']['family'].toString()+"|"+ //last name msg['recordTarget']['patientRole']['patient']['name']['given'].toString()+"|"+ //first name msg['recordTarget']['patientRole']['patient']['administrativeGenderCode']['@code'].toString()+"|"+ //gender msg['recordTarget']['patientRole']['patient']['birthTime']['@value'].toString(); //DOB msg['component']['structuredBody']['component'][8]['section']['title'].toString() 
       for each (seg in msg..component) 
       { Lab = ""; 
        Lab =seg['section']['title'].toString(); 
        if (section == "Results") 
       { 
        for each (seg in seg..entry..organizer) 
       { 

         Lab+= seg ['code']['@code'].toString()+"|"+ //LOINC code 
         seg ['code']['@displayName'].toString()+"|"+//actText 
         seg ['effectiveTime']['@value'].toString();//collection timestamp 

          } 
         } 
       } for each (seg in msg..component) 
       { 
        section = ""; 
        section =seg['section']['title'].toString(); 
        if (section == "Results") 

       { 
        for each (seg in seg..entry..organizer..component) 
       { 

         file+=header+"|"+Lab+"|"+ 
         seg ['observation']['code']['@code'].toString()+"|"+ //LOINC code 
         seg ['observation']['code']['@displayName'].toString()+"|"+//actText 
         seg ['observation']['effectiveTime']['@value'].toString()+"|"+//result timestamp 
         seg ['observation']['value']['@value'].toString()+"|"+//result value 
         seg ['observation']['value']['@unit'].toString()+"|"+//result unit 
         seg ['observation']['interpretationCode']['@code'].toString()+"!!!"+"\r"+"\n";//interpretationCode 

          } 
         } 
       } 

channelMap.put("FILE",file); 

답변

0

'for each'는 더 이상 사용되지 않으며 'for'를 사용하십시오.

당신은 도트 구문은 수에 작동 라인 2 (한 줄 댓글) 헤더 =에 구문 오류 ...

header=msg['recordTarget']['patientRole']['patient']['name']['family'].toString()+"|"+ //last name 
msg['recordTarget']['patientRole']['patient']['name']['given'].toString()+"|"+ //first name 
msg['recordTarget']['patientRole']['patient']['administrativeGenderCode']['@code'].toString()+"|"+ //gender 
msg['recordTarget']['patientRole']['patient']['birthTime']['@value'].toString(); //DOB 
msg['component']['structuredBody']['component'][8]['section']['title'].toString(); 

는 점 여러 줄에 걸쳐 분할해야이 리터럴

556..toString()==="556" 

(단일 점)

첫 번째 루프 섹션에서 ""의 초기 값을 절대로 변경하지 않습니다. section == "결과"는 항상 false로 평가되며, 후속 분기가 실행되지 않습니다.

xml을 json 파서로 사용하고 있습니까? 헤더 실제로 제 - 난 는걸 캐스트가 자동으로 수행됩니다

var file="", 
    header="", 
    Lab="", 
    section=""; 


header=msg['recordTarget']['patientRole']['patient']['name']['family'].toString()+"|"+ //last name 
    msg['recordTarget']['patientRole']['patient']['name']['given'].toString()+"|"+ //first name 
    msg['recordTarget']['patientRole']['patient']['administrativeGenderCode']['@code'].toString()+"|"+ //gender 
    msg['recordTarget']['patientRole']['patient']['birthTime']['@value'].toString(); //DOB 
    msg['component']['structuredBody']['component'][8]['section']['title'].toString(); 

for(seg in msg.component){ 
    Lab = ""; 
    Lab =seg['section']['title'].toString(); 
    if (section == "Results"){ 
     for(seg in seg .entry .organizer){ 

    Lab+= seg ['code']['@code'].toString()+"|"+ 
     //LOINC code 
     seg ['code']['@displayName'].toString()+"|"+ 
     //actText 
     seg ['effectiveTime']['@value'].toString(); 
     //collection timestamp 

    } 
    } 
} 

for(seg in msg.component){ 
    section = ""; 
    section =seg['section']['title'].toString(); 
    if (section == "Results"){ 
    for(seg in seg.entry.organizer.component){ 
    file+=header+"|"+Lab+"|"+ 
    seg ['observation']['code']['@code'].toString()+"|"+ 
     //LOINC code 
    seg ['observation']['code']['@displayName'].toString()+"|"+ 
     //actText 
    seg ['observation']['effectiveTime']['@value'].toString()+"|"+ 
     //result timestamp 
    seg ['observation']['value']['@value'].toString()+"|"+ 
     //result value 
    seg ['observation']['value']['@unit'].toString()+"|"+ 
     //result unit 
    seg ['observation']['interpretationCode']['@code'].toString()+"!!!"+"\r"+"\n"; 
     //interpretationCode 
    } 
    } 
} 

channelMap.put("FILE",file); 
+0

감사합니다 (문자열 + 무언가 문자열 + something.toString()로 인터프리터에 의해 변환) toString() 를 호출 할 필요가 있다고 생각하지 않습니다 실험실 루프가 완벽하게 작동합니다. 결과에 따라 오는 '치료 계획'의 '제목'을 포착하고 있으며, 이것이 내가 이해하지 못하는 부분입니다. 나는 json 파서에 xml을 사용하지 않고 Mirth에있는 메시지 트리 파서를 사용하고있다. –