+ {% for error in form.services.errors %}
+ {{error}}
+ {% endfor %}
+
+
+
Documents held
From 30afbf8b2d858589691f6abfcd5ed2d2c542756e Mon Sep 17 00:00:00 2001
From: Bea <66849242+beawitcht@users.noreply.github.com>
Date: Thu, 28 Mar 2024 15:22:15 +0000
Subject: [PATCH 02/15] youth changes progress
Changes:
- Updates GIC options for youth services
- service dropdown now filters relevant GIC options based on selections
---
app/forms/GICs.json | 2 +-
app/forms/input_form.py | 6 ++--
app/scripts/gics.py | 24 +++++++++-----
app/static/js/transinformed.js | 50 +++++++++++++++++++++++++-----
app/static/js/transinformed.min.js | 2 +-
app/templates/base.html | 2 +-
6 files changed, 65 insertions(+), 21 deletions(-)
diff --git a/app/forms/GICs.json b/app/forms/GICs.json
index a5555eb..f82584a 100644
--- a/app/forms/GICs.json
+++ b/app/forms/GICs.json
@@ -1 +1 @@
-{"GICs": [["Wales", "Welsh Gender Service - Cardiff - Wait time (months): 15"], ["Scotland", "Edinburgh Chalmers Centre - Wait time (months): 23"], ["England", "Nottingham Centre for Transgender Health - Wait time (months): 23"], ["Scotland", "Grampian - Wait time (months): 24"], ["Scotland", "Inverness Highland Sexual Health - Wait time (months): 29"], ["England", "Northants Northamptonshire Healthcare Trust - Wait time (months): 53"], ["Scotland", "Glasgow Sandyford - Wait time (months): 55"], ["England", "Leeds and York Partnership Trust - Wait time (months): 57"], ["Northern Ireland", "Belfast Brackenburn Clinic - Wait time (months): 59"], ["England", "London Tavistock and Portman Trust - Wait time (months): 60"], ["England", "Sheffield Porterbrook Clinic - Wait time (months): 62"], ["England", "Exeter Devon Partnership Trust - Wait time (months): 87"]]}
+{"GICs": [["Y-England", "National Referral Support Service - Wait time: 5 years"], ["Y-Wales", "National Referral Support Service - Wait time: 5 years"], ["Wales", "Welsh Gender Service - Cardiff - Wait time (months): 15"], ["Scotland", "Edinburgh Chalmers Centre - Wait time (months): 23"], ["England", "Nottingham Centre for Transgender Health - Wait time (months): 23"], ["Y-Northern Ireland", "Belfast KOI - Wait time (months): 24"], ["Scotland", "Grampian - Wait time (months): 24"], ["Scotland", "Inverness Highland Sexual Health - Wait time (months): 29"], ["Y-Scotland", "Glasgow Youth Sandyford - Wait time (months): 42"], ["England", "Northants Northamptonshire Healthcare Trust - Wait time (months): 53"], ["Scotland", "Glasgow Sandyford - Wait time (months): 55"], ["England", "Leeds and York Partnership Trust - Wait time (months): 57"], ["Northern Ireland", "Belfast Brackenburn Clinic - Wait time (months): 59"], ["England", "London Tavistock and Portman Trust - Wait time (months): 60"], ["England", "Sheffield Porterbrook Clinic - Wait time (months): 62"], ["England", "Exeter Devon Partnership Trust - Wait time (months): 87"]]}
\ No newline at end of file
diff --git a/app/forms/input_form.py b/app/forms/input_form.py
index 30e43a8..389f5dc 100644
--- a/app/forms/input_form.py
+++ b/app/forms/input_form.py
@@ -14,7 +14,7 @@
gic_options = [(country, clinic.replace('nan', 'Unknown')) for country, clinic in gic_options]
# change NaN's to Unknown
-gic_options.insert(0,("0", "Select a country to see GICs"))
+gic_options.insert(0,("0", "Select a country and service to see GICs"))
gic_options.insert(1,("1", "I don't have a preferred clinic"))
# import options for Private HRT providers
@@ -27,8 +27,8 @@
class InputForm(FlaskForm):
countries = SelectField("Country", choices=['Choose...','England', 'Northern Ireland', 'Scotland', 'Wales'], validators=[
DataRequired(), AnyOf(['England', 'Northern Ireland', 'Scotland', 'Wales'], message="Please select a country")])
- services = SelectField("Services", choices=['Choose...','Adult', 'Youth'], validators=[
- DataRequired(), AnyOf(['Adult', 'Youth'], message="Please select adult or youth services")])
+ services = SelectField("Services", choices=['Choose...','Adult (17+)', 'Youth (≤16)'], validators=[
+ DataRequired(), AnyOf(['Adult (17+)', 'Youth (≤16)'], message="Please select adult or youth services")])
self_med = BooleanField("I am self medicating")
self_med_likely = BooleanField("I am likely to start self medicating")
no_self_med = BooleanField("I am not currently or likely to start self medicating")
diff --git a/app/scripts/gics.py b/app/scripts/gics.py
index 244503f..b3ceb7d 100644
--- a/app/scripts/gics.py
+++ b/app/scripts/gics.py
@@ -35,7 +35,10 @@ async def on_ready():
df['Service'] = df['Service'].map(lambda x: x[:-len("more info")])
df['Service'] = df['Service'].map(lambda x: x.strip())
-
+# get youth wait times for England and Wales
+youth_table = pd.read_html(url, match="Longest wait")
+youth_df = youth_table[0]
+youth_times = youth_df["Longest wait"][0]
# Map names to full names
name_mappings = {
"Belfast": "Belfast Brackenburn Clinic",
@@ -59,7 +62,8 @@ async def on_ready():
country = ""
service = row['Service']
to_be_seen = row['To beseen(in months)']
-
+ youth_services = ["GIDS", "KOI", "Youth", "Hub"]
+
# Determine the country based on the service name
if "Belfast" in service:
country = "Northern Ireland"
@@ -69,21 +73,27 @@ async def on_ready():
country = "Scotland"
else:
country = "England"
+
+ # Determine if youth service
+ for identifier in youth_services:
+ if identifier in service:
+ country = "Y-" + country
if "Not accepting new patients" not in str(to_be_seen):
options.append((country, f"{service} - Wait time (months): {to_be_seen}" if pd.notna(to_be_seen) else f"{service} - Wait time (months): Unknown"))
-# # Filter out under 18 services
-# youth_services = ["GIDS", "KOI", "Youth", "Hub"]
-# options = [gic for gic in options if all(service not in gic[1] for service in youth_services)]
-# Filter services not taking referrals from GP/self
-invalid_services = ["London TransPlus"]
+
+# Filter services not taking new referrals from GP/self
+invalid_services = ["London TransPlus", "The Northern Hub", "The Southern Hub"]
options = [gic for gic in options if all(service not in gic[1] for service in invalid_services)]
# filter out < > from options
options = [(country, re.sub(r'<|>', '', option)) for country, option in options]
+# Add NRSS or the very concise name: NATIONAL REFERRAL SUPPORT SERVICE FOR THE NHS GENDER INCONGRUENCE SERVICE FOR CHILDREN AND YOUNG PEOPLE
+options.append(("Y-England", f"National Referral Support Service - Wait time: {youth_times}"))
+options.append(("Y-Wales", f"National Referral Support Service - Wait time: {youth_times}"))
# Sort options by months remaining
options = sorted(options, key=lambda x: int(re.search(r'\d+', str(x[1].split(': ')[1] if len(x) == 2 and 'Unknown' not in x[1] else '0')).group()))
diff --git a/app/static/js/transinformed.js b/app/static/js/transinformed.js
index 925732b..af396a3 100644
--- a/app/static/js/transinformed.js
+++ b/app/static/js/transinformed.js
@@ -2,8 +2,11 @@ window.addEventListener('load', function () {
revealContent();
privateProviderConditions();
countryFilters();
+ serviceFilters();
// Countries dropdown
document.getElementById('countries').addEventListener('change', countryFilters);
+ // Services dropdown
+ document.getElementById('services').addEventListener('change', serviceFilters);
// Medication Status
document.getElementById('selfMedCheck').addEventListener('click', checkboxStatus);
document.getElementById('likelyMedCheck').addEventListener('click', checkboxStatus);
@@ -93,10 +96,11 @@ function checkboxStatus() {
function disableButtonsLogic(){
var countriesSelect = document.getElementById("countries");
+ var servicesSelect = document.getElementById("services");
let docx = document.getElementById("docx")
let pdf = document.getElementById("pdf")
- // Only allow submission when a country is selected
- if (countriesSelect.value !== "Choose...") {
+ // Only allow submission when a country and service is selected
+ if (countriesSelect.value !== "Choose..." && servicesSelect.value !== "Choose...") {
docx.disabled = false;
if (pdf.innerText !== "PDF Unavailable") {
pdf.disabled = false;
@@ -113,31 +117,61 @@ function countryFilters() {
var countriesSelect = document.getElementById("countries");
var selectedCountry = countriesSelect.value;
+ var servicesSelect = document.getElementById("services");
+ var selectedService = servicesSelect.value;
+
// Only allow submission when a country is selected
disableButtonsLogic();
// Define a mapping between countries and their corresponding GIC options
- var countryGICMapping = {
- "England": ["England"],
- "Northern Ireland": ["Northern Ireland"],
- "Scotland": ["Scotland"],
- "Wales": ["Wales"]
- };
+ if (selectedService == "Youth (≤16)") {
+ var countryGICMapping = {
+ "Y-England": ["Y-England"],
+ "Y-Northern Ireland": ["Y-Northern Ireland"],
+ "Y-Scotland": ["Y-Scotland"],
+ "Y-Wales": ["Y-Wales"]
+ };
+ } else {
+ var countryGICMapping = {
+ "England": ["England"],
+ "Northern Ireland": ["Northern Ireland"],
+ "Scotland": ["Scotland"],
+ "Wales": ["Wales"]
+ };
+ }
+
// Filter valid GICs based on country
$("#gics").val(0).change();
// Hide all country options initially
+
+ $("#gics option[value='Y-England'], #gics option[value='Y-Northern Ireland'], #gics option[value='Y-Scotland'], #gics option[value='Y-Wales']").hide();
+
$("#gics option[value='England'], #gics option[value='Northern Ireland'], #gics option[value='Scotland'], #gics option[value='Wales']").hide();
+
+
// Show the options related to the selected country
if (countryGICMapping[selectedCountry]) {
countryGICMapping[selectedCountry].forEach(option => {
$("#gics option[value='" + option + "']").show();
});
+ } else if (countryGICMapping["Y-" + selectedCountry]) {
+ countryGICMapping["Y-" + selectedCountry].forEach(option => {
+ $("#gics option[value='" + option + "']").show();
+ });
+
} else {
$("#gics option[value='countryNeeded']").show();
}
+
+}
+
+function serviceFilters() {
+ countryFilters();
+
+ // TODO: update youth options available
}
function revealContent() {
diff --git a/app/static/js/transinformed.min.js b/app/static/js/transinformed.min.js
index 2575461..bc82a1c 100644
--- a/app/static/js/transinformed.min.js
+++ b/app/static/js/transinformed.min.js
@@ -1 +1 @@
-function checkboxStatus(){var e=document.getElementById("selfMedCheck"),t=document.getElementById("likelyMedCheck"),d=document.getElementById("bridgingDesired"),n=document.getElementById("bridgingDesiredLabel"),i=document.getElementById("noMedCheck"),c=document.getElementById("diagnosisCheck"),a=document.getElementById("hrtCheck"),o=document.getElementById("noDocCheck"),s=document.getElementById("immigrationCheck"),l=document.getElementById("immigrationLetterCheck");i.checked&&(d.disabled=!0,d.innerHTML="I)"),c.checked||a.checked?o.disabled=!0:o.disabled=!1,o.checked?(c.disabled=!0,a.disabled=!0):(c.disabled=!1,a.disabled=!1),!e.checked&&!t.checked||a.checked||i.checked?(d.disabled=!0,d.checked=!1,n.innerHTML="I need a bridging prescription (invalid medication status for bridging)"):(d.disabled=!1,n.innerHTML="I need a bridging prescription"),a.checked&&(d.disabled=!0,d.checked=!1,n.innerHTML="I need a bridging prescription (invalid document status for bridging)"),0!==$(".med-status-check:checked").length||a.checked||(d.disabled=!0,d.checked=!1,n.innerHTML="I need a bridging prescription (select medication status)"),e.checked?(t.disabled=!0,i.disabled=!0):t.checked?(e.disabled=!0,i.disabled=!0):i.checked?(e.disabled=!0,t.disabled=!0):(e.disabled=!1,t.disabled=!1,i.disabled=!1),s.checked||(l.checked=!1)}function disableButtonsLogic(){var e=document.getElementById("countries");let t=document.getElementById("docx"),d=document.getElementById("pdf");"Choose..."!==e.value?(t.disabled=!1,"PDF Unavailable"!==d.innerText&&(d.disabled=!1)):(t.disabled=!0,d.disabled=!0)}function countryFilters(){var e=document.getElementById("countries").value;disableButtonsLogic();var t={England:["England"],"Northern Ireland":["Northern Ireland"],Scotland:["Scotland"],Wales:["Wales"]};$("#gics").val(0).change(),$("#gics option[value='England'], #gics option[value='Northern Ireland'], #gics option[value='Scotland'], #gics option[value='Wales']").hide(),t[e]?t[e].forEach((e=>{$("#gics option[value='"+e+"']").show()})):$("#gics option[value='countryNeeded']").show()}function revealContent(){var e=document.getElementById("referralCheck"),t=document.getElementById("sharedCareCheck"),d=document.getElementById("gicSelector"),n=document.getElementById("privateSelector"),i=document.getElementById("immigrationCheck"),c=document.getElementById("immigrationOption");e.checked?d.hidden=!1:d.hidden=!0,t.checked?n.hidden=!1:n.hidden=!0,i.checked?c.hidden=!1:c.hidden=!0}function privateProviderConditions(){var e=document.getElementById("privateProviderList"),t=document.getElementById("notUK"),d=document.getElementById("preferred");"GenderGP"===e.value?(e.classList.remove("is-valid"),e.classList.add("is-invalid"),t.innerText="This provider is not based in the UK, which deters some GPs from agreeing to shared care."):e.value.includes("Other")||e.value.includes("haven't chosen")?(e.classList.remove("is-invalid"),e.classList.remove("is-valid"),d.innerText="",t.innerText=""):(e.classList.remove("is-invalid"),e.classList.add("is-valid"),d.innerText="This provider offers GMC registered and UK based specialists.")}function submitActionsDocx(){$(this).append(' '),$("#generationForm").removeProp("target"),submitActions()}function submitActionsPdf(){$(this).append(' '),$("#generationForm").prop({target:"_blank"}),submitActions()}function submitActions(){"0"!==gics.value&&"1"!==gics.value&&$("#gics :selected").val($("#gics :selected").text()),document.getElementById("generationForm").submit();const e=document.getElementById("alertPlaceholder"),t=document.createElement("div");t.innerHTML=['
','
Thank you for using our document generator, if you found this service useful please consider donating so that we can maintain this service.
',' ',"
"].join(""),e.append(t)}window.addEventListener("load",(function(){revealContent(),privateProviderConditions(),countryFilters(),document.getElementById("countries").addEventListener("change",countryFilters),document.getElementById("selfMedCheck").addEventListener("click",checkboxStatus),document.getElementById("likelyMedCheck").addEventListener("click",checkboxStatus),document.getElementById("noMedCheck").addEventListener("click",checkboxStatus),document.getElementById("diagnosisCheck").addEventListener("click",checkboxStatus),document.getElementById("hrtCheck").addEventListener("click",checkboxStatus),document.getElementById("noDocCheck").addEventListener("click",checkboxStatus),document.getElementById("referralCheck").addEventListener("click",revealContent),document.getElementById("sharedCareCheck").addEventListener("click",revealContent),document.getElementById("privateProviderList").addEventListener("change",privateProviderConditions),document.getElementById("immigrationCheck").addEventListener("click",revealContent),document.getElementById("immigrationCheck").addEventListener("click",checkboxStatus),document.getElementById("docx").addEventListener("click",submitActionsDocx),document.getElementById("pdf").addEventListener("click",submitActionsPdf)}));
\ No newline at end of file
+function checkboxStatus(){var e=document.getElementById("selfMedCheck"),t=document.getElementById("likelyMedCheck"),n=document.getElementById("bridgingDesired"),d=document.getElementById("bridgingDesiredLabel"),i=document.getElementById("noMedCheck"),c=document.getElementById("diagnosisCheck"),o=document.getElementById("hrtCheck"),a=document.getElementById("noDocCheck"),s=document.getElementById("immigrationCheck"),l=document.getElementById("immigrationLetterCheck");i.checked&&(n.disabled=!0,n.innerHTML="I)"),c.checked||o.checked?a.disabled=!0:a.disabled=!1,a.checked?(c.disabled=!0,o.disabled=!0):(c.disabled=!1,o.disabled=!1),!e.checked&&!t.checked||o.checked||i.checked?(n.disabled=!0,n.checked=!1,d.innerHTML="I need a bridging prescription (invalid medication status for bridging)"):(n.disabled=!1,d.innerHTML="I need a bridging prescription"),o.checked&&(n.disabled=!0,n.checked=!1,d.innerHTML="I need a bridging prescription (invalid document status for bridging)"),0!==$(".med-status-check:checked").length||o.checked||(n.disabled=!0,n.checked=!1,d.innerHTML="I need a bridging prescription (select medication status)"),e.checked?(t.disabled=!0,i.disabled=!0):t.checked?(e.disabled=!0,i.disabled=!0):i.checked?(e.disabled=!0,t.disabled=!0):(e.disabled=!1,t.disabled=!1,i.disabled=!1),s.checked||(l.checked=!1)}function disableButtonsLogic(){var e=document.getElementById("countries"),t=document.getElementById("services");let n=document.getElementById("docx"),d=document.getElementById("pdf");"Choose..."!==e.value&&"Choose..."!==t.value?(n.disabled=!1,"PDF Unavailable"!==d.innerText&&(d.disabled=!1)):(n.disabled=!0,d.disabled=!0)}function countryFilters(){var e=document.getElementById("countries").value,t=document.getElementById("services").value;if(disableButtonsLogic(),"Youth (≤16)"==t)var n={"Y-England":["Y-England"],"Y-Northern Ireland":["Y-Northern Ireland"],"Y-Scotland":["Y-Scotland"],"Y-Wales":["Y-Wales"]};else n={England:["England"],"Northern Ireland":["Northern Ireland"],Scotland:["Scotland"],Wales:["Wales"]};$("#gics").val(0).change(),$("#gics option[value='Y-England'], #gics option[value='Y-Northern Ireland'], #gics option[value='Y-Scotland'], #gics option[value='Y-Wales']").hide(),$("#gics option[value='England'], #gics option[value='Northern Ireland'], #gics option[value='Scotland'], #gics option[value='Wales']").hide(),n[e]?n[e].forEach((e=>{$("#gics option[value='"+e+"']").show()})):n["Y-"+e]?n["Y-"+e].forEach((e=>{$("#gics option[value='"+e+"']").show()})):$("#gics option[value='countryNeeded']").show()}function serviceFilters(){countryFilters()}function revealContent(){var e=document.getElementById("referralCheck"),t=document.getElementById("sharedCareCheck"),n=document.getElementById("gicSelector"),d=document.getElementById("privateSelector"),i=document.getElementById("immigrationCheck"),c=document.getElementById("immigrationOption");e.checked?n.hidden=!1:n.hidden=!0,t.checked?d.hidden=!1:d.hidden=!0,i.checked?c.hidden=!1:c.hidden=!0}function privateProviderConditions(){var e=document.getElementById("privateProviderList"),t=document.getElementById("notUK"),n=document.getElementById("preferred");"GenderGP"===e.value?(e.classList.remove("is-valid"),e.classList.add("is-invalid"),t.innerText="This provider is not based in the UK, which deters some GPs from agreeing to shared care."):e.value.includes("Other")||e.value.includes("haven't chosen")?(e.classList.remove("is-invalid"),e.classList.remove("is-valid"),n.innerText="",t.innerText=""):(e.classList.remove("is-invalid"),e.classList.add("is-valid"),n.innerText="This provider offers GMC registered and UK based specialists.")}function submitActionsDocx(){$(this).append(' '),$("#generationForm").removeProp("target"),submitActions()}function submitActionsPdf(){$(this).append(' '),$("#generationForm").prop({target:"_blank"}),submitActions()}function submitActions(){"0"!==gics.value&&"1"!==gics.value&&$("#gics :selected").val($("#gics :selected").text()),document.getElementById("generationForm").submit();const e=document.getElementById("alertPlaceholder"),t=document.createElement("div");t.innerHTML=['
','
Thank you for using our document generator, if you found this service useful please consider donating so that we can maintain this service.
',' ',"
"].join(""),e.append(t)}window.addEventListener("load",(function(){revealContent(),privateProviderConditions(),countryFilters(),serviceFilters(),document.getElementById("countries").addEventListener("change",countryFilters),document.getElementById("services").addEventListener("change",serviceFilters),document.getElementById("selfMedCheck").addEventListener("click",checkboxStatus),document.getElementById("likelyMedCheck").addEventListener("click",checkboxStatus),document.getElementById("noMedCheck").addEventListener("click",checkboxStatus),document.getElementById("diagnosisCheck").addEventListener("click",checkboxStatus),document.getElementById("hrtCheck").addEventListener("click",checkboxStatus),document.getElementById("noDocCheck").addEventListener("click",checkboxStatus),document.getElementById("referralCheck").addEventListener("click",revealContent),document.getElementById("sharedCareCheck").addEventListener("click",revealContent),document.getElementById("privateProviderList").addEventListener("change",privateProviderConditions),document.getElementById("immigrationCheck").addEventListener("click",revealContent),document.getElementById("immigrationCheck").addEventListener("click",checkboxStatus),document.getElementById("docx").addEventListener("click",submitActionsDocx),document.getElementById("pdf").addEventListener("click",submitActionsPdf)}));
\ No newline at end of file
diff --git a/app/templates/base.html b/app/templates/base.html
index 1d11d0a..ecedba5 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -28,7 +28,7 @@