我如何访问患者的ID?

时间:2018-06-05 20:37:03

标签: hapi-fhir

请查看我从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());

当我在调试器中检查患者时,我可以在字段myUnqualifiedId中看到该值,但我无法发现如何获取它。

enter image description here

1 个答案:

答案 0 :(得分:0)

我找到了它:

patient.getIdElement().getIdPart()