Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAH-3893 | Enhancement to raise Radiology atomfeed events on save of concept with class Radiology/Imaging Procedure #264

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
}


}
}
Loading