Skip to content

Commit

Permalink
Limit the Court File Search and Case Details endpoint to Provincial f…
Browse files Browse the repository at this point in the history
…iles only
  • Loading branch information
Ronaldo Macapobre committed Dec 13, 2024
1 parent 0d7d508 commit f17f883
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
8 changes: 4 additions & 4 deletions api/Controllers/FilesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task<ActionResult<RedactedCivilFileDetailResponse>> GetCivilFileDet
if (User.IsVcUser() && civilFileDetailResponse.SealedYN != "N")
return Forbid();

if (User.IsSupremeUser() && civilFileDetailResponse.CourtLevelCd != CivilFileDetailResponseCourtLevelCd.S)
if (User.IsSupremeUser() && civilFileDetailResponse.CourtLevelCd != CivilFileDetailResponseCourtLevelCd.P)
return Forbid();

return Ok(civilFileDetailResponse);
Expand Down Expand Up @@ -133,7 +133,7 @@ public async Task<ActionResult<CivilAppearanceDetail>> GetCivilAppearanceDetails
if (civilAppearanceDetail == null)
throw new NotFoundException("Couldn't find appearance detail with the provided file id and appearance id.");

if (User.IsSupremeUser() && civilAppearanceDetail.CourtLevelCd != CivilFileDetailResponseCourtLevelCd.S)
if (User.IsSupremeUser() && civilAppearanceDetail.CourtLevelCd != CivilFileDetailResponseCourtLevelCd.P)
return Forbid();

return Ok(civilAppearanceDetail);
Expand Down Expand Up @@ -223,7 +223,7 @@ public async Task<ActionResult<RedactedCriminalFileDetailResponse>> GetCriminalF
if (redactedCriminalFileDetailResponse?.JustinNo == null)
throw new NotFoundException("Couldn't find criminal file with this id.");

if (User.IsSupremeUser() && redactedCriminalFileDetailResponse.CourtLevelCd != CriminalFileDetailResponseCourtLevelCd.S)
if (User.IsSupremeUser() && redactedCriminalFileDetailResponse.CourtLevelCd != CriminalFileDetailResponseCourtLevelCd.P)
return Forbid();

return Ok(redactedCriminalFileDetailResponse);
Expand All @@ -244,7 +244,7 @@ public async Task<ActionResult<CriminalAppearanceDetail>> GetCriminalAppearanceD
if (appearanceDetail == null)
throw new NotFoundException("Couldn't find appearance details with the provided parameters.");

if (User.IsSupremeUser() && appearanceDetail.CourtLevelCd != CriminalFileDetailResponseCourtLevelCd.S)
if (User.IsSupremeUser() && appearanceDetail.CourtLevelCd != CriminalFileDetailResponseCourtLevelCd.P)
return Forbid();


Expand Down
15 changes: 8 additions & 7 deletions api/Services/Files/CivilFilesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task<FileSearchResponse> SearchAsync(FilesCivilQuery fcq)
"[\"A\", \"Y\", \"T\", \"F\", \"C\", \"M\", \"L\", \"R\", \"B\", \"D\", \"E\", \"G\", \"H\", \"N\", \"O\", \"P\", \"S\", \"V\"]"; // for now, use all types - TODO: determine proper list of types?
return await _filesClient.FilesCivilGetAsync(_requestAgencyIdentifierId, _requestPartId,
_applicationCode, fcq.SearchMode, fcq.FileHomeAgencyId, fcq.FileNumber, fcq.FilePrefix,
fcq.FilePermissions, fcq.FileSuffixNumber, fcq.MDocReferenceTypeCode, fcq.CourtClass, fcq.CourtLevel,
fcq.FilePermissions, fcq.FileSuffixNumber, fcq.MDocReferenceTypeCode, fcq.CourtClass, CourtLevelCd.P,
fcq.NameSearchType, fcq.LastName, fcq.OrgName, fcq.GivenName, fcq.Birth?.ToString("yyyy-MM-dd"),
fcq.SearchByCrownPartId, fcq.SearchByCrownActiveOnly, fcq.SearchByCrownFileDesignation,
fcq.MdocJustinNumberSet, fcq.PhysicalFileIdSet);
Expand Down Expand Up @@ -109,7 +109,7 @@ public async Task<List<RedactedCivilFileDetailResponse>> GetFilesByAgencyIdCodeA

