Skip to content

Commit

Permalink
BAH-3893 | Enhancement to raise Radiology atomfeed events on save of …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
mohan-13 authored Jun 4, 2024
1 parent 8697e05 commit 925996e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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<String> RADIOLOGY_TEST_CONCEPT_CLASSES = Arrays.asList("Radiology", "Radiology/Imaging Procedure");
public static final String RADIOLOGY_TEST_PARENT_CONCEPT_NAME = "Radiology";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -29,8 +29,9 @@ public class SaleableTypeEvent implements ConceptServiceOperationEvent {
private List<String> supportedOperations = Arrays.asList("saveConcept", "updateConcept", "retireConcept", "purgeConcept");

private List<String> unhandledClasses = new ArrayList<String>(){{
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<String> unhandledConcepsByName = Arrays.asList(ALL_SAMPLES, ALL_TESTS_AND_PANELS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -109,4 +120,4 @@ public void createEventForRadiologyTestWithParentConceptMissing() throws Excepti
assertEquals(event.getCategory(), ConceptServiceEventFactory.LAB);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -62,4 +62,4 @@ public void mapNameOfRadiologyTestFromConcept() throws Exception {
}


}
}

0 comments on commit 925996e

Please sign in to comment.