Skip to content

Commit

Permalink
Merge pull request #474 from hmcts/PRL-6575
Browse files Browse the repository at this point in the history
Remove state filter for hearings
  • Loading branch information
shashisk97 authored Nov 18, 2024
2 parents 95ed336 + 904ddeb commit af7677b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 30 deletions.
2 changes: 1 addition & 1 deletion charts/fis-hmc-api/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: "1.0"
description: A Helm chart for fis-hmc-api Application
name: fis-hmc-api
home: https://github.com/hmcts/fis-hmc-api
version: 0.0.34
version: 0.0.35
maintainers:
- name: HMCTS family integration team
dependencies:
Expand Down
1 change: 1 addition & 0 deletions charts/fis-hmc-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ java:
OIDC_S2S_MICROSERVICE_NAME: 'fis_hmc_api'
PRL_URL: 'http://prl-cos-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal'
PRL_HMC_S2S_AUTHORISED_SERVICES : xui_webapp,prl_cos_api,fis_hmc_api
CAFCASS_EXCLUDE_HEARING_STATES: HEARING_REQUESTED,AWAITING_LISTING,EXCEPTION,CANCELLATION_SUBMITTED
REF_DATA_VENUE_URL: 'http://rd-location-ref-api-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal/'
REF_DATA_JUDICIAL_URL: 'http://rd-judicial-api-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal/'
ROLE_ASSIGNMENT_SERVICE_URL: 'http://am-role-assignment-service-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal'
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class HearingsServiceImpl implements HearingsService {
@Value("${hearing_component.api.url}")
private String basePath;

@Value("#{'${cafcass.excludeHearingStates}'.split(',')}")
private List<String> hearingStatesToBeExcluded;

@Value("#{'${hearing_component.futureHearingStatus}'.split(',')}")
private List<String> futureHearingStatusList;

Expand Down Expand Up @@ -175,21 +178,20 @@ public List<Hearings> getHearingsByListOfCaseIds(
List<Hearings> hearingDetailsList =
hearingApiClient.getListOfHearingDetails(
userToken, s2sToken, new ArrayList<>(caseIdWithRegionIdMap.keySet()));
log.info("Hearing details list {}", hearingDetailsList);
for (var hearing : hearingDetailsList) {
try {
hearingDetails = hearing;
List<CaseHearing> filteredHearings =
hearingDetails.getCaseHearings().stream()
.filter(
eachHearing ->
eachHearing.getHmcStatus().equals(LISTED)
|| eachHearing
.getHmcStatus()
.equals(CANCELLED)
|| eachHearing
.getHmcStatus()
.equals(COMPLETED))
.toList();
List<CaseHearing> filteredHearings = hearingDetails.getCaseHearings();
log.info("Excluded hearing statuses {}", hearingStatesToBeExcluded);
if (CollectionUtils.isNotEmpty(hearingStatesToBeExcluded)) {
filteredHearings = filteredHearings.stream()
.filter(
eachHearing ->
!hearingStatesToBeExcluded.contains(eachHearing.getHmcStatus()))
.toList();
}
log.info("Filtered hearings {}", filteredHearings);
Hearings filteredCaseHearingsWithCount =
Hearings.hearingsWith()
.caseHearings(filteredHearings)
Expand Down Expand Up @@ -274,16 +276,14 @@ private void integrateVenueDetailsForCaseId(
Map<String, String> caseIdWithRegionIdMap) {

for (Hearings hearings : casesWithHearings) {
List<CaseHearing> listedOrCancelledHearings = getListedOrCancelledHearing(hearings);
if (!listedOrCancelledHearings.isEmpty()) {
if (null != hearings && !hearings.getCaseHearings().isEmpty()) {
CourtDetail caseCourt = getCourtDetail(allVenues, caseIdWithRegionIdMap, hearings);
if (caseCourt != null) {
hearings.setCourtTypeId(caseCourt.getCourtTypeId());
hearings.setCourtName(caseCourt.getHearingVenueName());
}


for (CaseHearing caseHearing : listedOrCancelledHearings) {
for (CaseHearing caseHearing : hearings.getCaseHearings()) {
for (HearingDaySchedule hearingSchedule : caseHearing.getHearingDaySchedule()) {
CourtDetail matchedCourt = getMatchedCourtDetail(
allVenues,
Expand Down Expand Up @@ -378,18 +378,6 @@ private static CourtDetail getCourtDetail(List<CourtDetail> allVenues,
.orElse(null);
}


private static List<CaseHearing> getListedOrCancelledHearing(Hearings hearings) {
return hearings.getCaseHearings().stream()
.filter(
hearing ->
(hearing.getHmcStatus().equals(LISTED)
|| hearing.getHmcStatus()
.equals(CANCELLED))
&& hearing.getHearingDaySchedule() != null)
.toList();
}

@Override
public Hearings getFutureHearings(String caseReference) {

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ hearing:
url: ${HEARING_API_URL:http://rd-commondata-api-demo.service.core-compute-demo.internal}
search-case-type-id: PRLAPPS

cafcass:
excludeHearingStates: ${CAFCASS_EXCLUDE_HEARING_STATES:HEARING_REQUESTED,AWAITING_LISTING,EXCEPTION,CANCELLATION_SUBMITTED}
ref_data_venue:
api:
url: ${REF_DATA_VENUE_URL:http://rd-location-ref-api-demo.service.core-compute-demo.internal/}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void shouldReturnCtfHearingsByListOfCaseIdsCancelledCaseHearingTest1() {
List<Hearings> hearingsResponse =
hearingsService.getHearingsByListOfCaseIds(caseIdWithRegionId, "Auth", "sauth");
Assertions.assertEquals("ABA5", hearingsResponse.get(0).getHmctsServiceCode());
Assertions.assertTrue(hearingsResponse.get(0).getCaseHearings().isEmpty()); }
Assertions.assertFalse(hearingsResponse.get(0).getCaseHearings().isEmpty()); }



Expand Down

0 comments on commit af7677b

Please sign in to comment.