Ttebra_soap_apiAsync Tebra SOAP 2.1
SOAP 2.1
Internals

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#

helper
to_plain_data(value) -> Any

Recursively convert a Zeep CompoundValue, OrderedDict, list, or tuple into plain Python dict and list structures with string keys.

Returnsdict / list / scalar
Example
plain = to_plain_data(response)
print(plain["Players"]["PlayerData"])

strip_none#

helper
strip_none(data) -> dict

Shallow copy of a mapping with all None-valued keys removed. Used to build compact SOAP filters.

Returnsdict
Example
strip_none({"PracticeName": "Clinic", "NPI": None})
# {"PracticeName": "Clinic"}

normalize_fields#

helper
normalize_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.

Returnsdict[str, bool]
Example
normalize_fields(["ID", "PracticeName"])
# {"ID": True, "PracticeName": True}
normalize_fields(None)
# {}

is_ghost_record#

helper
is_ghost_record(record, id_key='ID') -> bool

Detect 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.

Returnsbool

extract_records#

helper
extract_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.

Returnslist[dict[str, Any]]
Example
rows = extract_records(response, "Patients", "PatientData")
# [] for an empty result instead of [{"ID": None, ...}]

Dates & ranges

format_date#

helper
format_date(value) -> str

Normalize 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.

Returnsstr
Example
format_date("04/16/2026")  # "2026-04-16"

parse_iso_date#

helper
parse_iso_date(value) -> date

Parse any supported date input into a datetime.date.

Returnsdatetime.date

chunk_date_range#

helper
chunk_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.

Returnslist[tuple[str, str]]
Example
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#

helper
format_datetime_bound(value, *, end_of_day=False) -> str

Format 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.

Returnsstr
Example
format_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#

helper
split_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.

Returnstuple[str, str]
Example
split_patient_name("Patient, Test")   # ("Test", "Patient")
split_patient_name("Test Patient")     # ("Test", "Patient")

Related