use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class TranslateSnomedConceptMapRestTest method translateSpecificMappingTest.
// From a specific Map type reference set
@Test
public void translateSpecificMappingTest() throws Exception {
String mapTypeRefsetUri = "SNOMEDCT/" + FHIR_MAP_TYPE_REFSET_VERSION + "/refset/" + mapTypeRefSetIds.get(0);
String response = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).pathParam("id", mapTypeRefsetUri).param("code", FhirTestConcepts.MICROORGANISM).param("system", SnomedUri.SNOMED_BASE_URI_STRING).param("targetsystem", SnomedUri.SNOMED_BASE_URI_STRING).when().get("/ConceptMap/{id}/$translate").asString();
Fhir parameters = objectMapper.readValue(response, Parameters.Fhir.class);
Json json = new Parameters.Json(parameters);
TranslateResult result = objectMapper.convertValue(json, TranslateResult.class);
assertTrue(result.getResult());
assertTrue(result.getMessage().startsWith("Results for reference set"));
Collection<Match> matches = result.getMatches();
assertEquals(1, matches.size());
Optional<Match> optionalMatch = matches.stream().filter(m -> m.getSource().getUriValue().equals("http://snomed.info/sct/id/" + mapTypeRefSetIds.get(0))).findFirst();
assertTrue(optionalMatch.isPresent());
Match match = optionalMatch.get();
assertEquals("equivalent", match.getEquivalence().getCodeValue());
assertEquals("MO", match.getConcept().getCodeValue());
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class FhirBatchApiRestTest method singleRequestWithFailedLookup.
@Test
public void singleRequestWithFailedLookup() {
LookupRequest request = LookupRequest.builder().coding(Coding.builder().system("http://snomed.info/sct").code(Concepts.IS_A).build()).build();
Json json = new Parameters.Json(request);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json.parameters())).build();
RequestEntry entry2 = RequestEntry.builder().request(BatchRequest.createGetRequest("CodeSystem/$lookup?system=whatever&code=1234")).build();
Bundle bundle = Bundle.builder().language("en").total(2).type(BundleType.BATCH).addEntry(entry).addEntry(entry2).build();
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(bundle).when().post("/").prettyPeek().then().statusCode(200).body("resourceType", equalTo("Bundle")).body("type", is("batch-response")).body("entry[0].response.status", equalTo("200")).body("entry[0].resource.resourceType", equalTo("Parameters")).body("entry[1].response.status", equalTo("404")).body("entry[1].resource.resourceType", equalTo("OperationOutcome"));
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class FhirBatchApiRestTest method singleRequestWithInvalidParameters.
@Test
public void singleRequestWithInvalidParameters() {
LookupRequest request = LookupRequest.builder().coding(Coding.builder().system("http://snomed.info/sct").code(Concepts.IS_A).build()).build();
Json json = new Parameters.Json(request);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json.parameters())).build();
// Completely invalid request
RequestEntry entry2 = RequestEntry.builder().request(BatchRequest.createGetRequest("CodeSystem/$lookup?system=whatever?code=1234")).build();
Bundle bundle = Bundle.builder().language("en").total(2).type(BundleType.BATCH).addEntry(entry).addEntry(entry2).build();
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(bundle).when().post("/").prettyPeek().then().statusCode(200).body("resourceType", equalTo("Bundle")).body("type", is("batch-response")).body("entry[0].response.status", equalTo("200")).body("entry[0].resource.resourceType", equalTo("Parameters")).body("entry[1].response.status", equalTo("500")).body("entry[1].resource.resourceType", equalTo("OperationOutcome"));
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class ExpandValueSetRequestDeserializationTest method fullCircleTest.
// @Test
public void fullCircleTest() throws Exception {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
System.out.println("Building the lookup request object.");
LookupRequest request = LookupRequest.builder().coding(coding).build();
Json json1 = new Parameters.Json(request);
System.out.println("JSON params:" + json1);
Fhir fhir = new Parameters.Fhir(json1.parameters());
String fhirJson = objectMapper.writeValueAsString(fhir);
System.out.println("This is the JSON request from the client: " + fhirJson);
System.out.println("This is happening in the server-side...");
Fhir parameters = objectMapper.readValue(fhirJson, Parameters.Fhir.class);
System.out.println("Deserialized into FHIR parameters..." + parameters.getParameters());
System.out.println("Back to Domain JSON...");
Json json = new Parameters.Json(parameters);
LookupRequest lookupRequest = objectMapper.convertValue(json, LookupRequest.class);
System.out.println("... and back to the object representation we started from:" + lookupRequest);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class ExpandValueSetRequestDeserializationTest method deserializationTest.
@Test
public void deserializationTest() throws Exception {
ExpandValueSetRequest request = ExpandValueSetRequest.builder().url("http://valueset.url").valueSetVersion("20190101").contextDirection("direction-code").count(1).addDesignation("uk_en").addDesignation("us_en").date(TEST_DATE_STRING).filter("filter").build();
Json json = new Parameters.Json(request);
// System.out.println("JSON params:" + json);
Fhir fhirParameters = new Parameters.Fhir(request);
// fhirParameters.getParameters().forEach(p -> System.out.println(p));
Optional<Parameter> findFirst = fhirParameters.getParameters().stream().filter(p -> {
Uri url = (Uri) p.getValue();
return url.getUriValue().equals("http://valueset.url");
}).findFirst();
assertTrue(findFirst.isPresent());
// Fhir fhir = new Parameters.Fhir(json.parameters());
// printPrettyJson(fhir);
// String fhirJson = objectMapper.writeValueAsString(fhir);
// System.out.println("This is the JSON request from the client: " + fhirJson);
}
Aggregations