我正在尝试通过 Hapi 在 map-reduce 函数中解析 HL7 消息,当我运行 map 任务时出现EncodingNotSupportedException 。我试图将 \n 或 \r 添加到每个段的末尾,但我面临同样的错误。消息保存在文本文件中,并上传到 HDFS。我是否需要添加一些东西这是我的代码
String v = value.toString();
InputStream is = new StringBufferInputStream(v);
is = new BufferedInputStream(is);
Hl7InputStreamMessageStringIterator iter = new Hl7InputStreamMessageStringIterator(
is);
HapiContext hcontext = new DefaultHapiContext();
Message hapiMsg;
Parser p = hcontext.getGenericParser();
while (iter.hasNext()) {
String msg = iter.next();
try {
hapiMsg = p.parse(msg);
} catch (EncodingNotSupportedException e) {
e.printStackTrace();
return;
} catch (HL7Exception e) {
e.printStackTrace();
return;
}
}
示例消息
MSH|^~\&|HIS|RIH|EKG|EKG|20150121002000||ADT^A01||P|2.5.1
EVN||20150121002000|||||CITY GENL HOSP^0133195934^NPI
PID|1||95101100001^^^^PI^CITY GENL HOSP&0133195934&NPI||SNOW^JOHN^^^MR^^L||19560121002000|M||2054-5^White^CDCREC|470 Ocean Ave^^NEW YORK^^11226^USA^C^^29051||^^^^^513^5551212|||||95101100001||||2186-5^White American^CDCREC|||1
PV1||E||E||||||||||1||||||||||||||||||||||||||||||
OBX|1|NM|21612-7^PATIENT AGE REPORTED^LN||60|a^YEAR^UCUM|||||F|||201601131443
OBX|2|NM|21613-7^Urination^LN||2|a^DAY^UCUM|||||F|||19740514201500
DG1|001||4158^Diabetes^I9CDX||19740514201500|A|5478^Non-infectious
DG1|002||2222^Huntington^I9CDX||19610718121500|A|6958^Genetic