uk-fci / nhs-number

Python package to provide utilities for NHS Numbers, including validity checks, normalisation, and generation.
https://nhs-number.uk-fci.tech/
MIT License
6 stars 6 forks source link

Chi dob validation #38

Open andyatterton opened 5 months ago

andyatterton commented 5 months ago

Sorry duplicate PR, but I had aimed it at main instead of Dev hopefully this clears that up, and you can remove the other PR

Support for full CHI number validation and generation. Generate now uses synthetic numbers as the default.

I have removed all the warnings about the lack of support and adjusted the roadmap.

andylaw commented 5 months ago

This is failing unit test checks against Python 3.8, 3.9, 3.10 and 3.11. I hope that the tests did pass on previous commits. Regardless, that needs to be fixed.

andylaw commented 5 months ago

I also don't like the magic strings for male and female. Happy to debate that if someone wants to persuade me that this is me being unreasonable

andyatterton commented 5 months ago

This is failing unit test checks against Python 3.8, 3.9, 3.10 and 3.11. I hope that the tests did pass on previous commits. Regardless, that needs to be fixed.

Fix on it's way.

andyatterton commented 5 months ago

I also don't like the magic strings for male and female. Happy to debate that if someone wants to persuade me that this is me being unreasonable

Sorry saw this here and rolled with it. I have updated the PR to take is_male = True or is_female = True to indicate the sex being checked.

andylaw commented 5 months ago

@andyatterton - apologies. I still don't like the male/female thing. I didn't like @pacharanero's "male" string and your alternative double boolean suffers from the potential for both to be set to true. Whilst that might mitigate the current debate about how to manage CHI numbers for transgender and non-binary patients, I don't think it's appropriate.

I think I'd prefer a Gender Enum with two defined values (MALE and FEMALE) then use that as a single typed argument in the function signature. As I say, apologies for being picky - I don't want to blunt your enthusiasm

andyatterton commented 5 months ago

Please don't apologise, constructive feedback is always welcome and I have plenty of enthusiasm 😏

Included an enum. Once I get the all clear, I will fix the docs

andyatterton commented 5 months ago

@andylaw I was speaking to a colleague who suggested the enum might be better if the value of the enum were 1 and 2 rather than "MALE" and "FEMALE" to be in line with the way NHS digital record sex at birth. I agree with this but before I make the change I thought I would check in with you.

andylaw commented 5 months ago

@andyatterton - I was about to make the same suggestion to you 😃. Can you also, please, check in the CHI reference docs (I think we reference them somewhere in the code) to see if they use the word "Sex" or "Gender". There is already some controversy about how CHI numbers should be reallocated to non-binary and trans individuals and if we can tread the path of ultimate caution then we may save ourselves pain in the future. I'm afraid I can't remember what the terminology was from when I originally read the spec.

andyatterton commented 5 months ago

@andyatterton - I was about to make the same suggestion to you 😃. Can you also, please, check in the CHI reference docs (I think we reference them somewhere in the code) to see if they use the word "Sex" or "Gender". There is already some controversy about how CHI numbers should be reallocated to non-binary and trans individuals and if we can tread the path of ultimate caution then we may save ourselves pain in the future. I'm afraid I can't remember what the terminology was from when I originally read the spec.

I can not find a concrete answer to this, the link from the docs to the CHI numbers reference leads to an archived page and following the new link through to CHI numbers gets me here which is very nondescript. There is a further link to baby CHI which states CHI numbers are issued within three months of birth, so lends weight to the argument that the digit is sex assigned at birth.

NHS digital have some guidelines for recording gender, but also state that gender should not be confused with registered sex at birth.

Whilst looking at this I have seen a couple of articles discussing a change to the current system which all seem to quote from this, but again there is nothing official.

This article uses the term gender and assigned male/female at birth. It is concerned with screening inclusion as a result of CHI which again I think plays into sex, as it is focused on biological reason for testing.

I suppose my argument against labelling this field gender would be that NHS digital recognise that gender and registered sex at birth are separate items, CHI numbers are allocated within three months of birth and gender is non-binary so can not be modelled with a simple two digit system. I would say we move to gender once NHS Scotland provide a system by which to model that accurately.

