コード例 #1
0
    @Search
    public Observation search(
        @RequiredParam(name = "subject") ReferenceParam theSubject,
        @RequiredParam(name = "name") TokenOrListParam theName) {
      Observation o = new Observation();
      o.setId("1");

      o.getSubject().setReference(theSubject.getResourceType() + "/" + theSubject.getIdPart());
      for (BaseCodingDt next : theName.getListAsCodings()) {
        o.getName().getCoding().add(new CodingDt(next));
      }

      return o;
    }
コード例 #2
0
  @Test
  public void testSearchGetWithUnderscoreSearch() throws Exception {
    HttpGet httpGet =
        new HttpGet(
            "http://localhost:"
                + ourPort
                + "/Observation/_search?subject%3APatient=100&name=3141-9%2C8302-2%2C8287-5%2C39156-5");

    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.newXmlParser().parseBundle(responseContent);
    assertEquals(1, bundle.getEntries().size());

    Observation p = bundle.getResources(Observation.class).get(0);
    assertEquals("Patient/100", p.getSubject().getReference().toString());
    assertEquals(4, p.getName().getCoding().size());
    assertEquals("3141-9", p.getName().getCoding().get(0).getCode().getValue());
    assertEquals("8302-2", p.getName().getCoding().get(1).getCode().getValue());
  }