Skip to main content

Typed Python SDK for Medelement MIS API

Project description

medelement-mis

Typed Python SDK for Medelement MIS API.

Public Interface

Top-level imports are stable and intended for package consumers:

from medelement_mis import (
    MedelementClient,
    MedelementConfig,
    Environment,
    Gender,
    ColorCode,
    SOCIAL_STATUSES,
    CONCESSIONS,
)

Main API resources exposed by MedelementClient:

  • client.patients
    • search(...)
    • get_by_iin(iin)
    • create(...)
    • get(patient_code)
    • update(...)
  • client.receptions
    • create(...)
    • search(...)
    • search_pd(...)
    • get(reception_code)
    • reschedule(...)
    • remove(reception_code)
  • client.specialists
    • list()
  • client.timetable
    • get_timetable(...)
    • get_specialist_receptions(...)
  • client.nomenclatures
    • list(...)

Reference catalogs from docs:

  • SOCIAL_STATUSES (from docs/api/social_status.md)
  • CONCESSIONS (from docs/api/concessions.md)

Quick Start

from medelement_mis import MedelementClient, MedelementConfig

config = MedelementConfig(
    user_id="your_user_id",
    password="your_password",
    integrator_key="your_integrator_key",
    base_url="https://api.medelement.com/v1",
)

with MedelementClient(config=config) as client:
    patients = client.patients.search(lastname="Ivanov")
    for patient in patients:
        print(patient.profile_code, patient.lastname, patient.name)

    patients_by_iin = client.patients.get_by_iin("651004450150")
    for patient in patients_by_iin:
        print(patient.profile_code, patient.iin)

Error Handling

from httpx import TimeoutException, TransportError
from medelement_mis import APIError, AuthenticationError, MedelementClient, MedelementConfig, NotFoundError

config = MedelementConfig()

try:
    with MedelementClient(config=config) as client:
        patient = client.patients.get(123)
except NotFoundError:
    print("Patient not found")
except AuthenticationError:
    print("Check Basic auth credentials and X-Integrator-Key")
except APIError as exc:
    print(f"API returned an error: {exc}")
except (TimeoutException, TransportError) as exc:
    print(f"Network error after retries: {exc}")

HTTP 401, 403, 404, and 422 responses are normalized into SDK exceptions. Network timeouts and transport failures are retried for idempotent requests (GET, HEAD, OPTIONS) and then bubble up as httpx exceptions if all retries fail.

Logging

The SDK logs request and response lines at DEBUG level via the medelement_mis logger:

import logging

logging.basicConfig(level=logging.DEBUG)
logging.getLogger("medelement_mis").setLevel(logging.DEBUG)

This logs method, URL, and status code, but does not log authentication headers.

API Naming Notes

Most request models use snake_case field names. Some timetable endpoints use camelCase aliases because the upstream Medelement API requires that exact payload shape, for example specialistCode, beginDatetime, and companyCabinetCode in get_receptions_short.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

medelement_mis-0.1.7.tar.gz (40.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

medelement_mis-0.1.7-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file medelement_mis-0.1.7.tar.gz.

File metadata

  • Download URL: medelement_mis-0.1.7.tar.gz
  • Upload date:
  • Size: 40.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for medelement_mis-0.1.7.tar.gz
Algorithm Hash digest
SHA256 102dfa932ec6a5841898f6d1810644737428b733e060bb5b809fc5c43e56fe30
MD5 df97f99da9976cec15c46da609e51cbf
BLAKE2b-256 be6392a6a58f6cab4c54f7c26b3e1d97e43fa3f403f5d498ded5325e26f8ff6d

See more details on using hashes here.

File details

Details for the file medelement_mis-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for medelement_mis-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4fa837d081445631f117967793683a0e4d0a8c096951e51a730fbef52bb37453
MD5 fe078d1a8a3b0a7a5abbcee54c44ecd2
BLAKE2b-256 a60b7216ffffb5bb701b67f10fab49a7a9b2926760110a3e1f6edde670da0963

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page