diff --git a/CHANGELOG.md b/CHANGELOG.md index 7059e627b..b3a875c5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Note: version releases in the 0.x.y range may introduce breaking changes. - Flat : corrected handling of PARTY_PROXY ( see https://github.com/ehrbase/openEHR_SDK/pull/320) - Flat : corrected handling of history origin and ISM_TRANSITION (see https://github.com/ehrbase/openEHR_SDK/pull/329) +- Validation: fix validation of DV_TEXT with listopen (see https://github.com/ehrbase/openEHR_SDK/pull/335) - Walker, Flat, DTO, Validation : enhance performance of path handling ( see https://github.com/ehrbase/openEHR_SDK/pull/325 ) diff --git a/test-data/src/main/java/org/ehrbase/test_data/composition/CompositionTestDataSimSDTJson.java b/test-data/src/main/java/org/ehrbase/test_data/composition/CompositionTestDataSimSDTJson.java index 8b50d312b..67699eb8c 100644 --- a/test-data/src/main/java/org/ehrbase/test_data/composition/CompositionTestDataSimSDTJson.java +++ b/test-data/src/main/java/org/ehrbase/test_data/composition/CompositionTestDataSimSDTJson.java @@ -71,6 +71,7 @@ public enum CompositionTestDataSimSDTJson implements CompositionTestDataSimSDTJs "EREACT - Covid status monitoring - FLAT.json", OperationalTemplateTestData.EREACT_COVID_MANAGEMENT), NESTED("nested.en.v1", "nested.en.v1.json",OperationalTemplateTestData.NESTED), + RE_SPECT("nested.en.v1", "ReSPECT.json",OperationalTemplateTestData.RE_SPECT), IPS("International Patient Summary", "ips_flat.json",OperationalTemplateTestData.IPS); private final String filename; diff --git a/test-data/src/main/java/org/ehrbase/test_data/operationaltemplate/OperationalTemplateTestData.java b/test-data/src/main/java/org/ehrbase/test_data/operationaltemplate/OperationalTemplateTestData.java index f31a4d95b..9e92156ea 100644 --- a/test-data/src/main/java/org/ehrbase/test_data/operationaltemplate/OperationalTemplateTestData.java +++ b/test-data/src/main/java/org/ehrbase/test_data/operationaltemplate/OperationalTemplateTestData.java @@ -109,6 +109,7 @@ public enum OperationalTemplateTestData { "conformance-ehrbase.de.v0"), MULTIMEDIA_TEST("MultimediaTest", "multimedia_test.en.v1.opt", "multimedia_test.en.v1"), NESTED("nested.en.v1", "nested.en.v1.opt", "nested.en.v1"), + RE_SPECT("ReSPECT-3.v0", "ReSPECT-3.v0.opt", "ReSPECT-3.v0"), IPS("International Patient Summary", "ips.v0.opt", "International Patient Summary"), SECTION_CARDINALITY("Cardinality test template sections", "section_cardinality.opt", "cardinality_of_section"); diff --git a/test-data/src/main/resources/composition/flat/simSDT/ReSPECT.json b/test-data/src/main/resources/composition/flat/simSDT/ReSPECT.json new file mode 100644 index 000000000..fade833f7 --- /dev/null +++ b/test-data/src/main/resources/composition/flat/simSDT/ReSPECT.json @@ -0,0 +1,50 @@ +{ + "ctx/language": "en", + "ctx/territory": "US", + "ctx/composer_name": "Silvia Blake", + "ctx/id_namespace": "HOSPITAL-NS", + "ctx/id_scheme": "HOSPITAL-NS", + "ctx/participation_name": "Dr. Marcus Johnson", + "ctx/participation_function": "requester", + "ctx/participation_mode": "face-to-face communication", + "ctx/participation_id": "199", + "ctx/participation_name:1": "Lara Markham", + "ctx/participation_function:1": "performer", + "ctx/participation_id:1": "198", + "ctx/health_care_facility|name": "Hospital", + "ctx/health_care_facility|id": "9091", + "respect-3/context/status": "Complete and signed", + "respect-3/context/xds_metadata/document_type|code": "D.67", + "respect-3/context/xds_metadata/document_type|value": "D.67 description", + "respect-3/respect_headings/a2._shared_understanding/respect_summary/narrative_summary": "Narrative Summary 37", + "respect-3/respect_headings/a2._shared_understanding/details_of_other_relevant_care_planning_documents_and_where_to_find_them/advance_planning_document:0/description": "Description 19", + "respect-3/respect_headings/a2._shared_understanding/legal_welfare_proxies/legal_welfare_proxy_in_place:0/type": "Type 84", + "respect-3/respect_headings/a2._shared_understanding/legal_welfare_proxies/legal_welfare_proxy_in_place:0/status|code": "at0005", + "respect-3/respect_headings/a3._what_matters_to_me/what_matters_to_me/what_i_most_value": "What I most value 18", + "respect-3/respect_headings/a3._what_matters_to_me/what_matters_to_me/what_i_most_fear_wish_to_avoid": "What I most fear / wish to avoid 55", + "respect-3/respect_headings/a4._clinical_recommendations/recommendation/topic": "Topic 49", + "respect-3/respect_headings/a4._clinical_recommendations/recommendation/clinical_focus": "Prioritise extending life", + "respect-3/respect_headings/a4._clinical_recommendations/recommendation/clinical_guidance_on_interventions": "Clinical guidance on interventions 86", + "respect-3/respect_headings/a4._clinical_recommendations/cpr_decision/cpr_decision|code": "at0022", + "respect-3/respect_headings/a4._clinical_recommendations/cpr_decision/date_of_cpr_decision": "2022-03-03T09:15:53.069272+01:00", + "respect-3/respect_headings/a5._capacity_for_involvement/mental_capacity/decision_plan": "ReSPECT recommendations", + "respect-3/respect_headings/a5._capacity_for_involvement/mental_capacity/does_the_person_have_capacity_to_participate_in_making_recommendations_on_this_plan|code": "at0003", + "respect-3/respect_headings/a5._capacity_for_involvement/mental_capacity/if_no_in_what_way_does_this_person_lack_capacity": "If no, in what way does this person lack capacity? 69", + "respect-3/respect_headings/a6._involvement_in_making_plan/respect_involvement/involvement_in_recommendations/involvement:0|code": "at0004", + "respect-3/respect_headings/a6._involvement_in_making_plan/respect_involvement/involvement_in_recommendations/option_d": "Option D 59", + "respect-3/respect_headings/a7._clinician_signatures/clinician_signature:0/ism_transition/current_state|code": "532", + "respect-3/respect_headings/a7._clinician_signatures/clinician_signature:0/ism_transition/current_state|value": "completed", + "respect-3/respect_headings/a7._clinician_signatures/clinician_signature:0/service_name": "ReSPECT - clinician signature", + "respect-3/respect_headings/a7._clinician_signatures/clinician_signature:0/time": "2022-03-03T09:15:53.069433+01:00", + "respect-3/respect_headings/a8._emergency_contacts/emergency_contacts/care_team/name": "ReSPECT Emergency contacts", + "respect-3/respect_headings/a8._emergency_contacts/emergency_contacts/care_team/participant:0/role_and_relationship:0": "parent", + "respect-3/respect_headings/a8._emergency_contacts/emergency_contacts/care_team/participant:0/member/name:0/use|code": "at0002", + "respect-3/respect_headings/a8._emergency_contacts/emergency_contacts/care_team/participant:0/member/name:0/contact_name": "Contact name 53", + "respect-3/respect_headings/a8._emergency_contacts/emergency_contacts/care_team/participant:0/member/telephone:0/system|code": "at0012", + "respect-3/respect_headings/a8._emergency_contacts/emergency_contacts/care_team/participant:0/member/telephone:0/telephone_number": "Telephone number 79", + "respect-3/respect_headings/a8._emergency_contacts/emergency_contacts/care_team/participant:0/other_details_about_contact": "Other details about contact 33", + "respect-3/respect_headings/a9._review_of_plan/review_of_plan:0/ism_transition/current_state|code": "532", + "respect-3/respect_headings/a9._review_of_plan/review_of_plan:0/ism_transition/current_state|value": "completed", + "respect-3/respect_headings/a9._review_of_plan/review_of_plan:0/service_name": "ReSPECT clinical review", + "respect-3/respect_headings/a9._review_of_plan/review_of_plan:0/time": "2022-03-03T09:15:53.069499+01:00" +} \ No newline at end of file diff --git a/test-data/src/main/resources/operationaltemplate/ReSPECT-3.v0.opt b/test-data/src/main/resources/operationaltemplate/ReSPECT-3.v0.opt new file mode 100644 index 000000000..2a9c6b88c --- /dev/null +++ b/test-data/src/main/resources/operationaltemplate/ReSPECT-3.v0.opt @@ -0,0 +1,6589 @@ + + + \ No newline at end of file diff --git a/validation/src/main/java/org/ehrbase/validation/webtemplate/WebTemplateValidationUtils.java b/validation/src/main/java/org/ehrbase/validation/webtemplate/WebTemplateValidationUtils.java index 5a11d5495..6d841a341 100644 --- a/validation/src/main/java/org/ehrbase/validation/webtemplate/WebTemplateValidationUtils.java +++ b/validation/src/main/java/org/ehrbase/validation/webtemplate/WebTemplateValidationUtils.java @@ -19,6 +19,8 @@ import com.nedap.archie.base.MultiplicityInterval; import java.util.Objects; import java.util.Optional; + +import org.apache.commons.lang3.BooleanUtils; import org.ehrbase.webtemplate.model.WebTemplateInput; import org.ehrbase.webtemplate.model.WebTemplateInputValue; import org.ehrbase.webtemplate.model.WebTemplateNode; @@ -157,7 +159,7 @@ public static boolean hasValidationRange(WebTemplateInput input) { * otherwise */ public static boolean hasList(WebTemplateInput input) { - return !input.getList().isEmpty() && input.getListOpen() != Boolean.TRUE; + return !input.getList().isEmpty() && BooleanUtils.isNotTrue(input.getListOpen()); } /** diff --git a/validation/src/test/java/org/ehrbase/validation/CompositionValidatorTest.java b/validation/src/test/java/org/ehrbase/validation/CompositionValidatorTest.java index c459c12a3..62e7f0924 100644 --- a/validation/src/test/java/org/ehrbase/validation/CompositionValidatorTest.java +++ b/validation/src/test/java/org/ehrbase/validation/CompositionValidatorTest.java @@ -27,10 +27,14 @@ import javax.xml.bind.JAXBException; import org.apache.commons.io.IOUtils; import org.apache.xmlbeans.XmlException; +import org.ehrbase.serialisation.flatencoding.FlatFormat; +import org.ehrbase.serialisation.flatencoding.FlatJasonProvider; import org.ehrbase.serialisation.jsonencoding.CanonicalJson; import org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson; +import org.ehrbase.test_data.composition.CompositionTestDataSimSDTJson; import org.ehrbase.test_data.operationaltemplate.OperationalTemplateTestData; import org.ehrbase.validation.CompositionValidator; +import org.ehrbase.validation.webtemplate.TestDataTemplateProvider; import org.junit.jupiter.api.Test; import org.openehr.schemas.v1.OPERATIONALTEMPLATE; import org.openehr.schemas.v1.TemplateDocument; @@ -52,6 +56,15 @@ void testValidateInternationalPatientSummary() throws Exception { assertTrue(result.isEmpty()); } + @Test + void testValidateReSPECT() throws Exception { + var template = getOperationalTemplate(OperationalTemplateTestData.RE_SPECT); + var composition = getComposition(CompositionTestDataSimSDTJson.RE_SPECT); + + var result = validator.validate(composition, template); + assertTrue(result.isEmpty()); + } + @Test void testValidateInternationalPatientSummary_Invalid() throws Exception { var template = getOperationalTemplate(OperationalTemplateTestData.IPS); @@ -179,6 +192,12 @@ private Composition getComposition(CompositionTestDataCanonicalJson composition) IOUtils.toString(composition.getStream(), StandardCharsets.UTF_8), Composition.class); } + private Composition getComposition(CompositionTestDataSimSDTJson composition) + throws IOException { + return new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT,composition.getTemplate().getTemplateId()).unmarshal( + IOUtils.toString(composition.getStream(), StandardCharsets.UTF_8), Composition.class); + } + private Composition getComposition(String name) throws IOException, JAXBException { var unmarshaller = JAXBUtil.createRMContext().createUnmarshaller(); return (Composition) unmarshaller.unmarshal(