use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir 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.Fhir in project snow-owl by b2ihealthcare.
the class ValidateFhirCodeRestTest method validCodePostTest.
@Test
public void validCodePostTest() throws Exception {
ValidateCodeRequest request = ValidateCodeRequest.builder().code("login").build();
Fhir fhirParameters = new Parameters.Fhir(request);
String jsonBody = objectMapper.writeValueAsString(fhirParameters);
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).pathParam("id", FHIR_ISSUE_TYPE_CODESYSTEM_ID).body(jsonBody).when().post("/CodeSystem/{id}/$validate-code").then().body("resourceType", equalTo("Parameters")).body("parameter[0].name", equalTo("result")).body("parameter[0].valueBoolean", equalTo(true)).statusCode(200);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class ExpandValueSetRequestDeserializationTest method testDeserialization.
// @Test
public void testDeserialization() {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
LookupRequest request = LookupRequest.builder().coding(coding).build();
Fhir fhirParameters = new Parameters.Fhir(request);
fhirParameters.getParameters().forEach(p -> System.out.println(p));
Optional<Parameter> findFirst = fhirParameters.getParameters().stream().filter(p -> {
Coding pCoding = (Coding) p.getValue();
return pCoding.getSystemValue().equals("http://hl7.org/fhir/issue-severity");
}).findFirst();
assertTrue(findFirst.isPresent());
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir 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.Fhir 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