Skip to content

Commit

Permalink
Merge pull request #299 from beawitcht/development
Browse files Browse the repository at this point in the history
Youth guidance featureset
  • Loading branch information
beawitcht authored May 10, 2024
2 parents a686048 + bf8c721 commit 8d67967
Show file tree
Hide file tree
Showing 22 changed files with 280 additions and 134 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3
if: ${{ matrix.language == 'javascript' || matrix.language == 'python' }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ 3.9 ]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion app/blueprints/blog_routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Blueprint, render_template, abort
from main import cache, entries
import urllib.parse


blog_bp = Blueprint('blog', __name__)
Expand All @@ -14,7 +15,7 @@ def blogs():
@cache.cached(timeout=60 * 60 * 24 * 7)
def blog(title):
for rss_blog in entries:
if rss_blog.url_title == title:
if rss_blog.url_title == urllib.parse.quote_plus(title):
blog_number = entries.index(rss_blog)
# return 404 if failed to match blog
try:
Expand Down
5 changes: 4 additions & 1 deletion app/docproc/populate_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def remove_wait_times(name):

def generate_document(context, filetype):
docx = BytesIO()
doc = DocxTemplate(path / 'templates' / 'template_v1_0.docx')
if context['under_16'] == True:
doc = DocxTemplate(path / 'templates' / 'under_16_template.docx')
else:
doc = DocxTemplate(path / 'templates' / 'template_v1_0.docx')
jinja_env = jinja2.Environment(autoescape=True)
jinja_env.filters['possessive'] = possessive
jinja_env.filters['format_gic'] = remove_wait_times
Expand Down
Binary file modified app/docproc/templates/template_v1_0.docx
Binary file not shown.
Binary file added app/docproc/templates/under_16_template.docx
Binary file not shown.
Binary file added app/docproc/templates/~$mplate_v1_0.docx
Binary file not shown.
2 changes: 2 additions & 0 deletions app/docproc/tests/test_populate_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def test_generate_doc_docx():

context = {
'countries': 'England',
'services': 'Adult (17+)',
'self_med': True,
'self_med_likely': False,
'formal_diagnosis': True,
Expand All @@ -25,6 +26,7 @@ def test_generate_doc_docx():
'bridging_desired': False,
'gic_referral': True,
'chosen_gic': 'Leeds - Wait time (months): 44',
'under_16': False,
'name': 'Bea',
'email': '[email protected]',
'phone': '1234567890',
Expand Down
2 changes: 1 addition & 1 deletion app/forms/GICs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"GICs": [["Wales", "Welsh Gender Service - Cardiff - Wait time (months): 15"], ["Scotland", "Edinburgh Chalmers Centre - Wait time (months): 23"], ["Scotland", "Grampian - Wait time (months): 24"], ["England", "Nottingham Centre for Transgender Health - Wait time (months): 27"], ["Scotland", "Inverness Highland Sexual Health - Wait time (months): 29"], ["England", "Northants Northamptonshire Healthcare Trust - Wait time (months): 53"], ["England", "Leeds and York Partnership Trust - Wait time (months): 58"], ["England", "London Tavistock and Portman Trust - Wait time (months): 61"], ["Scotland", "Glasgow Sandyford - Wait time (months): 65"], ["England", "Sheffield Porterbrook Clinic - Wait time (months): 65"], ["Northern Ireland", "Belfast Brackenburn Clinic - Wait time (months): 75"], ["England", "Exeter Devon Partnership Trust - Wait time (months): 88"]]}
{"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"]]}
5 changes: 4 additions & 1 deletion app/forms/input_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,9 +27,12 @@
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 (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")
under_16 = BooleanField("I am 15 or under")
no_fixed_address = BooleanField("I do not have any proof of address")
no_id_proof = BooleanField("I do not have any proof of identification")
private_prescription = BooleanField("I have a private prescription for HRT")
Expand Down
24 changes: 17 additions & 7 deletions app/scripts/gics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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()))
Expand Down
2 changes: 0 additions & 2 deletions app/static/js/jquery-3.6.3.min.js

This file was deleted.

1 change: 0 additions & 1 deletion app/static/js/jquery-3.6.3.min.map

This file was deleted.

2 changes: 2 additions & 0 deletions app/static/js/jquery-3.7.1.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/static/js/jquery-3.7.1.min.map

Large diffs are not rendered by default.

Loading

0 comments on commit 8d67967

Please sign in to comment.