通过CCDA为实验室工作需要遍历父子和子段,但“Lab”的变量不起作用,但“Section”和“Header”正在工作:
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 :(得分:0)
'每个'已弃用,请使用';
第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"
全部替换.. (单点)
第一个循环部分中的永远不会改变其初始值"&#34 ;; section ==" Results"总是判断为false,后续的if分支永远不会执行。
你正在使用xml到json解析器吗? 我不相信侯需要调用toString() 演员表是自动完成的(字符串+某些内容由解释器转换为字符串+ something.toString())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);