Search in sources :

Example 1 with Parameters

use of com.b2international.snowowl.fhir.core.model.dt.Parameters 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");
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 2 with Parameters

use of com.b2international.snowowl.fhir.core.model.dt.Parameters 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");
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 3 with Parameters

use of com.b2international.snowowl.fhir.core.model.dt.Parameters 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);
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)

Example 4 with Parameters

use of com.b2international.snowowl.fhir.core.model.dt.Parameters 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());
}
Also used : ParametersRequestEntry(com.b2international.snowowl.fhir.core.model.ParametersRequestEntry) ParametersResponseEntry(com.b2international.snowowl.fhir.core.model.ParametersResponseEntry) ResourceRequestEntry(com.b2international.snowowl.fhir.core.model.ResourceRequestEntry) Entry(com.b2international.snowowl.fhir.core.model.Entry) ResourceResponseEntry(com.b2international.snowowl.fhir.core.model.ResourceResponseEntry) OperationOutcomeEntry(com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) ParametersResponseEntry(com.b2international.snowowl.fhir.core.model.ParametersResponseEntry) LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Link(com.b2international.snowowl.fhir.core.model.Link) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 5 with Parameters

use of com.b2international.snowowl.fhir.core.model.dt.Parameters in project snow-owl by b2ihealthcare.

the class BundleTest method deserializeRequestBundle.

@Test
public void deserializeRequestBundle() throws Exception {
    String jsonCoding = "{ \"type\" : \"batch\", " + "\"resourceType\" : \"Bundle\", " + "\"entry\" : " + "[{\"request\" : " + "{\"method\" : \"POST\"," + "\"url\" : \"CodeSystem/$lookup\"}," + "\"resource\" : " + "{\"resourceType\" : \"Parameters\"," + "\"parameter\" : [" + "{\"valueUri\" : \"http://loinc.org\"," + "\"name\" : \"system\"}," + "{\"valueCode\" : \"23245-4\"," + "\"name\" : \"code\"}" + "]" + "}" + "}," + "{\"request\" : " + "{\"method\" : \"POST\"," + "\"url\" : \"CodeSystem/$lookup\"}," + "\"resource\" : " + "{\"resourceType\" : \"Parameters\"," + "\"parameter\" : [" + "{\"name\" : \"system\"," + "\"valueUri\" : \"http://snomed.info/sct\"}" + ",{\"valueCode\" : \"263495000\"," + "\"name\" : \"code\"}" + "]" + "}}" + "]}";
    Bundle bundle = objectMapper.readValue(jsonCoding, Bundle.class);
    assertEquals(BundleType.BATCH.getCode(), bundle.getType());
    Iterator<Entry> iterator = bundle.getItems().iterator();
    Entry bundleEntry = iterator.next();
    assertTrue(bundleEntry instanceof ParametersRequestEntry);
    ParametersRequestEntry requestEntry = (ParametersRequestEntry) bundleEntry;
    BatchRequest batchRequest = requestEntry.getRequest();
    assertEquals(HttpVerb.POST.getCode(), batchRequest.getMethod());
    assertEquals("CodeSystem/$lookup", batchRequest.getUrl().getUriValue());
    Fhir requestResource = requestEntry.getRequestResource();
    // Back to Domain JSON...
    Json json = new Parameters.Json(requestResource);
    LookupRequest returnedLookupRequest = objectMapper.convertValue(json, LookupRequest.class);
    assertEquals("23245-4", returnedLookupRequest.getCode());
    assertEquals("http://loinc.org", returnedLookupRequest.getSystem());
    bundleEntry = iterator.next();
    assertTrue(bundleEntry instanceof ParametersRequestEntry);
    requestEntry = (ParametersRequestEntry) bundleEntry;
    batchRequest = requestEntry.getRequest();
    assertEquals(HttpVerb.POST.getCode(), batchRequest.getMethod());
    assertEquals("CodeSystem/$lookup", batchRequest.getUrl().getUriValue());
    requestResource = requestEntry.getRequestResource();
    // Back to Domain JSON...
    json = new Parameters.Json(requestResource);
    returnedLookupRequest = objectMapper.convertValue(json, LookupRequest.class);
    assertEquals("263495000", returnedLookupRequest.getCode());
    assertEquals("http://snomed.info/sct", returnedLookupRequest.getSystem());
}
Also used : BatchRequest(com.b2international.snowowl.fhir.core.model.BatchRequest) ParametersRequestEntry(com.b2international.snowowl.fhir.core.model.ParametersRequestEntry) ParametersResponseEntry(com.b2international.snowowl.fhir.core.model.ParametersResponseEntry) ResourceRequestEntry(com.b2international.snowowl.fhir.core.model.ResourceRequestEntry) Entry(com.b2international.snowowl.fhir.core.model.Entry) ResourceResponseEntry(com.b2international.snowowl.fhir.core.model.ResourceResponseEntry) OperationOutcomeEntry(com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) ParametersRequestEntry(com.b2international.snowowl.fhir.core.model.ParametersRequestEntry) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)18 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)16 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)14 Test (org.junit.Test)13 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)8 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)5 Match (com.b2international.snowowl.fhir.core.model.conceptmap.Match)5 TranslateResult (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult)5 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)5 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)4 Bundle (com.b2international.snowowl.fhir.core.model.Bundle)3 Entry (com.b2international.snowowl.fhir.core.model.Entry)3 OperationOutcomeEntry (com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry)3 ParametersRequestEntry (com.b2international.snowowl.fhir.core.model.ParametersRequestEntry)3 ParametersResponseEntry (com.b2international.snowowl.fhir.core.model.ParametersResponseEntry)3 ResourceRequestEntry (com.b2international.snowowl.fhir.core.model.ResourceRequestEntry)3 ResourceResponseEntry (com.b2international.snowowl.fhir.core.model.ResourceResponseEntry)3 LookupResult (com.b2international.snowowl.fhir.core.model.codesystem.LookupResult)3 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)3 RestExtensions.givenAuthenticatedRequest (com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest)3