bhf_smarthealth.utils.identifiers#

This module contains utility functions to generate / modify identifiers

Functions#

generate_deterministic_uuid_from_args(→ str)

Generate a UUID5 based on the SHA-1 hash of a namespace identifier (which is a UUID configured in the central config.py file) and a "name", where the name is any number of args. NULL values are replaced by a placeholder value to ensure consistency.

generate_nil_uuid(→ str)

Generate placeholder UUID value of entirely zeroes. Can be used as a 'sentinel value' instead of a NULL or None value.

Module Contents#

bhf_smarthealth.utils.identifiers.generate_deterministic_uuid_from_args(*args, null_placeholder: str = 'None', namespace: uuid.UUID = NAMESPACE) → str[source]#

Generate a UUID5 based on the SHA-1 hash of a namespace identifier (which is a UUID configured in the central config.py file) and a “name”, where the name is any number of args. NULL values are replaced by a placeholder value to ensure consistency.

Parameters:
  • null_placeholder (str, optional) – Placeholder value to replace NULL values with, by default “None”

  • namespace (uuid.UUID) – Persistent project namespace required for deterministic uuid generation

Returns:

The hashed string with {num_chars} number of characters

Return type:

str

Warning

This method of hashing an input is NOT secure and it intended only for the purpose of generating a performance-optimised, deterministic database key. It should NOT be used for data pseudonymisation.

bhf_smarthealth.utils.identifiers.generate_nil_uuid() → str[source]#

Generate placeholder UUID value of entirely zeroes. Can be used as a ‘sentinel value’ instead of a NULL or None value.

Returns:

UUID value in the form 00000000-0000-0000-0000-000000000000

Return type:

str