Skip to content

Commit 794cc2c

Browse files
BCSS-20629 - BCSS – Playwright - NHS Number Tools Markdown Improvements (#83)
BCSS – Playwright - NHS Number Tools Markdown Improvements - Utility Guide - NHSNumberTools.md is updated & also Doc String is updated for nhs_number_tools.py <!-- markdownlint-disable-next-line first-line-heading --> ## Description As per JIRA Ticket BCSS-20629 description, Utility Guide - NHSNumberTools.md is updated & also Doc String is updated for nhs_number_tools.py ## Context <!-- Why is this change required? What problem does it solve? --> This is required as a part of review activity of BCSS - Playwright - Update Utility Markdown Documentation ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [X] Refactoring (non-breaking change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [X] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [X] I have followed the code style of the project - [ ] I have added tests to cover my changes (where appropriate) - [X] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [X] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent 1980343 commit 794cc2c

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed

docs/utility-guides/NHSNumberTools.md

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,51 @@ common functionality that may apply to many services in relation to NHS Number m
88
- [Utility Guide: NHS Number Tools](#utility-guide-nhs-number-tools)
99
- [Table of Contents](#table-of-contents)
1010
- [Using the NHS Number Tools class](#using-the-nhs-number-tools-class)
11-
- [`spaced_nhs_number()`: Return Spaced NHS Number](#spaced_nhs_number-return-spaced-nhs-number)
11+
- [`_nhs_number_checks()`: Checks if the NHS number is valid](#_nhs_number_checks-checks-if-the-nhs-number-is-valid)
1212
- [Required Arguments](#required-arguments)
13+
- [Raises](#raises)
14+
- [Example Usage for `_nhs_number_checks()`](#example-usage-for-_nhs_number_checks)
15+
- [`spaced_nhs_number()`: Returns Spaced NHS Number](#spaced_nhs_number-returns-spaced-nhs-number)
16+
- [Required Arguments](#required-arguments-1)
1317
- [Returns](#returns)
18+
- [Example Usage for `spaced_nhs_number()`](#example-usage-for-spaced_nhs_number)
1419

1520
## Using the NHS Number Tools class
1621

1722
You can initialise the NHS Number Tools class by using the following code in your test file:
1823

19-
from utils.nhs_number_tools import NHSNumberTools
24+
```python
25+
from utils.nhs_number_tools import NHSNumberTools
26+
```
2027

21-
## `spaced_nhs_number()`: Return Spaced NHS Number
28+
## `_nhs_number_checks()`: Checks if the NHS number is valid
2229

23-
The `spaced_nhs_number()` method is designed to take the provided NHS number and return it in a formatted
24-
string of the format `nnn nnn nnnn`. It's a static method so can be used in the following way:
30+
The `_nhs_number_checks()` method does basic checks on NHS number value provided and raises an exception if the number is not valid
2531

26-
# Return formatted NHS number
27-
spaced_nhs_number = NHSNumberTools.spaced_nhs_number("1234567890")
32+
### Required Arguments
33+
34+
The following are required for `_nhs_number_checks()`:
35+
36+
| Argument | Format | Description |
37+
| ---------- | ------ | ----------------------- |
38+
| nhs_number | `str` | The NHS number to check |
39+
40+
### Raises
41+
42+
NHSNumberToolsException: If the NHS number is not numeric or not 10 digits long.
43+
44+
## Example Usage for `_nhs_number_checks()`
45+
46+
```python
47+
from utils.nhs_number_tools import NHSNumberTools
48+
incorrect_nhs_no = "A23456789"
49+
NHSNumberTools._nhs_number_checks(incorrect_nhs_no)
50+
```
51+
52+
## `spaced_nhs_number()`: Returns Spaced NHS Number
53+
54+
The `spaced_nhs_number()` method is designed to take the provided NHS number and return it in a formatted
55+
string of the format `nnn nnn nnnn`. It's a static method so can be used in the following way
2856

2957
### Required Arguments
3058

@@ -37,3 +65,11 @@ The following are required for `NHSNumberTools.spaced_nhs_number()`:
3765
### Returns
3866

3967
A `str` with the provided NHS number in `nnn nnn nnnn` format. For example, `NHSNumberTools.spaced_nhs_number(1234567890)` would return `123 456 7890`.
68+
69+
## Example Usage for `spaced_nhs_number()`
70+
71+
```python
72+
from utils.nhs_number_tools import NHSNumberTools
73+
# Return formatted NHS number
74+
spaced_nhs_number = NHSNumberTools.spaced_nhs_number("1234567890")
75+
```

utils/nhs_number_tools.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ class NHSNumberTools:
1111
@staticmethod
1212
def _nhs_number_checks(nhs_number: str) -> None:
1313
"""
14-
This does basic checks on NHS number values provided and raises an exception if the number is not valid.
14+
This will validate that the provided NHS number is numeric and exactly 10 digits long.
1515
1616
Args:
17-
nhs_number (str): The NHS number to check.
17+
nhs_number (str): The NHS number to validate.
18+
19+
Raises:
20+
NHSNumberToolsException: If the NHS number is not numeric or not 10 digits long.
21+
22+
Returns:
23+
None
1824
"""
1925
if not nhs_number.isnumeric():
2026
raise NHSNumberToolsException(

0 commit comments

Comments
 (0)