pat2vec.util.helper_functions
Functions
|
Extracts all occurrences of "NHS" followed by a 10-digit number. |
Retrieves a unique list of hospital IDs from a list of NHS numbers. |
- pat2vec.util.helper_functions.extract_nhs_numbers(input_string)[source]
Extracts all occurrences of “NHS” followed by a 10-digit number.
The function searches for the pattern “NHS” followed by a 10-digit number, which may contain spaces. It then cleans the extracted numbers by removing any spaces.
- Parameters:
input_string (
str
) – The string to search for NHS numbers.- Return type:
List
[str
]- Returns:
A list of all extracted 10-digit NHS numbers as strings.
Examples
>>> extract_nhs_numbers("NHS 123 456 7890") ['1234567890'] >>> extract_nhs_numbers("NHS 123 456 7890 and NHS 098 765 4321") ['1234567890', '0987654321']
- pat2vec.util.helper_functions.get_search_client_idcode_list_from_nhs_number_list(nhs_numbers, pat2vec_obj)[source]
Retrieves a unique list of hospital IDs from a list of NHS numbers.
This function uses a pat2vec_obj to perform a cohort search against an index (e.g., ‘pims_apps*’) to find the corresponding ‘HospitalID’ for each ‘PatNHSNo’ in the provided list.
- Parameters:
nhs_numbers (
List
[str
]) – A list of NHS numbers to search for.pat2vec_obj (
Any
) – An object with a cohort_searcher_with_terms_and_search method for querying the data source.
- Return type:
List
[str
]- Returns:
A unique list of hospital IDs found for the given NHS numbers.