Skip to main content

Medsenger.AI API

Doctor contracts, including completed ones

current = api.get_doctor_info(doctor_id=42)
all_contracts = api.get_all_doctor_info(doctor_id=42)

get_all_doctor_info calls POST /api/agents/doctor/info/all with the same api_key and doctor_id as /doctor/info. Both methods return state, doctor, contracts, and doctor_contracts in the same format. The new method also includes expired and manually closed contracts; each contract retains its active flag. Both methods include primary and helper doctor assignments and only contracts currently connected to the agent. If an agent is detached when a contract closes, that contract is no longer accessible through either method. Reporting agents that need archived contracts should have keep_alive_after_close enabled before closure. Deploy the updated server before using the new method; no database migration is needed.

Records by originating contract (0.1.107)

# Existing calls keep returning the patient's history across contracts.
history = api.get_records(contract_id=123, category_name="pulse")

# Only records created under contract 123; historical NULL records are excluded.
records = api.get_records(contract_id=123, category_name="pulse", record_contract_id=123)
count = api.get_records(contract_id=123, category_name="pulse", record_contract_id=123, return_count=True)
categories = api.get_available_categories(contract_id=123, record_contract_id=123)

answers = api.get_multiple_records([
    dict(contract_id=123, category_name="pulse", record_contract_id=123),
    dict(contract_id=123, category_name="weight", record_contract_id=123),
])

# For agents with global patient access:
records = api.get_records(user_id=456, record_contract_id=123)

contract_id continues to select the patient's access context. The optional record_contract_id filters records by their originating contract and works with both REST and gRPC, including REST fallback, grouped reads, counts, and batch queries. The selected contract must belong to the same patient and be accessible to the agent. Omitting the filter (or passing None) preserves the previous behavior.

Returned records include contract_id as an integer or None. Older records and user-level Health imports have no originating contract. Existing add_record and add_records calls already send the contract; the updated server persists it for every new record, including batched writes. No changes to writer agents are needed.

Deploy the database migration and all REST/gRPC servers before enabling the filter in clients. Old servers silently ignore the new field. Old clients continue to work with the new servers; updating the SDK is only necessary to use the new filter or receive the new field through gRPC. The new parameters are appended to existing signatures and existing positional arguments remain valid.

Compliance events

event = api.create_compliance_event(
    contract_id=contract_id,
    external_id="forms-action-request:42",
    code="form_7",
)

api.complete_compliance_event(
    contract_id,
    event_id=event["event"]["id"],
)

# An event can also be addressed by the agent's stable external identifier.
api.cancel_compliance_event(
    contract_id,
    external_id="forms-action-request:42",
)

history = api.get_compliance_events(
    "2026-08-01",
    "2026-08-17",
    user_id=user_id,
    limit=100,
)

Exactly one of event_id or external_id is required when completing or cancelling an event. History queries similarly require exactly one of contract_id or user_id.

Coalesced cache invalidation (0.1.109)

Install medsenger-api[cache] (SQLAlchemy 2.x). CacheUpdateOutbox is an optional adapter: it does not change /api/agents/cache, /params, /actions or socket payloads. A pure projection specifies which persisted fields affect an agent's cache. Changes to watched models and ORM bulk updates/deletes write one durable pending row per (agent_key, contract_id) in the SAME transaction. Raw SQL and bulk executemany must explicitly record invalidations; they must not silently bypass tracking.

batch() groups a request/task containing intermediate commits. PostgreSQL shared advisory locks prevent publishing its intermediate state, while an exclusive publisher lock prevents two workers from publishing the same revision. The publisher does not hold a database transaction during HTTP. A committed partial operation remains pending on failure; rolled-back changes disappear. A process crash releases its locks. HTTP failures retain the row with bounded retry delays; clinical operations are never retried by this component.

Watch only actual dependencies: forms' visible buttons and editable parameter values/locations; call booking visibility and visible locale; heart activation and upload-key revision. Runtime timers and device settings not present in the response do not invalidate. The renderer and projection should share pure code. Preserve array order and scalar types; do not include timestamps or freshly issued tokens in projections. A fresh token inside an actual backend snapshot must still be compared normally. External dependencies (patient profile, category metadata, token rotation) still require their existing backend invalidation paths; the agent observer does not claim to observe another service's database.

Run one standalone run_worker(app) process per agent initially. The fixed 0.5 s coalescing window is not extended by additional changes. Requests/tasks for other contracts remain independent. Multiple publishers are safe; measure pending age and throughput before increasing their number. Keep agent Flask workers available for the backend's /params and /actions callbacks.

Tests: TEST_POSTGRES_URL=<isolated-test-database> python -m unittest discover -s tests -p 'test_cache_*.py'. The PostgreSQL suite resets its test tables: never use an application database.

Metadata

Release files for medsenger-api 0.1.109

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for medsenger-api 0.1.109
File Size Uploaded Provenance Actions
medsenger_api-0.1.109.tar.gz 34.9 kB Without provenance Details for medsenger_api-0.1.109.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for medsenger-api 0.1.109
File Interpreter ABI Platform Actions
medsenger_api-0.1.109-py3-none-any.whl Python 3 none any Details for medsenger_api-0.1.109-py3-none-any.whl

Total release size: 60.9 kB

Release files / medsenger_api-0.1.109.tar.gz

Download URL medsenger_api-0.1.109.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
203a84e962a2f4ae40b02e398d2311fa14d28b0ee5a4a5989c9b1a799c28b35f
BLAKE2b-256 checksum
How to use checksums
9948d6ff9da54e69c08cf553daba55c421f18844cf2e3b6f9d8a50de0e624f08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release files / medsenger_api-0.1.109-py3-none-any.whl

Download URL medsenger_api-0.1.109-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6caf76ea31cf0797a756dafe8722e226b6ac97fe6af77163086053bd4db362b6
BLAKE2b-256 checksum
How to use checksums
78373f6d7fa30ed8efceeaf1c0b1b4b3f2d0025dbb021759b74ee82e291c828d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Security for medsenger-api 0.1.109

Provenance

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.109 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page