Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions apps/bb2_tools/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArchivedTokenStats,
DummyAdminObject,
UserStats,
SyntheticBeneficiaryFilter,
)
from apps.fhir.bluebutton.utils import get_patient_by_id

Expand Down Expand Up @@ -802,6 +803,30 @@ def changelist_view(self, request, extra_context=None):
return response


@admin.register(SyntheticBeneficiaryFilter)
class SyntheticBeneficiaryAdmin(admin.ModelAdmin):
# Add fields to display
list_display = (
"beneficiary_id",
"mbi_unhashed",
"medicaid_un",
"medicaid_pw",
"age",
"part_d_events_total",
)

advanced_filter_list = ()

list_filter = ('state',)

search_fields = (
"beneficiary_id",
"mbi_unhashed",
"medicaid_un",
"medicaid_pw",
)


class UserTypeFilter(admin.SimpleListFilter):
title = "User type"
parameter_name = "userprofile__type"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Generated by Django 4.2.17 on 2024-12-18 05:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('bb2_tools', '0003_delete_v2user'),
]

operations = [
migrations.CreateModel(
name='SyntheticBeneficiary',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('beneficiary_id', models.CharField(db_column='fhir_id', db_index=True, default=None, max_length=80, unique=True)),
('mbi_unhashed', models.CharField(db_column='user_mbi', db_index=True, default=None, max_length=11, unique=True, verbose_name='HASH of User MBI ID')),
('medicaid_un', models.TextField()),
('medicaid_pw', models.TextField()),
('age', models.IntegerField()),
('first_name', models.TextField()),
('last_name', models.TextField()),
('address_1', models.TextField()),
('address_2', models.TextField(blank=True, null=True)),
('city', models.TextField()),
('state', models.TextField()),
('postal_code', models.TextField()),
('part_d_contract_number', models.TextField(blank=True, null=True)),
('carrier_claims_total', models.IntegerField(default=0)),
('dme_claims_total', models.IntegerField(default=0)),
('hha_claims_total', models.IntegerField(default=0)),
('hospice_claims_total', models.IntegerField(default=0)),
('inpatient_claims_total', models.IntegerField(default=0)),
('outpatient_claims_total', models.IntegerField(default=0)),
('snf_claims_total', models.IntegerField(default=0)),
],
),
migrations.CreateModel(
name='SyntheticBeneficiaryFilter',
fields=[
],
options={
'verbose_name': 'Synthetic Beneficiary Filter',
'verbose_name_plural': 'Synthetic Beneficiary Filters',
'proxy': True,
'indexes': [],
'constraints': [],
},
bases=('bb2_tools.syntheticbeneficiary',),
),
]
58 changes: 58 additions & 0 deletions apps/bb2_tools/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.db import models
from oauth2_provider.models import AccessToken, RefreshToken

from apps.accounts.models import UserProfile
Expand Down Expand Up @@ -84,3 +85,60 @@ class Meta:
app_label = "bb2_tools"
verbose_name = "Application statistics"
verbose_name_plural = "Application statistics"


class SyntheticBeneficiary(models.Model):
beneficiary_id = models.CharField(
max_length=80,
null=False,
unique=True,
default=None,
db_column="fhir_id",
db_index=True,
)
mbi_unhashed = models.CharField(
max_length=11,
verbose_name="Unhashed MBI",
unique=True,
null=False,
default=None,
db_column="user_mbi",
db_index=True,
)
medicaid_un = models.TextField(null=False)
medicaid_pw = models.TextField(null=False)
age = models.IntegerField(null=False)
first_name = models.TextField(null=False)
last_name = models.TextField(null=False)
address_1 = models.TextField(null=False)
address_2 = models.TextField(blank=True, null=True)
city = models.TextField(null=False)
state = models.TextField(null=False)
postal_code = models.TextField(null=False)
part_d_contract_number = models.TextField(blank=True, null=True)
carrier_claims_total = models.IntegerField(default=0)
dme_claims_total = models.IntegerField(default=0)
hha_claims_total = models.IntegerField(default=0)
hospice_claims_total = models.IntegerField(default=0)
inpatient_claims_total = models.IntegerField(default=0)
outpatient_claims_total = models.IntegerField(default=0)
snf_claims_total = models.IntegerField(default=0)

@property
def part_d_events_total(self):
return self.carrier_claims_total + \
self.dme_claims_total + \
self.hha_claims_total + \
self.hospice_claims_total + \
self.inpatient_claims_total + \
self.outpatient_claims_total + \
self.snf_claims_total


class SyntheticBeneficiaryFilter(SyntheticBeneficiary):

class Meta:
proxy = True
app_label = "bb2_tools"
verbose_name = "Synthetic Beneficiary Filter"
verbose_name_plural = "Synthetic Beneficiary Filters"
18 changes: 18 additions & 0 deletions apps/dot_ext/migrations/0008_alter_application_data_access_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.17 on 2024-12-18 05:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dot_ext', '0007_merge_20231020_2004'),
]

operations = [
migrations.AlterField(
model_name='application',
name='data_access_type',
field=models.CharField(choices=[('ONE_TIME', 'ONE_TIME - No refresh token needed.'), ('RESEARCH_STUDY', 'RESEARCH_STUDY - No expiration.'), ('THIRTEEN_MONTH', 'THIRTEEN_MONTH - Access expires in 13-months.')], default='THIRTEEN_MONTH', max_length=16, null=True, verbose_name='Data Access Type:'),
),
]
1 change: 1 addition & 0 deletions hhs_oauth_server/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"rest_framework",
"rest_framework_csv",
"django_filters",
"advanced_filters",
# 1st Party (in-house) ----------
"apps.accounts",
"apps.capabilities",
Expand Down
Loading