> ## Documentation Index
> Fetch the complete documentation index at: https://docs.decodahealth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Patient Analytics Grouped

> Get patient analytics data grouped by location, patient_source, or provider.

Returns groups with summary stats and paginated patient rows per group.



## OpenAPI

````yaml get /analytics/dashboards/patient-breakdown/patient-analytics-grouped
openapi: 3.1.0
info:
  title: Decoda API
  description: External API documentation for the Decoda Health platform.
  version: '1.0'
servers: []
security: []
paths:
  /analytics/dashboards/patient-breakdown/patient-analytics-grouped:
    get:
      tags:
        - provider
        - analytics
        - analytics
      summary: Get Patient Analytics Grouped
      description: >-
        Get patient analytics data grouped by location, patient_source, or
        provider.


        Returns groups with summary stats and paginated patient rows per group.
      operationId: >-
        get_patient_analytics_grouped_analytics_dashboards_patient_breakdown_patient_analytics_grouped_get
      parameters:
        - name: TENANT
          in: header
          required: true
          schema:
            type: string
            title: Tenant
          description: The tenant you are making this request on behalf of
        - name: API-KEY
          in: header
          required: true
          schema:
            type: string
            title: Api-Key
          description: Your api key
        - name: timezone
          in: query
          required: false
          schema:
            type: string
            default: UTC
            title: Timezone
        - name: group_by
          in: query
          required: false
          schema:
            enum:
              - location
              - patient_source
              - provider
            type: string
            default: location
            title: Group By
        - name: sort_by
          in: query
          required: false
          schema:
            type: string
            default: last_appointment_date
            title: Sort By
        - name: sort_direction
          in: query
          required: false
          schema:
            enum:
              - asc
              - desc
            type: string
            default: desc
            title: Sort Direction
        - name: start_date
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Start Date
        - name: end_date
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: End Date
        - name: patient_source
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Patient Source
        - name: location_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Location Ids
        - name: days_since_last_appointment
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Days Since Last Appointment
        - name: patient_name
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Patient Name
        - name: patient_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Patient Id
        - name: last_appointment_service_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Last Appointment Service Ids
        - name: last_appointment_provider_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Last Appointment Provider Ids
        - name: last_visit_days
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Last Visit Days
        - name: visit_span_days
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Visit Span Days
        - name: per_page
          in: query
          required: false
          schema:
            type: integer
            maximum: 500
            minimum: 1
            default: 50
            title: Per Page
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PatientAnalyticsGroupedResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    PatientAnalyticsGroupedResponse:
      properties:
        groups:
          items:
            $ref: '#/components/schemas/PatientGroup'
          type: array
          title: Groups
        grandTotals:
          $ref: '#/components/schemas/PatientGroupSummary'
        totalCount:
          type: integer
          title: Totalcount
      type: object
      required:
        - groups
        - grandTotals
        - totalCount
      title: PatientAnalyticsGroupedResponse
      description: Response from the grouped patient analytics endpoint.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PatientGroup:
      properties:
        key:
          type: string
          title: Key
        label:
          type: string
          title: Label
        count:
          type: integer
          title: Count
        summary:
          $ref: '#/components/schemas/PatientGroupSummary'
        rows:
          items:
            $ref: '#/components/schemas/PatientAnalyticsItem'
          type: array
          title: Rows
      type: object
      required:
        - key
        - label
        - count
        - summary
        - rows
      title: PatientGroup
      description: A single group with summary and expandable patient rows.
    PatientGroupSummary:
      properties:
        totalPatients:
          type: integer
          title: Totalpatients
          default: 0
        totalSpent:
          type: integer
          title: Totalspent
          default: 0
        totalAppointments:
          type: integer
          title: Totalappointments
          default: 0
        avgSpent:
          type: integer
          title: Avgspent
          default: 0
        avgTenureDays:
          anyOf:
            - type: number
            - type: 'null'
          title: Avgtenuredays
        uniqueServices:
          type: integer
          title: Uniqueservices
          default: 0
        uniqueProviders:
          type: integer
          title: Uniqueproviders
          default: 0
      type: object
      title: PatientGroupSummary
      description: Aggregated summary for a patient group.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    PatientAnalyticsItem:
      properties:
        patient:
          $ref: '#/components/schemas/PatientTiny'
        patientSource:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientsource
          description: Patient source (e.g. WALK_IN, REFERRAL)
        firstAppointmentDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Firstappointmentdate
          description: First appointment date/time
        lastAppointmentDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Lastappointmentdate
          description: Last appointment date/time
        lastAppointmentServices:
          items:
            type: string
          type: array
          title: Lastappointmentservices
          description: Services from last appointment
        lastAppointmentProviders:
          items:
            $ref: >-
              #/components/schemas/decoda__apps__api__routes__analytics__dashboards__patient_breakdown__ProviderInfo
          type: array
          title: Lastappointmentproviders
          description: Providers from last appointment
        totalSpent:
          type: integer
          title: Totalspent
          description: Total amount spent in cents
          default: 0
        appointmentCount:
          type: integer
          title: Appointmentcount
          description: Total number of appointments
          default: 0
      type: object
      required:
        - patient
      title: PatientAnalyticsItem
      description: Individual patient analytics item.
    PatientTiny:
      properties:
        id:
          type: string
          title: Id
          description: The unique identifier for the user.
        firstName:
          anyOf:
            - type: string
            - type: 'null'
          title: Firstname
          description: The user's first name.
        lastName:
          anyOf:
            - type: string
            - type: 'null'
          title: Lastname
          description: The user's last name.
        phoneNumber:
          anyOf:
            - type: string
            - type: 'null'
          title: Phonenumber
          description: The user's phone number.
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
          description: The user's email address.
        type:
          $ref: '#/components/schemas/UserType'
          description: The type of user.
          default: PATIENT
        locationId:
          anyOf:
            - type: string
            - type: 'null'
          title: Locationid
          description: The location of the user.
        dateOfBirth:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Dateofbirth
          description: The date of birth of the patient.
        onSchedulingBlacklist:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Onschedulingblacklist
          description: Whether the patient is on the scheduling blacklist.
      type: object
      required:
        - id
      title: PatientTiny
    decoda__apps__api__routes__analytics__dashboards__patient_breakdown__ProviderInfo:
      properties:
        id:
          type: string
          title: Id
        firstName:
          type: string
          title: Firstname
        lastName:
          type: string
          title: Lastname
      type: object
      required:
        - id
        - firstName
        - lastName
      title: ProviderInfo
      description: Provider information.
    UserType:
      type: string
      enum:
        - PROVIDER
        - PATIENT
        - ASSISTANT
      title: UserType

````