Utilities
Helpers used throughout the library. They are public and safe to reuse when building custom requests or normalizing responses.
Serialization & normalization
to_plain_data#
helperto_plain_data(value) -> AnyRecursively convert a Zeep CompoundValue, OrderedDict, list, or tuple into plain Python dict and list structures with string keys.
dict / list / scalarplain = to_plain_data(response)
print(plain["Players"]["PlayerData"])strip_none#
helperstrip_none(data) -> dictShallow copy of a mapping with all None-valued keys removed. Used to build compact SOAP filters.
dictstrip_none({"PracticeName": "Clinic", "NPI": None})
# {"PracticeName": "Clinic"}normalize_fields#
helpernormalize_fields(fields) -> dict[str, bool]Convert a field selector into Tebra's Fields dictionary. None becomes {} (all fields), a list becomes {name: True}, and a mapping is preserved as booleans. Raises TypeError for a bare string.
dict[str, bool]normalize_fields(["ID", "PracticeName"])
# {"ID": True, "PracticeName": True}
normalize_fields(None)
# {}is_ghost_record#
helperis_ghost_record(record, id_key='ID') -> boolDetect Tebra's placeholder empty record. A record is a ghost when it is empty, when id_key is present and None, or when every value is None.
boolextract_records#
helperextract_records(response_dict, outer_key, inner_key, *, id_key='ID') -> list[dict]Extract a clean list from a Tebra ArrayOf* container, accepting a single mapping or a list and dropping ghost records.
list[dict[str, Any]]rows = extract_records(response, "Patients", "PatientData")
# [] for an empty result instead of [{"ID": None, ...}]Dates & ranges
format_date#
helperformat_date(value) -> strNormalize a date, datetime, YYYY-MM-DD, MM/DD/YY, MM/DD/YYYY, or YYYY/MM/DD value to YYYY-MM-DD. Unknown strings are returned stripped.
strformat_date("04/16/2026") # "2026-04-16"parse_iso_date#
helperparse_iso_date(value) -> dateParse any supported date input into a datetime.date.
datetime.datechunk_date_range#
helperchunk_date_range(start, end, *, max_days=60) -> list[tuple[str, str]]Split an inclusive [start, end] range into contiguous ISO windows of at most max_days inclusive days. Raises ValueError when max_days < 1.
list[tuple[str, str]]chunk_date_range("2026-01-01", "2026-03-01")
# [("2026-01-01", "2026-03-01")] -- 60 inclusive days
chunk_date_range("2026-01-01", "2026-04-16")format_datetime_bound#
helperformat_datetime_bound(value, *, end_of_day=False) -> strFormat a filter bound as an ISO-8601 UTC timestamp for appointment and schedule queries. Date-only input expands to 00:00:00Z or, with end_of_day=True, 23:59:59Z. Values with an explicit time keep it.
strformat_datetime_bound("2026-04-01")
# "2026-04-01T00:00:00Z"
format_datetime_bound("2026-04-01", end_of_day=True)
# "2026-04-01T23:59:59Z"split_patient_name#
helpersplit_patient_name(full_name) -> tuple[str, str]Split 'First Last', 'First Middle Last', or 'Last, First' into (first_name, last_name). Raises ValueError for an empty name.
tuple[str, str]split_patient_name("Patient, Test") # ("Test", "Patient")
split_patient_name("Test Patient") # ("Test", "Patient")