From 925996e18ea2b34fe9c080c50e3b6d5ecfdd234e Mon Sep 17 00:00:00 2001 From: MOHANKUMAR T <31698165+mohan-13@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:18:20 +0530 Subject: [PATCH] BAH-3893 | Enhancement to raise Radiology atomfeed events on save of concept with class Radiology/Imaging Procedure (#264) * BAH-3892 | Support atomfeed test events for concepts with class Test * BAH-3893 | Support atomfeed radiology events for concepts with class Radiology/Imaging Procedure --- .../labconcepts/contract/RadiologyTest.java | 5 ++++- .../labconcepts/model/event/RadiologyTestEvent.java | 6 +++--- .../labconcepts/model/event/SaleableTypeEvent.java | 5 +++-- .../model/event/RadiologyTestEventTest.java | 13 ++++++++++++- .../contract/mapper/RadiologyTestMapperTest.java | 4 ++-- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/reference-data/api/src/main/java/org/bahmni/module/referencedata/labconcepts/contract/RadiologyTest.java b/reference-data/api/src/main/java/org/bahmni/module/referencedata/labconcepts/contract/RadiologyTest.java index bdbb789726..fba0a3c334 100644 --- a/reference-data/api/src/main/java/org/bahmni/module/referencedata/labconcepts/contract/RadiologyTest.java +++ b/reference-data/api/src/main/java/org/bahmni/module/referencedata/labconcepts/contract/RadiologyTest.java @@ -1,6 +1,9 @@ package org.bahmni.module.referencedata.labconcepts.contract; +import java.util.Arrays; +import java.util.List; + public class RadiologyTest extends Resource { - public static final String RADIOLOGY_TEST_CONCEPT_CLASS = "Radiology"; + public static final List RADIOLOGY_TEST_CONCEPT_CLASSES = Arrays.asList("Radiology", "Radiology/Imaging Procedure"); public static final String RADIOLOGY_TEST_PARENT_CONCEPT_NAME = "Radiology"; } diff --git a/reference-data/omod/src/main/java/org/bahmni/module/referencedata/labconcepts/model/event/RadiologyTestEvent.java b/reference-data/omod/src/main/java/org/bahmni/module/referencedata/labconcepts/model/event/RadiologyTestEvent.java index 09230a6984..2f98ab8207 100644 --- a/reference-data/omod/src/main/java/org/bahmni/module/referencedata/labconcepts/model/event/RadiologyTestEvent.java +++ b/reference-data/omod/src/main/java/org/bahmni/module/referencedata/labconcepts/model/event/RadiologyTestEvent.java @@ -2,8 +2,8 @@ import org.openmrs.Concept; -import static org.bahmni.module.referencedata.labconcepts.contract.RadiologyTest.RADIOLOGY_TEST_CONCEPT_CLASS; -import static org.bahmni.module.referencedata.labconcepts.mapper.ConceptExtension.isOfConceptClass; +import static org.bahmni.module.referencedata.labconcepts.contract.RadiologyTest.RADIOLOGY_TEST_CONCEPT_CLASSES; +import static org.bahmni.module.referencedata.labconcepts.mapper.ConceptExtension.isOfAnyConceptClass; public class RadiologyTestEvent extends ConceptOperationEvent { @@ -14,7 +14,7 @@ public RadiologyTestEvent(String url, String category, String title) { @Override public boolean isResourceConcept(Concept concept) { - return isOfConceptClass(concept, RADIOLOGY_TEST_CONCEPT_CLASS); + return isOfAnyConceptClass(concept, RADIOLOGY_TEST_CONCEPT_CLASSES); } diff --git a/reference-data/omod/src/main/java/org/bahmni/module/referencedata/labconcepts/model/event/SaleableTypeEvent.java b/reference-data/omod/src/main/java/org/bahmni/module/referencedata/labconcepts/model/event/SaleableTypeEvent.java index 0deaaef970..6f884a6cd7 100644 --- a/reference-data/omod/src/main/java/org/bahmni/module/referencedata/labconcepts/model/event/SaleableTypeEvent.java +++ b/reference-data/omod/src/main/java/org/bahmni/module/referencedata/labconcepts/model/event/SaleableTypeEvent.java @@ -16,7 +16,7 @@ import static org.bahmni.module.referencedata.labconcepts.contract.Department.DEPARTMENT_CONCEPT_CLASS; import static org.bahmni.module.referencedata.labconcepts.contract.LabTest.LAB_TEST_CONCEPT_CLASSES; import static org.bahmni.module.referencedata.labconcepts.contract.Panel.LAB_SET_CONCEPT_CLASS; -import static org.bahmni.module.referencedata.labconcepts.contract.RadiologyTest.RADIOLOGY_TEST_CONCEPT_CLASS; +import static org.bahmni.module.referencedata.labconcepts.contract.RadiologyTest.RADIOLOGY_TEST_CONCEPT_CLASSES; import static org.bahmni.module.referencedata.labconcepts.contract.Sample.SAMPLE_CONCEPT_CLASS; public class SaleableTypeEvent implements ConceptServiceOperationEvent { @@ -29,8 +29,9 @@ public class SaleableTypeEvent implements ConceptServiceOperationEvent { private List supportedOperations = Arrays.asList("saveConcept", "updateConcept", "retireConcept", "purgeConcept"); private List unhandledClasses = new ArrayList(){{ - addAll(Arrays.asList(LAB_SET_CONCEPT_CLASS, SAMPLE_CONCEPT_CLASS, DEPARTMENT_CONCEPT_CLASS, RADIOLOGY_TEST_CONCEPT_CLASS)); + addAll(Arrays.asList(LAB_SET_CONCEPT_CLASS, SAMPLE_CONCEPT_CLASS, DEPARTMENT_CONCEPT_CLASS)); addAll(LAB_TEST_CONCEPT_CLASSES); + addAll(RADIOLOGY_TEST_CONCEPT_CLASSES); }}; private List unhandledConcepsByName = Arrays.asList(ALL_SAMPLES, ALL_TESTS_AND_PANELS); diff --git a/reference-data/omod/src/test/java/org/bahmni/module/referencedata/labconcepts/model/event/RadiologyTestEventTest.java b/reference-data/omod/src/test/java/org/bahmni/module/referencedata/labconcepts/model/event/RadiologyTestEventTest.java index c72fc7e58c..5292c26af8 100644 --- a/reference-data/omod/src/test/java/org/bahmni/module/referencedata/labconcepts/model/event/RadiologyTestEventTest.java +++ b/reference-data/omod/src/test/java/org/bahmni/module/referencedata/labconcepts/model/event/RadiologyTestEventTest.java @@ -70,6 +70,17 @@ public void createEventForSampleEvent() throws Exception { } + @Test + public void shouldCreateEventWhenClassIsRadiologyImagingProcedure() throws Exception{ + concept = new ConceptBuilder().withClass("Radiology/Imaging Procedure").withUUID(RADIOLOGY_TEST_CONCEPT_UUID).build(); + Event event = new Operation(ConceptService.class.getMethod("saveConcept", Concept.class)).apply(new Object[]{concept}).get(0); + Event anotherEvent = new Operation(ConceptService.class.getMethod("saveConcept", Concept.class)).apply(new Object[]{concept}).get(0); + assertNotNull(event); + assertFalse(event.getUuid().equals(anotherEvent.getUuid())); + assertEquals(event.getTitle(), ConceptServiceEventFactory.RADIOLOGY); + assertEquals(event.getCategory(), ConceptServiceEventFactory.LAB); + } + @Test public void shouldNotCreateEventForRadiologyEventIfThereIsDifferentConceptClass() throws Exception { concept = new ConceptBuilder().withClass("random").withClassUUID("some").withUUID(RADIOLOGY_TEST_CONCEPT_UUID).build(); @@ -109,4 +120,4 @@ public void createEventForRadiologyTestWithParentConceptMissing() throws Excepti assertEquals(event.getCategory(), ConceptServiceEventFactory.LAB); } -} \ No newline at end of file +} diff --git a/reference-data/omod/src/test/java/org/bahmni/module/referencedata/web/contract/mapper/RadiologyTestMapperTest.java b/reference-data/omod/src/test/java/org/bahmni/module/referencedata/web/contract/mapper/RadiologyTestMapperTest.java index dd3085dc7f..404fe03d0a 100644 --- a/reference-data/omod/src/test/java/org/bahmni/module/referencedata/web/contract/mapper/RadiologyTestMapperTest.java +++ b/reference-data/omod/src/test/java/org/bahmni/module/referencedata/web/contract/mapper/RadiologyTestMapperTest.java @@ -46,7 +46,7 @@ public void setUp() throws Exception { PowerMockito.mockStatic(Context.class); when(Context.getLocale()).thenReturn(defaultLocale); - radiologyConcept = new ConceptBuilder().withUUID("RadiologyUUID").withDateCreated(dateCreated).withClass(RadiologyTest.RADIOLOGY_TEST_CONCEPT_CLASS). + radiologyConcept = new ConceptBuilder().withUUID("RadiologyUUID").withDateCreated(dateCreated).withClass(RadiologyTest.RADIOLOGY_TEST_CONCEPT_CLASSES.get(0)). withDateChanged(dateChanged).withShortName("clavicle - right, 2 views (x-ray)").withName("Clavicle - Right, 2 views (X-ray)").build(); when(Context.getConceptService()).thenReturn(conceptService); @@ -62,4 +62,4 @@ public void mapNameOfRadiologyTestFromConcept() throws Exception { } -} \ No newline at end of file +}