//Return the basic entry without doing a lookup.
if (fileIdAndAppearanceDate.Count == 1)
return new List<RedactedCivilFileDetailResponse> { new RedactedCivilFileDetailResponse { PhysicalFileId = fileIdAndAppearanceDate.First().PhysicalFileId }} ;
return new List<RedactedCivilFileDetailResponse> { new RedactedCivilFileDetailResponse { PhysicalFileId = fileIdAndAppearanceDate.First().PhysicalFileId } };

var fileDetailTasks = new List<Task<CivilFileDetailResponse>>();
foreach (var fileId in fileIdAndAppearanceDate)
Expand Down Expand Up @@ -152,15 +152,16 @@ public async Task<RedactedCivilFileDetailResponse> FileIdAsync(string fileId, bo
foreach (var document in PopulateDetailCsrsDocuments(fileDetail.Appearance))
if (!isVcUser)
detail.Document.Add(document);

detail = await PopulateBaseDetail(detail);
detail.Appearances = appearances;

var fileContentCivilFile = fileContent?.CivilFile?.First(cf => cf.PhysicalFileID == fileId);
detail.Party = await PopulateDetailParties(detail.Party);
detail.Document = await PopulateDetailDocuments(detail.Document, fileContentCivilFile, isVcUser, isStaff);
detail.HearingRestriction = await PopulateDetailHearingRestrictions(fileDetail.HearingRestriction);
if (isVcUser) {
if (isVcUser)
{
//SCV-266 - Disable comments for VC Users.
foreach (var document in detail.Document)
document.CommentTxt = "";
Expand Down Expand Up @@ -427,7 +428,7 @@ private async Task<ICollection<CivilAppearanceDetailParty>> PopulateDetailedAppe
party.Representative = _mapper.Map<ICollection<CivilRepresentative>>(courtListParty.Representative);
foreach (var representative in party.Representative)
{
representative.AttendanceMethodDesc = await _lookupService.GetCivilAssetsDescription(representative.AttendanceMethodCd);
representative.AttendanceMethodDesc = await _lookupService.GetCivilAssetsDescription(representative.AttendanceMethodCd);
}
party.LegalRepresentative = courtListParty.LegalRepresentative;
}
Expand All @@ -449,7 +450,7 @@ private async Task<ICollection<CivilAppearanceDetailParty>> PopulateDetailedAppe

if (!counsel.AdditionalProperties.ContainsKey("counselName"))
continue;

var targetCounsel = party.Counsel?.FirstOrDefault(c => c.CounselFullName == counsel.CounselName);
if (targetCounsel == null)
continue;
Expand All @@ -473,7 +474,7 @@ private async Task<ICollection<CivilAppearanceDocument>> PopulateDetailedAppeara
{
document.Category = _lookupService.GetDocumentCategory(document.DocumentTypeCd);
document.DocumentTypeDescription = await _lookupService.GetDocumentDescriptionAsync(document.DocumentTypeCd);
document.ImageId = document.SealedYN != "N" ? null : document.ImageId;
document.ImageId = document.SealedYN != "N" ? null : document.ImageId;
foreach (var issue in document.Issue)
{
issue.IssueTypeDesc = await _lookupService.GetCivilDocumentIssueType(issue.IssueTypeCd);
Expand Down
12 changes: 6 additions & 6 deletions api/Services/Files/CriminalFilesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task<FileSearchResponse> SearchAsync(FilesCriminalQuery fcq)
return await _filesClient.FilesCriminalGetAsync(_requestAgencyIdentifierId,
_requestPartId, _applicationCode, fcq.SearchMode, fcq.FileHomeAgencyId, fcq.FileNumberTxt,
fcq.FilePrefixTxt, fcq.FilePermissions, fcq.FileSuffixNo, fcq.MdocRefTypeCode, fcq.CourtClass,
fcq.CourtLevel, fcq.NameSearchTypeCd, fcq.LastName, fcq.OrgName, fcq.GivenName,
CourtLevelCd.P, fcq.NameSearchTypeCd, fcq.LastName, fcq.OrgName, fcq.GivenName,
fcq.Birth?.ToString("yyyy-MM-dd"), fcq.SearchByCrownPartId, fcq.SearchByCrownActiveOnly,
fcq.SearchByCrownFileDesignation, fcq.MdocJustinNoSet, fcq.PhysicalFileIdSet);
}
Expand All @@ -86,14 +86,14 @@ public async Task<List<RedactedCriminalFileDetailResponse>> GetFilesByAgencyIdCo
});

var fileIdAndAppearanceDate = fileSearchResponse?.FileDetail?.Where(fd => mdocSequenceNumber == null || fd.MdocSeqNo == mdocSequenceNumber)
.SelectToList(fd => new { fd.MdocJustinNo , fd.NextApprDt });
.SelectToList(fd => new { fd.MdocJustinNo, fd.NextApprDt });

if (fileIdAndAppearanceDate == null || fileIdAndAppearanceDate.Count == 0)
return fileDetails;

//Return the basic entry without doing a lookup.
if (fileIdAndAppearanceDate.Count == 1)
return new List<RedactedCriminalFileDetailResponse> {new RedactedCriminalFileDetailResponse {JustinNo = fileIdAndAppearanceDate.First().MdocJustinNo}};
return new List<RedactedCriminalFileDetailResponse> { new RedactedCriminalFileDetailResponse { JustinNo = fileIdAndAppearanceDate.First().MdocJustinNo } };

//It seems the fileSearch and the FileDetails/FileContent bring up two different participant lists
//The fileSearch seems to include have extra participants.
Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task<CriminalAppearanceDetail> AppearanceDetailAsync(string fileId,
private List<CriminalDocument> GetInitiatingDocuments(ICollection<CfcDocument> documents)
{
return documents?.Where(doc => doc?.DocmClassification == "Initiating" && !string.IsNullOrEmpty(doc.ImageId))
.Select(a => new CriminalDocument {IssueDate = a.IssueDate, ImageId = a.ImageId}).ToList();
.Select(a => new CriminalDocument { IssueDate = a.IssueDate, ImageId = a.ImageId }).ToList();
}

private async Task<CriminalFileAppearances> PopulateDetailsAppearancesAsync(string fileId, FutureYN? future, HistoryYN? history)
Expand Down Expand Up @@ -379,12 +379,12 @@ private async Task<CriminalAccused> PopulateAppearanceCriminalAccused(string ful
FullName = fullName,
PartId = partId, //partyAppearanceMethod, doesn't always have a partId on DEV at least.
PartyAppearanceMethod = partyAppearanceMethod?.PartyAppearanceMethod,
PartyAppearanceMethodDesc = await _lookupService.GetCriminalAccusedAttend(partyAppearanceMethod?.PartyAppearanceMethod),
PartyAppearanceMethodDesc = await _lookupService.GetCriminalAccusedAttend(partyAppearanceMethod?.PartyAppearanceMethod),
AttendanceMethodCd = attendanceMethod?.AttendanceMethodCd,
AttendanceMethodDesc = await _lookupService.GetCriminalAssetsDescriptions(attendanceMethod?.AttendanceMethodCd),
AppearanceMethodCd = appearanceMethod?.AppearanceMethodCd,
AppearanceMethodDesc = await _lookupService.GetCriminalAssetsDescriptions(appearanceMethod?.AppearanceMethodCd)
};
};
}

private async Task<CriminalAdjudicator> PopulateAppearanceDetailAdjudicator(CfcAppearance appearanceFromAccused, ICollection<ClAttendanceMethod> attendanceMethods, ICollection<JCCommon.Clients.FileServices.CriminalAppearanceMethod> appearanceMethods)
Expand Down

0 comments on commit f17f883

Please sign in to comment.