fhir_to_pad_converter.py working
This commit is contained in:
36
validation.py
Normal file
36
validation.py
Normal 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
|
||||
Reference in New Issue
Block a user