diff --git a/app/forms/GICs.json b/app/forms/GICs.json index 15e872a..61bcd08 100644 --- a/app/forms/GICs.json +++ b/app/forms/GICs.json @@ -1 +1 @@ -{"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"], ["Y-Northern Ireland", "Belfast KOI - Wait time (months): 24"], ["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"], ["Y-Scotland", "Glasgow Youth Sandyford - Wait time (months): 58"], ["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"]]} \ No newline at end of file +{"GICs": [["Wales", "Gender Identity Wales - Wait time (months): 15"], ["Scotland", "The Edinburgh Chalmers Gender Identity Clinic - Wait time (months): 23"], ["Y-Northern Ireland", "KOI (young people) - Wait time (months): 24"], ["England", "Nottinghamshire Healthcare NHS Foundation Trust The Nottingham Centre for Transgender Health - Wait time (months): 27"], ["Scotland", "Highland Gender Identity Service - Wait time (months): 29"], ["Scotland", "Grampian Gender Identity Clinic - Wait time (months): 34"], ["England", "Northamptonshire Healthcare NHS Foundation Trust Gender Identity Clinic - Wait time (months): 53"], ["Y-Scotland", "The Sandyford NHS Gender Identity Clinic (Young People) - Wait time (months): 58"], ["England", "Leeds and York Partnership NHS Foundation Trust Gender Identity Service - Wait time (months): 58"], ["England", "The\u00a0Tavistock and Portman NHS Foundation Trust: Gender Identity Clinic for Adults - Wait time (months): 61"], ["Scotland", "The Sandyford NHS Gender Identity Clinic (Adults) - Wait time (months): 65"], ["England", "Sheffield Health and Social Care NHS Foundation Trust Gender Identity Service - Wait time (months): 65"], ["Northern Ireland", "Brackenburn Clinic Gender Identity Service - Wait time (months): 75"], ["England", "Devon Partnership NHS Trust West of England Specialist Gender Identity Clinic - Wait time (months): 88"], ["Y-England", "National Referral Support Service - Wait time: Unknown"], ["Y-Wales", "National Referral Support Service - Wait time: Unknown"]]} \ No newline at end of file diff --git a/app/scripts/gics.py b/app/scripts/gics.py index b3ceb7d..8e22f5d 100644 --- a/app/scripts/gics.py +++ b/app/scripts/gics.py @@ -27,49 +27,37 @@ async def on_ready(): options = [] -url = "https://genderkit.org.uk/resources/wait-times" +url = "https://transactual.org.uk/medical-transition/gender-dysphoria-clinics/" pd.options.mode.chained_assignment = None # get table of wait times from Gender Kit table = pd.read_html(url, match="hormones") + df = table[0] -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", - "Cardiff": "Welsh Gender Service - Cardiff", - "Edinburgh": "Edinburgh Chalmers Centre", - "Exeter": "Exeter Devon Partnership Trust", - "Glasgow": "Glasgow Sandyford", - "Glasgow Youth": "Glasgow Youth Sandyford", - "Inverness": "Inverness Highland Sexual Health", - "Leeds": "Leeds and York Partnership Trust", - "London GIC": "London Tavistock and Portman Trust", - "London GIDS": "London GIDS Tavistock and Portman Trust", - "Newcastle": "Newcastle Northern Region Gender Dysphoria Service", - "Northants": "Northants Northamptonshire Healthcare Trust", - "Nottingham": "Nottingham Centre for Transgender Health", - "Sheffield": "Sheffield Porterbrook Clinic" -} -df['Service'] = df['Service'].map(lambda x: name_mappings.get(x, x)) +#set column names equal to values in row index position 0 +df.columns = df.iloc[0] + +#remove first row from DataFrame +df = df[1:] + +# format service names +df["Service"] = df["Service"].map(lambda x: x.split("–", 1)[1]) +df["Service"] = df["Service"].map(lambda x: x.strip()) + + +youth_times = df["To be seen (in months)"] for _, row in df.iterrows(): country = "" - service = row['Service'] - to_be_seen = row['To beseen(in months)'] - youth_services = ["GIDS", "KOI", "Youth", "Hub"] + service = row[0] + to_be_seen = row[1] + youth_services = ["Young People", "young people"] # Determine the country based on the service name - if "Belfast" in service: + if re.search(r"\b(Brackenburn|KOI)\b", service): country = "Northern Ireland" - elif "Cardiff" in service: + elif "Wales" in service: country = "Wales" - elif re.search(r"\b(Edinburgh|Glasgow|Grampian|Inverness)\b", service): + elif re.search(r"\b(Edinburgh|Glasgow|Grampian|Inverness|Sandyford|Highland)\b", service): country = "Scotland" else: country = "England" @@ -79,25 +67,24 @@ async def on_ready(): if identifier in service: country = "Y-" + country - if "Not accepting new patients" not in str(to_be_seen): + if "?" 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 services not taking new referrals from GP/self -invalid_services = ["London TransPlus", "The Northern Hub", "The Southern Hub"] +invalid_services = ["London TransPlus", "The Northern Hub", "The Southern Hub", "for under 18s, coming soon", "Indigo Gender Service (New style clinic)"] 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}")) +options.append(("Y-England", f"National Referral Support Service - Wait time: Unknown")) +options.append(("Y-Wales", f"National Referral Support Service - Wait time: Unknown")) # 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())) - +options.sort(key=lambda x: int(re.search(r'(\d+)', x[1]).group(0)) if "Unknown" not in x[1] else 9999) new_options = {"GICs": options} new_options = json.dumps(new_options)