hapi-fhir - 如何访问患者 ID?
问题描述
请查看我从http://fhirtest.uhn.ca/baseDstu3收到的以下患者回复。我想访问 id 标签中的 4081340 值,但我无法在 org.hl7.fhir.dstu3.model.Patient API 中找到它。有人可以告诉我怎么做吗?
<Patient xmlns="http://hl7.org/fhir">
<id value="4081340"></id>
<meta>
<versionId value="1"></versionId>
<lastUpdated value="2018-06-04T15:13:28.069+00:00"></lastUpdated>
</meta>
<text>
<status value="generated"></status>
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="hapiHeaderText">Robert Jozef
<b>VAESSEN </b>
</div>
<table class="hapiPropertyTable">
<tbody>
<tr>
<td>Identifier</td>
<td>12345</td>
</tr>
<tr>
<td>Date of birth</td>
<td>
<span>30 January 1954</span>
</td>
</tr>
</tbody>
</table>
</div>
</text>
<identifier>
<system value="http://dmw.levy.com/mrn"></system>
<value value="12345"></value>
</identifier>
<name>
<family value="Vaessen"></family>
<given value="Robert"></given>
<given value="Jozef"></given>
</name>
<gender value="male"></gender>
<birthDate value="1954-01-30"></birthDate>
</Patient>
更新:
我想访问 4081340 值的原因是我需要它来执行如下代码:
private void deletePatient(String id) {
try {
OperationOutcome outcome = (OperationOutcome) client.delete().resourceById(new IdDt("Patient", id)).execute();
}
catch (Exception e) {
System.out.printf("Cannot delete patient with id = %s\n%s\n", id, e.getMessage());
}
}
private void retrievePatient(String id) {
try {
Patient patient = client.read().resource(Patient.class).withId(id).execute();
String description = parser.encodeResourceToString(patient);
System.out.printf("Successfully retrieved patient with ID = %s:\n%s\n", id, description);
}
catch (ResourceNotFoundException e) {
System.out.printf("Cannot find patient with id = %s\n", id);
}
}
以下语句均打印http://hapi.fhir.org/baseDstu3/Patient/4081340/_history/1。我可以解析它以获得 4081340
System.out.printf("\t%s\n", patient.getId());
System.out.printf("\t%s\n", patient.getIdBase());
System.out.printf("\t%s\n", patient.getIdElement());
当我在调试器中检查 Patient 时,我可以看到该字段中的值,myUnqualifiedId
但我不知道如何获取它。
解决方案
我找到了:
patient.getIdElement().getIdPart()
推荐阅读
- sql - 两个条件 Where 子句 SQL
- javascript - 在heroku上安装npm包
- ios - 将 Json 映射到 swift 对象时遇到问题
- image - 如何在 Julia 中更新图像像素的颜色?
- javascript - 网页中的空白
- html - 用户使用 django 2.2 登录时将登录页面重定向到主页
- c++ - 只有 wWinMain MSVC 2019 的链接器错误无法解析外部符号
- javascript - 嵌套 Redux Reducer 中的解构操作
- python - 尽管有 30 多个 kafka-monitor 副本,但 Kafka 主题仍然卡住了
- python - 从字节对象运行内存中的二进制可执行文件