use of org.hl7.fhir.dstu3.model.ResourceType in project openmrs-module-fhir2 by openmrs.
the class PatientFhirResourceProviderIntegrationTest method shouldReturnForPatientTypeEverythingWhenCountIsSpecifiedAsXml.
@Test
public void shouldReturnForPatientTypeEverythingWhenCountIsSpecifiedAsXml() throws Exception {
MockHttpServletResponse response = get("/Patient/$everything?_count=5").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(46)));
assertThat(result.getEntry(), hasSize(5));
List<Bundle.BundleEntryComponent> entries = result.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/"))));
assertThat(entries, everyItem(hasResource(hasProperty("resourceType", in(getEverythingValidResourceTypes())))));
}
use of org.hl7.fhir.dstu3.model.ResourceType in project openmrs-module-fhir2 by openmrs.
the class PatientFhirResourceProviderIntegrationTest method shouldReturnPatientTypeEverythingAsXml.
@Test
public void shouldReturnPatientTypeEverythingAsXml() throws Exception {
MockHttpServletResponse response = get("/Patient/$everything").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(46)));
assertThat(result.getEntry(), hasSize(46));
List<Bundle.BundleEntryComponent> entries = result.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/"))));
assertThat(entries, everyItem(hasResource(hasProperty("resourceType", in(getEverythingValidResourceTypes())))));
}
use of org.hl7.fhir.dstu3.model.ResourceType in project openmrs-module-fhir2 by openmrs.
the class PatientFhirResourceProviderIntegrationTest method shouldReturnForPatientTypeEverythingWhenCountIsSpecifiedAsXml.
@Test
public void shouldReturnForPatientTypeEverythingWhenCountIsSpecifiedAsXml() throws Exception {
MockHttpServletResponse response = get("/Patient/$everything?_count=5").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(46)));
assertThat(result.getEntry(), hasSize(5));
List<Bundle.BundleEntryComponent> entries = result.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/"))));
assertThat(entries, everyItem(hasResource(hasProperty("resourceType", in(getEverythingValidResourceTypes())))));
}
use of org.hl7.fhir.dstu3.model.ResourceType in project org.hl7.fhir.core by hapifhir.
the class ExamplesPackageBuilder method process.
private void process(String source) throws FHIRFormatError, FileNotFoundException, IOException {
Set<String> set = new HashSet<>();
for (File f : new File(source).listFiles()) {
if (f.getName().endsWith(".json")) {
JsonObject obj = JsonTrackingParser.parseJson(new FileInputStream(f));
if (obj.has("resourceType") && obj.has("id")) {
String type = obj.get("resourceType").getAsString();
String id = obj.get("id").getAsString();
byte[] content = TextFile.fileToBytes(f);
if (type.equals("ConceptMap")) {
System.out.println("convert " + f.getName());
content = r5ToR4B(content);
TextFile.bytesToFile(content, f);
}
// TextFile.bytesToFile(content, Utilities.path(dest2, type+"-"+id+".json"));
// if (!set.contains(type+"/"+id)) {
// set.add(type+"/"+id);
// pck.addFile(Category.RESOURCE, type+"-"+id+".json", content);
// }
}
}
}
// pck.finish();
//
}
use of org.hl7.fhir.dstu3.model.ResourceType in project org.hl7.fhir.core by hapifhir.
the class CorePackageTools method buildXml.
private void buildXml(String json, String xml, String version) throws FHIRFormatError, IOException {
for (File f : new File(Utilities.path(json, "package")).listFiles()) {
if (f.getName().endsWith(".json")) {
JsonObject j = new JsonTrackingParser().parseJson(f);
if (j.has("resourceType")) {
if ("1.4".equals(version)) {
String n = f.getName();
System.out.println(n);
String xn = Utilities.changeFileExt(n, ".xml");
org.hl7.fhir.dstu2016may.model.Resource r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(f));
new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(org.hl7.fhir.dstu2016may.formats.IParser.OutputStyle.NORMAL).compose(new FileOutputStream(Utilities.path(xml, "package", xn)), r);
}
}
}
}
}
Aggregations