Search in sources :

Example 1 with CodeableConcept

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;
}
Also used : Issue(com.b2international.snowowl.fhir.core.model.Issue) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) OperationOutcome(com.b2international.snowowl.fhir.core.model.OperationOutcome) CodeableConcept(com.b2international.snowowl.fhir.core.model.dt.CodeableConcept)

Example 2 with CodeableConcept

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());
}
Also used : Issue(com.b2international.snowowl.fhir.core.model.Issue) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) CodeableConcept(com.b2international.snowowl.fhir.core.model.dt.CodeableConcept) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 3 with CodeableConcept

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();
}
Also used : Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) CodeableConcept(com.b2international.snowowl.fhir.core.model.dt.CodeableConcept) Before(org.junit.Before)

Example 4 with CodeableConcept

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);
}
Also used : Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) ValidateCodeRequest(com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest) CodeableConcept(com.b2international.snowowl.fhir.core.model.dt.CodeableConcept) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 5 with CodeableConcept

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());
}
Also used : Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) CodeableConcept(com.b2international.snowowl.fhir.core.model.dt.CodeableConcept) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

CodeableConcept (com.b2international.snowowl.fhir.core.model.dt.CodeableConcept)11 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)10 Test (org.junit.Test)6 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)5 Issue (com.b2international.snowowl.fhir.core.model.Issue)4 OperationOutcome (com.b2international.snowowl.fhir.core.model.OperationOutcome)1 Builder (com.b2international.snowowl.fhir.core.model.OperationOutcome.Builder)1 ValidateCodeRequest (com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest)1 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)1 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)1 JsonPath (io.restassured.path.json.JsonPath)1 HashSet (java.util.HashSet)1 Before (org.junit.Before)1