Spring boot 如何将json数据转换为HL7格式?
我的数据库里有数据。我需要以json格式获取数据,并将其转换为HL7格式。 有人能帮我吗Spring boot 如何将json数据转换为HL7格式?,spring-boot,microservices,Spring Boot,Microservices,我的数据库里有数据。我需要以json格式获取数据,并将其转换为HL7格式。 有人能帮我吗 这将在spring boot中完成,这可能不是您想要的,但可能很有用 这是我在将HL7转换为Json时发现的另一个线程 使用spring boot data jpa获取数据,将该数据映射到Java对象(HL7Message),使用HAPI HL7 API创建转换器 <dependency> <groupId>ca.uhn.hapi</groupId>
这将在spring boot中完成,这可能不是您想要的,但可能很有用 这是我在将HL7转换为Json时发现的另一个线程
使用spring boot data jpa获取数据,将该数据映射到Java对象(HL7Message),使用HAPI HL7 API创建转换器
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-base</artifactId>
<version>2.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ca.uhn.hapi/hapi-structures-v25 -->
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v25</artifactId>
<version>2.3</version>
</dependency>
要以字符串形式转换HL7消息,请编写解析器
public String getHL7StrMessage(OMI_O23 message) {
String result = null;
String FLD_SEP = "|";
String ENC_CHAR = "^~\\&";
try {
// Parse the message
HapiContext hapiContext = new DefaultHapiContext();
message.getMSH().getFieldSeparator().setValue(FLD_SEP);
message.getMSH().getEncodingCharacters().setValue(ENC_CHAR);
log.debug("Parsing and encoding the OMI_O23 message");
Parser parser = hapiContext.getPipeParser();
result = parser.encode(message);
log.debug(result);
} catch (HL7Exception e) {
log.error(e);
}
return result;
}
我希望这会有所帮助。谢谢您的回复。您能告诉我如何使用HAPI dependency将hl7转换为json吗谢谢您的回复,但是您提供的链接是python的,我需要java的
public String getHL7StrMessage(OMI_O23 message) {
String result = null;
String FLD_SEP = "|";
String ENC_CHAR = "^~\\&";
try {
// Parse the message
HapiContext hapiContext = new DefaultHapiContext();
message.getMSH().getFieldSeparator().setValue(FLD_SEP);
message.getMSH().getEncodingCharacters().setValue(ENC_CHAR);
log.debug("Parsing and encoding the OMI_O23 message");
Parser parser = hapiContext.getPipeParser();
result = parser.encode(message);
log.debug(result);
} catch (HL7Exception e) {
log.error(e);
}
return result;
}