{
  "resourceType": "StructureDefinition",
  "id": "el-observation-wavefrontautoerefraction",
  "url": "http://fhir.essilorluxottica.com/fhir/StructureDefinition/el-observation-wavefrontautoerefraction",
  "version": "1.0.0",
  "name": "ELWavefrontAutoRefraction",
  "title": "EL Wavefront Auto Refraction Profile",
  "status": "draft",
  "description": "The EL Wavefront Auto Refraction Profile inherits from Observation resource. The profile contains all the elements in the Auto Refraction section in the VisionX EHR application. A single instance captures refraction and pupillary distances for OD or OS.",
  "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": "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-wavefrontautoerefraction"
          }
        ]
      },
      {
        "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.wavefront",
              "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:diopterIncrement",
        "path": "Observation.component",
        "sliceName": "diopterIncrement",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:diopterIncrement.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "diopterIncrement",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "[diop] Measure Increment"
            }
          ]
        }
      },
      {
        "id": "Observation.component:diopterIncrement.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:diopterIncrement.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "patternString": "[diop]"
      },
      {
        "id": "Observation.component:roomBrightnessLevel",
        "path": "Observation.component",
        "sliceName": "roomBrightnessLevel",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:roomBrightnessLevel.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "98908-7",
              "system": "http://loinc.org",
              "display": "Type of Room brightness level during testing"
            }
          ]
        }
      },
      {
        "id": "Observation.component:roomBrightnessLevel.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.essilorluxottica.com/fhir/ValueSet/el-observation-brightnessLevelLoincCode-vs"
        }
      },
      {
        "id": "Observation.component:powerOfSphere",
        "path": "Observation.component",
        "sliceName": "powerOfSphere",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:powerOfSphere.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "powerOfSphere",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Power of sphere"
            }
          ]
        }
      },
      {
        "id": "Observation.component:powerOfSphere.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:powerOfSphere.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "patternString": "[diop]"
      },
      {
        "id": "Observation.component:powerOfCylinder",
        "path": "Observation.component",
        "sliceName": "powerOfCylinder",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:powerOfCylinder.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "powerOfCylinder",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Power of cylinder"
            }
          ]
        }
      },
      {
        "id": "Observation.component:powerOfCylinder.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:powerOfCylinder.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "patternString": "[diop]"
      },
      {
        "id": "Observation.component:axisOfCylinder",
        "path": "Observation.component",
        "sliceName": "axisOfCylinder",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:axisOfCylinder.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "axisOfCylinder",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Axis of cylinder"
            }
          ]
        }
      },
      {
        "id": "Observation.component:axisOfCylinder.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:axisOfCylinder.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "patternString": "[diop]"
      },
      {
        "id": "Observation.component:pupillaryDistanceDistance",
        "path": "Observation.component",
        "sliceName": "pupillaryDistanceDistance",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:pupillaryDistanceDistance.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "pupillaryDistanceDistance",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Pupillary Distance distance"
            }
          ]
        }
      },
      {
        "id": "Observation.component:pupillaryDistanceDistance.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:pupillaryDistanceDistance.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "patternString": "mm"
      },
      {
        "id": "Observation.component:pupillaryDistanceNear",
        "path": "Observation.component",
        "sliceName": "pupillaryDistanceNear",
        "min": 0,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Observation.component:pupillaryDistanceNear.code",
        "path": "Observation.component.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "pupillaryDistanceNear",
              "system": "http://fhir.essilorluxottica.com/fhir/CodeSystem/el-observation-componentcode-cs",
              "display": "Pupillary distance Distance"
            }
          ]
        }
      },
      {
        "id": "Observation.component:pupillaryDistanceNear.value[x]",
        "path": "Observation.component.value[x]",
        "type": [
          {
            "code": "Quantity"
          }
        ]
      },
      {
        "id": "Observation.component:pupillaryDistanceNear.value[x].unit",
        "path": "Observation.component.value[x].unit",
        "patternString": "mm"
      }
    ]
  }
}