From b5fd01bd4f1a012249624341a6d07099527551a5 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sat, 11 Feb 2023 18:17:19 +1100 Subject: [PATCH] Display treatment phase for restricted/authority benefits Issue #1 --- html/index.html | 9 ++++++++- import_pbs_xml.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/html/index.html b/html/index.html index 06bea9b..9f77680 100644 --- a/html/index.html +++ b/html/index.html @@ -170,11 +170,18 @@ span.innerText = '(' + restriction['num_criteria'] + ' criteria)'; li.appendChild(span); + // Render restriction content + let content = ''; + if (restriction['treatment_phase']) { + content += '

' + restriction['treatment_phase'] + '

' + } + 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 }); } diff --git a/import_pbs_xml.py b/import_pbs_xml.py index 2e3d8e8..c8cf51c 100755 --- a/import_pbs_xml.py +++ b/import_pbs_xml.py @@ -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)):