{
  "resourceType": "StructureDefinition",
  "id": "el-observation-keratometryrefraction",
  "url": "http://fhir.essilorluxottica.com/fhir/StructureDefinition/el-observation-keratometryrefraction",
  "version": "1.0.0",
  "name": "ELKeratometryRefraction",
  "title": "EL Keratometry Refraction Profile",
  "status": "draft",
  "description": "The EL Keratometry Refraction Profile inherits from Observation resource. The profile contains all the elements in the Keratometry Refraction section in the VisionX EHR application. A single instance captures refraction for one eye.",
  "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": "eyecondition-requires-no-measurements",
            "severity": "error",
            "human": "OD/OS - if an eye condition exists there cannot be any measurements.",
            "expression": "(bodySite.coding.where( code = 'od' or code = 'os' ).exists()) and\n      component.value.coding.where( code = 'nolens').exists() or\n      component.value.coding.where( code = 'balance').exists() or\n      component.value.coding.where( code = 'prosthesis').exists()\n   implies\n      component.code.coding.where( code != 'eyeCondition' and code != 'diopterIncrement' and code != 'wearschedule' and code != '98908-7' and code != 'ophthalmoscopyMethod' ).exists().not()",
            "source": "http://fhir.essilorluxottica.com/fhir/StructureDefinition/el-observation-keratometryrefraction"
          },
          {
            "key": "no-eyecondition-requires-measurements",
            "severity": "error",
            "human": "OD/OS - if no eye condition exists there must be measurements.",
            "expression": "(bodySite.coding.where( code = 'od' or code = 'os' ).exists()) and\n      component.value.coding.where( code = 'eyeCondition' ).exists().not() and\n      component.value.coding.where( code = 'nolens').exists().not() and\n      component.value.coding.where( code = 'balance').exists().not() and\n      component.value.coding.where( code = 'prosthesis').exists().not()\n   implies\n      component.code.coding.where( code != 'eyeCondition' and code != 'diopterIncrement' and code != 'wearschedule' and code != '98908-7' and code != 'ophthalmoscopyMethod' ).exists()",
            "source": "http://fhir.essilorluxottica.com/fhir/StructureDefinition/el-observation-keratometryrefraction"
          },
          {
            "key": "ou-cannotcontain-refraction",
            "severity": "error",
            "human": "OU can only contain VA, PD and notes.",
            "expression": "bodySite.coding.where( code = 'ou' ).exists()\n   implies\n      component.code.coding.where( code != 'eyeCondition' and code != 'diopterIncrement' and code != 'wearschedule' and code != '98908-7' and code != 'ophthalmoscopyMethod' and code.matches('VA.*').not() and code.matches('pupillaryDistance.*').not() ).exists().not()",
            "source": "http://fhir.essilorluxottica.com/fhir/StructureDefinition/el-observation-keratometryrefraction"
          }
        ]
      },
      {
        "id": "Observation.meta.extension",
        "path": "Observation.meta.extension",
        "min": 1
      },
      {
        "id": "Observation.meta.extension:organization",
        "path": "Observation.meta.extension",
        "sliceName": "organization",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://fhir.essilorluxottica.com/fhir/StructureDefinition/el-meta-organization-extension"
            ]
          }
        ]
      },
      {
        "id": "Observation.meta.tag",
        "path": "Observation.meta.tag",
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.essilorluxottica.com/fhir/ValueSet/el-metatag-vs"
        }
      },
      {
        "id": "Observation.identifier",
        "path": "Observation.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Observation.identifier:refractionID",
        "path": "Observation.identifier",
        "sliceName": "refractionID",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.identifier:refractionID.system",
        "path": "Observation.identifier.system",
        "min": 1,
        "patternUri": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-grouping-cs"
      },
      {
        "id": "Observation.identifier:refractionID.value",
        "path": "Observation.identifier.value",
        "min": 1
      },
      {
        "id": "Observation.identifier:externalSystemID",
        "path": "Observation.identifier",
        "sliceName": "externalSystemID",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.identifier:externalSystemID.system",
        "path": "Observation.identifier.system",
        "min": 1,
        "patternUri": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-externalSystem-cs"
      },
      {
        "id": "Observation.identifier:externalSystemID.value",
        "path": "Observation.identifier.value",
        "min": 1
      },
      {
        "id": "Observation.status",
        "path": "Observation.status",
        "patternCode": "final"
      },
      {
        "id": "Observation.category",
        "path": "Observation.category",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "exam",
              "system": "http://terminology.hl7.org/CodeSystem/observation-category"
            }
          ]
        }
      },
      {
        "id": "Observation.code",
        "path": "Observation.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "autorefraction.keratometry",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-sectioncode-cs"
            }
          ]
        }
      },
      {
        "id": "Observation.subject",
        "path": "Observation.subject",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.essilorluxottica.com/fhir/StructureDefinition/el-patient"
            ]
          }
        ]
      },
      {
        "id": "Observation.encounter",
        "path": "Observation.encounter",
        "min": 1
      },
      {
        "id": "Observation.note",
        "path": "Observation.note",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.bodySite",
        "path": "Observation.bodySite",
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.essilorluxottica.com/fhir/ValueSet/el-eyelocation-vs"
        }
      },
      {
        "id": "Observation.component",
        "path": "Observation.component",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "code"
            }
          ],
          "rules": "open",
          "description": "Slice based on the component.code value"
        }
      },
      {
        "id": "Observation.component:eyeCondition",
        "path": "Observation.component",
        "sliceName": "eyeCondition",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:eyeCondition.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "eyeCondition",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Eye Condition"
            }
          ]
        }
      },
      {
        "id": "Observation.component:eyeCondition.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.essilorluxottica.com/fhir/ValueSet/el-eyecondition-vs"
        }
      },
      {
        "id": "Observation.component:cornealPowerHorizontal",
        "path": "Observation.component",
        "sliceName": "cornealPowerHorizontal",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:cornealPowerHorizontal.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "cornealPowerHorizontal",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Horizontal Corneal Power"
            }
          ]
        }
      },
      {
        "id": "Observation.component:cornealPowerHorizontal.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:cornealPowerHorizontal.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.essilorluxottica.com/fhir/ValueSet/el-observation-keratometryunits-vs"
        }
      },
      {
        "id": "Observation.component:meridianHorizontal",
        "path": "Observation.component",
        "sliceName": "meridianHorizontal",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:meridianHorizontal.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "meridianHorizontal",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Horizontal Meridian"
            }
          ]
        }
      },
      {
        "id": "Observation.component:meridianHorizontal.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:meridianHorizontal.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "patternString": "deg"
      },
      {
        "id": "Observation.component:cornealPowerVertical",
        "path": "Observation.component",
        "sliceName": "cornealPowerVertical",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:cornealPowerVertical.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "cornealPowerVertical",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Vertical Corneal Power"
            }
          ]
        }
      },
      {
        "id": "Observation.component:cornealPowerVertical.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:cornealPowerVertical.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.essilorluxottica.com/fhir/ValueSet/el-observation-keratometryunits-vs"
        }
      },
      {
        "id": "Observation.component:meridianVertical",
        "path": "Observation.component",
        "sliceName": "meridianVertical",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:meridianVertical.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "meridianVertical",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Vertical Meridian"
            }
          ]
        }
      },
      {
        "id": "Observation.component:meridianVertical.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:meridianVertical.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "patternString": "deg"
      }
    ]
  }
}