-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chi dob validation #38
base: develop
Are you sure you want to change the base?
Conversation
Check first six digits of a CHI are a date. Check when sex is added as an option it matches CHI number. Changed generate to supply numbers from synth range by default. Made sure generate supplies valid CHI numbers. Added tests.
Updated usage docs to inlude example. Removed CHI number support warnings. Updated Changelog
Incorrect use of warns(None) to assert no warning is raised. Pytest 7 requires different syntax. See https://docs.pytest.org/en/7.0.x/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for details
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. |
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 |
Fix on it's way. |
Changed the way a sex is specified to accept booleans for is_male or is_female
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. |
@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 |
reverted the two flags back to a single sex flag that is set using an enum nhs_number.Sex.MALE or FEMALE
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 |
@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. |
@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. |
str: a chi number without checksum digit | ||
""" | ||
start_datetime = datetime.datetime.strptime("1900-01-01", "%Y-%m-%d") | ||
end_datetime = datetime.datetime.strptime("1999-12-31", "%Y-%m-%d") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why end in 1999? I don't think it an issue but why not 2050 or somesuch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we are only interested in the last two digits of the year and 1900-1999 covers all possible numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have someone born in 1920 and someone born in 2020 does everything just work the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe there is any way to ascertain the full set of four year digits from a CHI number, so yes, I think it would work the same. Even the leap years would line up. You could in theory get the same result by getting a random int for range
00->99. If anyone knows differently though I am happy to adjust
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. |
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. |
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
<#38 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJCKE56HTJ3G4XFESV3WOTY7TMLDAVCNFSM6AAAAABGWVROY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBRGQ2DCNBUG4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
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? |
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. |
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) |
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. |
(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. |
(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. |
@andyatterton - failing test? |
@andyatterton - also, silence signifies both agreement and excessive real-life, paid employment workload :( I appreciate what you're doing here. |
ooopps, sorted that. Enums now 1 and 2. Think it's ready to go |
@andyatterton - apologies: the usage.md documentation around the Sex parameter doesn't seem to match the current code |
My bad, forgot about the docs. |
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. |
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 |
OK well how about I aim to have it merged by end of June? |
That would be wonderful, but please don't feel any pressure if that starts to look unlikely. Thanks Marcus |
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.