@ministryofjustice/hmpps-prison-permissions-lib 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Please use this to capture reasoning behind changes:
4
4
 
5
+ ## 2.5.0
6
+
7
+ Restricted diet and allergy read access for global search and updated dependencies.
8
+
9
+ ## 2.4.1
10
+
11
+ Fixed duplicate record conditional upgrade and updated dependencies.
12
+
5
13
  ## 2.4.0
6
14
 
7
15
  The Connect DPS team have been supporting a request to make duplicate prisoner records more visible to users.
@@ -0,0 +1,2 @@
1
+ import { TestScenarios } from '../../../../../../../testUtils/TestScenario';
2
+ export declare const dietReadScenarios: TestScenarios;
package/dist/index.cjs CHANGED
@@ -1068,6 +1068,15 @@ function personProtectedCharacteristicsCheck(context) {
1068
1068
  };
1069
1069
  }
1070
1070
 
1071
+ const dietReadCheck = matchBaseCheckAnd({
1072
+ ifRestrictedPatient: (user, prisoner) => isInUsersCaseLoad(prisoner.supportingPrisonId, user)
1073
+ ? exports.PermissionCheckStatus.OK
1074
+ : exports.PermissionCheckStatus.RESTRICTED_PATIENT,
1075
+ ifReleasedPrisoner: () => exports.PermissionCheckStatus.PRISONER_IS_RELEASED,
1076
+ ifTransferringPrisoner: () => exports.PermissionCheckStatus.PRISONER_IS_TRANSFERRING,
1077
+ ifPrisonNotInCaseload: () => exports.PermissionCheckStatus.NOT_IN_CASELOAD,
1078
+ });
1079
+
1071
1080
  const dietEditCheck = inActiveCaseLoadAndUserHasRole(exports.Role.DietAndAllergiesEdit);
1072
1081
 
1073
1082
  function personHealthAndMedicationCheck(context) {
@@ -1077,7 +1086,7 @@ function personHealthAndMedicationCheck(context) {
1077
1086
  ...check(exports.PersonHealthAndMedicationPermission.edit_pregnancy, prisonerProfileEditCheck),
1078
1087
  ...check(exports.PersonHealthAndMedicationPermission.read_smoker, baseCheck),
1079
1088
  ...check(exports.PersonHealthAndMedicationPermission.edit_smoker, prisonerProfileEditCheck),
1080
- ...check(exports.PersonHealthAndMedicationPermission.read_diet, baseCheck),
1089
+ ...check(exports.PersonHealthAndMedicationPermission.read_diet, dietReadCheck),
1081
1090
  ...check(exports.PersonHealthAndMedicationPermission.edit_diet, dietEditCheck),
1082
1091
  };
1083
1092
  }
@@ -1256,10 +1265,7 @@ class PermissionsService {
1256
1265
  prisoner,
1257
1266
  requestDependentOn,
1258
1267
  });
1259
- if (requestDependentOn.length > 0) {
1260
- return this.upgradePermissionsFromDuplicateRecords(prisoner, prisonerPermissions, duplicateRecords, user, requestDependentOn);
1261
- }
1262
- return prisonerPermissions;
1268
+ return this.upgradePermissionsFromDuplicateRecords(prisoner, prisonerPermissions, duplicateRecords, user, requestDependentOn);
1263
1269
  }
1264
1270
  calculatePrisonerPermissions({ user, prisoner, requestDependentOn, readOnly = false, }) {
1265
1271
  const context = {