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

# Update Patient Vitals and Link to ABHA

> Update the vitals data for a specific patient using the transaction ID. It processes the data and links it to the ABHA (Ayushman Bharat Health Account) if requested. Request body must include valid list of vitals.

Refer to the [Table](https://developer.eka.care/api-reference/user-app/vitals/vital-information-table) for proper eka_code, LOINC code and UCUM code mappings for different vital signs.




## OpenAPI

````yaml patch /trackers/api/v1/vitals/{txn_id}
openapi: 3.1.0
info:
  title: Vitals API Contract
  description: Documentation for the Vitals API endpoint for Samsung vital data.
  version: 1.0.0
  license:
    name: Proprietary License
    url: https://example.com/license
servers:
  - url: https://api.eka.care
    description: Production server
  - url: https://api.dev.eka.care
    description: Development server
security: []
tags:
  - name: Vitals
    description: API related to managing patient's vitals from Samsung devices.
paths:
  /trackers/api/v1/vitals/{txn_id}:
    patch:
      tags:
        - Vitals
      summary: Update Patient Vitals and Link to ABHA
      description: >
        Update the vitals data for a specific patient using the transaction ID.
        It processes the data and links it to the ABHA (Ayushman Bharat Health
        Account) if requested. Request body must include valid list of vitals.


        Refer to the
        [Table](https://developer.eka.care/api-reference/user-app/vitals/vital-information-table)
        for proper eka_code, LOINC code and UCUM code mappings for different
        vital signs.
      parameters:
        - name: txn_id
          in: path
          required: true
          schema:
            type: string
          description: Transaction ID to identify the specific vitals record.
          example: P-PP-111
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VitalRequest'
            example:
              vitals:
                - display_name: Pulse rate
                  identifiers:
                    unique_id: 354bks353
                    eka_code: lb-1201285132
                    loinc: '17616716'
                  vital_value:
                    value_type: NUM
                    value: 75
                  vital_unit:
                    display_unit: '{Counts}/min'
                    ucum_code: /min
                  measured_at:
                    measurement_type: INSTANT
                    start: '2025-01-30T06:19:23.583000+00:00'
                    end: null
                - display_name: Blood Glucose
                  identifiers:
                    unique_id: 354bks354
                    eka_code: lb-1201285133
                    loinc: 15074-8
                  vital_value:
                    value_type: NUM
                    value: 90
                  vital_unit:
                    display_unit: mg/dL
                    ucum_code: mg/dL
                  measured_at:
                    measurement_type: DURATION
                    start: '2025-01-30T06:19:23.583000+00:00'
                    end: '2025-01-30T06:29:23.583000+00:00'
      responses:
        '202':
          description: All vitals processed successfully with/without ABHA linking
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/SuccessResponseWithABHA'
                  - $ref: '#/components/schemas/SuccessResponseWithoutABHA'
        '206':
          description: Vitals partially processed successfully with/without ABHA linking
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/PartialSuccessResponseWithABHA'
                  - $ref: '#/components/schemas/PartialSuccessResponseWithoutABHA'
        '400':
          description: Bad Request - Invalid data or missing parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '401':
          description: Unauthorized - Invalid authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - auth: []
components:
  schemas:
    VitalRequest:
      type: object
      required:
        - vitals
      properties:
        vitals:
          type: array
          items:
            $ref: '#/components/schemas/Vital'
    SuccessResponseWithABHA:
      type: object
      properties:
        message:
          type: string
          example: >-
            All vitals data saved and successfully linked to ABHA for care
            context ID: ekap_durgesh-stage-002
        data:
          type: object
          properties:
            abha_linking:
              type: string
              example: success
            abha_message:
              type: string
              example: ABHA linking successful
            processing_status:
              type: object
              properties:
                processed:
                  type: array
                  items:
                    $ref: '#/components/schemas/ProcessedItem'
                  example:
                    - resource_type: vitals
                      fhir_id: e5d0b6c6-c932-5e0d-8a90-dc8e2729875c
                      identifier: ekap_0832043542354bks353
                failed:
                  type: array
                  items:
                    $ref: '#/components/schemas/FailedItem'
                  example: []
    SuccessResponseWithoutABHA:
      type: object
      properties:
        message:
          type: string
          example: 'All vitals data saved successfully for id: ekap_durgesh-stage-002'
        data:
          type: object
          properties:
            abha_linking:
              type: string
              example: Not requested
            processing_status:
              type: object
              properties:
                processed:
                  type: array
                  items:
                    $ref: '#/components/schemas/ProcessedItem'
                  example:
                    - resource_type: vitals
                      fhir_id: e5d0b6c6-c932-5e0d-8a90-dc8e2729875c
                      identifier: ekap_0832043542354bks353
                failed:
                  type: array
                  items:
                    $ref: '#/components/schemas/FailedItem'
                  example: []
    PartialSuccessResponseWithABHA:
      type: object
      properties:
        message:
          type: string
          example: >-
            Vitals data partially saved and successfully linked to ABHA for care
            context ID: ekap_durgesh-stage-002
        data:
          type: object
          properties:
            abha_linking:
              type: string
              example: success
            abha_message:
              type: string
              example: ABHA linking successful
            processing_status:
              $ref: '#/components/schemas/ProcessingStatus'
    PartialSuccessResponseWithoutABHA:
      type: object
      properties:
        message:
          type: string
          example: 'Vitals data partially saved for id: ekap_durgesh-stage-002'
        data:
          type: object
          properties:
            abha_linking:
              type: string
              example: Not requested
            processing_status:
              $ref: '#/components/schemas/ProcessingStatus'
    ValidationErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            error_code:
              type: string
              example: VALIDATION_ERROR
            display_message:
              type: string
              example: Please check your input data and try again.
            message:
              type: string
              example: 'non_field_errors: Either ''w-id'' or ''b-id'' is required'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            error_code:
              type: string
              example: INTERNAL_ERROR
            display_message:
              type: string
              example: An error occurred while processing your request.
            message:
              type: string
              example: >-
                Database connection timeout occurred while processing the
                request
    Vital:
      type: object
      required:
        - display_name
        - identifiers
        - vital_value
        - measured_at
      properties:
        display_name:
          type: string
          description: >-
            Display name of the vital sign (e.g., "Pulse rate", "Blood
            Glucose").
          example: Pulse rate
        identifiers:
          $ref: '#/components/schemas/Identifiers'
        vital_value:
          $ref: '#/components/schemas/VitalValue'
        vital_unit:
          $ref: '#/components/schemas/VitalUnit'
          description: >-
            Unit information. Required only when vital_value.value_type is
            "NUM".
        measured_at:
          $ref: '#/components/schemas/MeasuredAt'
    ProcessedItem:
      type: object
      properties:
        resource_type:
          type: string
          example: vitals
        fhir_id:
          type: string
          example: e5d0b6c6-c932-5e0d-8a90-dc8e2729875c
        identifier:
          type: string
          example: ekap_0832043542354bks353
    FailedItem:
      type: object
      properties:
        resource_type:
          type: string
          example: vitals
        identifier:
          type: string
          example: c932-5e0d-8a90-dc8e27
        error:
          type: object
          properties:
            code:
              type: string
              example: parsing_error
            message:
              type: string
              example: unable to parse the observation due to empty doc id
    ProcessingStatus:
      type: object
      properties:
        processed:
          type: array
          items:
            $ref: '#/components/schemas/ProcessedItem'
        failed:
          type: array
          items:
            $ref: '#/components/schemas/FailedItem'
    Identifiers:
      type: object
      required:
        - unique_id
      properties:
        unique_id:
          type: string
          description: Unique identifier for the vital measurement.
          example: 354bks353
        eka_code:
          type: string
          nullable: true
          description: >
            Eka internal code for the vital. 

            **Note:** Refer to the [Vital Information
            Table](https://developer.eka.care/api-reference/user-app/vitals/vital-information-table)
            for correct eka_code mappings.
          example: lb-1201285132
        loinc:
          type: string
          nullable: true
          description: >
            LOINC code corresponding to the vital sign. 

            **Note:** Refer to the [Vital Information
            Table](https://developer.eka.care/api-reference/user-app/vitals/vital-information-table)
            for correct LOINC code mappings.
          example: '17616716'
    VitalValue:
      type: object
      required:
        - value_type
        - value
      properties:
        value_type:
          type: string
          enum:
            - NUM
            - BOOL
            - STR
          description: Type of the vital value.
        value:
          oneOf:
            - type: number
            - type: boolean
            - type: string
          description: The actual value of the vital sign. Type depends on value_type.
          example: 75
    VitalUnit:
      type: object
      required:
        - display_unit
      properties:
        display_unit:
          type: string
          description: Human-readable unit of measurement.
          example: '{Counts}/min'
        ucum_code:
          type: string
          nullable: true
          description: >
            UCUM code for the unit. 

            **Note:** Refer to the [Vital Information
            Table](https://developer.eka.care/api-reference/user-app/vitals/vital-information-table)
            for correct UCUM code mappings.
          example: /min
    MeasuredAt:
      type: object
      required:
        - measurement_type
        - start
      properties:
        measurement_type:
          type: string
          enum:
            - INSTANT
            - DURATION
          description: Type of measurement timing.
        start:
          type: string
          format: date-time
          description: Start time of measurement.
          example: '2025-01-30T06:19:23.583000+00:00'
        end:
          type: string
          format: date-time
          nullable: true
          description: >-
            End time of measurement. Required only when measurement_type is
            "DURATION".
          example: '2025-01-30T06:29:23.583000+00:00'
  securitySchemes:
    auth:
      type: apiKey
      in: header
      name: auth
      description: |
        The API requires the following `auth` header for authentication.

````