Shared string formatting functions for standardizing values across the Hank AI stack.
pip install hank-format==0.3.0 Copy PIP instructions
pip install hank-format Usage from hank_format import as_name, as_date, as_date_str, as_datetime_str, as_time_str as_name("Primary: John Doe") # 'DOE, JOHN' as_name("Steven Hardman, APRN - CRNA") # 'HARDMAN, STEVEN, APRN, CRNA' as_name(last="Doe", first="John", suffix="Jr, MD") # 'DOE, JOHN, JR, MD' as_name(provider_dict={"fn": "John", "ln": "Doe", "tit": "MD"}) # 'DOE, JOHN, MD' as_date("12/31/2020 (age 30 yrs)") # datetime.date(2020, 12, 31) as_date_str("01012024") # '2024-01-01' as_datetime_str("2020-12-31T23:59") # '2020-12-31 23:59:00' as_datetime_str("23:59", precision="minute", default_date="2020-12-31") # '2020-12-31 23:59' as_time_str("11:30 pm") # '23:30' API Function Returns Notes as_name(value) str LAST, FIRST MIDDLE, SUFFIX, upper case. Strips Label: prefixes, [notes], (notes), *, and text after ;. as_name(*, last, first=None, middle=None, suffix=None) str Same output, built from parts. suffix may hold several credentials ("Jr, MD"). as_name(*, provider_dict) str Same output, built from a dumped hank-medicalnotes Provider (ln, fn, m, sfx, tit). tit is appended as a credential unless it is OTHER or UNKNOWN; other keys are ignored. ProviderDict is exported for typing. is_date(value) bool True when a year, month, and day are present. has_time(value) bool True when an hour and minute are present, or an hour with an am/pm marker (5pm). as_date(value) date | None Calendar date only. as_date_str(value) str YYYY-MM-DD or "". as_datetime(value, *, default_date=None) datetime | None Midnight when no time is present. Time-only input needs default_date. as_datetime_str(value, *, precision="second", default_date=None) str YYYY-MM-DD HH:MM:SS, or YYYY-MM-DD HH:MM with precision="minute". as_time(value) time | None Clock time only. as_time_str(value, *, precision="minute") str HH:MM, or HH:MM:SS with precision="second". Conventions:
Legacy as_time returned "" for anything without a time; the new datetime functions format a date-only value as midnight, hence the has_time guards.
uv sync # create .venv with Python 3.12 and the dev group uv run pytest # tests with 100% coverage enforced uv run ruff check . && uv run ruff format --check . uv run pyright uv build # sdist + wheel into dist/ Releasing Open a PR against main and add exactly one label: release:patch, release:minor, or release:major. On merge, the Release workflow bumps __version__ in hank_format/__init__.py, runs the tests, builds, commits Release vX.Y.Z, tags it, and pushes. A separate publish job then uploads the built artifacts to PyPI. If only the publish job fails, fix the cause and re-run that failed job. Do not re-run the whole workflow: the version is already bumped and tagged, so a full re-run would bump it again. Project links Data verified by PyPI on Oct 17, 2026 Data provided by the project maintainers, verified at the time the release was uploaded to PyPI. Home Issues Key dates PyPI data Data sourced directly from PyPI's database. Released: Oct 17, 2026 Latest release 1 maintainer PyPI data Data sourced directly from PyPI's database. shartzog Credits Author: Sam Hartzog
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.




