コード例 #1
1
  @Test
  public void testTwoInclude() throws Exception {
    HttpGet httpGet =
        new HttpGet(
            "http://localhost:"
                + ourPort
                + "/Patient?name=Hello&_include=foo&_include=bar&_pretty=true");
    HttpResponse status = ourClient.execute(httpGet);
    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());

    ourLog.info(responseContent);

    assertEquals(200, status.getStatusLine().getStatusCode());
    Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(1, bundle.size());

    Patient p = bundle.getResources(Patient.class).get(0);
    assertEquals(2, p.getName().size());
    assertEquals("Hello", p.getId().getIdPart());

    Set<String> values = new HashSet<String>();
    values.add(p.getName().get(0).getFamilyFirstRep().getValue());
    values.add(p.getName().get(1).getFamilyFirstRep().getValue());
    assertThat(values, containsInAnyOrder("foo", "bar"));
  }
コード例 #2
0
  @Test
  public void testIIncludedResourcesNonContainedInExtensionJson() throws Exception {
    HttpGet httpGet =
        new HttpGet(
            "http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true&_format=json");
    HttpResponse status = ourClient.execute(httpGet);
    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());

    assertEquals(200, status.getStatusLine().getStatusCode());
    Bundle bundle = ourCtx.newJsonParser().parseBundle(responseContent);

    ourLog.info(responseContent);

    assertEquals(3, bundle.size());
    assertEquals(
        new IdDt("Patient/p1"),
        bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
    assertEquals(
        new IdDt("Patient/p2"),
        bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
    assertEquals(
        new IdDt("Organization/o1"),
        bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
    assertEquals(
        BundleEntrySearchModeEnum.INCLUDE,
        bundle.getEntries().get(2).getSearchMode().getValueAsEnum());

    Patient p1 = (Patient) bundle.toListOfResources().get(0);
    assertEquals(0, p1.getContained().getContainedResources().size());

    Patient p2 = (Patient) bundle.toListOfResources().get(1);
    assertEquals(0, p2.getContained().getContainedResources().size());
  }
コード例 #3
0
  // @Test
  public void testMixedContainedAndNonContained() throws Exception {
    HttpGet httpGet =
        new HttpGet(
            "http://localhost:"
                + ourPort
                + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
    HttpResponse status = ourClient.execute(httpGet);
    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());

    ourLog.info(responseContent);

    assertEquals(200, status.getStatusLine().getStatusCode());
    Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(4, bundle.size());
  }
コード例 #4
0
  @Test
  public void testSearchSummaryData() throws Exception {
    HttpGet httpGet =
        new HttpGet("http://localhost:" + ourPort + "/Patient?_elements=name,maritalStatus");
    HttpResponse status = ourClient.execute(httpGet);
    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    ourLog.info(responseContent);

    assertEquals(200, status.getStatusLine().getStatusCode());
    assertThat(responseContent, containsString("<Patient"));
    assertThat(responseContent, not(containsString("THE DIV")));
    assertThat(responseContent, containsString("family"));
    assertThat(responseContent, containsString("maritalStatus"));
    assertThat(ourLastElements, containsInAnyOrder("name", "maritalStatus"));
  }
コード例 #5
0
  @Test
  public void testReadSummaryTrue() throws Exception {
    HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/1?_elements=name");
    HttpResponse status = ourClient.execute(httpGet);
    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());
    ourLog.info(responseContent);

    assertEquals(200, status.getStatusLine().getStatusCode());
    assertEquals(
        Constants.CT_FHIR_XML + Constants.CHARSET_UTF8_CTSUFFIX.replace(" ", "").toLowerCase(),
        status.getEntity().getContentType().getValue().replace(" ", "").replace("UTF", "utf"));
    assertThat(responseContent, not(containsString("<Bundle")));
    assertThat(responseContent, (containsString("<Patien")));
    assertThat(responseContent, not(containsString("<div>THE DIV</div>")));
    assertThat(responseContent, (containsString("family")));
    assertThat(responseContent, not(containsString("maritalStatus")));
    assertThat(ourLastElements, containsInAnyOrder("name"));
  }
コード例 #6
0
  @Test
  public void testOneIncludeXml() throws Exception {
    HttpGet httpGet =
        new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo");
    HttpResponse status = ourClient.execute(httpGet);
    String responseContent = IOUtils.toString(status.getEntity().getContent());
    IOUtils.closeQuietly(status.getEntity().getContent());

    assertEquals(200, status.getStatusLine().getStatusCode());

    ourLog.info(responseContent);

    Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
    assertEquals(1, bundle.size());

    Patient p = bundle.getResources(Patient.class).get(0);
    assertEquals(1, p.getName().size());
    assertEquals("Hello", p.getId().getIdPart());
    assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
  }