【发布时间】:2016-06-07 09:16:05
【问题描述】:
我正在编写一个 java 代码,用于使用 HAPI - FHIR DSTU2 HL7 中的 MedicationOrder 资源生成 POST 请求。我遇到了几个麻烦。
- 为包含的资源设置参考值。
- 生成的 XML 消息中不存在包含的资源。
- 操作结果为 HTTP/1.1 500 Internal Server Error 并显示消息 Expecting external element called 'feed', found: MedicationOrder。
任何熟悉 MedicationOrder 资源的人可以帮助我吗?
下面是java代码
public int sendMessage(MedicationOrder medicationOrder) throws ClientProtocolException, IOException
{
FhirContext ctx = FhirContext.forDstu2Hl7Org();
IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2");
HttpPost httpPost = new HttpPost("http://fhirtest.uhn.ca/baseDstu2");
String message = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(medicationOrder);
httpPost.setEntity((HttpEntity) new StringEntity(message, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
org.apache.http.HttpResponse response = client.getHttpClient().execute(httpPost);
return response.getStatusLine().getStatusCode();
}
【问题讨论】:
-
不清楚你在问什么。请包含您说您正在编写的 Java 代码 - 包含生成这些错误的 Java 代码会更有帮助。请在how to ask a good question 上查看一些有用的提示 - 问一个好问题可以提高您获得答案的机会。但同样重要的是,在发布问题之前先进行搜索并进行一些研究。还包括您尝试过的内容并指出您遇到的问题。
标签: java hl7-fhir hapi dstu2-fhir hapi-fhir