我正在尝试使用 HapiTestPanel 在 IHE 标准(ORU-R01 消息类型)上创建 HL7 消息,并且在 OBX 字段的开头有一个意外的空字,但我不知道错误在哪里。 .
发送此消息:
1|60|264864^/min^UCUM|||||R OBX|2|NM|150324^MDC_SAT_O2_ART^MDC|1.2.1.1|98|262688^MDC_DIM_PERCENT^MDC|||||R OBX|3|NM |150021^MDC_PRESS_BLD_NONINV_SYS^MDC|1.3.1.1|120|266016^MDC_DIM_MMHG^MDC||||R OBX|4|NM|150022^MDC_PRESS_BLD_NONINV_DIA^MDC|1.6.1.1|80|266016|||MDC_DIM_MMHG^MDC ||R OBX|5|NM|150023^MDC_PRESS_BLD_NONINV_MEAN^MDC|1.6.1.1|100|266016^MDC_DIM_MMHG^MDC|||||R OBX|6|NM|150037^MDC_PRESS_BLD_ART_ABP_SYS^MDC|1.6.1.1|126| 266016^MDC_DIM_MMHG^MDC|||||R OBX|7|NM|150038^MDC_PRESS_BLD_ART_ABP_DIA^MDC|1.6.1.1|76|266016^MDC_DIM_MMHG^MDC|||||R OBX|8|NM^|150039^MDC_PRESS_BLD_ART_ABP_MEAN MDC|1.6.1.1|92|266016^MDC_DIM_MMHG^MDC|||||R OBX|9|NM|151728^MDC_AWAY_CO2_ET^MDC|1.6.1.1|60|266016^MDC_DIM_MMHG^MDC|||||R OBX| 10|NM|151562^MDC_RESP_RATE^MDC|1.6.1.1|60|264928^MDC_DIM_RESP_PER_MIN^MDC|||||R||||||||| OBX|11|NM|150364^MDC_TEMP_BODY^MDC|1.0。
我在受体中得到了这个:
MSH|^~\&|LiFETouch17|LiFETouch17Facility|AnesthesiaApp|AnesthesiaAppFacility|20141112144500||ORU^R01^ORU_R01|Q123456789T123456789X123456|P|2.6||||||||IHE PCD ORU-R01
PID|||123456789|012345678 9^AA^^JP|BROS^MARIO||19850101000000|M|||123 FAKE STREET^MARIO LUIGI BROS PLACE^TOADSTOOL KINGDOM^NES^A1B2C3^JP^HOME^^1234|1234
PV1||O|ABCD^EFGH||||123456^DINO^YOSHI^^^^^^MSRM^CURRENT^^^NEIGHBOURHOOD DR NBR|^DOG^DUCKH UNT^^^^^^^CURRENT|||| |||||123456^DINO^YOSHI^^^^^MSRM^CURRENT^^^NEIGHBOURHOOD DR NBR||0123456789||||||||||||||||||||| |||20010101000000
OBR|1|080019FFFF4F6AFE20081211144657^AwareGateway^080019FFFF4F6AC0^EUI-64|080019FFFF4F6AC020081211144657^AwareGateway^080019FFFF4F6AC0^EUI-64|126.169.95.2^2000^MDC|||20081211144500
无效的1|60|264928^MDC_DIM_RESP_PER_MIN^MDC|||||R||||||||| OBX|11|NM|150364^MDC_TEMP_BODY^MDC|1.0.0.9|37|268192^MDC_DIM_DEGC^MDC|||||ROBX|12|NM|150364^MDC_EEG_BISPECTRAL_INDEX^MDC|1.0.0.9|37|262656^MDC_DIM_DIMLESS^ MDC|||||R
公共无效 onCreate() {
super.onCreate();
serverThread = new Thread(new Runnable() { public void run() { try{ Looper.prepare(); socket = new ServerSocket(8080); socket.setReuseAddress(true); socket.setPerformancePreferences(100, 100, 1);
while (!stop){
Socket accept = socket.accept();
accept.setPerformancePreferences(10, 100, 1);
accept.setKeepAlive(true);
try
{
/这里我得到了 16 行的消息/ /每行都以 \n 结尾,以区分受体中的片段/
in = new BufferedReader(new InputStreamReader(accept.getInputStream()));
int cont=0;
for (cont=0;cont<16;cont++){
if (cont==0){
aux = in.readLine();
aux=aux.substring(1);
if (aux.contains(inicio)){
hl7Message=aux+separator2;
}
else{
Log.v("Fail", "Error, the received data does not " +"follow the HL7 protocol");
break;
}
}
hl7Message+=in.readLine()+separator2;
}
}catch (IOException e2){
e2.printStackTrace();
}
/我用整个消息调用解析器/
hl7Parser(hl7Message);
}
} catch (Throwable e){
e.printStackTrace();
Log.e(getClass().getSimpleName(), "Error in Listener",e);
}
try
{
socket.close();
}
catch (IOException e)
{
Log.e(getClass().getSimpleName(), "keep it simple");
}
}
},"Server thread");
serverThread.start();
}
/这里我解析消息,首先我用 \n 分隔每一行,我有:MSH、PID、PV1、OBR 和 OBX(从 1 到 13) /
公共无效 hl7Parser(字符串 hl7Message){
String[] fieldsOfMessage= null;
fieldsOfMessage=hl7Message.split(separator2);
MSH=fieldsOfMessage[0];
PID=fieldsOfMessage[1];
PV1=fieldsOfMessage[2];
OBR=fieldsOfMessage[3];
for (int x=4; x<16;x++){
OBX+=fieldsOfMessage[x];
}
/这里我得到了第一个段的索引,以便能够在段内搜索所需的字段/
int[] indice;
//MSH SEGMENT
indice=get_indice(MSH);
/这些是所需的字段/
String sending_application, sending_facility, receiving_application,
receiving_facility, date, message_type,
message_control_id, processing_ID, version, sequence_number,
accept_ack_type, app_ack_type, country_code, principle_language, message_profile_id;
sending_application=MSH.substring(indice[1]+1,indice[2]);
sending_facility=MSH.substring(indice[2]+1,indice[3]);
receiving_application=MSH.substring(indice[3]+1,indice[4]);
receiving_facility=MSH.substring(indice[4]+1,indice[5]);
date=MSH.substring(indice[5]+1,indice[6]);
message_type=MSH.substring(indice[7]+1,indice[8]);
int tr=message_type.indexOf("^");
String type=message_type.substring(tr+1);
message_control_id=MSH.substring(indice[8]+1,indice[9]);
processing_ID=MSH.substring(indice[9]+1,indice[10]);
version=MSH.substring(indice[10]+1,indice[11]);
message_profile_id=MSH.substring(indice[19]+1);
Date now = new Date();
String standard_date = new SimpleDateFormat("yyyyMMddHHmmss.SSSZ").format(now);
/我在 OBX 字段得到 nullOBX... 而不是 OBX.. 之前得到了错误。/