Clinical note generation


Generates a clinical note by intelligently filling a structured template with information extracted from a raw text (stt, vtt, plain-text,…) transcription.

Below we will describe the entire process that allows the successful completion of note generation.

Request description

Endpoint: /api/v1/generate-clinical-note
Method: POST

Remember: you can see the URL to consume this API in the Introduction section.

{
  "Content-Type": "application/json",
  "Authorization": "Bearer <accessToken>"
}

Authorization: We'll pass the token obtained during the authentication process. You can reuse the generated tokens, as they have a 2-hour lifespan. Review this page: Credentials

To set the API version on a specific request, you can add a specific header named X-Invox-Medical-Api-Version with the value of the version you are targeting:

X-Invox-Medical-Api-Version: 2026-03-01

Payload structure

type GenerateReportPayloadType = {
  template: IAPITemplate; // Template used to generate the report
  transcription: string; // Transcription used as input to the report
  consultationSessionId?: string; // Optional consultation session ID to provide context for the identification of a clinical notes and assets related to the same consultation
};

export interface IAPITemplate {
  id: string;
  template_name: string;
  template_description: string;
  template_language: string;
  fields: APITemplateField[];
}

export interface APITemplateField {
  id: string;
  name: string;
  description: string;
  type: "string" | "number" | "array" | "boolean" | "enum";
  enumerableOptions?: string[];
  context?: string;
  history?: IFormattedField[];
  value: string | string[] | number | boolean;
}

For more details related to the template structure, using the following link: JSON Schema

Responses

Correct response

Successful request

Describe the characteristics of a satisfactory response

200

Response example:

{
  "isSuccessRequest": true,
  "templateFields": [
    {
      "id": "field-001",
      "value": "Dolor de cabeza intenso desde hace 3 días.",
      "name": "chief_complaint",
      "type": "string"
    },
    {
      "id": "field-002",
      "value": ["Ibuprofeno 400mg", "Paracetamol 1g"],
      "name": "current_medication",
      "type": "array"
    }
  ]
}
{
  "isSuccessRequest": true,
  "templateFields": [
    {
      "id": "field-001",
      "value": "Dolor de cabeza intenso desde hace 3 días.",
      "name": "chief_complaint",
      "type": "string"
    },
    {
      "id": "field-002",
      "value": ["Ibuprofeno 400mg", "Paracetamol 1g"],
      "name": "current_medication",
      "type": "array"
    }
  ],
  "generationMetadata": {
    "partial": false,
    "partialFailureCount": 0,
    "failedFields": [],
    "statusByField": {
      "field-001__chief_complaint": "SUCCESS",
      "field-002__current_medication": "SUCCESS"
    },
    "recommendation": "NONE"
  }
}
{
  "isSuccessRequest": true,
  "templateFields": [
    {
      "id": "field-001",
      "value": "Dolor de cabeza intenso desde hace 3 días.",
      "name": "chief_complaint",
      "type": "string"
    },
    {
      "id": "field-002",
      "value": [],
      "name": "current_medication",
      "type": "array"
    }
  ],
  "generationMetadata": {
    "partial": true,
    "partialFailureCount": 1,
    "failedFields": [
      {
        "fieldKey": "field-002__current_medication",
        "reasonCode": "REQUEST_TIMEOUT",
        "retryable": true
      }
    ],
    "statusByField": {
      "field-001__chief_complaint": "SUCCESS",
      "field-002__current_medication": "DEFAULTED"
    },
    "recommendation": "RETRY_RECOMMENDED"
  }
}
Response structure:
type GenerateReportResponseType = {
  isSuccessRequest: boolean;
  templateFields: ReportField[];
};

type ReportField = {
  id: string;
  value: string | string[] | number | boolean;
  name: string;
  type: "string" | "number" | "array" | "boolean" | "enum";
};
type GenerateReportResponseType = {
  isSuccessRequest: boolean;
  templateFields: ReportField[];
  generationMetadata: GenerationMetadata;
};

type ReportField = {
  id: string;
  value: string | string[] | number | boolean;
  name: string;
  type: "string" | "number" | "array" | "boolean" | "enum";
};

type GenerationMetadata = {
  partial: boolean; // true if the report was generated with some fields failed
  partialFailureCount: number; // number of fields that failed
  failedFields: FieldGenerationFailure[]; // details for each failed field
  statusByField: Record<string, "SUCCESS" | "DEFAULTED">; // status for each field
  recommendation: "NONE" | "RETRY_RECOMMENDED"; // guidance for the client
};

type FieldGenerationFailure = {
  fieldKey: string; // format: "<id>__<name>"
  reasonCode:
    | "REQUEST_TIMEOUT"
    | "FIELD_PROCESSING_ERROR"
    | "VALIDATION_FAILED"
    | "UNKNOWN";
  retryable: boolean; // whether a retry can recover the field
};

Wrong responses

Unauthorized request

Describes the response when the request is not authorized


401

Response body

type GenerateReportResponseType = {
  messsage: string;
};


Forbidden request

Describes the response when the API Key is not allowed to consume this service


403

Response body

type GenerateReportResponseType = {
  messsage: string;
  errorType: string;
};

Remember that to consume this service, the API Key must have the permission: GENERATE-REPORT

Bad request

Describe the features of a bad request

400

Response body

type GenerateReportResponseType = {
    messsage: string
    errorType: GENERATE_REPORT_ERROR_TYPE
}

enum GENERATE_REPORT_ERROR_TYPE {
    INVALID_LANGUAGE= 'invalidLanguage'
    INVALID_TRANSCRIPTION = 'invalidTranscription',
    EMPTY_TRANSCRIPTION = 'emptyTranscription',
    INVALID_TEMPLATE_NAME_LENGTH = 'invalidTemplateNameLength', // Max: 64 Characters
    INVALID_TEMPLATE_DESCRIPTION_LENGTH= 'invalidTemplateDescriptionLength', // Max: 256 Charachers
    EMPTY_TEMPLATE_FIELDS= 'emptyTemplateFields',
    ALL_FIELDS_MUST_HAVE_TYPE= 'allFieldsMustHaveType',
    FIELDS_WITH_INVALID_TYPE= 'FIELDS_WITH_INVALID_TYPE',
    ALL_FIELDS_MUST_HAVE_ID_AND_NAME= 'allFieldsMustHaveIdAndName',
    ALL_IDS_MUST_BE_UNIQUE= 'allIdsMustBeUnique',
    ENUMERABLE_OPTIONS_ARE_MISSING_OR_EMPTY_FOR_ENUM= 'enumerableOptionsAreMissingOrEmptyForEnum',
    ERROR_GENERATING_MEDICAL_REPORT='errorGeneratingMedicalReport'
}

Remember that the valid languages are: es_ES, ca_ES, pt_PT, pt_BR, en_GB, en_US, gl, eu, va
Remember that the valid types are: string, number, boolean, array, enum