0

Please have a look at the following code wherein I have a method that searches by family name and another that searches by system. Following the code I have provided the results that were produced by invoking each of these two methods. You can see that the system search returned three patients, the third one having the family name Vaessen. But, when I search for the family name Vaessen a timeout results. Would someone please help me to understand why this is happening?

Note: As you can see from the timeout exception, I am querying the public fhir server http://fhirtest.uhn.ca/baseDstu3

public void findPatientsInFamily(String family) {
    System.out.printf("\n\nFinding patients in family %s\n", family);
    findPatients(Patient.FAMILY.matches().value(family));
}

public void findPatientsInSystem(String system) {
    System.out.printf("\n\nFinding patients in system %s\n", system);
    findPatients(Patient.IDENTIFIER.hasSystemWithAnyCode(system));
}

@SuppressWarnings("rawtypes")
public void findPatients(ICriterion criterion) {

    try {
        Bundle bundle = client.search().forResource(Patient.class).where(criterion).returnBundle(Bundle.class).execute();

        for (BundleEntryComponent entry : bundle.getEntry()) {
            if (entry.getResource().getResourceType() == ResourceType.Patient) {
                Patient patient = (Patient) entry.getResource();
                System.out.printf("%s\n", parser.encodeResourceToString(patient));
            }
        }
    }
    catch(Exception e) {
        System.out.printf("Cannot find patients\n%s\n", e.getMessage());
    }
}

Results for the findPatientsInSystem(String system) method:

Finding patients in system http://dmw.levy.com/mrn
<Patient xmlns="http://hl7.org/fhir">
   <id value="4172808"></id>
   <meta>
      <versionId value="1"></versionId>
      <lastUpdated value="2018-06-07T14:10:52.336+00:00"></lastUpdated>
   </meta>
   <text>
      <status value="generated"></status>
      <div xmlns="http://www.w3.org/1999/xhtml">
         <div class="hapiHeaderText">Rachael 
            <b>LANEHART </b>
         </div>
         <table class="hapiPropertyTable">
            <tbody>
               <tr>
                  <td>Identifier</td>
                  <td>12345</td>
               </tr>
               <tr>
                  <td>Date of birth</td>
                  <td>
                     <span>30 December 1985</span>
                  </td>
               </tr>
            </tbody>
         </table>
      </div>
   </text>
   <identifier>
      <system value="http://dmw.levy.com/mrn"></system>
      <value value="12345"></value>
   </identifier>
   <name>
      <family value="Lanehart"></family>
      <given value="Rachael"></given>
   </name>
   <gender value="female"></gender>
   <birthDate value="1985-12-30"></birthDate>
</Patient>
<Patient xmlns="http://hl7.org/fhir">
   <id value="4149602"></id>
   <meta>
      <versionId value="1"></versionId>
      <lastUpdated value="2018-06-06T20:52:11.831+00:00"></lastUpdated>
   </meta>
   <text>
      <status value="generated"></status>
      <div xmlns="http://www.w3.org/1999/xhtml">
         <div class="hapiHeaderText">Ravi 
            <b>THAKKAR </b>
         </div>
         <table class="hapiPropertyTable">
            <tbody>
               <tr>
                  <td>Identifier</td>
                  <td>12345</td>
               </tr>
               <tr>
                  <td>Date of birth</td>
                  <td>
                     <span>14 April 1962</span>
                  </td>
               </tr>
            </tbody>
         </table>
      </div>
   </text>
   <identifier>
      <system value="http://dmw.levy.com/mrn"></system>
      <value value="12345"></value>
   </identifier>
   <name>
      <family value="Thakkar"></family>
      <given value="Ravi"></given>
   </name>
   <gender value="male"></gender>
   <birthDate value="1962-04-14"></birthDate>
</Patient>
<Patient xmlns="http://hl7.org/fhir">
   <id value="4013201"></id>
   <meta>
      <versionId value="1"></versionId>
      <lastUpdated value="2018-06-01T18:30:23.902+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>

Results for the findPatientsInFamily(String family) method:

Finding patients in family Vaessen
Cannot find patients
Failed to parse response from server when performing GET to URL http://fhirtest.uhn.ca/baseDstu3/Patient?family=Vaessen - java.net.SocketTimeoutException: Read timed out
Verticon
  • 2,419
  • 16
  • 34

1 Answers1

0

The way in which your code queries the FHIR Server should be fine for a Patient search by system or family name.

I tried the public test server through the UI at http://fhirtest.uhn.ca/ and everything appears to be down currently. Every request returns an error. There is already an issue posted here on GIT https://github.com/jamesagnew/hapi-fhir/issues/998.

It is also possible that when the server is back up, there may be so much patient data that your request will still error unless a large connection timeout is set, or more filter criteria is provided.

Preston
  • 308
  • 6
  • 14