Open to suggestions on this, as I'm far from an expert. Maybe we should contact NHS Digital for clarity, but it seems they may not be able to give us anything definitive.

eatyourpeas commented 5 months ago

My take on this, as someone who has works as a clinician in this space on the periphery, is that gender is social/societal construct and sex is a genetic state. In the world of disorders of sexual differentiation (DSD), a person might be born with an XY karyotype, but their phenotype may be ambiguous as a consequence of a variety of reasons - differential diagnosis here is often broad and needs multiple biochemical and radiological investigations to identify a cause. In these circumstances, in multidisciplinary meetings, gender is 'assigned' on the basis of clinical findings, surgical expectations, family wishes, biochemistry, diagnosis etc. Gender therefore is what goes on your birth certificate or passport, and may not be the same as your sex at birth. Gender, of course, can be reassigned also later on also at the request of individuals. I think that whilst many people of course identify as nonbinary or gender-fluid, this is not recognised at the present time in law - that is, it is not possible to have this reflected on a passport or driving license, I don't think.

For the purposes of this library I would argue that that decision would have been made before anyone used it - an official body would have assigned / reassigned someone's gender and that is what should be reflected in how the number is used? And for the moment, that is only male or female - as far as I understand, in any case.

VJ911 commented 5 months ago

AFAIK, it's sex at birth - which is taken as only binary. If at a later date, a change is requested, it results in issue of a new NHS number.

Disclaimer: that's what I recall. Don't know if that is still the current practice.

Side note: suggestion to use the NHS Data Dictionary ENUMs.

On Sun, 28 Apr 2024, 19:27 Andy Atterton, @.***> wrote:

@andyatterton https://github.com/andyatterton - I was about to make the same suggestion to you 😃. Can you also, please, check in the CHI reference docs (I think we reference them somewhere in the code) to see if they use the word "Sex" or "Gender". There is already some controversy about how CHI numbers should be reallocated to non-binary and trans individuals and if we can tread the path of ultimate caution then we may save ourselves pain in the future. I'm afraid I can't remember what the terminology was from when I originally read the spec.

I can not find a concrete answer to this, the link from the docs to the CHI numbers reference https://www.ndc.scot.nhs.uk/ leads to an archived page and following the new link through to CHI numbers gets me here https://publichealthscotland.scot/services/national-data-catalogue/data-dictionary/a-to-z-of-data-dictionary-terms/chi-number/?Search=C&ID=128&Title=CHI%20Number which is very nondescript. There is a further link to baby CHI https://publichealthscotland.scot/services/national-data-catalogue/data-dictionary/a-to-z-of-data-dictionary-terms/baby-chi-babies-1-to-3/ which states CHI numbers are issued within three months of birth, so lends weight to the argument that the digit is sex assigned at birth.

NHS digital have some guidelines https://digital.nhs.uk/data-and-information/data-collections-and-data-sets/data-sets/mental-health-services-data-set/submit-data/data-quality-of-protected-characteristics-and-other-vulnerable-groups/gender-identity for recording gender, but also state that gender should not be confused with registered sex at birth.

Whilst looking at this I have seen a couple of articles discussing a change to the current system which all seem to quote from this https://www.nss.nhs.scot/publications/foi-000084-requirements-for-processing-a-change-of-gender-and-title/foi-000084-requirements-for-processing-a-change-of-gender-and-title-html/, but again there is nothing official.

This article https://www.nhsinform.scot/healthy-living/screening/screening-information-for-the-transgender-community/ uses the term gender and assigned male/female at birth. It is concerned with screening inclusion as a result of CHI which again I think plays into sex, as it is focused on biological reason for testing.

I suppose my argument against labelling this field gender would be that NHS digital recognise that gender and registered sex at birth are separate items, CHI numbers are allocated within three months of birth and gender is non-binary so can not be modelled with a simple two digit system. I would say we move to gender once NHS Scotland provide a system by which to model that accurately.

Open to suggestions on this, as I'm far from an expert. Maybe we should contact NHS Digital for clarity, but it seems they may not be able to give us anything definitive.

— Reply to this email directly, view it on GitHub https://github.com/uk-fci/nhs-number/pull/38#issuecomment-2081441447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJCKE56HTJ3G4XFESV3WOTY7TMLDAVCNFSM6AAAAABGWVROY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBRGQ2DCNBUG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

