我真的很开心,也不太熟悉Java脚本,但我的Mirth 3.3源设置为TCP监听器,我收到HL7 ADT消息。我一直在使用Filter on Source with Type as Rule构建器来仅在PID3.1可用时处理消息。我想要实现的是如果消息由于缺少PID而被过滤我想发送AR消息,其中包含“缺少患者ID”的详细信息。我的最终目的地也是TCP监听器(不确定这是否重要)
我在全局脚本(后处理)中有以下代码
function setACK(sourceMsg,responseCode,responseMsg,responseStatus) {
importPackage(com.mirth.connect.model);
// responseStatus is an optional parameter
if (!responseStatus)
responseStatus = {'AA':Response.Status.SUCCESS,'AR':Response.Status.FILTERED,'AE':Response.Status.FAILURE}[responseCode] || Response.Status.UNKNOWN;
var ack = <HL7Message/>;
ack.MSH['MSH.1'] = sourceMsg.MSH['MSH.1'].toString();
ack.MSH['MSH.2'] = sourceMsg.MSH['MSH.2'].toString();
ack.MSH['MSH.3'] = sourceMsg.MSH['MSH.5'].copy();
ack.MSH['MSH.4'] = sourceMsg.MSH['MSH.6'].copy();
ack.MSH['MSH.5'] = sourceMsg.MSH['MSH.3'].copy();
ack.MSH['MSH.6'] = sourceMsg.MSH['MSH.4'].copy();
ack.MSH['MSH.7']['MSH.7.1'] = DateUtil.getCurrentDate('yyyyMMddHHmmss');
ack.MSH['MSH.9']['MSH.9.1'] = sourceMsg.MSH['MSH.9']['MSH.9.1'].toString();
ack.MSH['MSH.9']['MSH.9.2'] = sourceMsg.MSH['MSH.9']['MSH.9.2'].toString();
ack.MSH['MSH.9']['MSH.9.3'] = 'ACK';
ack.MSH['MSH.10'] = sourceMsg.MSH['MSH.10'].copy();
ack.MSH['MSH.11'] = sourceMsg.MSH['MSH.11'].copy();
ack.MSH['MSH.12'] = sourceMsg.MSH['MSH.12'].copy();
ack.MSA['MSA.1']['MSA.1.1'] = responseCode;
ack.MSA['MSA.2']['MSA.2.1'] = sourceMsg.MSH['MSH.10']['MSH.10.1'].toString();
ack.MSA['MSA.3']['MSA.3.1'] = responseMsg;
responseMap.put('ACK',new Response(responseStatus,SerializerFactory.getHL7Serializer().fromXML(ack)));
在源代码筛选器下,我有以下代码的Javascript规则
if(msg['PID']['PID.3']['PID.3.1'].toString().length > 0) {
return true;
}
setACK(msg,'AR',"MIssing Patient ID.");
return false;
这仍然无法正常工作,我仍然会收到处理错误消息。
答案 0 :(得分:0)
在接收器通道的 Source Transformer 中,您可以添加以下内容作为第一步:
var verified = false;
for each (var pid in msg['PID']['PID.3']) {
if (pid['PID.3.1'].toString()) {
verified = true;
break;
}
}
var ack;
if (verified) {
ack = ACKGenerator.generateAckResponse(connectorMessage.getRawData(), "AA", "Accepted");
} else {
ack = ACKGenerator.generateAckResponse(connectorMessage.getRawData(), "AE", "PID.3.1-Patient Identifier is missed");
destinationSet.removeAll();
}
responseMap.put("ACK", ack);
消息中可能发送了多个PID。此外,响应可能是 AE 代码,除非您的个人资料中的说明不同。 AR 保留用于其他类型的验证。此代码段不会检查传入邮件是否使用增强的确认模式。显然,您需要将通道的源连接器响应设置为ACK。