{
  "swagger": "2.0",
  "info": {
    "contact": {
      "email": "info@ehealth.fgov.be",
      "name": "eHealth Platform Belgium"
    },
    "title": "API eHealth Consent",
    "version": "2.1"
  },
  "host": "api.ehealth.fgov.be",
  "basePath": "/consent/v2",
  "schemes": [
    "https"
  ],
  "paths": {
    "/consents/{patientSsin}": {
      "delete": {
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "description": "Id of the patient (SSIN)",
            "in": "path",
            "name": "patientSsin",
            "required": true,
            "type": "string"
          },
          {
            "description": "Support card id of the patient, used for a stronger authentication in some cases. Is cross-checked with the inss.",
            "in": "query",
            "name": "patientCardNumber",
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "Success"
          },
          "400": {
            "description": "Validation error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "404": {
            "description": "No active consent for the patient",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "409": {
            "description": "The consent of a deceased patient cannot be updated",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "500": {
            "description": "Internal server error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          }
        },
        "security": [
          {
            "OAuth2": [
              "rest-access"
            ]
          }
        ],
        "tags": [
          "consent"
        ],
        "description": "Revokes the Consent of a patient",
        "operationId": "revokeConsent"
      },
      "get": {
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "description": "Id of the patient (SSIN)",
            "in": "path",
            "name": "patientSsin",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "The consent is found, with a status revoked, active or deceased",
            "schema": {
              "$ref": "#/definitions/consent"
            }
          },
          "400": {
            "description": "Validation error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "404": {
            "description": "No consent found for the patient",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "500": {
            "description": "Internal server error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          }
        },
        "security": [
          {
            "OAuth2": [
              "rest-access"
            ]
          }
        ],
        "tags": [
          "consent"
        ],
        "description": "Gets the Consent of a patient",
        "operationId": "getConsent"
      },
      "post": {
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "description": "Id of the patient (SSIN)",
            "in": "path",
            "name": "patientSsin",
            "required": true,
            "type": "string"
          },
          {
            "description": "Support card id of the patient, used for a stronger authentication in some cases. Is cross-checked with the inss.",
            "in": "query",
            "name": "patientCardNumber",
            "type": "string"
          }
        ],
        "responses": {
          "201": {
            "description": "Success"
          },
          "400": {
            "description": "Validation error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "409": {
            "description": "Consent already exists for the patient",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "500": {
            "description": "Internal server error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          }
        },
        "security": [
          {
            "OAuth2": [
              "rest-access"
            ]
          }
        ],
        "tags": [
          "consent"
        ],
        "description": "Activates the Consent of a patient",
        "operationId": "declareConsent"
      }
    },
    "/health": {
      "get": {
        "produces": [
          "application/json"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Service is UP",
            "schema": {
              "$ref": "#/definitions/HealthStatus"
            }
          },
          "403": {
            "description": "Unauthorized"
          },
          "500": {
            "description": "Internal server error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "503": {
            "description": "The service is DOWN or OUT_OF_SERVICE",
            "examples": {
              "application/json": {
                "details": {
                  "datastore": {
                    "status": "OUT_OF_SERVICE"
                  }
                },
                "status": "DOWN"
              }
            },
            "schema": {
              "$ref": "#/definitions/HealthStatus"
            }
          }
        },
        "security": [
          {
            "OAuth2": [
              "monitoring"
            ]
          }
        ],
        "tags": [
          "monitoring consent"
        ],
        "description": "Get the monitoring status of the service consent. Note that is only allowed for eHealth internal use.",
        "operationId": "getMonitoringInfo"
      }
    },
    "/histories/{patientSsin}": {
      "get": {
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "description": "Id of the patient (SSIN)",
            "in": "path",
            "name": "patientSsin",
            "required": true,
            "type": "string"
          },
          {
            "description": "limit of number of history entries",
            "in": "query",
            "name": "pageSize",
            "type": "integer"
          }
        ],
        "responses": {
          "200": {
            "description": "The consent history is found",
            "schema": {
              "items": {
                "$ref": "#/definitions/historyEntry"
              },
              "type": "array"
            }
          },
          "400": {
            "description": "Validation error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "404": {
            "description": "No consent history found for the patient",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          },
          "500": {
            "description": "Internal server error",
            "schema": {
              "items": {
                "$ref": "#/definitions/error"
              },
              "type": "array"
            }
          }
        },
        "security": [
          {
            "OAuth2": [
              "rest-access"
            ]
          }
        ],
        "tags": [
          "consent"
        ],
        "description": "Gets the Consent history of a patient",
        "operationId": "getConsentHistory"
      }
    }
  },
  "definitions": {
    "ComponentStatus": {
      "example": {
        "name": "name",
        "status": "status"
      },
      "properties": {
        "name": {
          "type": "string"
        },
        "status": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "HealthLevel": {
      "type": "string"
    },
    "HealthStatus": {
      "example": {
        "details": [
          {
            "name": "name",
            "status": "status"
          },
          {
            "name": "name",
            "status": "status"
          }
        ],
        "status": "status"
      },
      "properties": {
        "details": {
          "items": {
            "$ref": "#/definitions/ComponentStatus"
          },
          "type": "array"
        },
        "status": {
          "type": "string"
        }
      },
      "required": [
        "status"
      ],
      "type": "object"
    },
    "actor": {
      "example": {
        "firstName": "firstName",
        "identifier": [
          {
            "type": "type",
            "value": "value"
          },
          {
            "type": "type",
            "value": "value"
          }
        ],
        "name": "name",
        "qualificationCode": "qualificationCode"
      },
      "properties": {
        "firstName": {
          "type": "string"
        },
        "identifier": {
          "items": {
            "$ref": "#/definitions/identifier"
          },
          "minItems": 1,
          "type": "array"
        },
        "name": {
          "type": "string"
        },
        "qualificationCode": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "consent": {
      "example": {
        "patient": {
          "identifier": [
            {
              "type": "type",
              "value": "value"
            },
            {
              "type": "type",
              "value": "value"
            }
          ]
        },
        "revokeDate": "2000-01-23",
        "signDate": "2000-01-23",
        "status": "status"
      },
      "properties": {
        "patient": {
          "$ref": "#/definitions/patient"
        },
        "revokeDate": {
          "format": "date",
          "type": "string"
        },
        "signDate": {
          "format": "date",
          "type": "string"
        },
        "status": {
          "type": "string"
        }
      },
      "required": [
        "patient",
        "signDate",
        "status"
      ],
      "type": "object"
    },
    "error": {
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "historyEntry": {
      "example": {
        "author": [
          {
            "firstName": "firstName",
            "identifier": [
              {
                "type": "type",
                "value": "value"
              },
              {
                "type": "type",
                "value": "value"
              }
            ],
            "name": "name",
            "qualificationCode": "qualificationCode"
          },
          {
            "firstName": "firstName",
            "identifier": [
              {
                "type": "type",
                "value": "value"
              },
              {
                "type": "type",
                "value": "value"
              }
            ],
            "name": "name",
            "qualificationCode": "qualificationCode"
          }
        ],
        "operation": "operation",
        "timestamp": "2000-01-23T04:56:07.000+00:00"
      },
      "properties": {
        "author": {
          "items": {
            "$ref": "#/definitions/actor"
          },
          "type": "array"
        },
        "operation": {
          "type": "string"
        },
        "timestamp": {
          "format": "date-time",
          "type": "string"
        }
      },
      "required": [
        "author",
        "operation",
        "timestamp"
      ],
      "type": "object"
    },
    "identifier": {
      "example": {
        "type": "type",
        "value": "value"
      },
      "properties": {
        "type": {
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "value"
      ],
      "type": "object"
    },
    "patient": {
      "example": {
        "identifier": [
          {
            "type": "type",
            "value": "value"
          },
          {
            "type": "type",
            "value": "value"
          }
        ]
      },
      "properties": {
        "identifier": {
          "items": {
            "$ref": "#/definitions/identifier"
          },
          "minItems": 1,
          "type": "array"
        }
      },
      "required": [
        "identifier"
      ],
      "type": "object"
    }
  },
  "securityDefinitions": {
    "OAuth2": {
      "authorizationUrl": "https://api.ehealth.fgov.be/auth/realms/YourRealm/protocol/openid-connect/auth",
      "flow": "accessCode",
      "scopes": {
        "monitoring": "This is a workaround, don't use me",
        "rest-access": "Allows all operations on Consent service"
      },
      "tokenUrl": "https://api.ehealth.fgov.be/auth/realms/YourRealm/protocol/openid-connect/token",
      "type": "oauth2"
    }
  },
  "x-components": {}
}
