import json import os from pydantic_settings import BaseSettings class Settings(BaseSettings): hl7_host: str = "0.0.0.0" hl7_port: int = 6060 contec_ports: list = [511, 515, 516, 517, 518, 519, 520] monitor_ip: str = "" monitor_model: str = "CMS7000PLUS" target_api_url: str = "https://api.example.com/vitals" api_token: str = "" retry_interval_seconds: int = 60 log_file: str = "hl7_forwarder.log" database_url: str = "sqlite:///./hl7_forwarder.db" class Config: env_file = ".env" def get_settings() -> Settings: config_file = "config.json" if os.path.exists(config_file): with open(config_file, "r") as f: try: data = json.load(f) return Settings(**data) except json.JSONDecodeError: pass return Settings() settings = get_settings()