Skip to content

Commit 2f9cec5

Browse files
PR feedback
- removed blocksFuturePrivileges field from API request body - using enum for AA action against values - removed unneeded linter suppressions
1 parent 8caf19a commit 2f9cec5

File tree

13 files changed

+18
-49
lines changed

13 files changed

+18
-49
lines changed

backend/compact-connect/lambdas/python/common/cc_common/data_model/data_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from cc_common.data_model.schema import PrivilegeRecordSchema
1414
from cc_common.data_model.schema.adverse_action import AdverseActionData
1515
from cc_common.data_model.schema.base_record import SSNIndexRecordSchema
16-
from cc_common.data_model.schema.common import ActiveInactiveStatus, CompactEligibilityStatus
16+
from cc_common.data_model.schema.common import ActiveInactiveStatus, CompactEligibilityStatus, UpdateCategory
1717
from cc_common.data_model.schema.home_jurisdiction.record import ProviderHomeJurisdictionSelectionRecordSchema
1818
from cc_common.data_model.schema.license import LicenseData, LicenseUpdateData
1919
from cc_common.data_model.schema.military_affiliation.common import (
@@ -1018,7 +1018,7 @@ def encumber_privilege(self, adverse_action: AdverseActionData) -> None:
10181018
privilege_update_record = PrivilegeUpdateData.create_new(
10191019
{
10201020
'type': 'privilegeUpdate',
1021-
'updateType': 'encumbrance',
1021+
'updateType': UpdateCategory.ENCUMBRANCE,
10221022
'providerId': adverse_action.provider_id,
10231023
'compact': adverse_action.compact,
10241024
'jurisdiction': adverse_action.jurisdiction,

backend/compact-connect/lambdas/python/common/cc_common/data_model/provider_record_util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from enum import StrEnum
33

44
from cc_common.config import logger
5-
from cc_common.data_model.schema.common import ActiveInactiveStatus, CompactEligibilityStatus
5+
from cc_common.data_model.schema.common import ActiveInactiveStatus, AdverseActionAgainstEnum, CompactEligibilityStatus
66
from cc_common.data_model.schema.license.api import LicenseUpdatePreviousResponseSchema
77
from cc_common.data_model.schema.military_affiliation.common import MilitaryAffiliationStatus
88
from cc_common.data_model.schema.privilege.api import PrivilegeUpdatePreviousGeneralResponseSchema
@@ -146,8 +146,8 @@ def populate_provider_record(provider_id: str, license_record: dict, privilege_r
146146
}
147147
)
148148

149-
@classmethod
150-
def assemble_provider_records_into_object(cls, provider_records: list[dict]) -> dict:
149+
@staticmethod
150+
def assemble_provider_records_into_object(provider_records: list[dict]) -> dict:
151151
"""
152152
Assemble a list of provider records into a single object.
153153
@@ -193,9 +193,9 @@ def assemble_provider_records_into_object(cls, provider_records: list[dict]) ->
193193
privileges[f'{record["jurisdiction"]}-{record["licenseType"]}']['history'].append(record)
194194
case 'adverseAction':
195195
logger.debug('Identified adverse action record')
196-
if record['actionAgainst'] == 'privilege':
196+
if record['actionAgainst'] == AdverseActionAgainstEnum.PRIVILEGE:
197197
privileges[f'{record["jurisdiction"]}-{record["licenseType"]}']['adverseActions'].append(record)
198-
elif record['actionAgainst'] == 'license':
198+
elif record['actionAgainst'] == AdverseActionAgainstEnum.LICENSE:
199199
licenses[f'{record["jurisdiction"]}-{record["licenseType"]}']['adverseActions'].append(record)
200200

201201
if provider is None:

backend/compact-connect/lambdas/python/common/cc_common/data_model/schema/adverse_action/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ def action_against(self) -> str:
6565
def action_against(self, action_against_enum: AdverseActionAgainstEnum) -> None:
6666
self._data['actionAgainst'] = action_against_enum.value
6767

68-
@property
69-
def blocks_future_privileges(self) -> bool:
70-
return self._data['blocksFuturePrivileges']
71-
72-
@blocks_future_privileges.setter
73-
def blocks_future_privileges(self, value: bool) -> None:
74-
self._data['blocksFuturePrivileges'] = value
75-
7668
@property
7769
def clinical_privilege_action_category(self) -> str:
7870
return self._data['clinicalPrivilegeActionCategory']

backend/compact-connect/lambdas/python/common/cc_common/data_model/schema/adverse_action/api.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# ruff: noqa: N801, N815 invalid-name
2-
from marshmallow.fields import Boolean, Date, Raw, String
2+
from marshmallow.fields import Date, Raw, String
33
from marshmallow.validate import OneOf
44

55
from cc_common.data_model.schema.base_record import ForgivingSchema
6+
from cc_common.data_model.schema.common import AdverseActionAgainstEnum
67
from cc_common.data_model.schema.fields import ClinicalPrivilegeActionCategoryField, Compact, Jurisdiction
78

89

@@ -18,7 +19,6 @@ class AdverseActionPostRequestSchema(ForgivingSchema):
1819

1920
encumbranceEffectiveDate = Date(required=True, allow_none=False)
2021
clinicalPrivilegeActionCategory = ClinicalPrivilegeActionCategoryField(required=True, allow_none=False)
21-
blocksFuturePrivileges = Boolean(required=True, allow_none=False)
2222

2323

2424
class AdverseActionPublicResponseSchema(ForgivingSchema):
@@ -35,10 +35,9 @@ class AdverseActionPublicResponseSchema(ForgivingSchema):
3535
jurisdiction = Jurisdiction(required=True, allow_none=False)
3636
licenseTypeAbbreviation = String(required=True, allow_none=False)
3737
licenseType = String(required=True, allow_none=False)
38-
actionAgainst = String(required=True, allow_none=False, validate=OneOf(['privilege', 'license']))
38+
actionAgainst = String(required=True, allow_none=False, validate=OneOf([e for e in AdverseActionAgainstEnum]))
3939

4040
# Populated on creation
41-
blocksFuturePrivileges = Boolean(required=True, allow_none=False)
4241
creationEffectiveDate = Raw(required=True, allow_none=False)
4342
creationDate = Raw(required=True, allow_none=False)
4443
adverseActionId = Raw(required=True, allow_none=False)

backend/compact-connect/lambdas/python/common/cc_common/data_model/schema/adverse_action/record.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AdverseActionRecordSchema(BaseRecordSchema):
3030
actionAgainst = String(required=True, allow_none=False, validate=OneOf([e.value for e in AdverseActionAgainstEnum]))
3131

3232
# Populated on creation
33-
blocksFuturePrivileges = Boolean(required=True, allow_none=False)
33+
blocksFuturePrivileges = Boolean(required=True, allow_none=False, default=True)
3434
clinicalPrivilegeActionCategory = ClinicalPrivilegeActionCategoryField(required=True, allow_none=False)
3535
creationEffectiveDate = Date(required=True, allow_none=False)
3636
submittingUser = UUID(required=True, allow_none=False)
@@ -42,7 +42,7 @@ class AdverseActionRecordSchema(BaseRecordSchema):
4242
liftingUser = UUID(required=False, allow_none=False)
4343

4444
@pre_dump
45-
def generate_pk_sk(self, in_data, **_kwargs): # noqa: ARG001 unused-argument
45+
def generate_pk_sk(self, in_data, **_kwargs):
4646
in_data = self._populate_adverse_action_id(in_data)
4747
in_data['pk'] = f'{in_data["compact"]}#PROVIDER#{in_data["providerId"]}'
4848
# ensure this is passed in lowercase

backend/compact-connect/lambdas/python/common/cc_common/data_model/schema/base_record.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ class BaseRecordSchema(ForgivingSchema, ABC):
4747
type = String(required=True, allow_none=False)
4848

4949
@post_load
50-
def drop_base_gen_fields(self, in_data, **_kwargs): # noqa: ARG001 unused-argument
50+
def drop_base_gen_fields(self, in_data, **_kwargs):
5151
"""Drop the db-specific pk and sk fields before returning loaded data"""
5252
del in_data['pk']
5353
del in_data['sk']
5454
return in_data
5555

5656
@pre_dump
57-
def populate_type(self, in_data, **_kwargs): # noqa: ARG001 unused-argument
57+
def populate_type(self, in_data, **_kwargs):
5858
"""Populate db-specific fields before dumping to the database"""
5959
in_data['type'] = self._record_type
6060
return in_data
6161

6262
@pre_dump
63-
def populate_date_of_update(self, in_data, **_kwargs): # noqa: ARG001 unused-argument
63+
def populate_date_of_update(self, in_data, **_kwargs):
6464
"""Populate db-specific fields before dumping to the database"""
6565
# set the dateOfUpdate field to the current UTC time
6666
in_data['dateOfUpdate'] = config.current_standard_datetime
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"encumbranceEffectiveDate": "2023-01-15",
3-
"clinicalPrivilegeActionCategory": "Unsafe Practice or Substandard Care",
4-
"blocksFuturePrivileges": true
3+
"clinicalPrivilegeActionCategory": "Unsafe Practice or Substandard Care"
54
}

backend/compact-connect/lambdas/python/common/tests/unit/test_data_model/test_schema/test_adverse_action.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def test_adverse_action_data_class_getters_return_expected_values(self):
106106
self.assertEqual(adverse_action.jurisdiction, adverse_action_data['jurisdiction'])
107107
self.assertEqual(adverse_action.license_type_abbreviation, adverse_action_data['licenseTypeAbbreviation'])
108108
self.assertEqual(adverse_action.action_against, adverse_action_data['actionAgainst'])
109-
self.assertEqual(adverse_action.blocks_future_privileges, adverse_action_data['blocksFuturePrivileges'])
110109
self.assertEqual(
111110
adverse_action.clinical_privilege_action_category, adverse_action_data['clinicalPrivilegeActionCategory']
112111
)

backend/compact-connect/lambdas/python/provider-data-v1/handlers/encumbrance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def _generate_adverse_action_for_record_type(
8585
adverse_action.license_type_abbreviation = adverse_action_license_type_abbreviation
8686
adverse_action.license_type = adverse_action_license_type
8787
adverse_action.action_against = adverse_action_against_record_type
88-
adverse_action.blocks_future_privileges = adverse_action_request['blocksFuturePrivileges']
8988
adverse_action.clinical_privilege_action_category = ClinicalPrivilegeActionCategory(
9089
adverse_action_request['clinicalPrivilegeActionCategory']
9190
)

backend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_encumbrance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def _generate_test_body():
3131
return {
3232
'encumbranceEffectiveDate': TEST_ENCUMBRANCE_EFFECTIVE_DATE,
3333
'clinicalPrivilegeActionCategory': ClinicalPrivilegeActionCategory.UNSAFE_PRACTICE,
34-
'blocksFuturePrivileges': True,
3534
}
3635

3736

0 commit comments

Comments
 (0)