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

# Submit a FHIR bundle for ingestion

> Accepts a FHIR bundle containing Patient, MedicationStatement, MedicationRequest, Condition,
AllergyIntolerance, Observation, and Encounter resources. Each resource is validated and stored in
the tenant's workspace. The response includes an OperationOutcome and per-resource summary counters.




## OpenAPI

````yaml /openapi/marmar-cds.openapi.yaml post /v1/fhir/$submit
openapi: 3.1.0
info:
  title: Marmar Clinical Decision Support Reference
  version: 0.1.0
  description: >
    API for integrating Marmar's medication safety assessments into clinical
    workflows. Tenants can synchronize patient records, request assessments, and
    receive webhook notifications when assessments are completed.
servers:
  - url: https://cds.marmar.life
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
tags:
  - name: Patients
  - name: Assessments
  - name: Tenants
  - name: Webhooks
  - name: FHIR
paths:
  /v1/fhir/$submit:
    post:
      tags:
        - FHIR
      summary: Submit a FHIR bundle for ingestion
      description: >
        Accepts a FHIR bundle containing Patient, MedicationStatement,
        MedicationRequest, Condition,

        AllergyIntolerance, Observation, and Encounter resources. Each resource
        is validated and stored in

        the tenant's workspace. The response includes an OperationOutcome and
        per-resource summary counters.
      operationId: submitFhirBundle
      requestBody:
        required: true
        content:
          application/fhir+json:
            schema:
              $ref: '#/components/schemas/FhirBundle'
          application/json:
            schema:
              $ref: '#/components/schemas/FhirBundle'
      responses:
        '200':
          description: Bundle processed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FhirSubmitResponse'
        '400':
          description: Bundle failed validation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OperationOutcome'
      security:
        - BearerAuth: []
