fhir_to_pad_converter.py working

This commit is contained in:
Alexander Domene
2025-10-26 13:51:38 +01:00
parent f9d4bc6f11
commit a71284ee64
34 changed files with 279941 additions and 0 deletions

36
validation.py Normal file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Validation rules for the FHIR to PAD converter.
"""
from typing import Any, Dict, List, Tuple
from datetime import datetime
from typing import Any, Dict, List
from utils import collect_effective_dates
def validate_temporal_consistency(grouped_resources: List[Dict[str, Any]]) -> List[str]:
"""Checks for temporal consistency within a group of resources."""
warnings = []
now = datetime.now()
for resource in grouped_resources:
dates = collect_effective_dates(resource)
for d in dates:
if d.timestamp() > now.timestamp():
warnings.append(f"Resource {resource.get('id')} has an effective date in the future: {d.isoformat()}")
return warnings
def validate_codes(grouped_resources: List[Dict[str, Any]]) -> List[str]:
"""Checks for the validity of codes (e.g., ICD-10, GOÄ)."""
warnings = []
# Placeholder for code validation logic
return warnings
def run_validation(grouped_resources: List[Dict[str, Any]]) -> List[str]:
"""Runs all validation checks on a group of resources."""
all_warnings = []
all_warnings.extend(validate_temporal_consistency(grouped_resources))
all_warnings.extend(validate_codes(grouped_resources))
return all_warnings