{
  "@context": "http://www.w3.org/ns/shex.jsonld",
  "type": "Schema",
  "shapes": [
    { "type": "ShapeDecl",
    "id": "http://a.example/#Observation",
    "shapeExpr": {
      "type": "Shape",
      "expression": {
        "type": "EachOf",
        "expressions": [
          {
            "type": "TripleConstraint",
            "predicate": "http://hl7.org/ns/fhir#code",
            "min": 0,
            "max": 1
          },
          {
            "type": "TripleConstraint",
            "predicate": "http://hl7.org/ns/fhir#component",
            "valueExpr": {
              "type": "Shape",
              "expression": {
                "type": "EachOf",
                "expressions": [
                  {
                    "type": "TripleConstraint",
                    "predicate": "http://hl7.org/ns/fhir#code"
                  },
                  {
                    "type": "TripleConstraint",
                    "predicate": "http://hl7.org/ns/fhir#value"
                  }
                ]
              }
            },
            "min": 0,
            "max": -1
          }
        ]
      }
    } },
    {
      "id": "http://a.example/#Vital",
      "type": "ShapeDecl",
      "abstract": true,
      "shapeExpr": {
        "type": "ShapeAnd",
        "shapeExprs": [
          "http://a.example/#Observation",
          {
            "type": "Shape"
          }
        ]
      }
    },
    {
      "id": "http://a.example/#PostureVital",
      "type": "ShapeDecl",
      "abstract": true,
      "shapeExpr": {
        "type": "ShapeAnd",
        "shapeExprs": [
          "http://a.example/#Vital",
          {
            "type": "Shape",
            "extends": [
              "http://a.example/#Posture"
            ]
          }
        ]
      }
    },
    {
      "id": "http://a.example/#ReclinedVital",
      "type": "ShapeDecl",
      "abstract": true,
      "shapeExpr": {
        "type": "ShapeAnd",
        "shapeExprs": [
          "http://a.example/#PostureVital",
          {
            "type": "Shape",
            "extends": [
              "http://a.example/#Reclined"
            ]
          }
        ]
      }
    },
    { "type": "ShapeDecl",
    "id": "http://a.example/#BP",
    "shapeExpr": {
      "type": "ShapeAnd",
      "shapeExprs": [
        {
          "type": "Shape",
          "extends": [
            "http://a.example/#Vital"
          ]
        },
        {
          "type": "Shape",
          "expression": {
            "type": "EachOf",
            "expressions": [
              {
                "type": "TripleConstraint",
                "predicate": "http://hl7.org/ns/fhir#component",
                "valueExpr": {
                  "type": "Shape",
                  "expression": {
                    "type": "TripleConstraint",
                    "predicate": "http://hl7.org/ns/fhir#code",
                    "valueExpr": {
                      "type": "NodeConstraint",
                      "values": [
                        {
                          "value": "systolic"
                        }
                      ]
                    }
                  }
                }
              },
              {
                "type": "TripleConstraint",
                "predicate": "http://hl7.org/ns/fhir#component",
                "valueExpr": {
                  "type": "Shape",
                  "expression": {
                    "type": "TripleConstraint",
                    "predicate": "http://hl7.org/ns/fhir#code",
                    "valueExpr": {
                      "type": "NodeConstraint",
                      "values": [
                        {
                          "value": "diastolic"
                        }
                      ]
                    }
                  }
                }
              }
            ]
          }
        }
      ]
    } },
    { "type": "ShapeDecl",
    "id": "http://a.example/#PostureBP",
    "shapeExpr": {
      "type": "Shape",
      "extends": [
        "http://a.example/#BP",
        "http://a.example/#PostureVital"
      ]
    } },
    { "type": "ShapeDecl",
    "id": "http://a.example/#ReclinedBP",
    "shapeExpr": {
      "type": "Shape",
      "extends": [
        "http://a.example/#BP",
        "http://a.example/#ReclinedVital"
      ]
    } },
    { "type": "ShapeDecl",
    "id": "http://a.example/#Pulse",
    "shapeExpr": {
      "type": "ShapeAnd",
      "shapeExprs": [
        {
          "type": "Shape",
          "extends": [
            "http://a.example/#Vital"
          ]
        },
        {
          "type": "Shape",
          "expression": {
            "type": "TripleConstraint",
            "predicate": "http://hl7.org/ns/fhir#code",
            "valueExpr": {
              "type": "NodeConstraint",
              "values": [
                {
                  "value": "pulse"
                }
              ]
            }
          }
        }
      ]
    } },
    { "type": "ShapeDecl",
    "id": "http://a.example/#PosturePulse",
    "shapeExpr": {
      "type": "Shape",
      "extends": [
        "http://a.example/#Pulse",
        "http://a.example/#PostureVital"
      ]
    } },
    { "type": "ShapeDecl",
    "id": "http://a.example/#ReclinedPulse",
    "shapeExpr": {
      "type": "Shape",
      "extends": [
        "http://a.example/#Pulse",
        "http://a.example/#ReclinedVital"
      ]
    } },
    { "type": "ShapeDecl",
    "id": "http://a.example/#Posture",
    "shapeExpr": {
      "type": "Shape",
      "expression": {
        "type": "TripleConstraint",
        "predicate": "http://hl7.org/ns/fhir#component",
        "valueExpr": {
          "type": "Shape",
          "expression": {
            "type": "TripleConstraint",
            "predicate": "http://hl7.org/ns/fhir#code",
            "valueExpr": {
              "type": "NodeConstraint",
              "values": [
                {
                  "value": "posture"
                }
              ]
            }
          }
        }
      }
    } },
    { "type": "ShapeDecl",
    "id": "http://a.example/#Reclined",
    "shapeExpr": {
      "type": "ShapeAnd",
      "shapeExprs": [
        "http://a.example/#Posture",
        {
          "type": "Shape",
          "expression": {
            "type": "TripleConstraint",
            "predicate": "http://hl7.org/ns/fhir#component",
            "valueExpr": {
              "type": "Shape",
              "expression": {
                "type": "EachOf",
                "expressions": [
                  {
                    "type": "TripleConstraint",
                    "predicate": "http://hl7.org/ns/fhir#code",
                    "valueExpr": {
                      "type": "NodeConstraint",
                      "values": [
                        {
                          "value": "posture"
                        }
                      ]
                    }
                  },
                  {
                    "type": "TripleConstraint",
                    "predicate": "http://hl7.org/ns/fhir#value",
                    "valueExpr": {
                      "type": "NodeConstraint",
                      "values": [
                        {
                          "value": "reclined"
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    } }
  ]
}
