Search in sources :

Example 16 with Parameters

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

the class SubsumptionRequestDeserializationTest method lookupRequestCodeTest.

@Test
public void lookupRequestCodeTest() throws Exception {
    String jsonParam = "{\"resourceType\":\"Parameters\"," + "\"parameter\":[" + "{\"name\":\"codeA\",\"valueCode\":\"1234\"}," + "{\"name\":\"codeB\",\"valueCode\":\"5678\"}," + "{\"name\":\"system\",\"valueUri\":\"http://snomed.info/sct\"}," + "{\"name\":\"version\",\"valueString\":\"20180131\"}" + "]}";
    // Magic to turn the FHIR params -> Parameters -> LookupRequest
    Parameters.Fhir fhirParameters = objectMapper.readValue(jsonParam, Parameters.Fhir.class);
    SubsumptionRequest request = objectMapper.convertValue(fhirParameters.toJson(), SubsumptionRequest.class);
    assertEquals("1234", request.getCodeA());
    assertEquals("5678", request.getCodeB());
    assertEquals("http://snomed.info/sct", request.getSystem());
    assertEquals("20180131", request.getVersion());
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) SubsumptionRequest(com.b2international.snowowl.fhir.core.model.codesystem.SubsumptionRequest) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 17 with Parameters

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

the class ValidateCodeResultTest method fullCircleTest.

@Test
public void fullCircleTest() throws Exception {
    ValidateCodeResult request = ValidateCodeResult.builder().artefactNotFoundResult("http://hl7.org/fhir/issue-severity").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);
    ValidateCodeResult validateRequest = objectMapper.convertValue(json, ValidateCodeResult.class);
    System.out.println("... and back to the object representation we started from:" + validateRequest);
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) ValidateCodeResult(com.b2international.snowowl.fhir.core.model.ValidateCodeResult) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 18 with Parameters

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

the class TranslateResultSerializationTest method validResultTest.

@Test
public void validResultTest() throws Exception {
    Match match = Match.builder().equivalence(ConceptMapEquivalence.EQUAL).build();
    Match match2 = Match.builder().equivalence(ConceptMapEquivalence.DISJOINT).build();
    TranslateResult translateResult = TranslateResult.builder().message("This is a test result").addMatch(match).addMatch(match2).build();
    Fhir fhirParameters = new Parameters.Fhir(translateResult);
    Parameter parameter = fhirParameters.getByName("result").get();
    Boolean result = (Boolean) parameter.getValue();
    assertEquals(true, result.booleanValue());
    parameter = fhirParameters.getByName("message").get();
    String message = (String) parameter.getValue();
    assertEquals("This is a test result", message);
    parameter = fhirParameters.getByName("match").get();
    Parameters matchParameters = (Parameters) parameter.getValue();
    parameter = matchParameters.getByName("equivalence").get();
    assertEquals("equal", ((Code) parameter.getValue()).getCodeValue());
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) 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