use of com.b2international.snowowl.fhir.core.model.dt.Coding in project snow-owl by b2ihealthcare.
the class FhirExceptionIssueMatcher method matchesSafely.
@Override
protected boolean matchesSafely(FhirException validationException) {
OperationOutcome operationOutcome = validationException.toOperationOutcome();
Collection<Issue> issues = operationOutcome.getIssues();
if (issues.isEmpty()) {
return false;
}
foundIssue = issues.iterator().next();
boolean issueMatched = foundIssue.getCode().equals(expectedIssue.getCode()) && foundIssue.getSeverity().equals(expectedIssue.getSeverity()) && foundIssue.getDiagnostics().equals(expectedIssue.getDiagnostics());
if (!issueMatched) {
return false;
}
boolean collectionsMatch = HashMultiset.create(foundIssue.getLocations()).equals(HashMultiset.create(expectedIssue.getLocations())) && HashMultiset.create(foundIssue.getExpressions()).equals(HashMultiset.create(expectedIssue.getExpressions()));
if (!collectionsMatch) {
System.out.println("Issue expression do not match, found: " + foundIssue.getExpressions());
System.out.println("Issue locations do not match, found: " + foundIssue.getLocations());
return false;
}
if (foundIssue.getDetails() == null && expectedIssue.getDetails() != null) {
System.out.println("Codeable concept is null.");
return false;
}
if (foundIssue.getDetails() != null && expectedIssue.getDetails() == null) {
System.out.println("Codeable concept is not null: " + foundIssue.getDetails());
return false;
}
if (foundIssue.getDetails() != null && expectedIssue.getDetails() != null) {
CodeableConcept foundCodeableConcept = foundIssue.getDetails();
CodeableConcept expectedCodeableConcept = expectedIssue.getDetails();
Collection<Coding> foundCodings = foundCodeableConcept.getCodings();
Collection<Coding> expectedCodings = expectedCodeableConcept.getCodings();
boolean codingMatched = foundCodeableConcept.getText().equals(expectedCodeableConcept.getText()) && HashMultiset.create(foundCodings).equals(HashMultiset.create(expectedCodings));
if (!codingMatched) {
System.out.println("Codings do not match: " + foundCodeableConcept.getText());
return false;
}
}
return true;
}
use of com.b2international.snowowl.fhir.core.model.dt.Coding in project snow-owl by b2ihealthcare.
the class IssueTest method deserialize.
@Test
public void deserialize() throws Exception {
Issue issue = Issue.builder().severity(IssueSeverity.ERROR).code(IssueType.REQUIRED).addExpression("Issue expression").addLocation("Issue location").details(CodeableConcept.builder().addCoding(Coding.builder().code("A").display("A display").build()).text("Text").build()).build();
Issue readIssue = objectMapper.readValue(objectMapper.writeValueAsString(issue), Issue.class);
assertEquals(IssueSeverity.ERROR.getCode(), readIssue.getSeverity());
assertEquals(IssueType.REQUIRED.getCode(), readIssue.getCode());
assertThat(readIssue.getExpressions(), hasItems("Issue expression"));
assertThat(readIssue.getLocations(), hasItems("Issue location"));
CodeableConcept details = readIssue.getDetails();
assertEquals(1, details.getCodings().size());
assertEquals("Text", details.getText());
Coding coding = details.getCodings().iterator().next();
assertEquals("A", coding.getCode().getCodeValue());
assertEquals("A display", coding.getDisplay());
}
use of com.b2international.snowowl.fhir.core.model.dt.Coding in project snow-owl by b2ihealthcare.
the class SandBoxRestTest method buildCode.
// @Test
public void buildCode() throws IOException {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
LookupRequest request = LookupRequest.builder().coding(coding).addProperty("name").build();
Json json1 = new Parameters.Json(request);
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);
Parameters parameters2 = json.parameters();
List<Parameter> parameters3 = parameters2.getParameters();
for (Parameter parameter : parameters3) {
System.out.println("P: " + parameter);
}
LookupRequest lookupRequest = objectMapper.convertValue(json, LookupRequest.class);
System.out.println("... and back to the object representation we started from:" + lookupRequest);
Json finalJson = new Parameters.Json(lookupRequest);
Fhir finalFhir = new Parameters.Fhir(finalJson.parameters());
String stringJson = objectMapper.writeValueAsString(finalFhir);
System.out.println("Final final: " + stringJson);
/*
*/
// String jsonBody = objectMapper.writeValueAsString(fhirParameters);
// System.out.println("Json: " + jsonBody);
}
use of com.b2international.snowowl.fhir.core.model.dt.Coding in project snow-owl by b2ihealthcare.
the class CodeableConceptUsageContextTest method setup.
@Before
public void setup() throws Exception {
Coding coding = Coding.builder().code("1234").system("http://www.whocc.no/atc").version("20180131").build();
CodeableConcept cc = CodeableConcept.builder().addCoding(coding).text("text").build();
usageContext = CodeableConceptUsageContext.builder().code(Coding.builder().code("coding").display("codingDisplay").build()).value(cc).id("usageContextId").build();
}
use of com.b2international.snowowl.fhir.core.model.dt.Coding in project snow-owl by b2ihealthcare.
the class ValidateFhirCodeRestTest method validCodingTestWithPostTest.
@Test
public void validCodingTestWithPostTest() throws Exception {
String system = "http://hl7.org/fhir/issue-severity";
Coding coding = Coding.builder().system(system).code("fatal").build();
ValidateCodeRequest request = ValidateCodeRequest.builder().url(system).coding(coding).build();
Fhir fhirParameters = new Parameters.Fhir(request);
String jsonBody = objectMapper.writeValueAsString(fhirParameters);
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(jsonBody).when().post("/CodeSystem/$validate-code").then().body("resourceType", equalTo("Parameters")).body("parameter[0].name", equalTo("result")).body("parameter[0].valueBoolean", equalTo(true)).statusCode(200);
}
Aggregations