首页 > 解决方案 > 如何访问患者 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但我不知道如何获取它。

在此处输入图像描述

标签: hapi-fhir

解决方案


我找到了:

patient.getIdElement().getIdPart()

推荐阅读