@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")); }
private Device initializeDevice(Patient p) { log("Initializing device"); Device d = newDevice(); d.setManufacturer(deviceInfo.getManufacturerName()); d.setModel(deviceInfo.getModelNumber()); d.setVersion(deviceInfo.getFirmwareRevision()); NarrativeDt n = getNarrative(d); n.setDiv( n.getDiv() .getValueAsString() .substring(5, n.getDiv().getValueAsString().length() - 6) .concat("<strong>Serial Number: </strong>") .concat(deviceInfo.getSerialNumber()) .concat("<br /><strong>Name: </strong>") .concat(deviceInfo.getName()) .concat("<br /><strong>MAC Address: </strong>") .concat(deviceInfo.getAddress())); d.setText(n); CodeableConceptDt type = new CodeableConceptDt(); // TODO find valid url type.addCoding() .setCode("15-102") .setDisplay("Glukose-Analysegerät") .setSystem("http://umdns.org"); d.setType(type); d.setPatient(newResourceReference(p.getId())); d.setIdentifier(Arrays.asList(getIdentifier("/devices/", "" + deviceInfo.getSysID()))); log("Initializing device done"); return d; }
@Test public void testNoIncludes() throws Exception { HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello"); 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.size()); Patient p = bundle.getResources(Patient.class).get(0); assertEquals(0, p.getName().size()); assertEquals("Hello", p.getId().getIdPart()); }
@Test public void testOneIncludeJson() throws Exception { HttpGet httpGet = new HttpGet( "http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_format=json"); 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.newJsonParser().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()); }
private Observation initializeObservation( Patient p, DeviceMetric metric, GlucoseRecord r, QuantityDt qdt) { log("Initializing observation"); Observation o = newObservation(qdt); o.setCode(createCode(r.unit)); o.setSubject(newResourceReference(p.getId())); o.setDevice(newResourceReference(metric.getId())); // set date and time for observation DateTimeDt dt = new DateTimeDt(); dt.setValue(r.time.getTime()); o.setEffective(dt); o.setIdentifier( Arrays.asList( getIdentifier( "/devices/".concat("" + deviceInfo.getSysID()), "" + r.getSequenceNumber()))); // set narrative o.setText(getNarrative(o)); log("Initializing observation done"); return o; }