Skip to content

Commit

Permalink
task/WP-204: Add type of plan checklist to registration entities (#204)
Browse files Browse the repository at this point in the history
* Add type of plans checklist to reg form

* add plans checklist to list styling

* Database portion - add fields to entity db functions, and add them to listing view

* Add plan list to view record modal
  • Loading branch information
edmondsgarrett authored Aug 30, 2023
1 parent 0d7dfe9 commit f836a69
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ <h5>Entity {{forloop.counter}}</h5>
<dd class="c-data-list__value">{{entity.license}}</dd>
<dt class="c-data-list__key">NAIC Company Code</dt>
<dd class="c-data-list__value">{{entity.naic}}</dd>
<h6>Type of Plan</h6>
<dd>
<dl class="c-data-list--is-vert c-data-list--is-wide">
<dt class="c-data-list__key">Types of Plans</dt>
{% for plan_type, plan_type_selected in entity.plans_type.items %}
{% if plan_type_selected %}
<dd class="c-data-list__value">{{plan_type}}</dd>
{% endif %}
{% endfor %}
</dl>
</dd>
<h6>File Submission</h6>
<dd>
<dl class="c-data-list--is-vert c-data-list--is-wide">
Expand Down
15 changes: 10 additions & 5 deletions apcd-cms/src/apps/admin_regis_table/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,17 @@ def _set_entities(reg_ent):
'no_covered': reg_ent[6],
'ent_name': reg_ent[7],
'fein': reg_ent[8] if reg_ent[8] else None,
'plans_type': {
"Commercial": reg_ent[9],
"Medicare": reg_ent[10],
"Medicaid": reg_ent[11],
},
'files_type': {
"Eligibility/Enrollment": reg_ent[9],
"Provider": reg_ent[10],
"Medical": reg_ent[11],
"Pharmacy": reg_ent[12],
"Dental": reg_ent[13]
"Eligibility/Enrollment": reg_ent[12],
"Provider": reg_ent[13],
"Medical": reg_ent[14],
"Pharmacy": reg_ent[15],
"Dental": reg_ent[16]
}
}
def _set_contacts(reg_cont):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ input[name^="contact_phone"] {
/* Field Layouts */

/* To make (radio/check)box sets take up less vertical space */
#types_of_files, #submission_method, #on-behalf-of {
#types_of_files, #types_of_plans, #submission_method, #on-behalf-of {
display: flex;
flex-wrap: wrap;
column-gap: 1em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,31 @@ <h5 id="entity_header_{{ent_no}}_{{r.reg_id}}">Entity {{ ent_no }}</h5>
</div>
</div>
</div>
<h6>Type of Plan</h6>
<div class="field-wrapper required">
<label>
Plan Types
</label>
</div>

<div class="field-wrapper checkboxselectmultiple required">
<div class="field-errors" style="display: none"></div>

<ul id="types_of_plans" class="checkboxselectmultiple">
{% for plan_type, plan_type_selected in entity.plans_type.items %}
<li>
<label for="types_of_plans_{{ plan_type|lower }}_{{ent_no}}_{{r.reg_id}}"
><input
type="checkbox"
name="types_of_plans_{{ plan_type|lower }}_{{ent_no}}_{{r.reg_id}}"
id="types_of_plans_{{ plan_type|lower }}_{{ent_no}}_{{r.reg_id}}"
{% if plan_type_selected %}checked{% endif %}
/>{{ plan_type }}</label
>
</li>
{% endfor %}
</ul>
</div>
<h6>File Submission</h6>
<div class="field-wrapper required">
<label>
Expand Down Expand Up @@ -554,6 +579,50 @@ <h4>
</div>
</div>
</div>
<h6>Type of Plan</h6>
<div class="field-wrapper required">
<label>
Plan Types<span class="asterisk">*</span>
</label>
</div>

<div class="field-wrapper checkboxselectmultiple required">
<div class="field-errors" style="display: none"></div>

<ul id="types_of_plans" class="checkboxselectmultiple">
<li>
<label for="types_of_plans_commercial_1"
><input
type="checkbox"
name="types_of_plans_commercial_1"
id="types_of_plans_commercial_1"
required
/>Commercial</label
>
</li>
<li>
<label for="types_of_plans_medicare_1"
><input
type="checkbox"
name="types_of_plans_medicare_1"
id="types_of_plans_medicare_1"
required
/>Medicare</label
>
</li>
<li>
<label for="types_of_plans_medicaid_1"
><input
type="checkbox"
name="types_of_plans_medicaid_1"
id="types_of_plans_medicaid_1"
required
/>Medicaid</label
>
</li>
</ul>
</div>

<h6>File Submission</h6>
<div class="field-wrapper required">
<label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@
}));
}
</script>
<script id="form-entity_plan_type-required">
function entityPlanTypeValidation(ent_no, reg_id) {
const planGroup = Array.from(
document.querySelectorAll(`
input[name=types_of_plans_commercial_${ent_no}${ reg_id ? `_${reg_id}`: ''}],
input[name=types_of_plans_medicare_${ent_no}${ reg_id ? `_${reg_id}`: ''}],
input[name=types_of_plans_medicaid_${ent_no}${ reg_id ? `_${reg_id}`: ''}]`)
);
planGroup.forEach(i => i.addEventListener('invalid', function (event) {
if (!event.target.checked) {
event.target.setCustomValidity('Please select at least one plan type.');
}
}));
planGroup.forEach(i => i.addEventListener('click', function (event) {
planGroup.forEach(j => {
j.required = true;
if (planGroup.some(input => input.checked)) { // if box checked, no other inputs in this group are required
j.setCustomValidity('');
j.required = false;
}
});
}));
}
</script>
{# To let user add and remove entities #}
{# RFE: Do not duplicate entity markup #}
{# IDEA: HTML template for any instance; used by markup for 0, JS for 1+ #}
Expand Down Expand Up @@ -67,6 +91,7 @@

for (let ent_no = 1; ent_no < entities + 1; ent_no +=1) {
entityIdGroupValidation(ent_no, reg_id); // add validation for entities already on form at page load
entityPlanTypeValidation(ent_no, reg_id);
};
btnStatus();

Expand Down Expand Up @@ -154,6 +179,49 @@
</div>
</div>
</div>
<h6>Type of Plan</h6>
<div class="field-wrapper required">
<label>
Plan Types<span class="asterisk">*</span>
</label>
</div>
<div class="field-wrapper checkboxselectmultiple required">
<div class="field-errors" style="display: none"></div>
<ul id="types_of_plans" class="checkboxselectmultiple">
<li>
<label for="types_of_plans_commercial_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
><input
type="checkbox"
name="types_of_plans_commercial_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
id="types_of_plans_commercial_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
required
/>Commercial</label
>
</li>
<li>
<label for="types_of_plans_medicare_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
><input
type="checkbox"
name="types_of_plans_medicare_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
id="types_of_plans_medicare_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
required
/>Medicare</label
>
</li>
<li>
<label for="types_of_plans_medicaid_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
><input
type="checkbox"
name="types_of_plans_medicaid_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
id="types_of_plans_medicaid_${entities}{% if r %}_{{r.reg_id}}{% endif %}"
required
/>Medicaid</label
>
</li>
</ul>
</div>
<h6>File Submission</h6>
<div class="field-wrapper required">
<label>
Expand Down Expand Up @@ -278,14 +346,8 @@ <h6>
</div>
</div>
`;
const inputs = Array.from(
document.querySelectorAll(`
input[name=fein_${entities}{% if r %}_{{r.reg_id}}{% endif %}],
input[name=license_number_${entities}{% if r %}_{{r.reg_id}}{% endif %}],
input[name=naic_company_code_${entities}{% if r %}_{{r.reg_id}}{% endif %}]
`)
);
entityIdGroupValidation(entities, reg_id); // add entity id validation for new entities on form
entityIdGroupValidation(entities, reg_id); // add entity input validation for new entities on form
entityPlanTypeValidation(entities, reg_id);

const addEntityNameInput = document.querySelectorAll(`input[name=entity_name_${entities}{% if r %}_{{r.reg_id}}{% endif %}]`);
noEmptyInputs(addEntityNameInput);
Expand Down
17 changes: 16 additions & 1 deletion apcd-cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ def get_registration_entities(reg_id=None):
registration_entities.total_covered_lives,
registration_entities.entity_name,
registration_entities.fein,
registration_entities.plan_coml,
registration_entities.plan_mdcr,
registration_entities.plan_mdcd,
registration_entities.file_me,
registration_entities.file_pv,
registration_entities.file_mc,
Expand Down Expand Up @@ -331,6 +334,9 @@ def create_registration_entity(form, reg_id, iteration, from_update_reg=None):
_set_int(form['total_covered_lives_{}'.format(str_end)]),
_clean_value(form['entity_name_{}'.format(str_end)]),
_clean_value(form['fein_{}'.format(str_end)]),
True if 'types_of_plans_commercial_{}'.format(str_end) in form else False,
True if 'types_of_plans_medicare_{}'.format(str_end) in form else False,
True if 'types_of_plans_medicaid_{}'.format(str_end) in form else False,
True,
True if 'types_of_files_provider_{}'.format(str_end) in form else False,
True if 'types_of_files_medical_{}'.format(str_end) in form else False,
Expand All @@ -347,12 +353,15 @@ def create_registration_entity(form, reg_id, iteration, from_update_reg=None):
total_covered_lives,
entity_name,
fein,
plan_coml,
plan_mdcr,
plan_mdcd,
file_me,
file_pv,
file_mc,
file_pc,
file_dc
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"""
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"""

conn = psycopg2.connect(
host=APCD_DB['host'],
Expand Down Expand Up @@ -397,6 +406,9 @@ def update_registration_entity(form, reg_id, iteration, no_entities):
_set_int(form['total_covered_lives_{}'.format(str_end)]),
_clean_value(form['entity_name_{}'.format(str_end)]),
_clean_value(form['fein_{}'.format(str_end)]),
True if 'types_of_plans_commercial_{}'.format(str_end) in form else False,
True if 'types_of_plans_medicare_{}'.format(str_end) in form else False,
True if 'types_of_plans_medicaid_{}'.format(str_end) in form else False,
True if 'types_of_files_provider_{}'.format(str_end) in form else False,
True if 'types_of_files_medical_{}'.format(str_end) in form else False,
True if 'types_of_files_pharmacy_{}'.format(str_end) in form else False,
Expand All @@ -421,6 +433,9 @@ def update_registration_entity(form, reg_id, iteration, no_entities):
total_covered_lives = %s,
entity_name = %s,
fein = %s,
plan_coml = %s,
plan_mdcr = %s,
plan_mdcd = %s,
file_pv = %s,
file_mc = %s,
file_pc = %s,
Expand Down

0 comments on commit f836a69

Please sign in to comment.