use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class TranslateSnomedConceptMapRestTest method reverseTranslateMappingTest.
@Test
public void reverseTranslateMappingTest() throws Exception {
String response = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).param("code", "MO").param("system", SnomedUri.SNOMED_BASE_URI_STRING).param("targetsystem", SnomedUri.SNOMED_BASE_URI_STRING).param("reverse", true).when().get("/ConceptMap/$translate").then().extract().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());
assertEquals("4 match(es).", result.getMessage());
Collection<Match> matches = result.getMatches();
assertEquals(4, matches.size());
assertMatchExists(matches, 0, "equivalent");
assertMatchExists(matches, 1, "unmatched");
assertMatchExists(matches, 2, "unmatched");
assertMatchExists(matches, 3, "unmatched");
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class TranslateSnomedConceptMapRestTest method translateMappingTest.
@Test
public void translateMappingTest() throws Exception {
String response = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).param("code", FhirTestConcepts.MICROORGANISM).param("system", SnomedUri.SNOMED_BASE_URI_STRING).param("targetsystem", SnomedUri.SNOMED_BASE_URI_STRING).when().get("/ConceptMap/$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());
assertEquals("4 match(es).", result.getMessage());
Collection<Match> matches = result.getMatches();
assertEquals(4, matches.size());
assertMatchExists(matches, 0, "equivalent");
assertMatchExists(matches, 1, "unmatched");
assertMatchExists(matches, 2, "unmatched");
assertMatchExists(matches, 3, "unmatched");
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class FhirTest method convertToResult.
/**
* Converts the parameter-formatted response string to a {@link LookupResult} object
* @param responseString
* @return
* @throws Exception
*/
protected LookupResult convertToResult(String responseString) throws Exception {
Fhir parameters = objectMapper.readValue(responseString, Parameters.Fhir.class);
Json json = new Parameters.Json(parameters);
return objectMapper.convertValue(json, LookupResult.class);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class SandBoxRestTest method bulkRequestTest.
// @Test
public void bulkRequestTest() {
LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
Json json1 = new Parameters.Json(lookupRequest);
System.out.println("JSON params:" + json1);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
Bundle bundle = Bundle.builder().language("en").total(1).type(BundleType.BATCH).addEntry(entry).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"));
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Json in project snow-owl by b2ihealthcare.
the class BundleTest method buildResponseBundle.
@Test
public void buildResponseBundle() throws Exception {
LookupResult lookupResult = LookupResult.builder().name("test").display("display").addDesignation(Designation.builder().value("dValue").languageCode("uk").build()).addProperty(Property.builder().code("1234").description("propDescription").valueString("stringValue").addSubProperty(SubProperty.builder().code("subCode").description("subCodeDescription").valueInteger(1).build()).build()).build();
Json json1 = new Parameters.Json(lookupResult);
ParametersResponseEntry entry = ParametersResponseEntry.builder().resource(new Parameters.Fhir(json1.parameters())).response(BatchResponse.createOkResponse()).build();
Bundle bundle = Bundle.builder().language("en").type(BundleType.BATCH_RESPONSE).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(entry).build();
assertEquals("en", bundle.getLanguage().getCodeValue());
assertEquals(BundleType.BATCH_RESPONSE.getCode(), bundle.getType());
Link link = bundle.getLink().iterator().next();
assertEquals("self", link.getRelation());
assertEquals("http://localhost:8080/snowowl/CodeSystem", link.getUrl().getUriValue());
Entry bundleEntry = bundle.getItems().iterator().next();
assertTrue(bundleEntry instanceof ParametersResponseEntry);
ParametersResponseEntry responseEntry = (ParametersResponseEntry) bundleEntry;
assertEquals("200", responseEntry.getResponse().getStatus());
Fhir requestResource = responseEntry.getResponseResource();
// Back to Domain JSON...
Json json = new Parameters.Json(requestResource);
LookupResult returnedResponse = objectMapper.convertValue(json, LookupResult.class);
assertEquals("test", returnedResponse.getName());
assertEquals("display", returnedResponse.getDisplay());
}
Aggregations