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-3079 | Add InPatient drugs to Active and Inactive drug orders list #221

Merged
merged 1 commit into from
Jul 13, 2023
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
Expand Up @@ -97,11 +97,17 @@ public Map<String,DrugOrder> getDiscontinuedDrugOrders(List<DrugOrder> drugOrder
public List<DrugOrder> getInactiveDrugOrders(String patientUuid, Set<Concept> concepts, Set<Concept> drugConceptsToBeExcluded,
Collection<Encounter> encounters) {
Patient patient = openmrsPatientService.getPatientByUuid(patientUuid);
CareSetting careSettingByName = orderService.getCareSettingByName(CareSetting.CareSettingType.OUTPATIENT.toString());
CareSetting outPatientCareSetting = orderService.getCareSettingByName(CareSetting.CareSettingType.OUTPATIENT.toString());
CareSetting inPatientCareSetting = orderService.getCareSettingByName(CareSetting.CareSettingType.INPATIENT.toString());
Date asOfDate = new Date();
List<Order> orders = orderDao.getInactiveOrders(patient, orderService.getOrderTypeByName("Drug order"),
careSettingByName, asOfDate, concepts, drugConceptsToBeExcluded, encounters);
return mapOrderToDrugOrder(orders);
List<Order> outPatientOrders = orderDao.getInactiveOrders(patient, orderService.getOrderTypeByName("Drug order"),
outPatientCareSetting, asOfDate, concepts, drugConceptsToBeExcluded, encounters);
List<Order> inPatientOrders = orderDao.getInactiveOrders(patient, orderService.getOrderTypeByName("Drug order"),
inPatientCareSetting, asOfDate, concepts, drugConceptsToBeExcluded, encounters);
List<Order> allActiveDrugOrders = new ArrayList<>();
allActiveDrugOrders.addAll(outPatientOrders);
allActiveDrugOrders.addAll(inPatientOrders);
return mapOrderToDrugOrder(allActiveDrugOrders);
}

@Override
Expand Down Expand Up @@ -204,10 +210,16 @@ private List<OrderFrequencyData> getFrequencies() {
private List<DrugOrder> getActiveDrugOrders(String patientUuid, Date asOfDate, Set<Concept> conceptsToFilter,
Set<Concept> conceptsToExclude, Date startDate, Date endDate, Collection<Encounter> encounters) {
Patient patient = openmrsPatientService.getPatientByUuid(patientUuid);
CareSetting careSettingByName = orderService.getCareSettingByName(CareSetting.CareSettingType.OUTPATIENT.toString());
List<Order> orders = orderDao.getActiveOrders(patient, orderService.getOrderTypeByName("Drug order"),
careSettingByName, asOfDate, conceptsToFilter, conceptsToExclude, startDate, endDate, encounters);
return mapOrderToDrugOrder(orders);
CareSetting outPatientCareSetting = orderService.getCareSettingByName(CareSetting.CareSettingType.OUTPATIENT.toString());
CareSetting inPatientCareSetting = orderService.getCareSettingByName(CareSetting.CareSettingType.INPATIENT.toString());
List<Order> outPatientOrders = orderDao.getActiveOrders(patient, orderService.getOrderTypeByName("Drug order"),
outPatientCareSetting, asOfDate, conceptsToFilter, conceptsToExclude, startDate, endDate, encounters);
List<Order> inPatientOrders = orderDao.getActiveOrders(patient, orderService.getOrderTypeByName("Drug order"),
inPatientCareSetting, asOfDate, conceptsToFilter, conceptsToExclude, startDate, endDate, encounters);
List<Order> allActiveDrugOrders = new ArrayList<>();
allActiveDrugOrders.addAll(outPatientOrders);
allActiveDrugOrders.addAll(inPatientOrders);
return mapOrderToDrugOrder(allActiveDrugOrders);
}

private List<DrugOrder> mapOrderToDrugOrder(List<Order> orders){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.times;
import static org.mockito.MockitoAnnotations.initMocks;

public class BahmniDrugOrderServiceImplTest {
Expand Down Expand Up @@ -85,7 +86,7 @@ public void shouldGetActiveDrugOrdersOfAPatientProgram() throws ParseException {
bahmniDrugOrderService.getDrugOrders(PATIENT_UUID, true, conceptsToFilter, null, PATIENT_PROGRAM_UUID);

final Date value = dateArgumentCaptor.getValue();
verify(orderDao).getActiveOrders(mockPatient, mockOrderType, mockCareSetting, value, conceptsToFilter, null, null, null, encounters);
verify(orderDao, times(2)).getActiveOrders(mockPatient, mockOrderType, mockCareSetting, value, conceptsToFilter, null, null, null, encounters);
}

@Test
Expand Down