Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.nextmed.med.br/llms.txt

Use this file to discover all available pages before exploring further.

Chat e IA

Modelo de mensagem

type Message = {
  id: string;
  content: string;
  role: "user" | "assistant";
  timestamp: Date;
  type: "text" | "audio-transcribed";
  audioUrl?: string;
  suggestions?: string[];
  suggestionsLoading?: boolean;
};

Chat por encaminhamento

POST /api/chat/message
Body:
type ChatMessageRequest = {
  referralId: string;
  message: string;
  history: Message[];
};
Resposta:
  • 200 text/event-stream.
  • cada chunk e emitido no formato:
0:{"type":"text-delta","textDelta":"conteudo"}

Acoes rapidas

POST /api/chat/quick-action
Body:
type QuickActionRequest = {
  referralId: string;
  action: "suggestion" | "summary" | "anamnesis" | "diagnosis";
  history: Message[];
};
Resposta:
  • 200 text/event-stream com chunks text-delta.

Sugestoes de proximo passo

POST /api/chat/suggestions
Body:
type ChatSuggestionsRequest = {
  referralId: string;
  doctorMessage: string;
  assistantMessage: string;
  history: Message[];
};
Resposta:
{
  "suggestions": [
    "Sugestao curta.",
    "Outra sugestao curta."
  ]
}

Transcricao de audio

POST /api/chat/transcribe
Content-Type:
multipart/form-data
Campo:
audio: File
Formatos aceitos: mp3, wav, m4a, webm, ogg. Limite: 10 MB. Resposta:
{
  "transcription": "texto transcrito"
}

Chat de anamnese

POST /api/anamnesis-chat
Body:
type AnamnesisChatRequest = {
  messages: Array<{
    role: "user" | "assistant";
    content: string;
  }>;
  patient: {
    name: string;
    birthdate: string;
    gender: "male" | "female";
    is_neonate: boolean;
    is_foreigner: boolean;
  };
  complaint: string;
  initialAnamnesis?: string;
  conversationHistory?: string;
};
Resposta:
  • 200 text/event-stream com chunks text-delta.
  • quando a IA considera a anamnese completa, o conteudo pode conter ANAMNESE_COMPLETA:.

Gerar anamnese final

POST /api/anamnesis-chat/generate
Body:
type GenerateAnamnesisRequest = {
  patient: {
    name: string;
    birthdate: string;
    gender: "male" | "female";
    is_neonate: boolean;
    is_foreigner: boolean;
  };
  complaint: string;
  initialAnamnesis?: string;
  conversationHistory: string;
};
Resposta:
{
  "anamnesis": "texto final"
}

Avaliar anamnese e possivel AVC

POST /api/anamnesis-chat/evaluate
Body:
type EvaluateAnamnesisRequest = {
  anamnesis: string;
  complaint: string;
  patient: {
    name: string;
    birthdate: string;
    gender: "male" | "female";
    is_neonate: boolean;
    is_foreigner: boolean;
  };
};
Resposta:
type EvaluateAnamnesisResponse = {
  sufficient: boolean;
  reason: string;
  message: string;
  needsImprovement: boolean;
  suggestions?: string[];
  possibleStroke: boolean;
  strokeIndicators: string[];
};
Se nao houver chave OpenAI, o endpoint aplica uma validacao basica com heuristica local para possivel AVC.

Validar queixa principal

POST /api/anamnesis-chat/validate
Body:
type ValidateComplaintRequest = {
  complaint: string;
  patient: {
    name: string;
    age: number;
    gender: "male" | "female";
  };
};
Resposta:
type ValidateComplaintResponse = {
  valid: boolean;
  reason: string;
  message: string;
  suggestion?: string;
};