components:
  schemas:
    FhirBundle:
      type: object
      properties:
        resourceType:
          type: string
          enum:
            - Bundle
        type:
          type: string
          enum:
            - collection
            - batch
            - transaction
        entry:
          type: array
          items:
            $ref: '#/components/schemas/FhirBundleEntry'
      required:
        - resourceType
        - type
    FhirSubmitResponse:
      type: object
      properties:
        outcome:
          $ref: '#/components/schemas/OperationOutcome'
        summary:
          $ref: '#/components/schemas/FhirSubmitSummary'
      required:
        - outcome
        - summary
    OperationOutcome:
      type: object
      additionalProperties: false
      properties:
        resourceType:
          type: string
          enum:
            - OperationOutcome
        issue:
          type: array
          items:
            type: object
            additionalProperties: false
            properties:
              severity:
                type: string
                enum:
                  - fatal
                  - error
                  - warning
                  - information
              code:
                type: string
              diagnostics:
                type: string
              expression:
                type: array
                items:
                  type: string
            required:
              - severity
              - code
      required:
        - resourceType
        - issue
    FhirBundleEntry:
      type: object
      properties:
        resource:
          oneOf:
            - $ref: '#/components/schemas/FhirPatient'
            - $ref: '#/components/schemas/FhirMedicationStatement'
            - $ref: '#/components/schemas/FhirMedicationRequest'
            - $ref: '#/components/schemas/FhirCondition'
            - $ref: '#/components/schemas/FhirAllergyIntolerance'
            - $ref: '#/components/schemas/FhirObservation'
            - $ref: '#/components/schemas/FhirEncounter'
    FhirSubmitSummary:
      type: object
      properties:
        patients:
          type: integer
          minimum: 0
        medicationStatements:
          type: integer
          minimum: 0
        medicationRequests:
          type: integer
          minimum: 0
        conditions:
          type: integer
          minimum: 0
        allergies:
          type: integer
          minimum: 0
        observations:
          type: integer
          minimum: 0
        encounters:
          type: integer
          minimum: 0
        errors:
          type: integer
          minimum: 0
        warnings:
          type: integer
          minimum: 0
        ignored:
          type: integer
          minimum: 0
      required:
        - patients
        - medicationStatements
        - medicationRequests
        - conditions
        - allergies
        - observations
        - encounters
        - errors
        - warnings
        - ignored
    FhirPatient:
      type: object
      properties:
        resourceType:
          type: string
          enum:
            - Patient
        id:
          type: string
        identifier:
          type: array
          items:
            $ref: '#/components/schemas/FhirIdentifier'
        name:
          type: array
          items:
            $ref: '#/components/schemas/FhirHumanName'
        gender:
          type: string
        birthDate:
          type: string
      required:
        - resourceType
    FhirMedicationStatement:
      type: object
      properties:
        resourceType:
          type: string
          enum:
            - MedicationStatement
        id:
          type: string
        status:
          type: string
        medicationCodeableConcept:
          $ref: '#/components/schemas/FhirCodeableConcept'
        subject:
          $ref: '#/components/schemas/FhirReference'
        effectiveDateTime:
          type: string
        effectivePeriod:
          type: object
          properties:
            start:
              type: string
            end:
              type: string
        dateAsserted:
          type: string
        dosage:
          type: array
          items:
            $ref: '#/components/schemas/FhirDosage'
      required:
        - resourceType
        - subject
    FhirMedicationRequest:
      type: object
      properties:
        resourceType:
          type: string
          enum:
            - MedicationRequest
        id:
          type: string
        status:
          type: string
        intent:
          type: string
        medicationCodeableConcept:
          $ref: '#/components/schemas/FhirCodeableConcept'
        subject:
          $ref: '#/components/schemas/FhirReference'
        authoredOn:
          type: string
        requester:
          $ref: '#/components/schemas/FhirReference'
        dosageInstruction:
          type: array
          items:
            $ref: '#/components/schemas/FhirDosage'
      required:
        - resourceType
        - subject
    FhirCondition:
      type: object
      properties:
        resourceType:
          type: string
          enum:
            - Condition
        id:
          type: string
        clinicalStatus:
          $ref: '#/components/schemas/FhirCodeableConcept'
        verificationStatus:
          $ref: '#/components/schemas/FhirCodeableConcept'
        code:
          $ref: '#/components/schemas/FhirCodeableConcept'
        subject:
          $ref: '#/components/schemas/FhirReference'
        recordedDate:
          type: string
      required:
        - resourceType
        - subject
    FhirAllergyIntolerance:
      type: object
      properties:
        resourceType:
          type: string
          enum:
            - AllergyIntolerance
        id:
          type: string
        clinicalStatus:
          $ref: '#/components/schemas/FhirCodeableConcept'
        verificationStatus:
          $ref: '#/components/schemas/FhirCodeableConcept'
        code:
          $ref: '#/components/schemas/FhirCodeableConcept'
        patient:
          $ref: '#/components/schemas/FhirReference'
        recordedDate:
          type: string
        reaction:
          type: array
          items:
            type: object
            properties:
              description:
                type: string
              severity:
                type: string
      required:
        - resourceType
        - patient
    FhirObservation:
      type: object
      properties:
        resourceType:
          type: string
          enum:
            - Observation
        id:
          type: string
        status:
          type: string
        category:
          type: array
          items:
            $ref: '#/components/schemas/FhirCodeableConcept'
        code:
          $ref: '#/components/schemas/FhirCodeableConcept'
        subject:
          $ref: '#/components/schemas/FhirReference'
        effectiveDateTime:
          type: string
        valueQuantity:
          type: object
          properties:
            value:
              type: number
            unit:
              type: string
      required:
        - resourceType
        - code
        - subject
    FhirEncounter:
      type: object
      properties:
        resourceType:
          type: string
          enum:
            - Encounter
        id:
          type: string
        status:
          type: string
        class:
          type: object
          properties:
            code:
              type: string
            display:
              type: string
        subject:
          $ref: '#/components/schemas/FhirReference'
        period:
          type: object
          properties:
            start:
              type: string
            end:
              type: string
      required:
        - resourceType
        - subject
    FhirIdentifier:
      type: object
      properties:
        system:
          type: string
        value:
          type: string
      required:
        - value
    FhirHumanName:
      type: object
      properties:
        family:
          type: string
        given:
          type: array
          items:
            type: string
        text:
          type: string
    FhirCodeableConcept:
      type: object
      properties:
        text:
          type: string
        coding:
          type: array
          items:
            type: object
            properties:
              system:
                type: string
              code:
                type: string
              display:
                type: string
    FhirReference:
      type: object
      properties:
        reference:
          type: string
        display:
          type: string
      required:
        - reference
    FhirDosage:
      type: object
      properties:
        text:
          type: string
        route:
          $ref: '#/components/schemas/FhirCodeableConcept'
        method:
          $ref: '#/components/schemas/FhirCodeableConcept'
        doseQuantity:
          type: object
          properties:
            value:
              type: number
            unit:
              type: string
        timing:
          type: object
          properties:
            repeat:
              type: object
              properties:
                frequency:
                  type: number
                period:
                  type: number
                periodUnit:
                  type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key obtained from the Tenant Dashboard. Use as Authorization: Bearer
        YOUR_API_KEY

````