use of com.b2international.snowowl.fhir.core.model.dt.CodeableConcept 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.CodeableConcept 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.CodeableConcept 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.CodeableConcept in project snow-owl by b2ihealthcare.
the class ValidateFhirCodeRestTest method validCodeableConceptTestWithPostTest.
@Test
public void validCodeableConceptTestWithPostTest() throws Exception {
String system = "http://hl7.org/fhir/issue-severity";
Coding coding = Coding.builder().system(system).code("fatal").build();
CodeableConcept codeableConcept = CodeableConcept.builder().addCoding(coding).build();
ValidateCodeRequest request = ValidateCodeRequest.builder().url(system).codeableConcept(codeableConcept).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);
}
use of com.b2international.snowowl.fhir.core.model.dt.CodeableConcept in project snow-owl by b2ihealthcare.
the class CodeableConcepTest method build.
@Test
public void build() {
Coding coding = Coding.builder().code("codingCode").display("codingDisplay").build();
CodeableConcept codeableConcept = CodeableConcept.builder().addCoding(coding).text("codingText").build();
assertEquals("codingText", codeableConcept.getText());
Coding builtCoding = codeableConcept.getCodings().iterator().next();
assertEquals("codingCode", builtCoding.getCode().getCodeValue());
assertEquals("codingDisplay", builtCoding.getDisplay());
}
Aggregations