andyatterton commented 5 months ago

PERSON STATED GENDER is self-declared, or inferred by observation for those unable to declare.

If a patient can changed their CHI number at will, but the original CHI number is issued based on observation, then this covers both bases. This could also future-proof us if NHS Scotland adopt the full spectrum of numbers to included 3: Non-binary.

Anyone against person stated gender?

andyatterton commented 5 months ago

I'm not sure if I should take the silence as agreement 😆

Just to say, I'm off on holiday for a couple of weeks from Friday, so I won't be contributing to this beyond then. If someone wants to pick it up in my absence, great, if not I will try and get this over the line once I am back.

pacharanero commented 5 months ago

Thanks @andyatterton and apologies for the radio silence. I've been pretty tied up with a range of things and have therefore been watching the conversation, with excellent and helpful contributions from @andylaw @eatyourpeas @VJ911 .

I'm happy for the sex to be handled as an ENUM, with values 1 and 2 as opposed to strings.

I would favour the use of SEX (essentially binary sex assigned at birth - or if officially reassigned legally, and a new CHI number issued, then this new sex) as opposed to GENDER (which is societal and far more complex/nuanced), unless CHI numbers publicly change their policy on what is meant to be used to determine odd/even assignement.

However since the design of the CHI number means there are only two options (can be odd number or even number) then it seems unlikely they will be technically able to get involved in the complex and sensitive world of multiple gender identity options.

It seems actually more likely that they would just drop having the odd/even indicator of sex in the CHI number, since it is likely just to cause more problems than it solves. (example)

andyatterton commented 5 months ago

PERSON PHENOTYPIC SEX

A classification of the observed sex of a PERSON, relating to the biological, physiological and physical characteristics that differentiate men and women, determined by endocrine influences.

PERSON PHENOTYPIC SEX is observed by a PERSON (such as a CARE PROFESSIONAL), and is not self-stated.

This is an official data definition from NHS digital concerning sex. The only sticking point for me is the not self-stated comment because (I forget where I read this now) all you need to do to change your CHI number is state that you want to.

@andylaw I'm afraid I'm no closer to finding something definitive in writing about the correct language to use. The phrase that keeps coming up time and again when talking about that digits is that it "identifies you as male or female" which doesn't help one way or the other.

George-D-S commented 5 months ago

(Disclaimer - Co-worker of Andy)

I would just keep things simple and go for 'sex'.

If this is holding things up though is there any wording along the lines of "CHI Person Type" that could be used where the variable is defined in terms of the CHI format without specifying in the code what exactly that means.

andylaw commented 5 months ago

(clarification - the "Andy" that @George-D-S refers to is @andyatterton , I think)

Agreed on keeping it simple. Let's stick with SEX in the absence of anything definitive to guide us away from the rocky shores of gender identity and politics.

andylaw commented 5 months ago

@andyatterton - failing test?

andylaw commented 5 months ago

@andyatterton - also, silence signifies both agreement and excessive real-life, paid employment workload :( I appreciate what you're doing here.

andyatterton commented 5 months ago

@andyatterton - failing test?

ooopps, sorted that. Enums now 1 and 2. Think it's ready to go

andylaw commented 5 months ago

@andyatterton - apologies: the usage.md documentation around the Sex parameter doesn't seem to match the current code

andyatterton commented 5 months ago

@andyatterton - apologies: the usage.md documentation around the Sex parameter doesn't seem to match the current code

My bad, forgot about the docs.

pacharanero commented 3 months ago

Just a quick note to say that this has not been forgotten @andyatterton! Thanks for the contribution and we will most definitely merge this, I've been a little busy with a number of other projects lately so it's slipped a bit but it will get done.

andyatterton commented 3 months ago

No worries Marcus, I have been on two holidays in the last two months (fancy I know) so I haven't been working on the piece of code that I need this for anyway. Not to be pushy but do you have a rough ETA for this, I won't hold you to it, but it would help me with planning working for the next couple of weeks as I need to go through and replace our version with this. Thanks

pacharanero commented 3 months ago

OK well how about I aim to have it merged by end of June?

andyatterton commented 3 months ago

That would be wonderful, but please don't feel any pressure if that starts to look unlikely. Thanks Marcus