|
|
|
@ -92,31 +92,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
assertEquals(1, b.getEntries().size());
|
|
|
|
|
|
|
|
|
|
Binary bin = (Binary) b.getEntries().get(0).getResource();
|
|
|
|
|
assertArrayEquals(new byte[] {1,2,3,4}, bin.getContent());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testParseMetaUpdatedDate() {
|
|
|
|
|
//@formatter:off
|
|
|
|
|
String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
|
|
|
|
" <id value=\"e2ee823b-ee4d-472d-b79d-495c23f16b99\"/>\n" +
|
|
|
|
|
" <meta>\n" +
|
|
|
|
|
" <lastUpdated value=\"2015-06-22T15:48:57.554-04:00\"/>\n" +
|
|
|
|
|
" </meta>\n" +
|
|
|
|
|
" <type value=\"searchset\"/>\n" +
|
|
|
|
|
" <base value=\"http://localhost:58109/fhir/context\"/>\n" +
|
|
|
|
|
" <total value=\"0\"/>\n" +
|
|
|
|
|
" <link>\n" +
|
|
|
|
|
" <relation value=\"self\"/>\n" +
|
|
|
|
|
" <url value=\"http://localhost:58109/fhir/context/Patient?_pretty=true\"/>\n" +
|
|
|
|
|
" </link>\n" +
|
|
|
|
|
"</Bundle>";
|
|
|
|
|
//@formatter:on
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Bundle b = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, input);
|
|
|
|
|
|
|
|
|
|
InstantDt updated = ResourceMetadataKeyEnum.UPDATED.get(b);
|
|
|
|
|
assertEquals("2015-06-22T15:48:57.554-04:00", updated.getValueAsString());
|
|
|
|
|
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -137,7 +113,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
List<ExtensionDt> exts = p.getUndeclaredExtensionsByUrl("urn:foo");
|
|
|
|
|
assertEquals(1, exts.size());
|
|
|
|
|
ResourceReferenceDt rr = (ResourceReferenceDt)exts.get(0).getValue();
|
|
|
|
|
ResourceReferenceDt rr = (ResourceReferenceDt) exts.get(0).getValue();
|
|
|
|
|
o = (Organization) rr.getResource();
|
|
|
|
|
assertEquals("ORG", o.getName());
|
|
|
|
|
}
|
|
|
|
@ -156,9 +132,6 @@ public class XmlParserDstu2Test {
|
|
|
|
|
assertThat(str, containsString("<length><value value=\"123\"/><units value=\"day\"/></length>"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeAndParseBundleWithoutResourceIds() {
|
|
|
|
|
Organization org = new Organization();
|
|
|
|
@ -173,42 +146,6 @@ public class XmlParserDstu2Test {
|
|
|
|
|
assertTrue(parsed.getEntries().get(0).getResource().getId().isEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
IGenericClient c = ourCtx.newRestfulGenericClient("http://fhir-dev.healthintersections.com.au/open");
|
|
|
|
|
// c.registerInterceptor(new LoggingInterceptor(true));
|
|
|
|
|
c.read().resource("Patient").withId("324").execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeBundleWithContained() {
|
|
|
|
|
DiagnosticReport rpt = new DiagnosticReport();
|
|
|
|
|
rpt.addResult().setResource(new Observation().setCode(new CodeableConceptDt().setText("Sharp1")).setId("#1"));
|
|
|
|
|
rpt.addResult().setResource(new Observation().setCode(new CodeableConceptDt().setText("Uuid1")).setId("urn:uuid:UUID1"));
|
|
|
|
|
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Bundle b = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
|
|
|
|
b.addEntry().setResource(rpt);
|
|
|
|
|
|
|
|
|
|
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(b);
|
|
|
|
|
ourLog.info(encoded);
|
|
|
|
|
|
|
|
|
|
assertThat(encoded, stringContainsInOrder(
|
|
|
|
|
"<DiagnosticReport",
|
|
|
|
|
"<contained",
|
|
|
|
|
"<Observation",
|
|
|
|
|
"<text value=\"Sharp1\"",
|
|
|
|
|
"</DiagnosticReport"
|
|
|
|
|
));
|
|
|
|
|
assertThat(encoded, not(stringContainsInOrder(
|
|
|
|
|
"<DiagnosticReport",
|
|
|
|
|
"<contained",
|
|
|
|
|
"<Observation",
|
|
|
|
|
"<contained",
|
|
|
|
|
"<Observation",
|
|
|
|
|
"</DiagnosticReport"
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeAndParseContained() {
|
|
|
|
|
IParser xmlParser = ourCtx.newXmlParser().setPrettyPrint(true);
|
|
|
|
@ -260,7 +197,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
// And re-encode once more, with the references cleared
|
|
|
|
|
patient.getContained().getContainedResources().clear();
|
|
|
|
|
patient.getManagingOrganization().setReference((String)null);
|
|
|
|
|
patient.getManagingOrganization().setReference((String) null);
|
|
|
|
|
encoded = xmlParser.encodeResourceToString(patient);
|
|
|
|
|
ourLog.info(encoded);
|
|
|
|
|
assertThat(encoded, stringContainsInOrder(Arrays.asList("<contained>", "<Organization ", "<id value=\"1\"/>", "</Organization", "</contained>", "<reference value=\"#1\"/>")));
|
|
|
|
@ -269,7 +206,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
// And re-encode once more, with the references cleared and a manually set local ID
|
|
|
|
|
patient.getContained().getContainedResources().clear();
|
|
|
|
|
patient.getManagingOrganization().setReference((String)null);
|
|
|
|
|
patient.getManagingOrganization().setReference((String) null);
|
|
|
|
|
patient.getManagingOrganization().getResource().setId(("#333"));
|
|
|
|
|
encoded = xmlParser.encodeResourceToString(patient);
|
|
|
|
|
ourLog.info(encoded);
|
|
|
|
@ -278,7 +215,6 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeAndParseExtensionOnResourceReference() {
|
|
|
|
|
DataElement de = new DataElement();
|
|
|
|
@ -298,13 +234,12 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
List<ExtensionDt> exts = b.getUndeclaredExtensionsByUrl("urn:foo");
|
|
|
|
|
assertEquals(1, exts.size());
|
|
|
|
|
ResourceReferenceDt rr = (ResourceReferenceDt)exts.get(0).getValue();
|
|
|
|
|
ResourceReferenceDt rr = (ResourceReferenceDt) exts.get(0).getValue();
|
|
|
|
|
o = (Organization) rr.getResource();
|
|
|
|
|
assertEquals("ORG", o.getName());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeAndParseExtensions() throws Exception {
|
|
|
|
|
|
|
|
|
@ -348,9 +283,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
|
|
|
|
|
assertThat(enc, containsString("<Patient xmlns=\"http://hl7.org/fhir\"><extension url=\"http://example.com/extensions#someext\"><valueDateTime value=\"2011-01-02T11:13:15\"/></extension>"));
|
|
|
|
|
assertThat(enc, containsString("<modifierExtension url=\"http://example.com/extensions#modext\"><valueDate value=\"1995-01-02\"/></modifierExtension>"));
|
|
|
|
|
assertThat(
|
|
|
|
|
enc,
|
|
|
|
|
containsString("<extension url=\"http://example.com#parent\"><extension url=\"http://example.com#child\"><valueString value=\"value1\"/></extension><extension url=\"http://example.com#child\"><valueString value=\"value2\"/></extension></extension>"));
|
|
|
|
|
assertThat(enc, containsString("<extension url=\"http://example.com#parent\"><extension url=\"http://example.com#child\"><valueString value=\"value1\"/></extension><extension url=\"http://example.com#child\"><valueString value=\"value2\"/></extension></extension>"));
|
|
|
|
|
assertThat(enc, containsString("<given value=\"Joe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"given\"/></extension></given>"));
|
|
|
|
|
assertThat(enc, containsString("<given value=\"Shmoe\"><extension url=\"http://examples.com#givenext_parent\"><extension url=\"http://examples.com#givenext_child\"><valueString value=\"CHILD\"/></extension></extension></given>"));
|
|
|
|
|
|
|
|
|
@ -437,7 +370,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, enc);
|
|
|
|
|
List<IdDt> gotLabels = ResourceMetadataKeyEnum.PROFILES.get(parsed);
|
|
|
|
|
|
|
|
|
|
assertEquals(2,gotLabels.size());
|
|
|
|
|
assertEquals(2, gotLabels.size());
|
|
|
|
|
|
|
|
|
|
IdDt label = (IdDt) gotLabels.get(0);
|
|
|
|
|
assertEquals("http://foo/Profile1", label.getValue());
|
|
|
|
@ -451,7 +384,6 @@ public class XmlParserDstu2Test {
|
|
|
|
|
assertEquals(new Tag("scheme2", "term2", "label2"), tagList.get(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeAndParseMetaProfiles() {
|
|
|
|
|
Patient p = new Patient();
|
|
|
|
@ -539,7 +471,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, enc);
|
|
|
|
|
List<BaseCodingDt> gotLabels = ResourceMetadataKeyEnum.SECURITY_LABELS.get(parsed);
|
|
|
|
|
|
|
|
|
|
assertEquals(2,gotLabels.size());
|
|
|
|
|
assertEquals(2, gotLabels.size());
|
|
|
|
|
|
|
|
|
|
CodingDt label = (CodingDt) gotLabels.get(0);
|
|
|
|
|
assertEquals("SYSTEM1", label.getSystem());
|
|
|
|
@ -609,7 +541,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeBinaryWithNoContentType() {
|
|
|
|
|
Binary b = new Binary();
|
|
|
|
|
b.setContent(new byte[] {1,2,3,4});
|
|
|
|
|
b.setContent(new byte[] { 1, 2, 3, 4 });
|
|
|
|
|
|
|
|
|
|
String output = ourCtx.newXmlParser().encodeResourceToString(b);
|
|
|
|
|
ourLog.info(output);
|
|
|
|
@ -692,7 +624,6 @@ public class XmlParserDstu2Test {
|
|
|
|
|
assertThat(encoded, stringContainsInOrder("<Bundle", "<base value=\"urn:uuid:\"/>", "<entry>", "<Patient", "<id value="));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeBundleOldStyleContainingResourceWithUuidBaseBundleBaseIsSetDifferently() {
|
|
|
|
|
Patient p = new Patient();
|
|
|
|
@ -708,6 +639,22 @@ public class XmlParserDstu2Test {
|
|
|
|
|
assertThat(encoded, stringContainsInOrder("<Bundle", "<base value=\"urn:oid:\"/>", "<entry>", "<base value=\"urn:uuid:\"/>", "<Patient", "<id value="));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeBundleWithContained() {
|
|
|
|
|
DiagnosticReport rpt = new DiagnosticReport();
|
|
|
|
|
rpt.addResult().setResource(new Observation().setCode(new CodeableConceptDt().setText("Sharp1")).setId("#1"));
|
|
|
|
|
rpt.addResult().setResource(new Observation().setCode(new CodeableConceptDt().setText("Uuid1")).setId("urn:uuid:UUID1"));
|
|
|
|
|
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Bundle b = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
|
|
|
|
b.addEntry().setResource(rpt);
|
|
|
|
|
|
|
|
|
|
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(b);
|
|
|
|
|
ourLog.info(encoded);
|
|
|
|
|
|
|
|
|
|
assertThat(encoded, stringContainsInOrder("<DiagnosticReport", "<contained", "<Observation", "<text value=\"Sharp1\"", "</DiagnosticReport"));
|
|
|
|
|
assertThat(encoded, not(stringContainsInOrder("<DiagnosticReport", "<contained", "<Observation", "<contained", "<Observation", "</DiagnosticReport")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* See #113
|
|
|
|
|
*/
|
|
|
|
@ -738,33 +685,15 @@ public class XmlParserDstu2Test {
|
|
|
|
|
String encoded = p.encodeResourceToString(medicationPrescript);
|
|
|
|
|
ourLog.info(encoded);
|
|
|
|
|
|
|
|
|
|
//@formatter:on
|
|
|
|
|
assertThat(encoded, stringContainsInOrder(
|
|
|
|
|
"<MedicationPrescription xmlns=\"http://hl7.org/fhir\">",
|
|
|
|
|
"<contained>",
|
|
|
|
|
"<Medication xmlns=\"http://hl7.org/fhir\">",
|
|
|
|
|
"<id value=\"123\"/>",
|
|
|
|
|
"<code>",
|
|
|
|
|
"<coding>",
|
|
|
|
|
"<system value=\"urn:sys\"/>",
|
|
|
|
|
"<code value=\"code1\"/>",
|
|
|
|
|
"</coding>",
|
|
|
|
|
"</code>",
|
|
|
|
|
"</Medication>",
|
|
|
|
|
"</contained>",
|
|
|
|
|
"<medication>",
|
|
|
|
|
"<reference value=\"#123\"/>",
|
|
|
|
|
"<display value=\"MedRef\"/>",
|
|
|
|
|
"</medication>",
|
|
|
|
|
"</MedicationPrescription>"));
|
|
|
|
|
// @formatter:on
|
|
|
|
|
assertThat(
|
|
|
|
|
encoded,
|
|
|
|
|
stringContainsInOrder("<MedicationPrescription xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"123\"/>", "<code>", "<coding>", "<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>", "</Medication>",
|
|
|
|
|
"</contained>", "<medication>", "<reference value=\"#123\"/>", "<display value=\"MedRef\"/>", "</medication>", "</MedicationPrescription>"));
|
|
|
|
|
//@formatter:off
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* See #113
|
|
|
|
|
*/
|
|
|
|
@ -792,27 +721,14 @@ public class XmlParserDstu2Test {
|
|
|
|
|
ourLog.info(encoded);
|
|
|
|
|
|
|
|
|
|
//@formatter:on
|
|
|
|
|
assertThat(encoded, stringContainsInOrder(
|
|
|
|
|
"<MedicationPrescription xmlns=\"http://hl7.org/fhir\">",
|
|
|
|
|
"<contained>",
|
|
|
|
|
"<Medication xmlns=\"http://hl7.org/fhir\">",
|
|
|
|
|
"<id value=\"1\"/>",
|
|
|
|
|
"<code>",
|
|
|
|
|
"<coding>",
|
|
|
|
|
"<system value=\"urn:sys\"/>",
|
|
|
|
|
"<code value=\"code1\"/>",
|
|
|
|
|
"</coding>",
|
|
|
|
|
"</code>",
|
|
|
|
|
"</Medication>",
|
|
|
|
|
"</contained>",
|
|
|
|
|
"<medication>",
|
|
|
|
|
"<reference value=\"#1\"/>",
|
|
|
|
|
"<display value=\"MedRef\"/>",
|
|
|
|
|
"</medication>",
|
|
|
|
|
"</MedicationPrescription>"));
|
|
|
|
|
assertThat(
|
|
|
|
|
encoded,
|
|
|
|
|
stringContainsInOrder("<MedicationPrescription xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"1\"/>", "<code>", "<coding>", "<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>", "</Medication>",
|
|
|
|
|
"</contained>", "<medication>", "<reference value=\"#1\"/>", "<display value=\"MedRef\"/>", "</medication>", "</MedicationPrescription>"));
|
|
|
|
|
//@formatter:off
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* See #113
|
|
|
|
|
*/
|
|
|
|
@ -844,29 +760,14 @@ public class XmlParserDstu2Test {
|
|
|
|
|
ourLog.info(encoded);
|
|
|
|
|
|
|
|
|
|
//@formatter:on
|
|
|
|
|
assertThat(encoded, stringContainsInOrder(
|
|
|
|
|
"<MedicationPrescription xmlns=\"http://hl7.org/fhir\">",
|
|
|
|
|
"<contained>",
|
|
|
|
|
"<Medication xmlns=\"http://hl7.org/fhir\">",
|
|
|
|
|
"<id value=\"123\"/>",
|
|
|
|
|
"<code>",
|
|
|
|
|
"<coding>",
|
|
|
|
|
"<system value=\"urn:sys\"/>",
|
|
|
|
|
"<code value=\"code1\"/>",
|
|
|
|
|
"</coding>",
|
|
|
|
|
"</code>",
|
|
|
|
|
"</Medication>",
|
|
|
|
|
"</contained>",
|
|
|
|
|
"<medication>",
|
|
|
|
|
"<reference value=\"#123\"/>",
|
|
|
|
|
"<display value=\"MedRef\"/>",
|
|
|
|
|
"</medication>",
|
|
|
|
|
"</MedicationPrescription>"));
|
|
|
|
|
assertThat(
|
|
|
|
|
encoded,
|
|
|
|
|
stringContainsInOrder("<MedicationPrescription xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"123\"/>", "<code>", "<coding>", "<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>", "</Medication>",
|
|
|
|
|
"</contained>", "<medication>", "<reference value=\"#123\"/>", "<display value=\"MedRef\"/>", "</medication>", "</MedicationPrescription>"));
|
|
|
|
|
//@formatter:off
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
|
|
|
|
IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
|
|
|
|
@ -895,6 +796,43 @@ public class XmlParserDstu2Test {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* #158
|
|
|
|
|
*/
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeEmptyTag() {
|
|
|
|
|
TagList tagList = new TagList();
|
|
|
|
|
tagList.addTag(null, null, null);
|
|
|
|
|
tagList.addTag(null, null, "Label");
|
|
|
|
|
|
|
|
|
|
Patient p = new Patient();
|
|
|
|
|
ResourceMetadataKeyEnum.TAG_LIST.put(p, tagList);
|
|
|
|
|
|
|
|
|
|
String encoded = ourCtx.newXmlParser().encodeResourceToString(p);
|
|
|
|
|
assertThat(encoded, not(containsString("tag")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* #158
|
|
|
|
|
*/
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeEmptyTag2() {
|
|
|
|
|
TagList tagList = new TagList();
|
|
|
|
|
tagList.addTag("scheme", "code", null);
|
|
|
|
|
tagList.addTag(null, null, "Label");
|
|
|
|
|
|
|
|
|
|
Patient p = new Patient();
|
|
|
|
|
ResourceMetadataKeyEnum.TAG_LIST.put(p, tagList);
|
|
|
|
|
|
|
|
|
|
String encoded = ourCtx.newXmlParser().encodeResourceToString(p);
|
|
|
|
|
assertThat(encoded, containsString("tag"));
|
|
|
|
|
assertThat(encoded, containsString("scheme"));
|
|
|
|
|
assertThat(encoded, not(containsString("Label")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeExtensionWithResourceContent() {
|
|
|
|
|
IParser parser = ourCtx.newXmlParser();
|
|
|
|
@ -916,6 +854,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEncodeNonContained() {
|
|
|
|
|
// Create an organization
|
|
|
|
@ -956,6 +895,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testMoreExtensions() throws Exception {
|
|
|
|
|
|
|
|
|
@ -1313,7 +1253,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
ExtensionDt ext = ref.getUndeclaredExtensions().get(0);
|
|
|
|
|
assertEquals("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset", ext.getUrl());
|
|
|
|
|
assertEquals(ResourceReferenceDt.class, ext.getValue().getClass());
|
|
|
|
|
assertEquals("#2179414-permitted", ((ResourceReferenceDt)ext.getValue()).getReference().getValue());
|
|
|
|
|
assertEquals("#2179414-permitted", ((ResourceReferenceDt) ext.getValue()).getReference().getValue());
|
|
|
|
|
|
|
|
|
|
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(de));
|
|
|
|
|
|
|
|
|
@ -1324,25 +1264,6 @@ public class XmlParserDstu2Test {
|
|
|
|
|
assertEquals(input, output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* See #191
|
|
|
|
|
*/
|
|
|
|
|
@Test
|
|
|
|
|
public void testParseBundleWithLinksOfUnknownRelation() throws Exception {
|
|
|
|
|
String input =IOUtils.toString(XmlParserDstu2Test.class.getResourceAsStream("/bundle_orion.xml"));
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Bundle parsed = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, input);
|
|
|
|
|
|
|
|
|
|
Link link = parsed.getLink().get(0);
|
|
|
|
|
assertEquals("just trying add link", link.getRelation());
|
|
|
|
|
assertEquals("blarion", link.getUrl());
|
|
|
|
|
|
|
|
|
|
Entry entry = parsed.getEntry().get(0);
|
|
|
|
|
link = entry.getLink().get(0);
|
|
|
|
|
assertEquals("orionhealth.edit", link.getRelation());
|
|
|
|
|
assertEquals("Observation", link.getUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testParseBundleNewWithPlaceholderIds() {
|
|
|
|
|
//@formatter:off
|
|
|
|
@ -1472,7 +1393,6 @@ public class XmlParserDstu2Test {
|
|
|
|
|
Bundle b = ourCtx.newXmlParser().parseBundle(bundle);
|
|
|
|
|
assertEquals(1, b.getEntries().size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -1513,12 +1433,29 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testParseBundleWithBinary() {
|
|
|
|
|
// TODO: implement this test, make sure we handle ID and meta correctly in Binary
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* See #191
|
|
|
|
|
*/
|
|
|
|
|
@Test
|
|
|
|
|
public void testParseBundleWithLinksOfUnknownRelation() throws Exception {
|
|
|
|
|
String input = IOUtils.toString(XmlParserDstu2Test.class.getResourceAsStream("/bundle_orion.xml"));
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Bundle parsed = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, input);
|
|
|
|
|
|
|
|
|
|
Link link = parsed.getLink().get(0);
|
|
|
|
|
assertEquals("just trying add link", link.getRelation());
|
|
|
|
|
assertEquals("blarion", link.getUrl());
|
|
|
|
|
|
|
|
|
|
Entry entry = parsed.getEntry().get(0);
|
|
|
|
|
link = entry.getLink().get(0);
|
|
|
|
|
assertEquals("orionhealth.edit", link.getRelation());
|
|
|
|
|
assertEquals("Observation", link.getUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* see #144 and #146
|
|
|
|
|
*/
|
|
|
|
@ -1557,7 +1494,6 @@ public class XmlParserDstu2Test {
|
|
|
|
|
assertEquals("patient family", p.getNameFirstRep().getFamilyAsSingleString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Thanks to Alexander Kley!
|
|
|
|
|
*/
|
|
|
|
@ -1584,7 +1520,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.DocumentManifest actual = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.DocumentManifest.class, encoded);
|
|
|
|
|
assertEquals(1, actual.getContained().getContainedResources().size());
|
|
|
|
|
assertEquals(1, actual.getContent().size());
|
|
|
|
|
assertNotNull(((ResourceReferenceDt)actual.getContent().get(0).getP()).getResource());
|
|
|
|
|
assertNotNull(((ResourceReferenceDt) actual.getContent().get(0).getP()).getResource());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1649,6 +1585,30 @@ public class XmlParserDstu2Test {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testParseMetaUpdatedDate() {
|
|
|
|
|
//@formatter:off
|
|
|
|
|
String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
|
|
|
|
" <id value=\"e2ee823b-ee4d-472d-b79d-495c23f16b99\"/>\n" +
|
|
|
|
|
" <meta>\n" +
|
|
|
|
|
" <lastUpdated value=\"2015-06-22T15:48:57.554-04:00\"/>\n" +
|
|
|
|
|
" </meta>\n" +
|
|
|
|
|
" <type value=\"searchset\"/>\n" +
|
|
|
|
|
" <base value=\"http://localhost:58109/fhir/context\"/>\n" +
|
|
|
|
|
" <total value=\"0\"/>\n" +
|
|
|
|
|
" <link>\n" +
|
|
|
|
|
" <relation value=\"self\"/>\n" +
|
|
|
|
|
" <url value=\"http://localhost:58109/fhir/context/Patient?_pretty=true\"/>\n" +
|
|
|
|
|
" </link>\n" +
|
|
|
|
|
"</Bundle>";
|
|
|
|
|
//@formatter:on
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Bundle b = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, input);
|
|
|
|
|
|
|
|
|
|
InstantDt updated = ResourceMetadataKeyEnum.UPDATED.get(b);
|
|
|
|
|
assertEquals("2015-06-22T15:48:57.554-04:00", updated.getValueAsString());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testParseNarrative() throws Exception {
|
|
|
|
|
//@formatter:off
|
|
|
|
@ -1689,7 +1649,7 @@ public class XmlParserDstu2Test {
|
|
|
|
|
String bundleText = xmlParser.encodeResourceToString(bundle);
|
|
|
|
|
ourLog.info(bundleText);
|
|
|
|
|
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Bundle reincarnatedBundle = xmlParser.parseResource (ca.uhn.fhir.model.dstu2.resource.Bundle.class, bundleText);
|
|
|
|
|
ca.uhn.fhir.model.dstu2.resource.Bundle reincarnatedBundle = xmlParser.parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, bundleText);
|
|
|
|
|
Patient reincarnatedPatient = reincarnatedBundle.getAllPopulatedChildElementsOfType(Patient.class).get(0);
|
|
|
|
|
|
|
|
|
|
assertEquals("Patient", patient.getId().getResourceType());
|
|
|
|
@ -1703,6 +1663,10 @@ public class XmlParserDstu2Test {
|
|
|
|
|
XMLUnit.setIgnoreWhitespace(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
IGenericClient c = ourCtx.newRestfulGenericClient("http://fhir-dev.healthintersections.com.au/open");
|
|
|
|
|
// c.registerInterceptor(new LoggingInterceptor(true));
|
|
|
|
|
c.read().resource("Patient").withId("324").execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|