{
    "resourceType": "StructureDefinition",
    "id": "observation-validation",
    "url": "https://ny.sepsis.ipro.org/fhir/StructureDefinition/observation-validation",
    "version": "1.1.0",
    "name": "ObservationBPValidation",
    "title": "Observation Profile for Blood Pressure Validation",
    "status": "draft",
    "date": "2025-05-12",
    "publisher": "Example Org",
    "description": "Profile enforcing that blood pressure readings occur on or after birth and stay within 140/90.",
    "fhirVersion": "4.0.1",
    "kind": "resource",
    "abstract": false,
    "type": "Observation",
    "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Observation",
    "derivation": "constraint",
    "differential": {
      "element": [
            {
                "id": "Observation",
                "path": "Observation",
                "constraint": [
                    {
                        "key": "obs-subject-resolve",
                        "severity": "error",
                        "human": "Couldn't resolve patient's birthDate.",
                        "expression": "subject.resolve().birthDate.exists()"
                    },
                    {
                        "key": "obs-effective-after-birth",
                        "severity": "error",
                        "human": "Observation effectiveDateTime must not precede patient's birthDate.",
                        "expression": "effective.ofType(dateTime).exists() and subject.resolve().birthDate.exists() and effective.ofType(dateTime) >= subject.resolve().birthDate"
                    },
                    {
                        "key": "systolic-max",
                        "severity": "error",
                        "human": "Systolic blood pressure must be ≤ 200 mmHg.",
                        "expression": "component.where(code.coding.code='8480-6').value.ofType(Quantity).value <= 200"
                    },
                    {
                        "key": "diastolic-max",
                        "severity": "error",
                        "human": "Diastolic blood pressure must be ≤ 150 mmHg.",
                        "expression": "component.where(code.coding.code='8462-4').value.ofType(Quantity).value <= 150"
                    }
                ]
            },
            {
                "id": "Observation.subject",
                "path": "Observation.subject",
                "min": 1,
                "max": "1",
                "type": [
                    {
                    "code": "Reference",
                    "targetProfile": [
                        "https://ny.sepsis.ipro.org/fhir/StructureDefinition/patient-validation"
                    ]
                    }
                ]
            }
        ]
    }
}