Display treatment phase for restricted/authority benefits

Issue #1
This commit is contained in:
RunasSudo 2023-02-11 18:17:19 +11:00
parent 16a47cbb3a
commit b5fd01bd4f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 17 additions and 3 deletions

View File

@ -170,11 +170,18 @@
span.innerText = '(' + restriction['num_criteria'] + ' criteria)';
li.appendChild(span);
// Render restriction content
let content = '';
if (restriction['treatment_phase']) {
content += '<p><i>' + restriction['treatment_phase'] + '</i></p>'
}
content += restriction['criteria_rendered'];
// Create popover for criteria
new bootstrap.Popover(span, {
trigger: 'hover focus',
title: restriction['indication'],
content: restriction['criteria_rendered'],
content: content,
html: true
});
}

View File

@ -43,7 +43,7 @@ cur.execute('DROP TABLE IF EXISTS pbs_item_restriction')
cur.execute('CREATE TABLE pbs_item_restriction (item_code TEXT, restriction_code INTEGER)')
cur.execute('DROP TABLE IF EXISTS pbs_restriction')
cur.execute('CREATE TABLE pbs_restriction (code INTEGER PRIMARY KEY, treatment_of INTEGER, indication TEXT, criteria_operator TEXT, criteria_rendered TEXT)')
cur.execute('CREATE TABLE pbs_restriction (code INTEGER PRIMARY KEY, treatment_of INTEGER, indication TEXT, treatment_phase TEXT, criteria_operator TEXT, criteria_rendered TEXT)')
cur.execute('DROP TABLE IF EXISTS pbs_restriction_criteria')
cur.execute('CREATE TABLE pbs_restriction_criteria (restriction_code INTEGER, criteria_code INTEGER)')
@ -194,6 +194,13 @@ for restriction_id in sorted(list(restrictions_to_parse)):
code = restriction.find('pbs:code[@rdf:resource="http://pbs.gov.au/code/restriction"]', ns).text
treatment_of = restriction.find('pbs:code[@rdf:resource="http://pbs.gov.au/code/treatment-of"]', ns).text
# Get treatment phase if any
treatment_phase = None
if treatment_phase_reference := restriction.find('pbs:treatment-phase-reference', ns):
treatment_phase_id = treatment_phase_reference.get('{http://www.w3.org/1999/xlink}href').lstrip('#')
treatment_phase_elem = root.find('pbs:prescribing-texts-list', ns).find('pbs:treatment-phase[@xml:id="' + treatment_phase_id + '"]', ns)
treatment_phase = treatment_phase_elem.find('pbs:preferred-term', ns).text
# Build the name of the indication (episodicity, severity, condition)
indication_id = restriction.find('pbs:indication-reference', ns).get('{http://www.w3.org/1999/xlink}href').lstrip('#')
indication = root.find('pbs:prescribing-texts-list', ns).find('pbs:indication[@xml:id="' + indication_id + '"]', ns)
@ -236,7 +243,7 @@ for restriction_id in sorted(list(restrictions_to_parse)):
else:
operator = None
cur.execute('INSERT INTO pbs_restriction (code, treatment_of, indication, criteria_operator) VALUES (?, ?, ?, ?)', (code, treatment_of, ' '.join(indication_strings), operator))
cur.execute('INSERT INTO pbs_restriction (code, treatment_of, indication, treatment_phase, criteria_operator) VALUES (?, ?, ?, ?, ?)', (code, treatment_of, ' '.join(indication_strings), treatment_phase, operator))
# Parse criteria
for criteria_id in sorted(list(criteria_to_parse)):