diff --git a/schemas/imageFilter.schema.json b/schemas/imageFilter.schema.json new file mode 100644 index 0000000..6916096 --- /dev/null +++ b/schemas/imageFilter.schema.json @@ -0,0 +1,649 @@ +{ + "$id":"https://raw.githubusercontent.com/SPINEProject/SPINE-json-schema/master/schemas/imageFilter.schema.json", + "$schema":"http://json-schema.org/draft-07/schema#", + "title":"Schema to filter image based on DICOM parameters.", + "type":"object", + "definitions":{ + "operator":{ + "$id":"#operator", + "decription":"Description of an operators", + "type":"object", + "properties":{ + "label":{ + "description":"Label of the operator", + "type":"string" + }, + "value":{ + "description":"Value of the operator", + "type":"string" + } + }, + "required":[ + "label", + "value" + ] + }, + "operatorEqual":{ + "$id":"#operatorEqual", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "=" + ] + }, + "value":{ + "enum":[ + "equals" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorNotEqual":{ + "$id":"#operatorNotEqual", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "!=" + ] + }, + "value":{ + "enum":[ + "not equals" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorLessThan":{ + "$id":"#operatorLessThan", + "properties":{ + "label":{ + "enum":[ + "<" + ] + }, + "value":{ + "enum":[ + "less than" + ] + } + }, + "required":[ + "label", + "value" + ] + }, + "operatorLesserEqual":{ + "$id":"#operatorLesserEqual", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "<=" + ] + }, + "value":{ + "enum":[ + "less than or equal to" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorGreaterEqual":{ + "$id":"#operatorGreaterEqual", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + ">=" + ] + }, + "value":{ + "enum":[ + "greater than or equal to" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorGreaterThan":{ + "$id":"#operatorGreaterThan", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + ">" + ] + }, + "value":{ + "enum":[ + "greater than" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorContains":{ + "$id":"#operatorContains", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "contains" + ] + }, + "vale":{ + "enum":[ + "contains" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorDoesNotContains":{ + "$id":"#operatorDoesNotContains", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "does not contain" + ] + }, + "value":{ + "enum":[ + "does not contain" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorIncludes":{ + "$id":"#operatorIncludes", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "includes" + ] + }, + "value":{ + "enum":[ + "includes" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorDoesNotInclude":{ + "$id":"#operatorDoesNotInclude", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "does not include" + ] + }, + "value":{ + "enum":[ + "does not include" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorIn":{ + "$id":"#operatorIn", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "in" + ] + }, + "value":{ + "enum":[ + "in" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorNotIn":{ + "$id":"#operatorDoesNotInclude", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "not in" + ] + }, + "value":{ + "enum":[ + "not in" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorAND":{ + "$id":"#operatorAND", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "AND" + ] + }, + "value":{ + "enum":[ + "AND" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "operatorOR":{ + "$id":"#operatorOR", + "allOf":[ + { + "properties":{ + "label":{ + "enum":[ + "OR" + ] + }, + "value":{ + "enum":[ + "OR" + ] + } + }, + "required":[ + "label", + "value" + ] + } + ] + }, + "textualOperator":{ + "$id":"#textualOperator", + "description":"Textual operator", + "type":"object", + "properties":{ + "type":{ + "type":"string", + "enum":[ + "TEXTUAL_OPERATOR" + ] + }, + "variant":{ + "type":"string", + "enum":[ + "SINGLE_VALUE", + "ALL_ELEMENT", + "ANY_ELEMENT" + ] + } + }, + "required":[ + "type" + ], + "oneOf":[ + { + "$ref":"#/definitions/operatorContains" + }, + { + "$ref":"#/definitions/operatorDoesNotContains" + }, + { + "$ref":"#/definitions/operatorEqual" + }, + { + "$ref":"#/definitions/operatorNotEqual" + }, + { + "$ref":"#/definitions/operatorIn" + }, + { + "$ref":"#/definitions/operatorNotIn" + } + ] + }, + "numericalOperator":{ + "$id":"#numericalOperator", + "description":"Numerical operator", + "type":"object", + "properties":{ + "type":{ + "type":"string", + "enum":[ + "NUMERICAL_OPERATOR" + ] + }, + "variant":{ + "type":"string", + "enum":[ + "SINGLE_VALUE", + "ALL_ELEMENT", + "ANY_ELEMENT" + ] + } + }, + "required":[ + "type" + ], + "oneOf":[ + { + "$ref":"#/definitions/operatorEqual" + }, + { + "$ref":"#/definitions/operatorNotEqual" + }, + { + "$ref":"#/definitions/operatorIn" + }, + { + "$ref":"#/definitions/operatorNotIn" + }, + { + "$ref":"#/definitions/operatorLessThan" + }, + { + "$ref":"#/definitions/operatorLesserEqual" + }, + { + "$ref":"#/definitions/operatorGreaterEqual" + }, + { + "$ref":"#/definitions/operatorGreaterThan" + } + ] + }, + "logicalOperator":{ + "$id":"#logicalOperator", + "description":"Logical operator", + "type":"object", + "properties":{ + "type":{ + "type":"string", + "enum":[ + "LOGICAL_OPERATOR" + ] + } + }, + "required":[ + "type" + ], + "oneOf":[ + { + "$ref":"#/definitions/operatorAND" + }, + { + "$ref":"#/definitions/operatorOR" + } + ] + }, + "arrayOperator":{ + "$id":"#arrayOperator", + "description":"Array operator", + "type":"object", + "properties":{ + "type":{ + "type":"string", + "enum":[ + "ARRAY_OPERATOR" + ] + } + }, + "required":[ + "type" + ], + "oneOf":[ + { + "$ref":"#/definitions/operatorIncludes" + }, + { + "$ref":"#/definitions/operatorDoesNotInclude" + }, + { + "$ref":"#/definitions/operatorEqual" + }, + { + "$ref":"#/definitions/operatorNotEqual" + } + ] + }, + "criterion":{ + "$id":"#criterion", + "description":"Criterion", + "type":"object", + "properties":{ + "attribute":{ + "description":"Name of the attribute to filter", + "type":"string" + }, + "operator":{ + "oneOf":[ + { + "$ref":"#/definitions/numericalOperator" + }, + { + "$ref":"#/definitions/textualOperator" + }, + { + "$ref":"#/definitions/arrayOperator" + } + ] + }, + "value":{ + "description":"Value for the criterion." + } + } + }, + "expression":{ + "$id":"#expression", + "description":"Expression", + "type":"object", + "properties":{ + "logicalOperator":{ + "description":"Logical operator ruling the expression. For instance if the logical operator is AND, then all the expression will AND all the criteria and expressions, e.g., Criteria_1 AND Criteria_2 AND Expression_1 AND Expression_2", + "$ref":"#/definitions/logicalOperator" + }, + "criteria":{ + "description":"List of criteria in the expression", + "type":"array", + "items":{ + "$ref":"#/definitions/criterion" + } + }, + "expressions":{ + "description":"List of expression in the expression.", + "type":"array", + "items":{ + "$ref":"#/definitions/expression" + } + } + }, + "required":[ + "logicalOperator", + "criteria", + "expressions" + ] + }, + "imageFilterPost":{ + "$id":"#imageFilterPost", + "decription":"image filter when posted", + "type":"object", + "properties":{ + "filter":{ + "$ref":"#/definitions/expression" + } + }, + "required":[ + "filter" + ] + }, + "imageFilterDoc":{ + "$id":"#imageFilterDoc", + "decription":"image filter when posted", + "type":"object", + "properties":{ + "filter":{ + "$ref":"#/definitions/expression" + }, + "_id":{ + "type":"string", + "format": "uuid" + }, + "_rev":{ + "type":"string" + }, + "docType": { + "type": "string", + "enum": ["imageFilter"] + }, + "reference":{ + "type":"object", + "properties":{ + "ownerId": { + "type": "string", + "format": "uuid" + } + }, + "additionalProperties": false, + "required": ["ownerId"] + } + }, + "additionalProperties": false, + "required":[ + "filter", + "reference", + "docType" + ] + }, + "imageFilterSnapshotDoc":{ + "$id":"#imageFilterSnapshotDoc", + "decription":"image filter when posted", + "type":"object", + "properties":{ + "query":{ + "type":"object" + }, + "result":{ + "type":"array" + }, + "queryDate":{ + "type": "string" + }, + "_id":{ + "type":"string", + "format": "uuid" + }, + "docType": { + "type": "string", + "enum": ["imageFilterSnapshot"] + }, + "_rev":{ + "type":"string" + }, + "reference":{ + "type":"object", + "properties":{ + "ownerId": { + "type": "string" + }, + "imageFilterId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": ["ownerId","imageFilterId"] + } + }, + "required":[ + "query", + "result", + "queryDate", + "reference", + "docType" + ], + "additionalProperties": false + } + } +} diff --git a/schemas/imageFilterAttribute.json b/schemas/imageFilterAttribute.json new file mode 100644 index 0000000..dfc2c3c --- /dev/null +++ b/schemas/imageFilterAttribute.json @@ -0,0 +1,158 @@ +{ + "$id":"https://raw.githubusercontent.com/SPINEProject/SPINE-json-schema/master/schemas/imageFilterAttribute.schema.json", + "$schema":"http://json-schema.org/draft-07/schema#", + "title":"Image filter attribute", + "type":"object", + "definitions": { + "attributeBase": { + "$id": "#attributeBase", + "description": "Attribute base schema", + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "NUMBER", + "STRING" + ] + }, + "isOrdered": { + "type": "boolean" + }, + "attributeKey": { + "type": "string" + }, + "attributeLabel": { + "type": "string" + }, + "multiplicityMin": { + "type": "number", + "min": 1 + }, + "multiplicityMax": { + "oneOf": [ + { + "type": "number", + "min": 1 + }, + { + "type": "string", + "enum": [ + "N" + ] + } + ] + }, + "options": { + "type": "object", + "properties": { + "areOtherValuesAllowed": { + "type": "boolean" + }, + "enum": { + "type": "array" + }, + "min": { + "type": "number" + }, + "max": { + "type": "number" + } + }, + "required": [ + "areOtherValuesAllowed" + ], + "additionalProperties": false + } + }, + "required": [ + "type", + "attributeKey", + "attributeLabel", + "multiplicityMin", + "multiplicityMax", + "options" + ], + "additionalProperties": false + }, + "attributeNumber": { + "$id": "#attributeNumber", + "description": "Attribute schema when atribute type is number", + "type": "object", + "allOf": [{ + "properties": { + "type": { + "type": "string", + "enum": [ + "NUMBER" + ] + }, + "options": { + "properties": { + "areOtherValuesAllowed": {}, + "enum": { + "items": { + "type": "number" + } + }, + "min": {}, + "max": {} + }, + "additionalProperties": false + } + }},{ + "$ref": "#/definitions/attributeBase" + }] + }, + "attributeString": { + "$id": "#attributeString", + "description": "Attribute schema when atribute type is string", + "type": "object", + "allOf": [ + { + "properties": { + "type": { + "type": "string", + "enum": [ + "STRING" + ] + }, + "options": { + "properties": { + "areOtherValuesAllowed": {}, + "enum": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + } + } + }, + { + "$ref": "#/definitions/attributeBase" + } + ] + }, + "attribute": { + "$id": "#attribute", + "description": "Attribute", + "type": "object", + "oneOf": [ + { + "$ref": "#/definitions/attributeNumber" + }, + { + "$ref": "#/definitions/attributeString" + } + ] + } + }, + "allOf": [ + { + "$ref": "#/definitions/attribute" + } + ] +}