Skip to content

Commit 1be7f8a

Browse files
bwang-icfsb-benohe
andauthored
Brandon/bb2 3951 saving unhashed mbi (#1352)
* testing changes * adding migration for mbi values * committing for now * removing unnecessary script files and just committing changes to store unhashed mbi * re-adding management * removing unnecessary migration * adding unhashed mbi to db * removing mbi from logs and including mbi in model * adding necessary alter migration back in * adding mbi to tests and db * adding mbi to archived crosswalk and removing test logic as it was causing errors in unit tests * adding mbi to archived crosswalk and removing test logic as it was causing errors in unit tests * manually removing test mbi references * cleanup * removing validation around ensuring same fhir id to allow for changes in refresh * removing unique constraint on fhir_id and modifying test accordingly * removing fhir_id unique constraint * Reverting fhir id changes and only adding mbi column changes --------- Co-authored-by: sb-benohe <71290292+sb-benohe@users.noreply.github.com>
1 parent b1b1f6c commit 1be7f8a

File tree

5 files changed

+83
-2
lines changed

5 files changed

+83
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.2.20 on 2025-06-30 22:56
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('bluebutton', '0004_createnewapplication_mycredentialingrequest'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='crosswalk',
15+
name='_user_mbi',
16+
field=models.CharField(db_index=True, default=None, max_length=11, null=True, verbose_name='Unhashed MBI'),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.2.20 on 2025-07-09 00:41
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('bluebutton', '0005_crosswalk__user_mbi'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='crosswalk',
15+
name='_user_mbi',
16+
field=models.CharField(db_column='user_mbi', db_index=True, default=None, max_length=11, null=True, verbose_name='Unhashed MBI'),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.2.20 on 2025-07-18 17:56
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('bluebutton', '0006_alter_crosswalk__user_mbi'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='archivedcrosswalk',
15+
name='_user_mbi',
16+
field=models.CharField(db_column='user_mbi', db_index=True, default=None, max_length=11, null=True, verbose_name='Unhashed MBI'),
17+
),
18+
]

apps/fhir/bluebutton/models.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,15 @@ class Crosswalk(models.Model):
119119
db_column="user_mbi_hash",
120120
db_index=True,
121121
)
122-
122+
# This stores the unhashed MBI value.
123+
_user_mbi = models.CharField(
124+
max_length=11,
125+
verbose_name="Unhashed MBI",
126+
null=True,
127+
default=None,
128+
db_column="user_mbi",
129+
db_index=True,
130+
)
123131
objects = models.Manager() # Default manager
124132
real_objects = RealCrosswalkManager() # Real bene manager
125133
synth_objects = SynthCrosswalkManager() # Synth bene manager
@@ -145,6 +153,10 @@ def user_hicn_hash(self):
145153
def user_mbi_hash(self):
146154
return self._user_mbi_hash
147155

156+
@property
157+
def user_mbi(self):
158+
return self._user_mbi
159+
148160
@user_hicn_hash.setter
149161
def user_hicn_hash(self, value):
150162
self._user_id_hash = value
@@ -153,6 +165,10 @@ def user_hicn_hash(self, value):
153165
def user_mbi_hash(self, value):
154166
self._user_mbi_hash = value
155167

168+
@user_mbi.setter
169+
def user_mbi(self, value):
170+
self._user_mbi = value
171+
156172

157173
class ArchivedCrosswalk(models.Model):
158174
"""
@@ -215,7 +231,15 @@ class ArchivedCrosswalk(models.Model):
215231
db_column="user_mbi_hash",
216232
db_index=True,
217233
)
218-
234+
# This stores the unhashed MBI value.
235+
_user_mbi = models.CharField(
236+
max_length=11,
237+
verbose_name="Unhashed MBI",
238+
null=True,
239+
default=None,
240+
db_column="user_mbi",
241+
db_index=True,
242+
)
219243
# Date/time that the Crosswalk instance was created
220244
date_created = models.DateTimeField()
221245

apps/mymedicare_cb/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def get_and_update_user(slsx_client: OAuth2ConfigSLSx, request=None):
3333
slsx_client = OAuth2ConfigSLSx encapsulates all slsx exchanges and user info values as listed below:
3434
subject = ID provider's sub or username
3535
mbi_hash = Previously hashed mbi
36+
mbi = Unhashed MBI from SLSx
3637
hicn_hash = Previously hashed hicn
3738
first_name
3839
last_name
@@ -125,6 +126,7 @@ def get_and_update_user(slsx_client: OAuth2ConfigSLSx, request=None):
125126
user.crosswalk.user_id_type = hash_lookup_type
126127
user.crosswalk.user_hicn_hash = slsx_client.hicn_hash
127128
user.crosswalk.user_mbi_hash = slsx_client.mbi_hash
129+
user.crosswalk.user_mbi = slsx_client.mbi
128130
user.crosswalk.save()
129131

130132
# Beneficiary has been successfully matched!
@@ -231,6 +233,7 @@ def create_beneficiary_record(slsx_client: OAuth2ConfigSLSx, fhir_id=None, user_
231233
user=user,
232234
user_hicn_hash=slsx_client.hicn_hash,
233235
user_mbi_hash=slsx_client.mbi_hash,
236+
user_mbi=slsx_client.mbi,
234237
fhir_id=fhir_id,
235238
user_id_type=user_id_type,
236239
)

0 commit comments

Comments
 (0)