Skip to content

Commit

Permalink
OAM-48: Added destination/source filter for Wards/Services
Browse files Browse the repository at this point in the history
  • Loading branch information
sradziszewski authored and pwargulak committed Jun 13, 2024
1 parent 3462463 commit b8113d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,21 @@ private List<ValidSourceDestinationDto> createAssignmentDto(
return true;
}
})
.filter(assignment -> {
// check if assignment facility is type Ward/Service AND is in the same zone as facility
if (assignment.getNode().isRefDataFacility()) {
FacilityDto assignmentFacility =
facilitiesById.get(assignment.getNode().getReferenceId());
if (assignmentFacility.getType().getCode().equals("WS")) {
return assignmentFacility.getGeographicZone().getId()
.equals(facility.getGeographicZone().getId());
} else {
return true;
}
} else {
return true;
}
})
.filter(assignment -> !assignment.getNode().isRefDataFacility()
|| hasGeoAffinity(assignment, facility, facilitiesById))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,13 @@ public void shouldReturnListOfDestinationDtosWhenFindValidDestinationAssignment(
assertThat(facility.getName(), is(FACILITY_NODE_NAME));
assertThat(facility.getIsFreeTextAllowed(), is(false));
}

/*
*
*
*
*
*
* */
@Test
public void
shouldReturnListOfAllDestinationDtosWhenFindValidDestinationAssignmentWithParams()
Expand Down Expand Up @@ -780,6 +786,7 @@ private GeographicZoneDto generateGeographicZone(UUID districtLevelId, UUID regi
private FacilityDto createFacilityDtoWithFacilityType(UUID facilityId, UUID facilityTypeId) {
FacilityTypeDto facilityDto = new FacilityTypeDto();
facilityDto.setId(facilityTypeId);
facilityDto.setCode("TEST");
return FacilityDto.builder()
.id(facilityId)
.type(facilityDto)
Expand Down

0 comments on commit b8113d9

Please sign in to comment.