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());
}
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);
}
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());
}
Aggregations