openapi: 3.0.0
info:
  title: Clinics API
  version: '1.0'
  description: >-
    Web service that stores information about clinics, clinicians and their
    patients
  contact:
    name: Tidepool
    url: https://www.tidepool.org
    email: support@tidepool.org
  license:
    name: BSD-2-Clause
    url: https://github.com/tidepool-org/clinic/blob/master/LICENSE
  x-tidepool-service: https://github.com/tidepool-org/clinic/
servers:
  - url: https://external.integration.tidepool.org
    description: integration
  - url: https://api.tidepool.org
    description: production
  - url: https://dev1.dev.tidepool.org
    description: dev1
  - url: https://qa1.development.tidepool.org
    description: qa1
  - url: https://qa2.development.tidepool.org
    description: qa2
paths:
  /v1/clinics:
    get:
      summary: List Clinics
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinics.v1'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.v1'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.v1'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.v1'
      operationId: ListClinics
      description: Retrieve the list of clinics
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/shareCode'
        - $ref: '#/components/parameters/createdTimeStart'
        - $ref: '#/components/parameters/createdTimeEnd'
        - $ref: '#/components/parameters/ehrEnabled'
      x-roles:
        - TIDEPOOL_ADMIN
        - CLINIC_ADMIN
        - CLINIC_CLINICIAN
    parameters: []
    post:
      summary: Create Clinic
      operationId: CreateClinic
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinic.v1'
            application/xml:
              schema:
                type: object
                properties: {}
        '400':
          description: Bad Request
        '403':
          description: Forbidden
        '500':
          description: Internal Server Error
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/clinic.v1'
      description: Create a new clinic
      x-roles: []
      tags:
        - Clinics
      parameters: []
  /v1/clinics/share_code/{shareCode}:
    parameters:
      - schema:
          type: string
          minLength: 1
        name: shareCode
        in: path
        required: true
    get:
      summary: Get Clinic by Share Code
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinic.v1'
      operationId: GetClinicByShareCode
      description: Retrieve a clinic object with a share code
  /v1/clinics/{clinicId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      summary: Get Clinic
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinic.v1'
          links:
            get-clinicians:
              operationId: get-clinics-clinicid-clinicians
              parameters:
                clinicid: $request.query.clinicid
        '400':
          description: Bad Request
        '403':
          description: Forbidden
        '500':
          description: Internal Server Error
      operationId: GetClinic
      description: Retrieve a clinic by id
      x-roles:
        - TIDEPOOL_ADMIN
        - CLINIC_ADMIN
        - CLINIC_CLINICIAN
      parameters: []
    put:
      summary: Update Clinic
      operationId: UpdateClinic
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinic.v1'
        '400':
          description: Bad Request
        '403':
          description: Forbidden
        '500':
          description: Internal Server Error
      description: Update an existing clinic
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/clinic.v1'
          application/xml:
            schema:
              type: object
              properties: {}
        description: ''
      security:
        - sessionToken: []
      x-roles:
        - TIDEPOOL_ADMIN
        - CLINIC_ADMIN
      tags:
        - Clinics
    delete:
      summary: Delete Clinic
      operationId: DeleteClinic
      responses:
        '204':
          description: No Content
      description: >-
        Deletes a clinic if there are no connected patient accounts (besides
        demo accounts).
      tags:
        - Clinics
  /v1/clinics/{clinicId}/clinicians:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      summary: List Clinicians
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinicians.v1'
      operationId: ListClinicians
      description: 'Retrieve the list of clinic members. '
      parameters:
        - $ref: '#/components/parameters/search'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/email'
        - $ref: '#/components/parameters/role'
    post:
      summary: Create Clinician
      operationId: CreateClinician
      responses:
        '200':
          description: OK
      description: Internal endpoint to create a new clinician
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/clinician.v1'
      tags:
        - Clinics
  /v1/clinics/{clinicId}/tide_report:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      summary: View TIDE Report
      description: Retrieve a report of patients with tags by TIDE categories
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/tideResponse.v1'
      operationId: TideReport
      parameters:
        - schema:
            type: string
            pattern: ^(1d|7d|14d|30d)$
            example: 7d
          in: query
          name: period
          description: Time Period to display
          required: true
        - name: tags
          description: Comma-separated list of patient tag IDs
          schema:
            type: array
            items:
              $ref: '#/components/schemas/objectId.v1'
            minItems: 1
          in: query
          style: form
          explode: false
          required: true
        - name: lastDataCutoff
          description: Inclusive minimum of date of last data from a patient.
          schema:
            type: string
            format: date-time
          in: query
          required: true
        - name: categories
          description: >
            Comma-separated list of TIDE report categories to return in queried
            order. If omitted or empty, the default TIDE categories will be
            returned - see example.
          schema:
            type: array
            x-go-type-skip-optional-pointer: true
            x-omitempty: true
            x-omitzero: true
            items:
              type: string
              enum:
                - timeInVeryLowPercent
                - timeInAnyLowPercent
                - timeInExtremeHighPercent
                - timeInVeryHighPercent
                - timeInAnyHighPercent
                - dropInTimeInTargetPercent
                - timeInTargetPercent
                - timeCGMUsePercent
                - meetingTargets
          in: query
          style: form
          explode: false
          example:
            - timeInVeryLowPercent
            - timeInAnyLowPercent
            - timeInVeryHighPercent
            - timeInAnyHighPercent
            - dropInTimeInTargetPercent
            - timeCGMUsePercent
            - meetingTargets
        - name: excludeNoData
          description: >-
            If true, then exclude / omit patients with no data in the TIDE
            report.
          schema:
            type: boolean
            x-go-type-skip-optional-pointer: true
            x-omitempty: true
          in: query
  /v1/clinics/{clinicId}/patients:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      summary: List Patients
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientsResponse.v1'
      operationId: ListPatients
      parameters:
        - $ref: '#/components/parameters/search'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/sort'
        - schema:
            type: string
            pattern: ^(cgm|bgm)$
            example: cgm
          in: query
          name: sortType
          description: Summary type to sort by
        - schema:
            type: string
            pattern: ^(1d|7d|14d|30d)$
            example: 7d
          in: query
          name: period
          description: Time Period to display, filter, and sort
        - schema:
            type: string
            format: date-time
          in: query
          name: lastReviewed
          description: Inclusive
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.max
          description: Max glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.min
          description: Min glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.averageGlucoseMmol
          description: Average glucose value of records in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.glucoseManagementIndicator
          description: Glucose management Indicator of records
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeCGMUsePercent
          description: Percentage of time [0.0-1.0]  of CGM use
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInVeryLowPercent
          description: Percentage of time [0.0-1.0]  below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInAnyLowPercent
          description: Percentage of time [0.0-1.0]  below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInLowPercent
          description: Percentage of time [0.0-1.0]  in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInTargetPercent
          description: Percentage of time [0.0-1.0]  in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInHighPercent
          description: Percentage of time [0.0-1.0]  in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInVeryHighPercent
          description: Percentage of time [0.0-1.0]  above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInExtremeHighPercent
          description: Percentage of time [0.0-1.0]  above 350 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInAnyHighPercent
          description: Percentage of time [0.0-1.0]  above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeCGMUseMinutes
          description: Minutes of CGM use
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInVeryLowMinutes
          description: Minutes below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInAnyLowMinutes
          description: Minutes below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInLowMinutes
          description: Minutes in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInTargetMinutes
          description: Minutes in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInHighMinutes
          description: Minutes in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInVeryHighMinutes
          description: Minutes above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInExtremeHighMinutes
          description: Minutes above 350 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInAnyHighMinutes
          description: Minutes above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeCGMUseRecords
          description: Records of CGM use
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInVeryLowRecords
          description: Records below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInAnyLowRecords
          description: Records below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInLowRecords
          description: Records in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInTargetRecords
          description: Records in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInHighRecords
          description: Records in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInVeryHighRecords
          description: Records above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInAnyHighRecords
          description: Records above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.averageDailyRecords
          description: Average records per day
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.totalRecords
          description: Total records in period
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.hoursWithData
          description: Total hours with data in period
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.daysWithData
          description: Total days with data in period
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.standardDeviation
          description: Standard deviation of glucose values in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.coefficientOfVariation
          description: Coefficient Of Variation of glucose values in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.max
          description: Max glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.min
          description: Min glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.averageGlucoseMmol
          description: Average glucose value of records in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInVeryLowPercent
          description: Percentage of time [0.0-1.0]  below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInAnyLowPercent
          description: Percentage of time [0.0-1.0]  below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInLowPercent
          description: Percentage of time [0.0-1.0]  in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInTargetPercent
          description: Percentage of time [0.0-1.0]  in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInHighPercent
          description: Percentage of time [0.0-1.0]  in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInVeryHighPercent
          description: Percentage of time [0.0-1.0]  above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInExtremeHighPercent
          description: Percentage of time [0.0-1.0]  above 350 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInAnyHighPercent
          description: Percentage of time [0.0-1.0]  above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInVeryLowRecords
          description: Records below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInAnyLowRecords
          description: Records below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInLowRecords
          description: Records in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInTargetRecords
          description: Records in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInHighRecords
          description: Records in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInVeryHighRecords
          description: Records above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInAnyHighRecords
          description: Records above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.averageDailyRecords
          description: Average records per day
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.totalRecords
          description: Total records in period
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.maxDelta
          description: Delta of Max glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.minDelta
          description: Delta of Min glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.averageGlucoseMmolDelta
          description: Delta of average glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.glucoseManagementIndicatorDelta
          description: Glucose management Indicator of records
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeCGMUsePercentDelta
          description: Delta of time of CGM use
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInVeryLowPercentDelta
          description: Delta of time below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInAnyLowPercentDelta
          description: Delta of time below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInLowPercentDelta
          description: Delta of time in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInTargetPercentDelta
          description: Delta of time in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInHighPercentDelta
          description: Delta of time in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInVeryHighPercentDelta
          description: Delta of time above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInExtremeHighPercentDelta
          description: Delta of time above 350 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.timeInAnyHighPercentDelta
          description: Delta of time above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeCGMUseMinutesDelta
          description: Delta of minutes of CGM use
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInVeryLowMinutesDelta
          description: Delta of minutes below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInAnyLowMinutesDelta
          description: Delta of minutes below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInLowMinutesDelta
          description: Delta of minutes in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInTargetMinutesDelta
          description: Delta of minutes in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInHighMinutesDelta
          description: Delta of minutes in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInVeryHighMinutesDelta
          description: Delta of minutes above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInExtremeHighMinutesDelta
          description: Delta of minutes above 350 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInAnyHighMinutesDelta
          description: Delta of minutes above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeCGMUseRecordsDelta
          description: Delta of records count
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInVeryLowRecordsDelta
          description: Delta of records below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInAnyLowRecordsDelta
          description: Delta of records below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInLowRecordsDelta
          description: Delta of records in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInTargetRecordsDelta
          description: Delta of records in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInHighRecordsDelta
          description: Delta of records in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInVeryHighRecordsDelta
          description: Delta of records above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.timeInAnyHighRecordsDelta
          description: Delta of records above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.averageDailyRecordsDelta
          description: Delta of average records per day
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.totalRecordsDelta
          description: Delta of total records
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.hoursWithDataDelta
          description: Delta of total hours with data
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: cgm.daysWithDataDelta
          description: Delta of total days with data
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.standardDeviationDelta
          description: Delta of the standard deviation of glucose values in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: cgm.coefficientOfVariationDelta
          description: Delta of the coefficient of glucose values in mmol/L
        - schema:
            type: string
            format: date-time
          in: query
          name: cgm.lastDataFrom
          description: Inclusive
        - schema:
            type: string
            format: date-time
          in: query
          name: cgm.lastDataTo
          description: Exclusive
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.maxDelta
          description: Delta of Max glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.minDelta
          description: Delta of Min glucose value in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.averageGlucoseMmolDelta
          description: Delta of the average glucose values in mmol/L
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInVeryLowPercentDelta
          description: Delta of time below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInAnyLowPercentDelta
          description: Delta of time below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInLowPercentDelta
          description: Delta of time in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInTargetPercentDelta
          description: Delta of time in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInHighPercentDelta
          description: Delta of time in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInVeryHighPercentDelta
          description: Delta of time above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInExtremeHighPercentDelta
          description: Delta of time above 350 mg/dL
        - schema:
            $ref: '#/components/schemas/FloatFilter'
          in: query
          name: bgm.timeInAnyHighPercentDelta
          description: Delta of time above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInVeryLowRecordsDelta
          description: Delta of records below 54 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInAnyLowRecordsDelta
          description: Delta of records below 70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInLowRecordsDelta
          description: Delta of records in range 54-70 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInTargetRecordsDelta
          description: Delta of records in range 70-180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInHighRecordsDelta
          description: Delta of records in range 180-250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInVeryHighRecordsDelta
          description: Delta of records above 250 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.timeInAnyHighRecordsDelta
          description: Delta of records above 180 mg/dL
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.averageDailyRecordsDelta
          description: Delta of average records per day
        - schema:
            $ref: '#/components/schemas/IntFilter'
          in: query
          name: bgm.totalRecordsDelta
          description: Delta of total record count
        - schema:
            type: string
            format: date-time
          in: query
          name: bgm.lastDataFrom
          description: Inclusive
        - schema:
            type: string
            format: date-time
          in: query
          name: bgm.lastDataTo
          description: Exclusive
        - schema:
            type: array
            items:
              type: string
              format: ^[a-f0-9]{24}$
          in: query
          name: tags
          description: Comma-separated list of patient tag IDs
          style: form
          explode: false
        - name: sites
          schema:
            type: array
            items:
              type: string
              format: ^[a-f0-9]{24}$
          in: query
          description: Comma-separated list of clinic site IDs
          style: form
          explode: false
        - name: omitNonStandardRanges
          description: |
            Whether patients whose glycemic ranges selection is *not*
            the ADA standard ranges (e.g. as used by the TIDE report)
            should be omitted.
          schema:
            type: boolean
          in: query
      description: Retrieve a list of patients of a clinic
    post:
      summary: Create Patient Account
      operationId: CreatePatientAccount
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patient.v1'
      description: Create a custodial account for a patient
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patient.v1'
      tags:
        - Clinics
  /v1/clinics/{clinicId}/patient_tags:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Create Patient Tag
      operationId: CreatePatientTag
      responses:
        '200':
          description: The newly-created patient tag
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientTag.v1'
      description: Create a new patient tag
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patientTag.v1'
      tags:
        - Clinics
  /v1/clinics/{clinicId}/sites:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Create a Site
      operationId: CreateSite
      responses:
        '200':
          description: The newly-created clinic site
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/site.v1'
      description: Create a Site
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/siteCreation.v1'
      tags:
        - Clinics
  /v1/clinics/{clinicId}/sites/{siteId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/siteId'
    put:
      summary: Update a Site
      operationId: UpdateSite
      responses:
        '200':
          description: The updated clinic site
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/site.v1'
      description: Update a Site
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/site.v1'
      tags:
        - Clinics
    delete:
      summary: Delete a Site
      operationId: DeleteSite
      responses:
        '204':
          description: No content
      description: Delete a Site
      tags:
        - Clinics
  /v1/clinics/{clinicId}/sites/{siteId}/merge:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/siteId'
    post:
      summary: Merge two sites
      operationId: MergeSite
      responses:
        '200':
          description: The merged clinic site
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/site.v1'
      description: >-
        Merge a site, identified in the request body, into the site identified
        in the URL.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/siteById.v1'
      tags:
        - Clinics
  /v1/clinics/{clinicId}/clinicians/{clinicianId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/clinicianId'
    get:
      summary: Get Clinician
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinician.v1'
      operationId: GetClinician
      description: Retrieve a member of clinic given their user id
    put:
      summary: Update Clinician
      operationId: UpdateClinician
      responses:
        '200':
          description: OK
      description: Update existing clinician
      tags:
        - Clinics
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/clinician.v1'
    delete:
      summary: Delete Clinician
      operationId: DeleteClinician
      responses:
        '200':
          description: OK
      description: Removes a clinician from a clinic
      tags:
        - Clinics
  /v1/clinics/{clinicId}/patients/{patientId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientId'
    get:
      summary: Get Patient
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patient.v1'
      operationId: GetPatient
      description: Retrieve a patient of clinic given their user id
    post:
      summary: Create Patient from Existing User
      operationId: CreatePatientFromUser
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patient.v1'
      description: Internal endpoint for creating a patient from an existing user
      tags:
        - Clinics
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createPatient.v1'
    put:
      summary: Update Patient
      operationId: UpdatePatient
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patient.v1'
      description: Update existing patient of a clinic
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patient.v1'
      tags:
        - Clinics
    delete:
      summary: Delete Patient
      operationId: DeletePatient
      responses:
        '204':
          description: No Content
      description: >-
        Deletes patient from a clinic. Requires the request to be made by a
        clinic admin or the currently authenticated user id to match the patient
        id.
      tags:
        - Clinics
  /v1/clinics/{clinicId}/patient_tags/{patientTagId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientTagId'
    put:
      summary: Update Patient Tag
      operationId: UpdatePatientTag
      responses:
        '200':
          description: The updated patient tag
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientTag.v1'
      description: Update existing patient tag
      tags:
        - Clinics
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patientTag.v1'
    delete:
      summary: Delete Patient Tag
      operationId: DeletePatientTag
      responses:
        '204':
          description: No content
      description: Removes a patient tag from a clinic and tagged patients
      tags:
        - Clinics
  /v1/clinics/{clinicId}/patient_tags/{patientTagId}/site:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientTagId'
    post:
      summary: Convert Patient Tag to Site
      operationId: ConvertPatientTagToSite
      responses:
        '200':
          description: The newly converted site.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/site.v1'
        '409':
          description: >-
            Cannot convert the tag to a site. This could occur for example when
            the maximum number of sites has already been reached.
      description: Convert a patient tag to a site.
      tags:
        - Clinics
  /v1/clinics/{clinicId}/invites/clinicians:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Invite Clinician
      operationId: InviteClinician
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinician.v1'
      description: Send an invite to clinician's email address to join a clinic.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/inviteClinician.v1'
      tags:
        - Clinics
        - Confirmations
  /v1/clinics/{clinicId}/invites/clinicians/{inviteId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/inviteId'
    patch:
      summary: Resend Clinician Invite
      operationId: ResendInvite
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/confirmation.v1'
      description: Resend invite to the email address of the clinician.
      tags:
        - Clinics
        - Confirmations
    delete:
      summary: Delete Invite
      operationId: DeleteInvite
      responses:
        '200':
          description: OK
      description: Deletes unaccepted invite
      tags:
        - Clinics
        - Confirmations
    get:
      summary: Get Clinician Invite
      operationId: GetClinicianInvite
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/confirmation.v1'
      description: Retrieve an invitation sent to clinician to join the clinic
      tags:
        - Confirmations
  /v1/clinics/{clinicId}/invites/clinicians/{inviteId}/clinician:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/inviteId'
    patch:
      summary: Associate Clinician to User
      operationId: AssociateClinicianToUser
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinician.v1'
      description: Internal endpoint to associate a clinician to a user.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/associateClinicianToUser.v1'
      tags:
        - Clinics
    delete:
      summary: Delete Invited Clinician
      operationId: DeleteInvitedClinician
      responses:
        '200':
          description: OK
      description: Internal endpoint to delete an invited clinician object
      tags:
        - Clinics
    get:
      summary: Get Invited Clinician
      operationId: GetInvitedClinician
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinician.v1'
      description: Internal endpoint to retrieve invited clinician.
      tags:
        - Clinics
  /v1/clinics/{clinicId}/invites/patients:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      summary: Get Patient Invites
      tags:
        - Clinics
        - Confirmations
      responses:
        '200':
          description: OK
      operationId: GetPatientInvites
      description: >-
        Retrieve the list of all pending invites from users who would like to
        share their accounts with the clinic and become patients.
  /v1/clinics/{clinicId}/invites/patients/{inviteId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/inviteId'
    put:
      summary: Accept Patient Invitation
      operationId: AcceptPatientInvitation
      responses:
        '200':
          description: OK
      description: >-
        Accept a pending invite from a user who would like to share their
        account with the clinic and become a patient.
      tags:
        - Clinics
        - Confirmations
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AcceptPatientInvitation'
  /v1/clinics/{clinicId}/patients/{patientId}/reviews:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientId'
    put:
      summary: Update Patient Reviews
      operationId: UpdatePatientReviews
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientReviews.v1'
      description: Update the patient's last reviewed date and clinician ID
      tags:
        - Clinics
    delete:
      summary: Delete Patient Reviews
      operationId: DeletePatientReviews
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientReviews.v1'
        '404':
          description: No review to delete
        '409':
          description: Cannot revert a different clinician's review
      description: Revert the patient's last reviewed date to the previous set
      tags:
        - Clinics
  /v1/clinics/{clinicId}/patients/{patientId}/permissions:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientId'
    put:
      summary: Update Patient Permissions
      operationId: UpdatePatientPermissions
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientPermissions.v1'
      description: >-
        Update permissions that a clinic has over a patient account. If all
        permissions are revoked as a result of the update, the patient profile
        will be removed from the clinic.


        Only patients can change the permissions.
      tags:
        - Clinics
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patientPermissions.v1'
      parameters: []
  /v1/clinics/{clinicId}/patients/{patientId}/permissions/{permission}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientId'
      - schema:
          type: string
          enum:
            - custodian
            - view
            - upload
            - note
        name: permission
        in: path
        required: true
    delete:
      summary: Delete Patient Permission
      operationId: DeletePatientPermission
      description: >-
        Remove a single permission that a clinic has over a patient account. If
        all permissions are revoked as a result of the update, the patient
        profile will be removed from the clinic.


        Only patients can change the permissions.
      tags:
        - Clinics
      parameters: []
      responses:
        '204':
          description: No Content
  /v1/patients/{userId}/clinics:
    parameters:
      - $ref: '#/components/parameters/userId'
    get:
      summary: List Clinics for Patient
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientClinicRelationships.v1'
      operationId: ListClinicsForPatient
      description: Get all clinics a user is a patient of
      parameters:
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
  /v1/clinicians/{userId}/invites:
    parameters:
      - $ref: '#/components/parameters/userId'
    get:
      summary: List Clinician Invites
      tags:
        - Clinics
        - Confirmations
      responses:
        '200':
          description: OK
      operationId: ListClinicianInvites
      description: Retrieve a list of the outstanding invites to join a clinic
  /v1/clinicians/{userId}/invites/{inviteId}:
    parameters:
      - $ref: '#/components/parameters/userId'
      - $ref: '#/components/parameters/inviteId'
    delete:
      summary: Dismiss Clinician Invite
      operationId: DismissClinicianInvite
      responses:
        '200':
          description: OK
      tags:
        - Clinics
        - Confirmations
      description: Dismisses an invite sent from a clinic to clinician
    put:
      summary: Accept Clinician Invite
      operationId: AcceptClinicianInvite
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinician.v1'
      description: >-
        Accept an invite to join a clinic as clinician. The clinician will be
        associated to the currently authenticated user if the email in their
        profile matches the email of the invite.
      tags:
        - Clinics
        - Confirmations
  /v1/clinicians/{userId}/clinics:
    parameters:
      - $ref: '#/components/parameters/userId'
    get:
      summary: List Clinics for Clinician
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinicianClinicRelationships.v1'
      operationId: ListClinicsForClinician
      description: Returns a list of all clinics a clinician is a member of
      parameters:
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
  /v1/clinics/{clinicId}/migrations:
    parameters:
      - schema:
          type: string
        name: clinicId
        in: path
        required: true
    post:
      summary: Migrate Legacy Clinician Patients
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/migration.v1'
      operationId: MigrateLegacyClinicianPatients
      tags:
        - Clinics
        - Internal
      description: 'Migrate the patients of a legacy clinic account. '
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/migration.v1'
    get:
      summary: Retrieve Migration Status
      operationId: ListMigrations
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/migrations.v1'
      description: ListMigrations
      tags:
        - Clinics
        - Internal
  /v1/clinicians/{userId}/migrate:
    parameters:
      - schema:
          type: string
        name: userId
        in: path
        required: true
    post:
      summary: Enable Clinics
      tags:
        - Clinics
        - Internal
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clinic.v1'
      operationId: EnableNewClinicExperience
      description: >-
        Internal only endpoint to enable new clinic experience for a legacy
        clinician account. Patients won't be migrated until the clinic details
        are populated and migration is explicitly kicked-off by blip.
  /v1/clinics/{clinicId}/migrate:
    parameters:
      - schema:
          type: string
        name: clinicId
        in: path
        required: true
    post:
      summary: Trigger initial migration
      tags:
        - Clinics
        - Internal
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/migration.v1'
      operationId: TriggerInitialMigration
      description: Trigger the initial migration
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/triggerMigration.v1'
  /v1/clinics/{clinicId}/migrations/{userId}:
    parameters:
      - $ref: '#/components/parameters/clinicId.v1'
      - $ref: '#/components/parameters/userId'
    get:
      summary: Get Migration
      tags:
        - Clinics
        - Internal
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/migration.v1'
      operationId: GetMigration
      description: Get a migration by user id
    patch:
      summary: Update Migration
      operationId: UpdateMigration
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/migration.v1'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/migrationUpdate.v1'
      description: Internal endpoint to update the status of a migration
      tags:
        - Clinics
        - Internal
  /v1/users/{userId}/clinics:
    parameters:
      - $ref: '#/components/parameters/userId'
    delete:
      summary: Remove User from Clinics
      operationId: DeleteUserFromClinics
      responses:
        '200':
          description: OK
      tags:
        - Clinics
        - Internal
      description: >-
        Internal endpoint that deletes any user associations with clinics they
        are a patient or a member of.


        If the user is a patient of a clinic the service will delete the
        patient-clinic relationship.


        If the user is one of many admins of any clinic the service will delete
        the clinician-clinic relationship.


        If the user is the only admin of a clinic the service will:

        - delete the clinician record, leaving the clinic without an admin

        - delete all non-custodial patient relationships of the clinic

        - keep all custodian relationships, allowing users to claim custodial
        accounts with an email

        - keep all custodian accounts and data even if they can’t be claimed
        when there isn’t an email address associated with the account
    post:
      summary: Update User Details
      operationId: UpdateClinicUserDetails
      responses:
        '204':
          description: No Content
      description: >-
        Internal endpoint to update clinician details. In the future it may be
        extended to support patient updates.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateUserDetails.v1'
      tags:
        - Clinics
        - Internal
  /v1/clinicians:
    get:
      summary: List All Clinicians
      tags:
        - Clinics
        - Internal
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/clinicianClinicRelationship.v1'
      operationId: ListAllClinicians
      parameters:
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/createdTimeStart'
        - $ref: '#/components/parameters/createdTimeEnd'
      description: >-
        Returns list of all clinician/clinic relationships in the system.
        Internal endpoint used for reporting purposes.
  /v1/patients/{patientId}/summary:
    parameters:
      - $ref: '#/components/parameters/patientId'
    post:
      summary: UpdatePatientSummary
      operationId: UpdatePatientSummary
      responses:
        '200':
          description: OK
        '404':
          description: Not Found
      description: >-
        Internal endpoint which updates the summary in all patient records which
        match the user id.
      tags:
        - Clinics
        - Internal
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patientSummary.v1'
        description: ''
  /v1/summaries/{summaryId}/clinics:
    parameters:
      - $ref: '#/components/parameters/summaryId'
    delete:
      summary: DeletePatientSummary
      operationId: DeletePatientSummary
      responses:
        '200':
          description: OK
        '204':
          description: No Change
      description: >-
        Internal endpoint which deletes the summary in all patient records which
        match the summary id.
      tags:
        - Clinics
        - Internal
  /v1/patients/{userId}/data_sources:
    parameters:
      - $ref: '#/components/parameters/userId'
    put:
      summary: Create or update a data source for a patient
      operationId: UpdatePatientDataSources
      responses:
        '200':
          description: OK
        '404':
          description: Not Found
      description: >-
        Internal endpoint to upsert patient data source provider details in all
        their associated clinic records.
      tags:
        - Clinics
        - Internal
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/dataSources.v1'
  /v1/clinics/{clinicId}/tier:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Update Tier
      operationId: UpdateTier
      responses:
        '200':
          description: OK
      description: Internal endpoint to update clinic service tier
      tags:
        - Clinics
        - Internal
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTier'
  /v1/clinics/{clinicId}/suppressed_notifications:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Update Suppressed Notifications
      operationId: UpdateSuppressedNotifications
      responses:
        '200':
          description: OK
      description: Endpoint to update clinic suppressed notifications
      tags:
        - Clinics
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSuppressedNotifications'
  /v1/clinics/{clinicId}/patients/{patientId}/upload_reminder:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientId'
    post:
      summary: Send Upload Reminder
      operationId: SendUploadReminder
      responses:
        '200':
          description: OK
      description: Sends upload reminder to the patient
      tags:
        - Clinics
  /v1/clinics/{clinicId}/patients/assign_tag/{patientTagId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientTagId'
    post:
      summary: Assign Patient Tag To Clinic Patients
      operationId: AssignPatientTagToClinicPatients
      requestBody:
        description: Array of clinic patient user IDs to target for tag assignment.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/tidepoolUserIds.v1'
      responses:
        '200':
          description: OK
      description: Assign a patient tag to a subset of clinic patients
      tags:
        - Clinics
        - Internal
  /v1/clinics/{clinicId}/patients/delete_tag/{patientTagId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientTagId'
    post:
      summary: Delete Patient Tag From Clinic Patients
      operationId: DeletePatientTagFromClinicPatients
      requestBody:
        description: >-
          Pass an array of patient IDs to target a subset of the clinic
          patients. Omit request body to target all clinic patients.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/tidepoolUserIds.v1'
      responses:
        '200':
          description: OK
      description: Delete a patient tag from all or a subset of clinic patients
      tags:
        - Clinics
        - Internal
  /v1/clinics/{clinicId}/membership_restrictions:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      summary: List Membership Restrictions
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/membershipRestrictions.v1'
      operationId: ListMembershipRestrictions
      description: >-
        Returns a list of the membership restrictions that will be evaluated
        when a user joins a clinic.


        Only clinic admins can access this endpoint.
    put:
      summary: Update Membership Restrictions
      operationId: UpdateMembershipRestrictions
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/membershipRestrictions.v1'
      description: An internal endpoint to update clinic membership restrictions
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/membershipRestrictions.v1'
      x-internal: true
      tags:
        - Clinics
        - Internal
  /v1/redox:
    post:
      summary: Redox EHR Endpoint
      operationId: ProcessEHRMessage
      responses:
        '200':
          description: OK
      tags:
        - Internal
        - Redox
        - Clinics
      description: An endpoint for incoming Redox messages
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties: {}
      x-internal: true
  /v1/redox/verify:
    post:
      summary: Redox Verify Endpoint
      operationId: VerifyEndpoint
      responses:
        '200':
          description: OK
      tags:
        - Internal
        - Redox
        - Clinics
      x-internal: true
      description: Internal endpoint for Redox challenge verification
  /v1/clinics/{clinicId}/settings/ehr:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      summary: Get EHR Settings
      tags:
        - Clinics
        - Internal
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ehrSettings.v1'
      operationId: GetEHRSettings
      description: Returns EHR related settings
      x-internal: true
    put:
      summary: Update EHR Settings
      operationId: UpdateEHRSettings
      responses:
        '200':
          description: OK
      description: Update EHR related settings for a clinic
      tags:
        - Clinics
        - Internal
      x-internal: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ehrSettings.v1'
  /v1/redox/match:
    post:
      summary: Match Clinic and Patient
      operationId: MatchClinicAndPatient
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ehrMatchResponse.v1'
        '404':
          description: Not Found
      tags:
        - Clinics
        - Internal
      description: >
        An internal endpoint used for matching an EHR request (e.g. NewOrder) to
        a clinic and patient.


        If a clinic with the provided details cannot be found, the service will
        return `404 Not Found` and will not attempt to match patients to the
        provided details.


        Due to lack of uniqueness constraints on the MRN and DOB fields it's
        possible that multiple patient records match the provided attributes.
        All results will be returned in the response and it's the calling
        services responsiblity to determine how to handle duplicates records.


        If a unique match is found, the patient matching criteria will be added
        to the patient record for future use (e.g. pushing data on a schedule).
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ehrMatchRequest.v1'
      x-internal: true
  /v1/clinics/{clinicId}/settings/mrn:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      summary: Get MRN Settings
      tags:
        - Clinics
        - Internal
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/mrnSettings.v1'
      operationId: GetMRNSettings
      x-internal: true
      description: Retrieve MRN settings
    put:
      summary: Update MRN Settings
      operationId: UpdateMRNSettings
      responses:
        '200':
          description: OK
      tags:
        - Clinics
        - Internal
      description: Update MRN Settings
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/mrnSettings.v1'
  /v1/clinics/{clinicId}/settings/patient_count:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      operationId: GetPatientCountSettings
      summary: Get Patient Count Settings
      description: Get Patient Count settings
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientCountSettings.v1'
      x-internal: true
    put:
      operationId: UpdatePatientCountSettings
      summary: Update Patient Count Settings
      description: Update Patient Count Settings
      tags:
        - Clinics
        - Internal
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patientCountSettings.v1'
      responses:
        '200':
          description: OK
  /v1/clinics/{clinicId}/patient_count:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    get:
      operationId: GetPatientCount
      summary: Get Patient Count
      description: Get Patient Count
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientCount.v1'
  /v1/clinics/{clinicId}/patient_count/refresh:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      operationId: RefreshPatientCount
      summary: Refresh Patient Count
      responses:
        '200':
          description: OK
      description: >-
        An internal endpoint to refresh the patient count for the specified
        clinic.
      tags:
        - Clinics
        - Internal
      x-internal: true
      parameters: []
  /v1/clinics/{clinicId}/ehr/sync:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Sync EHR Data
      operationId: SyncEHRData
      responses:
        '202':
          description: Accepted
      description: >-
        An internal endpoint which will push the latest patient summary
        statistics and PDF reports for all patients who have an active
        subscription. The actual data is pushed asynchronously. A successful
        response means that an asynchronous task has been scheduled for each
        patient of the clinic with an active subscription.


        Will return 404 Not Found if the clinic does not have an active EHR
        connection.
      tags:
        - Clinics
        - Internal
      x-internal: true
      parameters: []
  /v1/patients:
    get:
      summary: Find Patients
      tags:
        - Clinics
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patientClinicRelationships.v1'
      operationId: FindPatients
      description: Returns all patients to which the clinician has access to
      parameters:
        - schema:
            type: string
          in: query
          name: mrn
        - schema:
            type: string
          in: query
          name: birthDate
        - schema:
            type: string
          in: query
          name: workspaceId
          description: The identifier of the workspace
        - schema:
            type: string
            enum:
              - clinicId
              - ehrSourceId
          in: query
          name: workspaceIdType
          description: The type of the workspace identifier
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/limit'
  /v1/xealth/preorder:
    parameters: []
    post:
      summary: Preorder Form Webhook
      operationId: XealthPreorder
      responses:
        '200':
          description: OK
      tags:
        - Clinics
        - Internal
      x-internal: true
      description: >-
        The Preorder endpoint can be invoked when a care provider attempts to
        place an order manually within the EHR. Subscribers can use Preorder
        Forms to present additional information to, or receive input from, a
        care provider before an order can be placed. Preorder Forms can also be
        implemented so as to prevent an order from being placed entirely.


        https://sandbox.xealth.io/app/api-docs#tag/Digital-Care/paths/preorder/post
  /v1/xealth/programs:
    put:
      summary: Get Programs
      operationId: XealthGetPrograms
      responses:
        '200':
          description: OK
      tags:
        - Clinics
        - Internal
      x-internal: true
  /v1/xealth/program:
    put:
      summary: Get Program Url
      operationId: XealthGetProgramUrl
      responses:
        '200':
          description: OK
      description: ''
      tags:
        - Clinics
        - Internal
      x-internal: true
  /v1/xealth/notification:
    post:
      summary: Notification Webhook
      operationId: XealthNotification
      responses:
        '200':
          description: OK
      description: ''
      tags:
        - Clinics
        - Internal
      x-internal: true
  /v1/xealth/report/web/viewer.html:
    get:
      summary: View PDF Report
      tags:
        - Clinics
        - Internal
      responses:
        '200':
          description: OK
      operationId: ViewPDFReport
      description: View PDF report for a given patient of a clinic
      parameters:
        - schema:
            type: string
          in: query
          name: clinicId
          required: true
        - schema:
            type: string
          in: query
          name: patientId
          required: true
        - schema:
            type: string
          in: query
          name: restricted_token
          required: true
      x-internal: true
    parameters: []
  /v1/clinics/{clinicId}/service_accounts:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Add Service Account
      operationId: AddServiceAccount
      responses:
        '200':
          description: OK
      description: Adds authentication client's service account as a new clinician member.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/addServiceAccount.v1'
      tags:
        - Clinics
        - Internal
      x-internal: true
  /v1/patients/{patientId}/ehr/sync:
    parameters:
      - $ref: '#/components/parameters/patientId'
    post:
      summary: Sync EHR Data for Patient
      operationId: SyncEHRDataForPatient
      responses:
        '202':
          description: Accepted
      description: >-
        An internal endpoint which will push the latest patient summary
        statistics and PDF reports to all EHR enabled clinics for which the
        patient has an active subscription. The actual data is pushed
        asynchronously. A successful response means that an asynchronous task
        has been scheduled.


        A 404 response will be returned if no active subscriptions can be found
        for given patient.
      tags:
        - Clinics
        - Internal
      x-internal: true
  /v1/clinics/{clinicId}/reports/merge:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Generate Clinic Merge Report
      operationId: GenerateMergeReport
      responses:
        '200':
          description: OK
      description: Generates a spreadsheet report for merging two clinics
      tags:
        - Clinics
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/generateMergeReport.v1'
        description: ''
  /v1/clinics/{clinicId}/merge:
    parameters:
      - $ref: '#/components/parameters/clinicId'
    post:
      summary: Merge Clinic
      operationId: MergeClinic
      responses:
        '200':
          description: OK
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/mergeClinic.v1'
      tags:
        - Clinics
        - Internal
      x-internal: true
      description: >-
        Merges tags, patients, clinicians, invites and share codes of the source
        clinic
  /v1/clinics/{clinicId}/patients/{patientId}/connect/{providerId}:
    parameters:
      - $ref: '#/components/parameters/clinicId'
      - $ref: '#/components/parameters/patientId'
      - $ref: '#/components/parameters/providerId'
    post:
      summary: Connect Provider
      operationId: ConnectProvider
      responses:
        '204':
          description: No Content
      tags:
        - Clinics
        - Internal
      description: Send a new request to the patient to connect a data provider
components:
  schemas:
    clinics.v1:
      type: array
      items:
        $ref: '#/components/schemas/clinic.v1'
    clinicians.v1:
      type: array
      items:
        $ref: '#/components/schemas/clinician.v1'
    patients.v1:
      type: array
      items:
        $ref: '#/components/schemas/patient.v1'
    patientTag.v1:
      type: object
      title: Patient Tag
      description: ''
      properties:
        id:
          $ref: '#/components/schemas/objectid.v1'
        name:
          type: string
          description: The tag display name
          minLength: 1
          maxLength: 20
          pattern: ^[\p{L}\p{N}_+><-]{1}[\p{L}\p{N}\s_+><-]*$
        numPatients:
          type: integer
          x-go-type-skip-optional-pointer: true
          x-omitzero: true
      required:
        - id
        - name
    dataSources.v1:
      type: array
      items:
        $ref: '#/components/schemas/dataSource.v1'
    site.v1:
      type: object
      title: Site
      description: A clinic's physical or logical location.
      properties:
        id:
          $ref: '#/components/schemas/siteId.v1'
        name:
          $ref: '#/components/schemas/siteName.v1'
        numPatients:
          type: integer
          x-go-type-skip-optional-pointer: true
          x-omitzero: true
      required:
        - id
        - name
    siteCreation.v1:
      type: object
      title: Site
      description: A clinic's physical or logical location.
      properties:
        name:
          $ref: '#/components/schemas/siteName.v1'
      required:
        - name
    tidepoolUserIds.v1:
      type: array
      nullable: true
      description: Array of Tidepool User IDs
      items:
        $ref: '#/components/schemas/tidepooluserid'
      minItems: 1
      maxItems: 1000
      uniqueItems: true
    patientClinicRelationship.v1:
      title: PatientClinicRelationship
      type: object
      properties:
        patient:
          $ref: '#/components/schemas/patient.v1'
        clinic:
          $ref: '#/components/schemas/clinic.v1'
      required:
        - patient
        - clinic
    patientClinicRelationships.v1:
      title: PatientClinicRelationships
      type: array
      items:
        $ref: '#/components/schemas/patientClinicRelationship.v1'
    createPatient.v1:
      title: Create Patient
      type: object
      properties:
        permissions:
          $ref: '#/components/schemas/patientPermissions.v1'
        isMigrated:
          type: boolean
        legacyClinicianId:
          $ref: '#/components/schemas/tidepooluserid'
        attestationSubmitted:
          type: boolean
        fullName:
          type: string
          description: The full name of the patient
          minLength: 1
        birthDate:
          type: string
          format: date
          example: '2012-08-30'
        mrn:
          type: string
          description: The medical record number of the patient
          minLength: 1
        tags:
          $ref: '#/components/schemas/patientTagIds.v1'
        sites:
          type: array
          x-go-type-skip-optional-pointer: true
          x-omitempty: false
          x-omitzero: true
          items:
            $ref: '#/components/schemas/site.v1'
        glycemicRanges:
          $ref: '#/components/schemas/glycemicRanges.v1'
        diagnosisType:
          $ref: '#/components/schemas/diagnosisType.v1'
    associateClinicianToUser.v1:
      title: Associate Clinician
      type: object
      properties:
        userId:
          type: string
      required:
        - userId
    clinicianClinicRelationship.v1:
      title: ClinicianClinicRelationship
      type: object
      properties:
        clinician:
          $ref: '#/components/schemas/clinician.v1'
        clinic:
          $ref: '#/components/schemas/clinic.v1'
      required:
        - clinician
        - clinic
    clinicianClinicRelationships.v1:
      title: ClinicianClinicRelationships
      type: array
      items:
        $ref: '#/components/schemas/clinicianClinicRelationship.v1'
    migration.v1:
      title: Migration
      type: object
      properties:
        userId:
          type: string
          description: >-
            The user id of the legacy clinician account that needs to be
            migrated.
          minLength: 1
        status:
          $ref: '#/components/schemas/migrationStatus.v1'
        createdTime:
          type: string
          format: date-time
          readOnly: true
        updatedTime:
          type: string
          format: date-time
          readOnly: true
        attestationTime:
          type: string
          format: date-time
          readOnly: true
      required:
        - userId
        - createdTime
        - updatedTime
    migrations.v1:
      title: Migrations
      type: array
      items:
        $ref: '#/components/schemas/migration.v1'
    migrationUpdate.v1:
      title: MigrationUpdate
      type: object
      properties:
        status:
          $ref: '#/components/schemas/migrationStatus.v1'
      required:
        - status
    meta.v1:
      title: Meta
      type: object
      properties:
        count:
          description: The number of items matching the filter
          type: integer
        totalCount:
          description: The total number of items
          type: integer
    patientsResponse.v1:
      title: PatientsResponse
      type: object
      properties:
        data:
          $ref: '#/components/schemas/patients.v1'
        meta:
          $ref: '#/components/schemas/meta.v1'
    updateUserDetails.v1:
      title: UpdateUserDetails
      type: object
      properties:
        email:
          type: string
          format: email
          minLength: 1
    triggerMigration.v1:
      title: TriggerMigration
      type: object
      properties:
        attestationSubmitted:
          type: boolean
    patientReviews.v1:
      type: array
      items:
        $ref: '#/components/schemas/patientReview.v1'
    FloatFilter:
      type: string
      pattern: ^(>=|>|<=|<)[+-]?((\d+(\.\d*)?)|(\.\d+))$
      example: '>=5.5'
    IntFilter:
      type: string
      pattern: ^(>=|>|<=|<)[+-]?\d+$
      example: '>=7'
    UpdateTier:
      title: UpdateTier
      type: object
      properties:
        tier:
          $ref: '#/components/schemas/tier.v1'
      required:
        - tier
    tier.v1:
      type: string
      title: Clinic Service Tier
      enum:
        - tier0100
        - tier0200
        - tier0300
        - tier0400
      example: tier0100
    UpdateSuppressedNotifications:
      title: UpdateSuppressedNotifications
      type: object
      properties:
        suppressedNotifications:
          $ref: '#/components/schemas/suppressedNotifications.v1'
      required:
        - suppressedNotifications
    ehrMatchRequest.v1:
      title: EHR Match Request
      x-stoplight:
        id: nq0mlm5dqdfw0
      type: object
      x-examples: {}
      properties:
        messageRef:
          $ref: '#/components/schemas/ehrMatchMessageRef.v1'
        patients:
          $ref: '#/components/schemas/ehrMatchRequestPatientsOptions.v1'
    ehrMatchResponse.v1:
      title: EHRMatchResponse
      x-stoplight:
        id: pekkj09rlany0
      type: object
      properties:
        clinic:
          $ref: '#/components/schemas/clinic.v1'
        patients:
          $ref: '#/components/schemas/patients.v1'
        settings:
          $ref: '#/components/schemas/ehrSettings.v1'
      required:
        - clinic
        - settings
    ehrMatchMessageRef.v1:
      title: EHRMatchMessageRef
      x-stoplight:
        id: a1215t5vip3tr
      type: object
      properties:
        dataModel:
          type: string
          enum:
            - Order
        eventType:
          type: string
          enum:
            - New
        documentId:
          type: string
      required:
        - dataModel
        - eventType
        - documentId
    AcceptPatientInvitation:
      title: AcceptPatientInvitation
      x-stoplight:
        id: vo0jck92hztsj
      type: object
      properties:
        fullName:
          type: string
          description: The full name of the patient
          minLength: 1
        birthDate:
          type: string
          format: date
          example: '2012-08-30'
        mrn:
          type: string
          description: The medical record number of the patient
          minLength: 1
        tags:
          $ref: '#/components/schemas/patientTagIds.v1'
        sites:
          type: array
          x-go-type-skip-optional-pointer: true
          x-omitempty: false
          x-omitzero: true
          items:
            $ref: '#/components/schemas/site.v1'
        glycemicRanges:
          $ref: '#/components/schemas/glycemicRanges.v1'
        diagnosisType:
          $ref: '#/components/schemas/diagnosisType.v1'
    addServiceAccount.v1:
      title: AddServiceAccount
      x-stoplight:
        id: 3c7ko800mld31
      type: object
      properties:
        name:
          type: string
          x-stoplight:
            id: 3333gszyq3x79
          minLength: 1
        client_id:
          type: string
          x-stoplight:
            id: kgfyaapmfjies
          minLength: 1
        client_secret:
          type: string
          x-stoplight:
            id: 8jdosn0tlbqp5
          minLength: 1
      required:
        - name
        - client_id
        - client_secret
    generateMergeReport.v1:
      title: GenerateMergeReport
      x-stoplight:
        id: 3oq18sasrzo0o
      type: object
      properties:
        sourceId:
          $ref: '#/components/schemas/clinicId.v1'
      required:
        - sourceId
    mergeClinic.v1:
      title: MergeClinics
      x-stoplight:
        id: 6hn01uuhln0wx
      type: object
      properties:
        sourceId:
          $ref: '#/components/schemas/clinicId.v1'
    ehrMatchRequestPatientsOptions.v1:
      title: Patient Matching Options
      x-stoplight:
        id: 43n6iid3zghxm
      type: object
      properties:
        criteria:
          type: array
          x-stoplight:
            id: 1odrg3q8zzdil
          description: Performs an "OR" match for each item in the array
          minItems: 1
          items:
            x-stoplight:
              id: mgi1k2jyojc4k
            type: string
            enum:
              - MRN
              - MRN_DOB
              - DOB_FULLNAME
        onUniqueMatch:
          type: string
          x-stoplight:
            id: s9ujf5ce4vhc1
          enum:
            - ENABLE_REPORTS
            - DISABLE_REPORTS
          description: Optional action to be performed when a unique match has been found
      required:
        - criteria
    clinicId.v1:
      title: Clinic ID
      description: Clinic identifier.
      type: string
      minLength: 24
      maxLength: 24
      pattern: ^[a-f0-9]{24}$
      readOnly: true
      example: 2fe2488217ee43e1b2e83c2f
    streetAddress.v1:
      title: Street Address
      description: Street address.
      type: string
      minLength: 1
    city.v1:
      title: City
      description: City name.
      type: string
      minLength: 1
      example: Palo Alto
    postalCode.v1:
      title: Postal Code
      description: >-
        Postal code. In the U.S., typically the zip code such as `94301` or
        `94301-1704`.
      type: string
      minLength: 1
      example: '94301'
    state.v1:
      title: State
      description: >-
        State or province. In the U.S., typically something like `CA` or
        `California`.
      type: string
      minLength: 1
      example: CA
    country.v1:
      title: Country
      description: Country name.
      type: string
      minLength: 1
      example: USA
    objectid.v1:
      title: Object Id
      type: string
      description: String representation of a resource id
      minLength: 24
      maxLength: 24
      pattern: ^[a-f0-9]{24}$
      readOnly: true
    siteId.v1:
      allOf:
        - $ref: '#/components/schemas/objectid.v1'
        - x-go-type-skip-optional-pointer: true
          x-go-type: string
          readOnly: true
    siteName.v1:
      type: string
      x-go-type-skip-optional-pointer: true
      description: The site's name.
      minLength: 1
      maxLength: 200
      pattern: ^[[:graph:]\p{L}\p{N}][[:graph:]\p{L}\p{N} ]*$
    phoneNumber.v1:
      title: Phone Number
      type: object
      properties:
        type:
          type: string
          minLength: 1
        number:
          type: string
          minLength: 1
      required:
        - number
      example:
        type: main
        number: +1 (555) 555-1212
    phoneNumbers.v1:
      title: Phone phoneNumbers
      description: An array of phone numbers.
      type: array
      uniqueItems: true
      minItems: 1
      items:
        $ref: '#/components/schemas/phoneNumber.v1'
    name.v1:
      title: Clinic Name
      description: Name of the clinic.
      type: string
      minItems: 1
    shareCode.v1:
      title: Clinic Share Code
      description: >-
        Globally unique share code for a clinic. The share code is 3 groups of 4
        uppercase alphanumeric characters in each group. Ambiguous characters
        such as `I` and `1`, or `O` and `0` are excluded.
      type: string
      pattern: >-
        ^[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{4}$
      readOnly: true
    suppressedNotifications.v1:
      title: Suppressed Notifications
      type: object
      properties:
        patientClinicInvitation:
          type: boolean
      additionalProperties: false
    clinicTimezone.v1:
      title: Clinic Timezone
      x-stoplight:
        id: 7htuwravuo8sn
      type: string
      enum:
        - Africa/Abidjan
        - Africa/Accra
        - Africa/Addis_Ababa
        - Africa/Algiers
        - Africa/Asmara
        - Africa/Asmera
        - Africa/Bamako
        - Africa/Bangui
        - Africa/Banjul
        - Africa/Bissau
        - Africa/Blantyre
        - Africa/Brazzaville
        - Africa/Bujumbura
        - Africa/Cairo
        - Africa/Casablanca
        - Africa/Ceuta
        - Africa/Conakry
        - Africa/Dakar
        - Africa/Dar_es_Salaam
        - Africa/Djibouti
        - Africa/Douala
        - Africa/El_Aaiun
        - Africa/Freetown
        - Africa/Gaborone
        - Africa/Harare
        - Africa/Johannesburg
        - Africa/Juba
        - Africa/Kampala
        - Africa/Khartoum
        - Africa/Kigali
        - Africa/Kinshasa
        - Africa/Lagos
        - Africa/Libreville
        - Africa/Lome
        - Africa/Luanda
        - Africa/Lubumbashi
        - Africa/Lusaka
        - Africa/Malabo
        - Africa/Maputo
        - Africa/Maseru
        - Africa/Mbabane
        - Africa/Mogadishu
        - Africa/Monrovia
        - Africa/Nairobi
        - Africa/Ndjamena
        - Africa/Niamey
        - Africa/Nouakchott
        - Africa/Ouagadougou
        - Africa/Porto-Novo
        - Africa/Sao_Tome
        - Africa/Timbuktu
        - Africa/Tripoli
        - Africa/Tunis
        - Africa/Windhoek
        - America/Adak
        - America/Anchorage
        - America/Anguilla
        - America/Antigua
        - America/Araguaina
        - America/Argentina/Buenos_Aires
        - America/Argentina/Catamarca
        - America/Argentina/ComodRivadavia
        - America/Argentina/Cordoba
        - America/Argentina/Jujuy
        - America/Argentina/La_Rioja
        - America/Argentina/Mendoza
        - America/Argentina/Rio_Gallegos
        - America/Argentina/Salta
        - America/Argentina/San_Juan
        - America/Argentina/San_Luis
        - America/Argentina/Tucuman
        - America/Argentina/Ushuaia
        - America/Aruba
        - America/Asuncion
        - America/Atikokan
        - America/Atka
        - America/Bahia
        - America/Bahia_Banderas
        - America/Barbados
        - America/Belem
        - America/Belize
        - America/Blanc-Sablon
        - America/Boa_Vista
        - America/Bogota
        - America/Boise
        - America/Buenos_Aires
        - America/Cambridge_Bay
        - America/Campo_Grande
        - America/Cancun
        - America/Caracas
        - America/Catamarca
        - America/Cayenne
        - America/Cayman
        - America/Chicago
        - America/Chihuahua
        - America/Ciudad_Juarez
        - America/Coral_Harbour
        - America/Cordoba
        - America/Costa_Rica
        - America/Creston
        - America/Cuiaba
        - America/Curacao
        - America/Danmarkshavn
        - America/Dawson
        - America/Dawson_Creek
        - America/Denver
        - America/Detroit
        - America/Dominica
        - America/Edmonton
        - America/Eirunepe
        - America/El_Salvador
        - America/Ensenada
        - America/Fort_Nelson
        - America/Fort_Wayne
        - America/Fortaleza
        - America/Glace_Bay
        - America/Godthab
        - America/Goose_Bay
        - America/Grand_Turk
        - America/Grenada
        - America/Guadeloupe
        - America/Guatemala
        - America/Guayaquil
        - America/Guyana
        - America/Halifax
        - America/Havana
        - America/Hermosillo
        - America/Indiana/Indianapolis
        - America/Indiana/Knox
        - America/Indiana/Marengo
        - America/Indiana/Petersburg
        - America/Indiana/Tell_City
        - America/Indiana/Vevay
        - America/Indiana/Vincennes
        - America/Indiana/Winamac
        - America/Indianapolis
        - America/Inuvik
        - America/Iqaluit
        - America/Jamaica
        - America/Jujuy
        - America/Juneau
        - America/Kentucky/Louisville
        - America/Kentucky/Monticello
        - America/Knox_IN
        - America/Kralendijk
        - America/La_Paz
        - America/Lima
        - America/Los_Angeles
        - America/Louisville
        - America/Lower_Princes
        - America/Maceio
        - America/Managua
        - America/Manaus
        - America/Marigot
        - America/Martinique
        - America/Matamoros
        - America/Mazatlan
        - America/Mendoza
        - America/Menominee
        - America/Merida
        - America/Metlakatla
        - America/Mexico_City
        - America/Miquelon
        - America/Moncton
        - America/Monterrey
        - America/Montevideo
        - America/Montreal
        - America/Montserrat
        - America/Nassau
        - America/New_York
        - America/Nipigon
        - America/Nome
        - America/Noronha
        - America/North_Dakota/Beulah
        - America/North_Dakota/Center
        - America/North_Dakota/New_Salem
        - America/Nuuk
        - America/Ojinaga
        - America/Panama
        - America/Pangnirtung
        - America/Paramaribo
        - America/Phoenix
        - America/Port-au-Prince
        - America/Port_of_Spain
        - America/Porto_Acre
        - America/Porto_Velho
        - America/Puerto_Rico
        - America/Punta_Arenas
        - America/Rainy_River
        - America/Rankin_Inlet
        - America/Recife
        - America/Regina
        - America/Resolute
        - America/Rio_Branco
        - America/Rosario
        - America/Santa_Isabel
        - America/Santarem
        - America/Santiago
        - America/Santo_Domingo
        - America/Sao_Paulo
        - America/Scoresbysund
        - America/Shiprock
        - America/Sitka
        - America/St_Barthelemy
        - America/St_Johns
        - America/St_Kitts
        - America/St_Lucia
        - America/St_Thomas
        - America/St_Vincent
        - America/Swift_Current
        - America/Tegucigalpa
        - America/Thule
        - America/Thunder_Bay
        - America/Tijuana
        - America/Toronto
        - America/Tortola
        - America/Vancouver
        - America/Virgin
        - America/Whitehorse
        - America/Winnipeg
        - America/Yakutat
        - America/Yellowknife
        - Antarctica/Casey
        - Antarctica/Davis
        - Antarctica/DumontDUrville
        - Antarctica/Macquarie
        - Antarctica/Mawson
        - Antarctica/McMurdo
        - Antarctica/Palmer
        - Antarctica/Rothera
        - Antarctica/South_Pole
        - Antarctica/Syowa
        - Antarctica/Troll
        - Antarctica/Vostok
        - Arctic/Longyearbyen
        - Asia/Aden
        - Asia/Almaty
        - Asia/Amman
        - Asia/Anadyr
        - Asia/Aqtau
        - Asia/Aqtobe
        - Asia/Ashgabat
        - Asia/Ashkhabad
        - Asia/Atyrau
        - Asia/Baghdad
        - Asia/Bahrain
        - Asia/Baku
        - Asia/Bangkok
        - Asia/Barnaul
        - Asia/Beirut
        - Asia/Bishkek
        - Asia/Brunei
        - Asia/Calcutta
        - Asia/Chita
        - Asia/Choibalsan
        - Asia/Chongqing
        - Asia/Chungking
        - Asia/Colombo
        - Asia/Dacca
        - Asia/Damascus
        - Asia/Dhaka
        - Asia/Dili
        - Asia/Dubai
        - Asia/Dushanbe
        - Asia/Famagusta
        - Asia/Gaza
        - Asia/Harbin
        - Asia/Hebron
        - Asia/Ho_Chi_Minh
        - Asia/Hong_Kong
        - Asia/Hovd
        - Asia/Irkutsk
        - Asia/Istanbul
        - Asia/Jakarta
        - Asia/Jayapura
        - Asia/Jerusalem
        - Asia/Kabul
        - Asia/Kamchatka
        - Asia/Karachi
        - Asia/Kashgar
        - Asia/Kathmandu
        - Asia/Katmandu
        - Asia/Khandyga
        - Asia/Kolkata
        - Asia/Krasnoyarsk
        - Asia/Kuala_Lumpur
        - Asia/Kuching
        - Asia/Kuwait
        - Asia/Macao
        - Asia/Macau
        - Asia/Magadan
        - Asia/Makassar
        - Asia/Manila
        - Asia/Muscat
        - Asia/Nicosia
        - Asia/Novokuznetsk
        - Asia/Novosibirsk
        - Asia/Omsk
        - Asia/Oral
        - Asia/Phnom_Penh
        - Asia/Pontianak
        - Asia/Pyongyang
        - Asia/Qatar
        - Asia/Qostanay
        - Asia/Qyzylorda
        - Asia/Rangoon
        - Asia/Riyadh
        - Asia/Saigon
        - Asia/Sakhalin
        - Asia/Samarkand
        - Asia/Seoul
        - Asia/Shanghai
        - Asia/Singapore
        - Asia/Srednekolymsk
        - Asia/Taipei
        - Asia/Tashkent
        - Asia/Tbilisi
        - Asia/Tehran
        - Asia/Tel_Aviv
        - Asia/Thimbu
        - Asia/Thimphu
        - Asia/Tokyo
        - Asia/Tomsk
        - Asia/Ujung_Pandang
        - Asia/Ulaanbaatar
        - Asia/Ulan_Bator
        - Asia/Urumqi
        - Asia/Ust-Nera
        - Asia/Vientiane
        - Asia/Vladivostok
        - Asia/Yakutsk
        - Asia/Yangon
        - Asia/Yekaterinburg
        - Asia/Yerevan
        - Atlantic/Azores
        - Atlantic/Bermuda
        - Atlantic/Canary
        - Atlantic/Cape_Verde
        - Atlantic/Faeroe
        - Atlantic/Faroe
        - Atlantic/Jan_Mayen
        - Atlantic/Madeira
        - Atlantic/Reykjavik
        - Atlantic/South_Georgia
        - Atlantic/St_Helena
        - Atlantic/Stanley
        - Australia/ACT
        - Australia/Adelaide
        - Australia/Brisbane
        - Australia/Broken_Hill
        - Australia/Canberra
        - Australia/Currie
        - Australia/Darwin
        - Australia/Eucla
        - Australia/Hobart
        - Australia/LHI
        - Australia/Lindeman
        - Australia/Lord_Howe
        - Australia/Melbourne
        - Australia/NSW
        - Australia/North
        - Australia/Perth
        - Australia/Queensland
        - Australia/South
        - Australia/Sydney
        - Australia/Tasmania
        - Australia/Victoria
        - Australia/West
        - Australia/Yancowinna
        - Brazil/Acre
        - Brazil/DeNoronha
        - Brazil/East
        - Brazil/West
        - CET
        - CST6CDT
        - Canada/Atlantic
        - Canada/Central
        - Canada/Eastern
        - Canada/Mountain
        - Canada/Newfoundland
        - Canada/Pacific
        - Canada/Saskatchewan
        - Canada/Yukon
        - Chile/Continental
        - Chile/EasterIsland
        - Cuba
        - EET
        - EST
        - EST5EDT
        - Egypt
        - Eire
        - Etc/GMT
        - Etc/GMT+0
        - Etc/GMT+1
        - Etc/GMT+10
        - Etc/GMT+11
        - Etc/GMT+12
        - Etc/GMT+2
        - Etc/GMT+3
        - Etc/GMT+4
        - Etc/GMT+5
        - Etc/GMT+6
        - Etc/GMT+7
        - Etc/GMT+8
        - Etc/GMT+9
        - Etc/GMT-0
        - Etc/GMT-1
        - Etc/GMT-10
        - Etc/GMT-11
        - Etc/GMT-12
        - Etc/GMT-13
        - Etc/GMT-14
        - Etc/GMT-2
        - Etc/GMT-3
        - Etc/GMT-4
        - Etc/GMT-5
        - Etc/GMT-6
        - Etc/GMT-7
        - Etc/GMT-8
        - Etc/GMT-9
        - Etc/GMT0
        - Etc/Greenwich
        - Etc/UCT
        - Etc/UTC
        - Etc/Universal
        - Etc/Zulu
        - Europe/Amsterdam
        - Europe/Andorra
        - Europe/Astrakhan
        - Europe/Athens
        - Europe/Belfast
        - Europe/Belgrade
        - Europe/Berlin
        - Europe/Bratislava
        - Europe/Brussels
        - Europe/Bucharest
        - Europe/Budapest
        - Europe/Busingen
        - Europe/Chisinau
        - Europe/Copenhagen
        - Europe/Dublin
        - Europe/Gibraltar
        - Europe/Guernsey
        - Europe/Helsinki
        - Europe/Isle_of_Man
        - Europe/Istanbul
        - Europe/Jersey
        - Europe/Kaliningrad
        - Europe/Kiev
        - Europe/Kirov
        - Europe/Kyiv
        - Europe/Lisbon
        - Europe/Ljubljana
        - Europe/London
        - Europe/Luxembourg
        - Europe/Madrid
        - Europe/Malta
        - Europe/Mariehamn
        - Europe/Minsk
        - Europe/Monaco
        - Europe/Moscow
        - Europe/Nicosia
        - Europe/Oslo
        - Europe/Paris
        - Europe/Podgorica
        - Europe/Prague
        - Europe/Riga
        - Europe/Rome
        - Europe/Samara
        - Europe/San_Marino
        - Europe/Sarajevo
        - Europe/Saratov
        - Europe/Simferopol
        - Europe/Skopje
        - Europe/Sofia
        - Europe/Stockholm
        - Europe/Tallinn
        - Europe/Tirane
        - Europe/Tiraspol
        - Europe/Ulyanovsk
        - Europe/Uzhgorod
        - Europe/Vaduz
        - Europe/Vatican
        - Europe/Vienna
        - Europe/Vilnius
        - Europe/Volgograd
        - Europe/Warsaw
        - Europe/Zagreb
        - Europe/Zaporozhye
        - Europe/Zurich
        - GB
        - GB-Eire
        - GMT
        - GMT+0
        - GMT-0
        - GMT0
        - Greenwich
        - HST
        - Hongkong
        - Iceland
        - Indian/Antananarivo
        - Indian/Chagos
        - Indian/Christmas
        - Indian/Cocos
        - Indian/Comoro
        - Indian/Kerguelen
        - Indian/Mahe
        - Indian/Maldives
        - Indian/Mauritius
        - Indian/Mayotte
        - Indian/Reunion
        - Iran
        - Israel
        - Jamaica
        - Japan
        - Kwajalein
        - Libya
        - MET
        - MST
        - MST7MDT
        - Mexico/BajaNorte
        - Mexico/BajaSur
        - Mexico/General
        - NZ
        - NZ-CHAT
        - Navajo
        - PRC
        - PST8PDT
        - Pacific/Apia
        - Pacific/Auckland
        - Pacific/Bougainville
        - Pacific/Chatham
        - Pacific/Chuuk
        - Pacific/Easter
        - Pacific/Efate
        - Pacific/Enderbury
        - Pacific/Fakaofo
        - Pacific/Fiji
        - Pacific/Funafuti
        - Pacific/Galapagos
        - Pacific/Gambier
        - Pacific/Guadalcanal
        - Pacific/Guam
        - Pacific/Honolulu
        - Pacific/Johnston
        - Pacific/Kanton
        - Pacific/Kiritimati
        - Pacific/Kosrae
        - Pacific/Kwajalein
        - Pacific/Majuro
        - Pacific/Marquesas
        - Pacific/Midway
        - Pacific/Nauru
        - Pacific/Niue
        - Pacific/Norfolk
        - Pacific/Noumea
        - Pacific/Pago_Pago
        - Pacific/Palau
        - Pacific/Pitcairn
        - Pacific/Pohnpei
        - Pacific/Ponape
        - Pacific/Port_Moresby
        - Pacific/Rarotonga
        - Pacific/Saipan
        - Pacific/Samoa
        - Pacific/Tahiti
        - Pacific/Tarawa
        - Pacific/Tongatapu
        - Pacific/Truk
        - Pacific/Wake
        - Pacific/Wallis
        - Pacific/Yap
        - Poland
        - Portugal
        - ROC
        - ROK
        - Singapore
        - Turkey
        - UCT
        - US/Alaska
        - US/Aleutian
        - US/Arizona
        - US/Central
        - US/East-Indiana
        - US/Eastern
        - US/Hawaii
        - US/Indiana-Starke
        - US/Michigan
        - US/Mountain
        - US/Pacific
        - US/Samoa
        - UTC
        - Universal
        - W-SU
        - WET
        - Zulu
    clinic.v1:
      title: Clinic
      description: Clinic
      type: object
      properties:
        id:
          $ref: '#/components/schemas/clinicId.v1'
        address:
          $ref: '#/components/schemas/streetAddress.v1'
        city:
          $ref: '#/components/schemas/city.v1'
        postalCode:
          $ref: '#/components/schemas/postalCode.v1'
        state:
          $ref: '#/components/schemas/state.v1'
        country:
          $ref: '#/components/schemas/country.v1'
        patientTags:
          type: array
          items:
            $ref: '#/components/schemas/patientTag.v1'
        sites:
          type: array
          x-go-type-skip-optional-pointer: true
          items:
            $ref: '#/components/schemas/site.v1'
        lastDeletedPatientTag:
          $ref: '#/components/schemas/patientTag.v1'
        phoneNumbers:
          $ref: '#/components/schemas/phoneNumbers.v1'
        clinicType:
          type: string
          minLength: 1
          enum:
            - provider_practice
            - healthcare_system
            - veterinary_clinic
            - other
            - researcher
        clinicSize:
          type: string
          enum:
            - 0-249
            - 250-499
            - 500-999
            - 1000+
        name:
          $ref: '#/components/schemas/name.v1'
        shareCode:
          $ref: '#/components/schemas/shareCode.v1'
        canMigrate:
          type: boolean
          readOnly: true
        website:
          type: string
          format: uri
        createdTime:
          type: string
          format: date-time
          readOnly: true
        updatedTime:
          type: string
          format: date-time
          readOnly: true
        tierDescription:
          type: string
          minLength: 1
          example: Free
          readOnly: true
        tier:
          type: string
          example: tier0100
          minLength: 1
          readOnly: true
        preferredBgUnits:
          type: string
          enum:
            - mg/dL
            - mmol/L
        suppressedNotifications:
          $ref: '#/components/schemas/suppressedNotifications.v1'
        timezone:
          $ref: '#/components/schemas/clinicTimezone.v1'
      required:
        - id
        - name
        - shareCode
        - canMigrate
        - createdTime
        - updatedTime
        - tierDescription
        - tier
        - preferredBgUnits
    error.v1:
      title: Error
      type: object
      properties:
        code:
          type: integer
          example: 404
        message:
          type: string
          example: Requested resources was not found
      required:
        - code
        - message
    tidepooluserid:
      type: string
      title: Tidepool User ID
      pattern: >-
        ^([0-9a-f]{10}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$
      description: >-
        String representation of a Tidepool User ID. Old style IDs are 10-digit
        strings consisting of only hexadeximcal digits. New style IDs are
        36-digit [UUID
        v4](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random))
      readOnly: true
      x-go-type: string
    clinicianRoles.v1:
      type: array
      title: Clinician Permissions
      minItems: 1
      uniqueItems: true
      items:
        type: string
        enum:
          - CLINIC_ADMIN
          - CLINIC_MEMBER
          - PRESCRIBER
    clinician.v1:
      title: Clinician
      description: The `id` may be empty if the clinician invite has not been accepted.
      type: object
      properties:
        id:
          $ref: '#/components/schemas/tidepooluserid'
        inviteId:
          type: string
          description: The id of the invite if it hasn't been accepted
        email:
          type: string
          x-go-type: string
          format: email
        name:
          type: string
          description: The name of the clinician
          minLength: 1
        roles:
          $ref: '#/components/schemas/clinicianRoles.v1'
        createdTime:
          type: string
          format: date-time
          readOnly: true
        updatedTime:
          type: string
          format: date-time
          readOnly: true
      required:
        - email
        - roles
        - createdTime
        - updatedTime
    objectId.v1:
      title: Object Id
      type: string
      description: String representation of a resource id
      minLength: 24
      maxLength: 24
      pattern: ^[a-f0-9]{24}$
    patientTagIds.v1:
      type: array
      title: Patient Tag ID List
      uniqueItems: true
      nullable: true
      items:
        title: Patient Tag ID
        description: Patient Tag identifier.
        type: string
        minLength: 24
        maxLength: 24
        pattern: ^[a-f0-9]{24}$
        readOnly: true
    tideFilters.v1:
      type: object
      title: tidefilters.v1
      description: Visual representation of filtered categories selected
      properties:
        dropInTimeInTargetPercent:
          type: string
          pattern: ^(>=|>|<=|<)\d\.\d\d?$
          example: '>0.5'
        timeCGMUsePercent:
          type: string
          pattern: ^(>=|>|<=|<)\d\.\d\d?$
          example: '>0.5'
        timeInAnyLowPercent:
          type: string
          pattern: ^(>=|>|<=|<)\d\.\d\d?$
          example: '>0.5'
        timeInExtremeHighPercent:
          type: string
          pattern: ^(>=|>|<=|<)\d\.\d\d?$
          example: '>0.5'
        timeInHighPercent:
          type: string
          pattern: ^(>=|>|<=|<)\d\.\d\d?$
          example: '>0.5'
        timeInTargetPercent:
          type: string
          pattern: ^(>=|>|<=|<)\d\.\d\d?$
          example: '>0.5'
        timeInVeryHighPercent:
          type: string
          pattern: ^(>=|>|<=|<)\d\.\d\d?$
          example: '>0.5'
        timeInVeryLowPercent:
          type: string
          pattern: ^(>=|>|<=|<)\d\.\d\d?$
          example: '>0.5'
    tideConfig.v1:
      type: object
      title: tideconfig.v1
      description: ''
      properties:
        schemaVersion:
          description: TIDE schema version
          type: number
          x-go-type: int
        clinicId:
          $ref: '#/components/schemas/clinicId.v1'
        period:
          type: string
          pattern: ^(1d|7d|14d|30d)$
          example: 7d
        lastDataCutoff:
          type: string
          format: date-time
        highGlucoseThreshold:
          description: >-
            Minimum exclusive threshold in mmol/L for categorizing if a glucose
            value is high as established by the AACE.
          type: number
          x-go-type: float64
        veryHighGlucoseThreshold:
          description: >-
            Minimum exclusive threshold in mmol/L for categorizing if a glucose
            value is very high as established by the AACE.
          type: number
          x-go-type: float64
        extremeHighGlucoseThreshold:
          description: >-
            Minimum inclusive threshold in mmol/L for categorizing if a glucose
            value is extremely high. Not defined by the AACE.
          type: number
          x-go-type: float64
        lowGlucoseThreshold:
          description: >-
            Maximum exclusive threshold in mmol/L for categorizing if a glucose
            value is low as established by the AACE.
          type: number
          x-go-type: float64
        veryLowGlucoseThreshold:
          description: >-
            Maximum exclusive threshold in mmol/L for categorizing if a glucose
            value is very low as established by the AACE.
          type: number
          x-go-type: float64
        tags:
          $ref: '#/components/schemas/patientTagIds.v1'
        filters:
          $ref: '#/components/schemas/tideFilters.v1'
      required:
        - schemaVersion
        - clinicId
        - period
        - lastDataCutoff
        - highGlucoseThreshold
        - veryHighGlucoseThreshold
        - lowGlucoseThreshold
        - veryLowGlucoseThreshold
        - tags
        - filters
    patientReview.v1:
      type: object
      title: patientreview.v1
      description: A summary of a patients recent data
      properties:
        clinicianId:
          type: string
        time:
          type: string
          format: date-time
      required:
        - clinicianId
        - time
    providerName.v1:
      title: Provider Name
      type: string
      minLength: 1
      maxLength: 100
      example: dexcom
    datetime.v1:
      title: Date/Time
      description: >-
        [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) / [ISO
        8601](https://www.iso.org/iso-8601-date-and-time-format.html) timestamp
        _with_ timezone information
      type: string
      format: date-time
      example: '2017-02-06T02:37:46Z'
      x-go-type: string
    dataSource.v1:
      type: object
      title: Patient data source
      properties:
        state:
          type: string
          title: Data source connection state
          enum:
            - pending
            - pendingReconnect
            - connected
            - disconnected
            - error
          example: connected
        providerName:
          $ref: '#/components/schemas/providerName.v1'
        dataSourceId:
          title: Data Source Object Id
          type: string
          description: String representation of a resource id
          minLength: 24
          maxLength: 24
          pattern: ^[a-f0-9]{24}$
          readOnly: true
        modifiedTime:
          $ref: '#/components/schemas/datetime.v1'
        expirationTime:
          $ref: '#/components/schemas/datetime.v1'
      required:
        - state
        - providerName
    tidePatient.v1:
      type: object
      title: tidepatient.v1
      description: ''
      properties:
        id:
          $ref: '#/components/schemas/tidepooluserid'
        email:
          type: string
          x-go-type: string
          format: email
        fullName:
          type: string
          description: The full name of the patient
          minLength: 1
        tags:
          $ref: '#/components/schemas/patientTagIds.v1'
        reviews:
          type: array
          nullable: true
          x-go-type-skip-optional-pointer: true
          items:
            $ref: '#/components/schemas/patientReview.v1'
        dataSources:
          type: array
          nullable: true
          items:
            $ref: '#/components/schemas/dataSource.v1'
      required:
        - id
        - tags
    tideResultPatient.v1:
      type: object
      title: tideresultpatient.v1
      description: ''
      properties:
        averageGlucoseMmol:
          description: Average Glucose of records in this period
          type: number
          example: 5.5
          x-go-type: float64
        glucoseManagementIndicator:
          type: number
          x-go-type: float64
          description: A derived value which emulates A1C
          example: 7.5
        timeInVeryLowPercent:
          description: Percentage of time spent in very low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInAnyLowPercent:
          description: Percentage of time spent in any low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInLowPercent:
          description: Percentage of time spent in low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInTargetPercentDelta:
          description: >-
            Difference between the timeInTargetPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        timeInHighPercent:
          description: Percentage of time spent in high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInVeryHighPercent:
          description: Percentage of time spent in very high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInExtremeHighPercent:
          description: Percentage of time spent in extreme high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInAnyHighPercent:
          description: Percentage of time spent in any high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInTargetPercent:
          description: Percentage of time spent in target glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeCGMUsePercent:
          description: Percentage of time spent wearing a cgm
          type: number
          example: 0.35
          x-go-type: float64
        timeCGMUseMinutes:
          description: Counter of minutes spent wearing a cgm
          type: number
          example: 200
          x-go-type: int
        lastData:
          type: string
          format: date-time
        patient:
          $ref: '#/components/schemas/tidePatient.v1'
      required:
        - patient
    tideResults.v1:
      type: object
      title: tideresults.v1
      description: ''
      additionalProperties:
        type: array
        items:
          $ref: '#/components/schemas/tideResultPatient.v1'
    tideResponse.v1:
      type: object
      title: tide.v1
      description: Report of at-risk patients based on specific grouping criteria
      properties:
        config:
          $ref: '#/components/schemas/tideConfig.v1'
        results:
          $ref: '#/components/schemas/tideResults.v1'
      required:
        - config
        - results
    patientPermissions.v1:
      type: object
      title: Patient Permissions
      properties:
        custodian:
          type: object
        view:
          type: object
        note:
          type: object
        upload:
          type: object
    summaryId.v1:
      title: Summary ID
      description: Summary Unique Identifier
      type: string
      minLength: 0
      maxLength: 24
      pattern: ^[a-f0-9]{0,24}$
      example: 2fe2488217ee43e1b2e83c2f
    summaryConfig.v1:
      type: object
      title: config.v1
      x-go-type-skip-optional-pointer: true
      description: Summary schema version and calculation configuration
      properties:
        schemaVersion:
          description: Summary schema version
          type: number
          x-go-type: int
        highGlucoseThreshold:
          description: Threshold used for determining if a value is high
          type: number
          x-go-type: float64
        veryHighGlucoseThreshold:
          description: Threshold used for determining if a value is very high
          type: number
          x-go-type: float64
        lowGlucoseThreshold:
          description: Threshold used for determining if a value is low
          type: number
          x-go-type: float64
        veryLowGlucoseThreshold:
          description: Threshold used for determining if a value is very low
          type: number
          x-go-type: float64
      required:
        - schemaVersion
        - highGlucoseThreshold
        - veryHighGlucoseThreshold
        - lowGlucoseThreshold
        - veryLowGlucoseThreshold
    summaryDates.v1:
      type: object
      title: dates.v1
      x-go-type-skip-optional-pointer: true
      description: dates tracked for summary calculation
      properties:
        lastUpdatedDate:
          description: Date of the last calculation
          type: string
          format: date-time
        lastUpdatedReason:
          description: List of reasons the summary was updated for
          type: array
          items:
            type: string
        hasFirstData:
          type: boolean
        firstData:
          description: Date of the first included value
          type: string
          format: date-time
        hasLastData:
          type: boolean
        lastData:
          description: Date of the last calculated value
          type: string
          format: date-time
        hasLastUploadDate:
          type: boolean
        lastUploadDate:
          description: Created date of the last calculated value
          type: string
          format: date-time
        hasOutdatedSince:
          type: boolean
        outdatedSince:
          description: >-
            Date of the first user upload after lastData, removed when
            calculated
          type: string
          format: date-time
        outdatedSinceLimit:
          description: >-
            Upper limit of the OutdatedSince value to prevent infinite queue
            duration
          type: string
          format: date-time
        outdatedReason:
          description: List of reasons the summary was marked outdated for
          type: array
          items:
            type: string
      required:
        - hasFirstData
        - hasLastData
        - hasLastUploadDate
        - hasOutdatedSince
    cgmPeriod.v1:
      type: object
      title: cgmperiod.v1
      description: 'Summary of a specific CGM time period (currently: 1d, 7d, 14d, 30d)'
      properties:
        min:
          type: number
          example: 3
          x-go-type: float64
        minDelta:
          type: number
          example: 3
          x-go-type: float64
        max:
          type: number
          example: 8
          x-go-type: float64
        maxDelta:
          type: number
          example: 8
          x-go-type: float64
        hasAverageGlucoseMmol:
          type: boolean
        averageGlucoseMmol:
          description: Average Glucose of records in this period
          type: number
          example: 5.5
          x-go-type: float64
        averageGlucoseMmolDelta:
          description: >-
            Difference between the averageGlucose in this period and the other
            offset version
          type: number
          example: 2.5
          x-go-type: float64
        hasGlucoseManagementIndicator:
          type: boolean
        glucoseManagementIndicator:
          type: number
          x-go-type: float64
          description: A derived value which emulates A1C
          example: 7.5
        glucoseManagementIndicatorDelta:
          type: number
          x-go-type: float64
          description: >-
            Difference between the glucoseManagementIndicator in this period and
            the other offset version
          example: 7.5
        hasTimeInTargetPercent:
          type: boolean
        timeInTargetPercent:
          description: Percentage of time spent in target glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInTargetPercentDelta:
          description: >-
            Difference between the timeInTargetPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInTargetMinutes:
          type: boolean
        timeInTargetMinutes:
          description: Counter of minutes spent in target glucose range
          type: number
          example: 200
          x-go-type: int
        timeInTargetMinutesDelta:
          description: >-
            Difference between the timeInTargetMinutes in this period and
            version in the opposite offset
          type: number
          example: 20
          x-go-type: int
        hasTimeInTargetRecords:
          type: boolean
        timeInTargetRecords:
          description: Counter of records in target glucose range
          type: number
          example: 10
          x-go-type: int
        timeInTargetRecordsDelta:
          description: >-
            Difference between the timeInTargetRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInHighPercent:
          type: boolean
        timeInHighPercent:
          description: Percentage of time spent in high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInHighPercentDelta:
          description: >-
            Difference between the timeInHighPercent in this period and version
            in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInHighMinutes:
          type: boolean
        timeInHighMinutes:
          description: Counter of minutes spent in high glucose range
          type: number
          example: 200
          x-go-type: int
        timeInHighMinutesDelta:
          description: >-
            Difference between the timeInHighMinutes in this period and version
            in the opposite offset
          type: number
          example: 20
          x-go-type: int
        hasTimeInHighRecords:
          type: boolean
        timeInHighRecords:
          description: Counter of records in high glucose range
          type: number
          example: 10
          x-go-type: int
        timeInHighRecordsDelta:
          description: >-
            Difference between the timeInHighRecords in this period and version
            in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInVeryHighPercent:
          type: boolean
        timeInVeryHighPercent:
          description: Percentage of time spent in very high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInVeryHighPercentDelta:
          description: >-
            Difference between the timeInVeryHighPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInVeryHighMinutes:
          type: boolean
        timeInVeryHighMinutes:
          description: Counter of minutes spent in very high glucose range
          type: number
          example: 200
          x-go-type: int
        timeInVeryHighMinutesDelta:
          description: >-
            Difference between the timeInVeryHighMinutes in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInVeryHighRecords:
          type: boolean
        timeInVeryHighRecords:
          description: Counter of records in very high glucose range
          type: number
          example: 10
          x-go-type: int
        timeInVeryHighRecordsDelta:
          description: >-
            Difference between the timeInVeryHighRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInExtremeHighPercent:
          type: boolean
        timeInExtremeHighPercent:
          description: Percentage of time spent in extreme high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInExtremeHighPercentDelta:
          description: >-
            Difference between the timeInExtremeHighPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInExtremeHighMinutes:
          type: boolean
        timeInExtremeHighMinutes:
          description: Counter of minutes spent in extreme high glucose range
          type: number
          example: 200
          x-go-type: int
        timeInExtremeHighMinutesDelta:
          description: >-
            Difference between the timeInExtremeHighMinutes in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInExtremeHighRecords:
          type: boolean
        timeInExtremeHighRecords:
          description: Counter of records in extreme high glucose range
          type: number
          example: 10
          x-go-type: int
        timeInExtremeHighRecordsDelta:
          description: >-
            Difference between the timeInExtremeHighRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInAnyHighPercent:
          type: boolean
        timeInAnyHighPercent:
          description: Percentage of time spent in Any high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInAnyHighPercentDelta:
          description: >-
            Difference between the timeInAnyHighPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInAnyHighMinutes:
          type: boolean
        timeInAnyHighMinutes:
          description: Counter of minutes spent in Any high glucose range
          type: number
          example: 200
          x-go-type: int
        timeInAnyHighMinutesDelta:
          description: >-
            Difference between the timeInAnyHighMinutes in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInAnyHighRecords:
          type: boolean
        timeInAnyHighRecords:
          description: Counter of records in Any high glucose range
          type: number
          example: 10
          x-go-type: int
        timeInAnyHighRecordsDelta:
          description: >-
            Difference between the timeInAnyHighRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInLowPercent:
          type: boolean
        timeInLowPercent:
          description: Percentage of time spent in low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInLowPercentDelta:
          description: >-
            Difference between the timeInLowPercent in this period and version
            in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInLowMinutes:
          type: boolean
        timeInLowMinutes:
          description: Counter of minutes spent in low glucose range
          type: number
          example: 200
          x-go-type: int
        timeInLowMinutesDelta:
          description: >-
            Difference between the timeInLowMinutes in this period and version
            in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInLowRecords:
          type: boolean
        timeInLowRecords:
          description: Counter of records in low glucose range
          type: number
          example: 10
          x-go-type: int
        timeInLowRecordsDelta:
          description: >-
            Difference between the timeInLowRecords in this period and version
            in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInVeryLowPercent:
          type: boolean
        timeInVeryLowPercent:
          description: Percentage of time spent in very low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInVeryLowPercentDelta:
          description: >-
            Difference between the timeInVeryLowPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInVeryLowMinutes:
          type: boolean
        timeInVeryLowMinutes:
          description: Counter of minutes spent in very low glucose range
          type: number
          example: 200
          x-go-type: int
        timeInVeryLowMinutesDelta:
          description: >-
            Difference between the timeInVeryLowMinutes in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInVeryLowRecords:
          type: boolean
        timeInVeryLowRecords:
          description: Counter of records in very low glucose range
          type: number
          example: 10
          x-go-type: int
        timeInVeryLowRecordsDelta:
          description: >-
            Difference between the timeInVeryLowRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInAnyLowPercent:
          type: boolean
        timeInAnyLowPercent:
          description: Percentage of time spent in Any low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInAnyLowPercentDelta:
          description: >-
            Difference between the timeInAnyLowPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInAnyLowMinutes:
          type: boolean
        timeInAnyLowMinutes:
          description: Counter of minutes spent in Any low glucose range
          type: number
          example: 200
          x-go-type: int
        timeInAnyLowMinutesDelta:
          description: >-
            Difference between the timeInAnyLowMinutes in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInAnyLowRecords:
          type: boolean
        timeInAnyLowRecords:
          description: Counter of records in Any low glucose range
          type: number
          example: 10
          x-go-type: int
        timeInAnyLowRecordsDelta:
          description: >-
            Difference between the timeInAnyLowRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeCGMUsePercent:
          type: boolean
        timeCGMUsePercent:
          description: Percentage of time spent wearing a cgm
          type: number
          example: 0.35
          x-go-type: float64
        timeCGMUsePercentDelta:
          description: >-
            Difference between the timeCGMUsePercent in this period and version
            in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeCGMUseMinutes:
          type: boolean
        timeCGMUseMinutes:
          description: Counter of minutes spent wearing a cgm
          type: number
          example: 200
          x-go-type: int
        timeCGMUseMinutesDelta:
          description: >-
            Difference between the timeCGMUseMinutes in this period and version
            in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeCGMUseRecords:
          type: boolean
        timeCGMUseRecords:
          description: Counter of minutes spent wearing a cgm
          type: number
          example: 10
          x-go-type: int
        timeCGMUseRecordsDelta:
          description: >-
            Difference between the timeCGMUseRecords in this period and version
            in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTotalRecords:
          type: boolean
        totalRecords:
          description: Counter of records
          type: number
          example: 10
          x-go-type: int
        totalRecordsDelta:
          description: >-
            Difference between the totalRecords in this period and version in
            the opposite offset
          type: number
          example: 10
          x-go-type: int
        hasAverageDailyRecords:
          type: boolean
        averageDailyRecords:
          description: Average daily readings
          type: number
          example: 3.5
          x-go-type: float64
        averageDailyRecordsDelta:
          description: >-
            Difference between the averageDailyRecords in this period and
            version in the opposite offset
          type: number
          example: 2.5
          x-go-type: float64
        standardDeviation:
          type: number
          example: 2.5
          x-go-type: float64
        standardDeviationDelta:
          type: number
          example: 2.5
          x-go-type: float64
        coefficientOfVariation:
          type: number
          example: 2.5
          x-go-type: float64
        coefficientOfVariationDelta:
          type: number
          example: 2.5
          x-go-type: float64
        hoursWithData:
          type: number
          example: 2
          x-go-type: int
        hoursWithDataDelta:
          type: number
          example: 2
          x-go-type: int
        daysWithData:
          type: number
          example: 2
          x-go-type: int
        daysWithDataDelta:
          type: number
          example: 2
          x-go-type: int
      required:
        - hasAverageGlucoseMmol
        - hasGlucoseManagementIndicator
        - hasTimeInTargetPercent
        - hasTimeInTargetMinutes
        - hasTimeInTargetRecords
        - hasTimeInHighPercent
        - hasTimeInHighMinutes
        - hasTimeInHighRecords
        - hasTimeInVeryHighPercent
        - hasTimeInVeryHighMinutes
        - hasTimeInVeryHighRecords
        - hasTimeInExtremeHighPercent
        - hasTimeInExtremeHighMinutes
        - hasTimeInExtremeHighRecords
        - hasTimeInLowPercent
        - hasTimeInLowMinutes
        - hasTimeInLowRecords
        - hasTimeInVeryLowPercent
        - hasTimeInVeryLowMinutes
        - hasTimeInVeryLowRecords
        - hasTimeInAnyLowPercent
        - hasTimeInAnyLowMinutes
        - hasTimeInAnyLowRecords
        - hasTimeInAnyHighPercent
        - hasTimeInAnyHighMinutes
        - hasTimeInAnyHighRecords
        - hasTimeCGMUsePercent
        - hasTimeCGMUseMinutes
        - hasTimeCGMUseRecords
        - hasTotalRecords
        - hasAverageDailyRecords
        - standardDeviation
        - standardDeviationDelta
        - coefficientOfVariation
        - coefficientOfVariationDelta
        - hoursWithData
        - hoursWithDataDelta
        - daysWithData
        - daysWithDataDelta
        - min
        - minDelta
        - max
        - maxDelta
    cgmPeriods.v1:
      type: object
      title: cgmperiods.v1
      x-go-type-skip-optional-pointer: true
      description: A map to each supported CGM summary period
      additionalProperties:
        $ref: '#/components/schemas/cgmPeriod.v1'
    cgmStats.v1:
      type: object
      title: cgmstats.v1
      description: A summary of a users recent CGM glucose values
      properties:
        id:
          $ref: '#/components/schemas/summaryId.v1'
        config:
          $ref: '#/components/schemas/summaryConfig.v1'
        dates:
          $ref: '#/components/schemas/summaryDates.v1'
        periods:
          $ref: '#/components/schemas/cgmPeriods.v1'
    bgmPeriod.v1:
      type: object
      title: bgmperiod.v1
      description: 'Summary of a specific BGM time period (currently: 1d, 7d, 14d, 30d)'
      properties:
        min:
          type: number
          example: 3
          x-go-type: float64
        minDelta:
          type: number
          example: 3
          x-go-type: float64
        max:
          type: number
          example: 8
          x-go-type: float64
        maxDelta:
          type: number
          example: 8
          x-go-type: float64
        hasAverageGlucoseMmol:
          type: boolean
        averageGlucoseMmol:
          description: Average Glucose of records in this period
          type: number
          example: 5.5
          x-go-type: float64
        averageGlucoseMmolDelta:
          description: >-
            Difference between the averageGlucose in this period and the other
            offset version
          type: number
          example: 2.5
          x-go-type: float64
        hasTimeInTargetPercent:
          type: boolean
        timeInTargetPercent:
          description: Percentage of time spent in target glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInTargetPercentDelta:
          description: >-
            Difference between the timeInTargetPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInTargetRecords:
          type: boolean
        timeInTargetRecords:
          description: Counter of records in target glucose range
          type: number
          example: 10
          x-go-type: int
        timeInTargetRecordsDelta:
          description: >-
            Difference between the timeInTargetRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInHighPercent:
          type: boolean
        timeInHighPercent:
          description: Percentage of time spent in high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInHighPercentDelta:
          description: >-
            Difference between the timeInHighPercent in this period and version
            in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInHighRecords:
          type: boolean
        timeInHighRecords:
          description: Counter of records in high glucose range
          type: number
          example: 10
          x-go-type: int
        timeInHighRecordsDelta:
          description: >-
            Difference between the timeInHighRecords in this period and version
            in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInVeryHighPercent:
          type: boolean
        timeInVeryHighPercent:
          description: Percentage of time spent in very high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInVeryHighPercentDelta:
          description: >-
            Difference between the timeInVeryHighPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInVeryHighRecords:
          type: boolean
        timeInVeryHighRecords:
          description: Counter of records in very high glucose range
          type: number
          example: 10
          x-go-type: int
        timeInVeryHighRecordsDelta:
          description: >-
            Difference between the timeInVeryHighRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInExtremeHighPercent:
          type: boolean
        timeInExtremeHighPercent:
          description: Percentage of time spent in extreme high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInExtremeHighPercentDelta:
          description: >-
            Difference between the timeInExtremeHighPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInExtremeHighRecords:
          type: boolean
        timeInExtremeHighRecords:
          description: Counter of records in extreme high glucose range
          type: number
          example: 10
          x-go-type: int
        timeInExtremeHighRecordsDelta:
          description: >-
            Difference between the timeInExtremeHighRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInAnyHighPercent:
          type: boolean
        timeInAnyHighPercent:
          description: Percentage of time spent in Any high glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInAnyHighPercentDelta:
          description: >-
            Difference between the timeInAnyHighPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInAnyHighRecords:
          type: boolean
        timeInAnyHighRecords:
          description: Counter of records in Any high glucose range
          type: number
          example: 10
          x-go-type: int
        timeInAnyHighRecordsDelta:
          description: >-
            Difference between the timeInAnyHighRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInLowPercent:
          type: boolean
        timeInLowPercent:
          description: Percentage of time spent in low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInLowPercentDelta:
          description: >-
            Difference between the timeInLowPercent in this period and version
            in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInLowRecords:
          type: boolean
        timeInLowRecords:
          description: Counter of records in low glucose range
          type: number
          example: 10
          x-go-type: int
        timeInLowRecordsDelta:
          description: >-
            Difference between the timeInLowRecords in this period and version
            in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInVeryLowPercent:
          type: boolean
        timeInVeryLowPercent:
          description: Percentage of time spent in very low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInVeryLowPercentDelta:
          description: >-
            Difference between the timeInVeryLowPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInVeryLowRecords:
          type: boolean
        timeInVeryLowRecords:
          description: Counter of records in very low glucose range
          type: number
          example: 10
          x-go-type: int
        timeInVeryLowRecordsDelta:
          description: >-
            Difference between the timeInVeryLowRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTimeInAnyLowPercent:
          type: boolean
        timeInAnyLowPercent:
          description: Percentage of time spent in Any low glucose range
          type: number
          example: 0.35
          x-go-type: float64
        timeInAnyLowPercentDelta:
          description: >-
            Difference between the timeInAnyLowPercent in this period and
            version in the opposite offset
          type: number
          example: 0.2
          x-go-type: float64
        hasTimeInAnyLowRecords:
          type: boolean
        timeInAnyLowRecords:
          description: Counter of records in Any low glucose range
          type: number
          example: 10
          x-go-type: int
        timeInAnyLowRecordsDelta:
          description: >-
            Difference between the timeInAnyLowRecords in this period and
            version in the opposite offset
          type: number
          example: 5
          x-go-type: int
        hasTotalRecords:
          type: boolean
        totalRecords:
          description: Counter of records
          type: number
          example: 10
          x-go-type: int
        totalRecordsDelta:
          description: >-
            Difference between the totalRecords in this period and version in
            the opposite offset
          type: number
          example: 10
          x-go-type: int
        hasAverageDailyRecords:
          type: boolean
        averageDailyRecords:
          description: Average daily readings
          type: number
          example: 3.5
          x-go-type: float64
        averageDailyRecordsDelta:
          description: >-
            Difference between the averageDailyRecords in this period and
            version in the opposite offset
          type: number
          example: 2.5
          x-go-type: float64
        standardDeviation:
          type: number
          example: 2.5
          x-go-type: float64
        standardDeviationDelta:
          type: number
          example: 2.5
          x-go-type: float64
        coefficientOfVariation:
          type: number
          example: 2.5
          x-go-type: float64
        coefficientOfVariationDelta:
          type: number
          example: 2.5
          x-go-type: float64
        daysWithData:
          type: number
          example: 2
          x-go-type: int
        daysWithDataDelta:
          type: number
          example: 2
          x-go-type: int
      required:
        - min
        - minDelta
        - max
        - maxDelta
        - hasAverageGlucoseMmol
        - hasTimeInTargetPercent
        - hasTimeInTargetRecords
        - hasTimeInHighPercent
        - hasTimeInHighRecords
        - hasTimeInVeryHighPercent
        - hasTimeInVeryHighRecords
        - hasTimeInExtremeHighPercent
        - hasTimeInExtremeHighRecords
        - hasTimeInAnyHighPercent
        - hasTimeInAnyHighRecords
        - hasTimeInLowPercent
        - hasTimeInLowRecords
        - hasTimeInVeryLowPercent
        - hasTimeInVeryLowRecords
        - hasTimeInAnyLowPercent
        - hasTimeInAnyLowRecords
        - hasTotalRecords
        - hasAverageDailyRecords
        - daysWithData
        - daysWithDataDelta
    bgmPeriods.v1:
      type: object
      title: bgmperiods.v1
      description: A map to each supported BGM summary period
      x-go-type-skip-optional-pointer: true
      additionalProperties:
        $ref: '#/components/schemas/bgmPeriod.v1'
    bgmStats.v1:
      type: object
      title: bgmstats.v1
      description: A summary of a users recent BGM glucose values
      properties:
        id:
          $ref: '#/components/schemas/summaryId.v1'
        config:
          $ref: '#/components/schemas/summaryConfig.v1'
        dates:
          $ref: '#/components/schemas/summaryDates.v1'
        periods:
          $ref: '#/components/schemas/bgmPeriods.v1'
    patientSummary.v1:
      type: object
      title: patientsummary.v1
      description: A summary of a patients recent data
      properties:
        cgmStats:
          $ref: '#/components/schemas/cgmStats.v1'
        bgmStats:
          $ref: '#/components/schemas/bgmStats.v1'
    providerId.v1:
      title: Third-Party Data Providers
      x-stoplight:
        id: fdmfczqym3ocn
      type: string
      enum:
        - dexcom
        - twiist
        - abbott
    providerConnectionRequest.v1:
      title: Provider Connection Request
      x-stoplight:
        id: nim4cceb0lu0w
      type: object
      properties:
        createdTime:
          type: string
          x-stoplight:
            id: efcvyea5slw36
          format: date-time
        providerName:
          $ref: '#/components/schemas/providerId.v1'
          x-stoplight:
            id: ej94kmuykpg1k
      required:
        - createdTime
        - providerName
    providerConnectionRequests.v1:
      title: providerconnectionrequests.v1
      x-stoplight:
        id: c8q7wrz5rtge5
      type: object
      readOnly: true
      properties:
        twiist:
          type: array
          x-stoplight:
            id: 7ve65jmart7pj
          items:
            $ref: '#/components/schemas/providerConnectionRequest.v1'
            x-stoplight:
              id: 47ez7wiccxdut
        dexcom:
          type: array
          x-stoplight:
            id: 7ve65jmart7pj
          items:
            $ref: '#/components/schemas/providerConnectionRequest.v1'
            x-stoplight:
              id: 913pgkbkz62eq
        abbott:
          type: array
          x-stoplight:
            id: u9rfvrr2njlcq
          items:
            $ref: '#/components/schemas/providerConnectionRequest.v1'
            x-stoplight:
              id: 47ez7wiccxdut
      required:
        - twiist
        - dexcom
        - abbott
    glycemicRangesThresholdUpperBound.v1:
      type: object
      properties:
        value:
          type: number
          format: float
        units:
          type: string
          enum:
            - mg/dL
            - mmol/L
      required:
        - value
        - units
    glycemicRangesThreshold.v1:
      type: object
      properties:
        name:
          type: string
          minLength: 1
        upperBound:
          $ref: '#/components/schemas/glycemicRangesThresholdUpperBound.v1'
        inclusive:
          type: boolean
          default: false
          x-go-type-skip-optional-pointer: true
      required:
        - name
        - upperBound
    glycemicRangesCustom.v1:
      type: object
      properties:
        name:
          type: string
          minLength: 1
        thresholds:
          type: array
          items:
            $ref: '#/components/schemas/glycemicRangesThreshold.v1'
          minLength: 4
          maxLength: 5
      required:
        - name
        - thresholds
      x-go-type-skip-optional-pointer: true
      x-omitzero: true
    glycemicRangesPreset.v1:
      type: string
      minLength: 1
      enum:
        - adaStandard
        - adaPregnancyType1
        - adaPregnancyType2
        - adaHighRisk
      x-enum-varnames:
        - ADAStandard
        - ADAPregnancyType1
        - ADAPregnancyType2
        - ADAHighRisk
      default: adaStandard
      x-go-type-skip-optional-pointer: true
      x-omitzero: true
    glycemicRanges.v1:
      properties:
        type:
          type: string
          enum:
            - preset
            - custom
          default: preset
        custom:
          $ref: '#/components/schemas/glycemicRangesCustom.v1'
        preset:
          $ref: '#/components/schemas/glycemicRangesPreset.v1'
      required:
        - type
    diagnosisType.v1:
      title: Diagnosis Type
      type: string
      enum:
        - type1
        - type2
        - type3c
        - gestational
        - prediabetes
        - lada
        - mody
        - other
        - notApplicable
        - ''
      example: type1
    patient.v1:
      type: object
      title: Patient
      properties:
        id:
          $ref: '#/components/schemas/tidepooluserid'
        email:
          type: string
          x-go-type: string
          format: email
        fullName:
          type: string
          description: The full name of the patient
          minLength: 1
        birthDate:
          type: string
          format: date
          example: '2012-08-30'
        mrn:
          type: string
          description: The medical record number of the patient
          minLength: 1
        tags:
          $ref: '#/components/schemas/patientTagIds.v1'
        targetDevices:
          type: array
          items:
            type: string
        permissions:
          $ref: '#/components/schemas/patientPermissions.v1'
        createdTime:
          type: string
          format: date-time
          readOnly: true
        updatedTime:
          type: string
          format: date-time
          readOnly: true
        attestationSubmitted:
          type: boolean
        dataSources:
          type: array
          nullable: true
          items:
            $ref: '#/components/schemas/dataSource.v1'
        lastUploadReminderTime:
          type: string
          format: date-time
          readOnly: true
        summary:
          $ref: '#/components/schemas/patientSummary.v1'
          readOnly: true
        reviews:
          type: array
          nullable: true
          x-go-type-skip-optional-pointer: true
          items:
            $ref: '#/components/schemas/patientReview.v1'
        connectionRequests:
          $ref: '#/components/schemas/providerConnectionRequests.v1'
          x-stoplight:
            id: 502rliv0l2tyy
          description: Requests for each provider are listed in reverse chronological order
          readOnly: true
        sites:
          type: array
          x-go-type-skip-optional-pointer: true
          x-omitempty: false
          x-omitzero: true
          items:
            $ref: '#/components/schemas/site.v1'
        glycemicRanges:
          $ref: '#/components/schemas/glycemicRanges.v1'
        diagnosisType:
          $ref: '#/components/schemas/diagnosisType.v1'
      required:
        - id
        - fullName
        - birthDate
        - createdTime
        - updatedTime
        - connectionRequests
    siteById.v1:
      type: object
      title: SiteById
      description: A clinic's physical or logical location—id only.
      properties:
        id:
          $ref: '#/components/schemas/objectid.v1'
      required:
        - id
    emailaddress.v1:
      title: Email Address
      description: >-
        An email address, as specified by [RFC
        5322](https://datatracker.ietf.org/doc/html/rfc5322).
      type: string
      format: email
      minLength: 6
      example: example@tidepool.org
      x-go-type: string
    inviteClinician.v1:
      title: Invite Clinician
      type: object
      description: ''
      properties:
        email:
          $ref: '#/components/schemas/emailaddress.v1'
        roles:
          $ref: '#/components/schemas/clinicianRoles.v1'
      required:
        - email
        - roles
    key.v1:
      title: Confirmation key that uniquely identifies each confirmation
      type: string
      minLength: 32
      maxLength: 32
      example: Sds2PHMALZrmt++JyD5mIjLkZruJldiM
    confirmation-type.v1:
      title: Confirmation Type
      type: string
      enum:
        - password_reset
        - careteam_invitation
        - clinician_invitation
        - signup_confirmation
        - no_account
    status.v1:
      title: Confirmation Status
      type: string
      enum:
        - pending
        - completed
        - canceled
        - declined
    birthday.v1:
      title: Birthday
      type: string
      format: date
      example: '2012-08-30'
      x-go-type: string
    diagnosisdate.v1:
      title: Diagnosis Date
      type: string
      format: date
      pattern: ^\d{4}-\d{2}-\d{2}$
      example: '2013-05-09'
      x-go-type: string
    patientprofile.v1:
      title: Patient User Profile
      type: object
      properties:
        birthday:
          $ref: '#/components/schemas/birthday.v1'
        diagnosisDate:
          $ref: '#/components/schemas/diagnosisdate.v1'
        isOtherPerson:
          type: boolean
          example: false
        fullName:
          type: string
          example: James Jellyfish
    creatorprofile.v1:
      title: Creator user profile
      type: object
      properties:
        fullName:
          type: string
        patient:
          $ref: '#/components/schemas/patientprofile.v1'
      required:
        - fullName
        - patient
    creator.v1:
      title: Creator
      type: object
      properties:
        userid:
          $ref: '#/components/schemas/tidepooluserid'
        profile:
          $ref: '#/components/schemas/creatorprofile.v1'
      required:
        - userid
        - profile
    restrictions.v1:
      title: Acceptance restrictions
      type: object
      properties:
        canAccept:
          type: boolean
          description: Whether the invite can be accepted by the current user
        requiredIdp:
          type: string
          description: >-
            Set if the user must be authenticated against a specific identity
            provider before they are able to accept the invite
      required:
        - canAccept
    expiresAt.v1:
      title: Expiration Time
      type: string
      format: date-time
      description: If specified, the invitation will expire at the given date and time.
      example: '2024-01-30T08:11:00Z'
    confirmation.v1:
      title: Confirmation
      type: object
      properties:
        key:
          $ref: '#/components/schemas/key.v1'
        type:
          $ref: '#/components/schemas/confirmation-type.v1'
        status:
          $ref: '#/components/schemas/status.v1'
        email:
          $ref: '#/components/schemas/emailaddress.v1'
        creatorId:
          $ref: '#/components/schemas/tidepooluserid'
        created:
          $ref: '#/components/schemas/datetime.v1'
        modified:
          $ref: '#/components/schemas/datetime.v1'
        creator:
          $ref: '#/components/schemas/creator.v1'
        context:
          type: string
        restrictions:
          $ref: '#/components/schemas/restrictions.v1'
        expiresAt:
          $ref: '#/components/schemas/expiresAt.v1'
      required:
        - key
        - type
        - status
        - email
        - creatorId
        - created
    migrationStatus.v1:
      type: string
      title: Migration Status
      enum:
        - PENDING
        - RUNNING
        - COMPLETED
      description: The current status of the migration
    membershipRestriction.v1:
      title: Membership Restriction
      type: object
      description: A user joining a clinic must match all of the defined restrictions
      properties:
        emailDomain:
          type: string
          format: hostname
          description: >-
            The restriction applies only if the user has an email address with a
            matching domain
        requiredIdp:
          type: string
          description: >-
            If this attribute is set, at the time of joining the clinic the user
            must be authenticated against this identity provider
      required:
        - emailDomain
    membershipRestrictions.v1:
      title: Membership Restrictions
      type: object
      description: >-
        A user joining a clinic must match at least one of the specified
        membership restrictions
      properties:
        restrictions:
          type: array
          items:
            $ref: '#/components/schemas/membershipRestriction.v1'
    ehrDestinations.v1:
      title: Default Redox destination ID and per-model overrides
      x-stoplight:
        id: z6cjrz20e5mvu
      type: object
      properties:
        flowsheet:
          type: string
          description: Destination ID override for Flowsheets
          minLength: 1
        results:
          type: string
          description: Destination ID override for Results
          minLength: 1
        notes:
          type: string
          description: Destination ID override for Notes
          minLength: 1
      required:
        - flowsheet
        - results
        - notes
    ehrProcedures.v1:
      title: EHR Procedure Codes Map
      x-stoplight:
        id: gy7do1thlm3g5
      type: object
      properties:
        enableSummaryReports:
          type: string
          minLength: 1
          description: Procedure Code for Summary Statistics and PDF Reports subscription
        disableSummaryReports:
          type: string
          minLength: 1
        createAccount:
          type: string
          minLength: 1
        createAccountAndEnableReports:
          type: string
          x-stoplight:
            id: nb3o2a7kkebar
    scheduledReports.v1:
      title: scheduledreports.v1
      x-stoplight:
        id: or3i2vsiyder8
      type: object
      description: Scheduled Report Settings
      properties:
        onUploadEnabled:
          type: boolean
          x-stoplight:
            id: ij8d2vhz49f0u
          description: >
            Send a PDF Report and a Flowsheet to Redox after a dataset is
            uploaded.
        onUploadNoteEventType:
          type: string
          x-stoplight:
            id: h02b819r2xdy0
          enum:
            - New
            - Replace
          default: New
        cadence:
          type: string
          x-stoplight:
            id: ibtk59wcgho89
          enum:
            - 1d
            - 7d
            - 14d
            - 30d
            - DISABLED
          description: >-
            The cadence of the scheduled reports. Disabling the scheduled
            reports does not affect reports which are generated after a dataset
            is uploaded.
      required:
        - onUploadEnabled
        - cadence
    ehrTagsSettings.v1:
      title: EHR Tags Settings
      x-stoplight:
        id: w3h05rpqc45iv
      type: object
      description: This configuration only applies to integrations using Redox Data Model
      properties:
        codes:
          type: array
          x-stoplight:
            id: fcr5es83pzi6r
          description: >-
            Codes of the clinical info items used to select the tags to
            associate with the patient. If defined, all tags of a patient will
            be replaced every time an enrollment order for the patient is
            processed.
          items:
            x-stoplight:
              id: h40mu6ujxknzf
            type: string
        separator:
          type: string
          x-stoplight:
            id: ic7t703igp2rn
          description: >-
            If set to a non-empty string, the tag values will be split using
            this separator
          minLength: 1
    ehrFlowsheetSettings.v1:
      title: Flowsheet Settings
      type: object
      properties:
        icode:
          type: boolean
          description: >-
            Determine if values should be sent in accorance with ICode2 rounding
            standards, or if we should send the values at higher precision.
      required:
        - icode
    ehrSettings.v1:
      title: EHR Settings
      x-stoplight:
        id: m0iw4p0mf24nb
      type: object
      properties:
        enabled:
          type: boolean
          description: Enable or disable the EHR integration
        sourceId:
          type: string
        destinationIds:
          $ref: '#/components/schemas/ehrDestinations.v1'
        procedureCodes:
          $ref: '#/components/schemas/ehrProcedures.v1'
        mrnIdType:
          type: string
          x-stoplight:
            id: x74orwp43yu91
          minLength: 1
        provider:
          type: string
          x-stoplight:
            id: z31vhe9hbaqrn
          enum:
            - xealth
            - redox
        scheduledReports:
          $ref: '#/components/schemas/scheduledReports.v1'
          x-stoplight:
            id: lgfrpsps4x37a
          description: Scheduled Report Settings
        tags:
          $ref: '#/components/schemas/ehrTagsSettings.v1'
          x-stoplight:
            id: hp97ilzsssprv
        flowsheets:
          $ref: '#/components/schemas/ehrFlowsheetSettings.v1'
      required:
        - enabled
        - sourceId
        - procedureCodes
        - mrnIdType
        - provider
        - scheduledReports
        - tags
        - flowsheets
    mrnSettings.v1:
      title: MRN Settings
      x-stoplight:
        id: 876c3qkxy3ih9
      type: object
      properties:
        required:
          type: boolean
          description: Require MRN when creating or updating patients
        unique:
          type: boolean
          description: Enforce MRN uniqueness constraint
      required:
        - required
        - unique
    patientCountLimit.v1:
      title: Patient Count Limit
      type: object
      properties:
        plan:
          description: The plan-based patient count limit
          type: integer
          minimum: 0
        startDate:
          description: The start date when the patient count limit should be applied
          $ref: '#/components/schemas/datetime.v1'
        endDate:
          description: >-
            The end date when the patient count limit should no longer be
            applied
          $ref: '#/components/schemas/datetime.v1'
      required:
        - plan
    patientCountSettings.v1:
      title: Patient Count Settings
      type: object
      properties:
        hardLimit:
          description: >-
            The hard limit for the clinic patient count where new patients
            cannot be created
          $ref: '#/components/schemas/patientCountLimit.v1'
        softLimit:
          description: >-
            The soft limit for the clinic patient count where new patients may
            still be created
          $ref: '#/components/schemas/patientCountLimit.v1'
    patientProviderCount.v1:
      title: Patient Provider Count
      description: >-
        The count of patients associated with the clinic for a specific
        provider. As each patient may be 

        associated with multiple providers, the sum of all provider counts may
        exceed the total patient count.
      type: object
      properties:
        total:
          description: >-
            The count of patients that have a specific provider as a data
            source.
          type: integer
          minimum: 0
        states:
          description: >-
            The count of patients for the provider segmented by data source
            state. The possible

            states are connected, disconnected, error, pending, and
            pendingReconnect.
          type: object
          additionalProperties:
            type: integer
            minimum: 0
      required:
        - total
        - states
    patientCount.v1:
      title: Patient Count
      type: object
      properties:
        total:
          description: >-
            The count of all patients associated with the clinic, regardless of
            classification.
          type: integer
          minimum: 0
        demo:
          description: >-
            The count of patients associated with the clinic that are classified
            as demo and do not 

            apply towards the plan-based patient count limit. Currently this is
            limited to 0 or 1,

            but allows for future expansion with multiple demo patients if
            needed.
          type: integer
          minimum: 0
        plan:
          description: >-
            The count of patients associated with the clinic classified as
            applying towards the 

            plan-based patient count limit. This excludes patients classified as
            demo as well as any 

            other classifications that do not apply towards the plan-based
            patient count limit 

            for various business reasons.
          type: integer
          minimum: 0
        providers:
          type: object
          description: >-
            The count of patients associated with the clinic by provider. As
            each patient may be associated 

            with multiple providers, the sum of all provider counts may exceed
            the total patient count.
          additionalProperties:
            $ref: '#/components/schemas/patientProviderCount.v1'
      required:
        - total
        - demo
        - plan
  securitySchemes:
    sessionToken:
      name: x-tidepool-session-token
      type: apiKey
      in: header
      description: A Tidepool session token
  parameters:
    offset:
      name: offset
      in: query
      schema:
        type: integer
        minimum: 0
    limit:
      name: limit
      in: query
      schema:
        type: integer
        minimum: 1
        default: 10
    clinicId:
      name: clinicId
      in: path
      required: true
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
    clinicianId:
      name: clinicianId
      in: path
      required: true
      schema:
        type: string
        pattern: >-
          ^([0-9a-f]{10}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$
    patientId:
      name: patientId
      in: path
      required: true
      schema:
        type: string
        pattern: >-
          ^([0-9a-f]{10}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$
    patientTagId:
      name: patientTagId
      in: path
      required: true
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
    siteId:
      name: siteId
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/objectId.v1'
    userId:
      name: userId
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/tidepooluserid'
    summaryId:
      name: summaryId
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/summaryId.v1'
    inviteId:
      name: inviteId
      in: path
      required: true
      schema:
        type: string
        minLength: 1
    shareCode:
      name: shareCode
      in: query
      required: false
      schema:
        type: string
    search:
      name: search
      in: query
      required: false
      schema:
        type: string
      description: Full text search query
    email:
      name: email
      in: query
      required: false
      schema:
        type: string
        format: email
    role:
      name: role
      in: query
      required: false
      schema:
        type: string
    sort:
      name: sort
      in: query
      required: false
      schema:
        type: string
        pattern: (?:-|\+)(?:[a-zA-Z]|_)+
      description: Sort order and attribute (e.g. +name or -name)
    createdTimeStart:
      name: createdTimeStart
      in: query
      required: false
      schema:
        type: string
        format: date-time
      description: Return records created after the given date (inclusive)
    createdTimeEnd:
      name: createdTimeEnd
      in: query
      required: false
      schema:
        type: string
        format: date-time
      description: Return records created before the given date (exclusive)
    ehrEnabled:
      name: ehrEnabled
      in: query
      required: false
      schema:
        type: boolean
      description: Retrieve clinics with enabled EHR integration
    providerId:
      name: providerId
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/providerId.v1'
      description: Provider ID
    clinicId.v1:
      description: Clinic ID
      name: clinicId
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/clinicId.v1'
tags:
  - name: Clinics
    description: Manage clinics, clinians and patients.
  - name: Confirmations
    description: Manage confirmations for account creation, sharing invites, etc.
  - name: Internal
    description: APIs intended for internal use by Tidepool.
  - name: Redox
    description: Public endpoints invoked by Redox.
security:
  - sessionToken: []
