Skip to content

Commit

Permalink
task/wp-385-386-multiple-submitter-codes-for-listing (#249)
Browse files Browse the repository at this point in the history
* task/wp-386-386-multiple-submitter-codes-for-listing

* Updated links on exception forms

* Adjusted query

* Removing duplicate modal changes from Garrett's PR to avoid
merge conflicts

* Update apcd-cms/src/apps/submitter_renewals_listing/views.py

---------

Co-authored-by: edmondsgarrett <[email protected]>
  • Loading branch information
sophia-massie and edmondsgarrett authored Nov 10, 2023
1 parent d7da1f2 commit 1836fbf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1>Other Exception Request</h1>
eligible for an exception to certain data submission requirements under H.B. 2090 (87(R))
and associated regulations. Please review the legislation and regulation before
submitting this form. Links to both can be found on the
<a href="https://sph.uth.edu/research/centers/chcd/apcd/" target="_blank">Texas All-Payor Claims Database
<a href="https://sph.uth.edu/research/centers/center-for-health-care-data/texas-all-payor-claims-database/index.htm" target="_blank">Texas All-Payor Claims Database
website.</a>
</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1>Threshold Exception Request</h1>
eligible for an exception to certain data submission requirements under H.B. 2090 (87(R))
and associated regulations. Please review the legislation and regulation before
submitting this form. Links to both can be found on the
<a href="https://sph.uth.edu/research/centers/chcd/apcd/#TID-44be0947-bee9-41b1-b81a-ddea0b971e14-3" target="_blank">Texas All-Payor Claims Database
<a href="https://sph.uth.edu/research/centers/center-for-health-care-data/texas-all-payor-claims-database/index.htm" target="_blank">Texas All-Payor Claims Database
website.</a>
</p>
<div class="forms">
Expand Down
46 changes: 29 additions & 17 deletions apcd-cms/src/apps/submitter_renewals_listing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@ class SubmittersTable(RegistrationsTable):
def get(self, request, *args, **kwargs):
try:
response = get_submitter_code(request.user)
submitter_code = response.content
data = json.loads(submitter_code)
submitter_code = data['submitter_code']
registrations_content = get_registrations(submitter_code=submitter_code)
submitter_code = json.loads(response.content)['submitter_code']
registrations_content = []
registrations_entities = []
registrations_contacts = []
for reg in registrations_content:
reg_id = int(reg[0])
registrations_entities.append(get_registration_entities(reg_id=reg_id)) # get entities and contacts for reg id's
registrations_contacts.append(get_registration_contacts(reg_id=reg_id)) # we have already verified are associated w/ given submitter code
registrations_entities = get_registration_entities(submitter_code=submitter_code)
registrations_contacts = get_registration_contacts(submitter_code=submitter_code)
registration_list = get_registrations(submitter_code=submitter_code)
for registration in registration_list:
registrations_content.append(registration)
context = self.get_context_data(registrations_content, registrations_entities, registrations_contacts, *args,**kwargs)
template = loader.get_template(self.template_name)
return HttpResponse(template.render(context, request))
except:
except Exception as e:
logger.error("An error occurred: %s", str(e))
context = super(RegistrationsTable, self).get_context_data(*args, **kwargs)
template = loader.get_template('submitter_listing_error.html')
return HttpResponse(template.render(context, request))
Expand All @@ -40,14 +36,30 @@ def dispatch(self, request, *args, **kwargs):
return super(SubmittersTable, self).dispatch(request, *args, **kwargs)

def get_context_data(self, registrations_content, registrations_entities, registrations_contacts, *args, **kwargs):
context = super().get_context_data(registrations_content, registrations_entities, registrations_contacts, *args, **kwargs)
context['header'] = ['Business Name', 'Year', 'Type', 'Location', 'Registration Status', 'Actions']
context['pagination_url_namespaces'] = 'register:submitter_regis_table'
return context
registrations_entities = []
registrations_contacts = []
try:
for registration in registrations_content:
reg_id = registration[0]
contacts = get_registration_contacts(reg_id=reg_id)
entity = get_registration_entities(reg_id=reg_id)
for c in contacts:
registrations_contacts.append(c)
for e in entity:
registrations_entities.append(e)
context = super().get_context_data(registrations_content, registrations_entities, registrations_contacts, *args, **kwargs)
context['header'] = ['Business Name', 'Year', 'Type', 'Location', 'Registration Status', 'Actions']
context['pagination_url_namespaces'] = 'register:submitter_regis_table'
return context
except Exception as e:
logger.error("A context error occurred: %s", str(e))
context = super(RegistrationsTable, self).get_context_data(*args, **kwargs)
return context


def get_submitter_code(request):
submitter = get_submitter_info(str(request))
submitter_codes = []
for i in submitter:
submitter_code = i[1]
return JsonResponse(({'submitter_code' : submitter_code} if submitter_code else ""), safe=False)
submitter_codes.append(i[1])
return JsonResponse({'submitter_code' : submitter_codes} if submitter_codes else [], safe=False)
4 changes: 2 additions & 2 deletions apcd-cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def get_registrations(reg_id=None, submitter_code=None):
registrations.registration_year
FROM registrations
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
{f"LEFT JOIN registration_submitters on registrations.registration_id = registration_submitters.registration_id LEFT JOIN submitters ON registration_submitters.submitter_id = submitters.submitter_id WHERE submitter_code = '{str(submitter_code)}' ORDER BY registrations.registration_id" if submitter_code is not None else ''}"""
{f"LEFT JOIN registration_submitters on registrations.registration_id = registration_submitters.registration_id LEFT JOIN submitters ON registration_submitters.submitter_id = submitters.submitter_id WHERE submitter_code = ANY(%s) ORDER BY registrations.registration_id" if submitter_code is not None else ''}"""
cur = conn.cursor()
cur.execute(query)
cur.execute(query, (submitter_code,))
return cur.fetchall()

except Exception as error:
Expand Down

0 comments on commit 1836fbf

Please sign in to comment.