Uk nhs number validate
uk-nhs-number-validate · version 1.0.0 · Identifiers & check digits · free, no key needed
Validate a 10-digit NHS number's modulus 11 check digit (NHS Data Dictionary); 11 minus remainder = 10 is never valid.
Use when you need to: validate an nhs number · check digit for a uk nhs number · is this nhs number valid.
Decide before calling
Read the versioned contract and the supported scope below. Reuse uk-nhs-number-validate@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use uk-nhs-number-validate@1.0.0 for validate an nhs number. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- validate an nhs number
- check digit for a uk nhs number
- is this nhs number valid
- verify a patient's nhs number modulus 11
- nhs number checksum check
- בדיקת מספר NHS בריטי
Not supported
- a live Personal Demographics Service (PDS) lookup
- validating a Community Health Index (CHI) or Health and Care Number (H&C number), the Scottish/Welsh schemes
- stripping hyphens or other separators (only U+0020 spaces are removed)
Behavior
- normalized = nhs_number with every U+0020 SPACE removed (the conventional 3-3-4 grouping); no other characters are stripped. normalized.length != 10 returns reason wrong_length; length 10 but not all-digit returns reason invalid_character; both leave normalized/check_digit null.
- check_digit = normalized[9], populated once length and charset pass.
- Weighted sum over the first 9 digits: weight = [10, 9, 8, 7, 6, 5, 4, 3, 2]. remainder = sum mod 11; total = 11 - remainder.
- If total == 11, expected check digit is 0. If total == 10, the number can never be valid: reason check_digit_invalid, regardless of the actual tenth digit (distinct from an ordinary mismatch, per the NHS Data Dictionary's own rule). Otherwise expected is total, compared to check_digit for reason check_digit_mismatch.
Input
nhs_number(string, required): min length 1; max length 24
Output
valid(boolean, required)reason(one of null, "wrong_length", "invalid_character", "check_digit_invalid", "check_digit_mismatch", required)normalized(string or null, required): pattern^[0-9]{10}$check_digit(string or null, required): pattern^[0-9]$
Limits
- max nhs number bytes: 24
Example
Request input:
{
"nhs_number": "943 476 5919"
}
Response:
{
"result": {
"valid": true,
"reason": null,
"normalized": "9434765919",
"check_digit": "9"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "uk-nhs-number-validate",
"version": "1.0.0",
"input": {
"nhs_number": "943 476 5919"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/uk-nhs-number-validate/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"nhs_number":"943 476 5919"}'
The machine-readable contract is at /v1/tools/uk-nhs-number-validate/versions/1.0.0.
CLI
node cli.mjs run uk-nhs-number-validate 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Imo number validate: Validate a 7-digit IMO ship identification number's weighted mod-10 check digit, with or without the 'IMO ' prefix.
- Isin validate: Validate a 12-character ISIN's ISO 6166 Luhn check digit and parse its country prefix, NSIN and NSIN scheme.
- Iso6346 container validate: Validate an 11-character ISO 6346 container number's mod-11 check digit and split the owner code, category and serial.
- Npi validate: Validate a 10-digit US National Provider Identifier using the Luhn formula with the constant 80840 healthcare prefix.
- Upu s10 validate: Validate a 13-char UPU S10 postal identifier's weighted mod-11 check digit, split service indicator and country.
- Checkdigit validate: Validate a full value's trailing check digit(s) against a named algorithm (Luhn, Verhoeff, Damm, ISO 7064, GS1, mod 10).