- consultation: 添加 description 字段 + 症状描述输入 + 建议填写提醒 - health/index: 使用 validateNum 添加体征范围校验(血压/心率/血糖/体重) - mall: 隐藏未实现的积分任务空壳入口 - pkg-doctor-core: 工作台加载失败添加重试按钮和错误状态 - index: 医护人员跳转返回 null 替代 Loading 避免无用渲染
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import { api, requestUnlimited } from './request';
|
|
|
|
export interface ConsultationSession {
|
|
id: string;
|
|
patient_id: string;
|
|
doctor_id: string | null;
|
|
patient_name?: string | null;
|
|
doctor_name?: string | null;
|
|
consultation_type: string;
|
|
status: string;
|
|
subject?: string | null;
|
|
last_message?: string | null;
|
|
last_message_at: string | null;
|
|
unread_count_patient: number;
|
|
unread_count_doctor?: number;
|
|
created_at: string;
|
|
updated_at?: string;
|
|
version?: number;
|
|
}
|
|
|
|
export interface ConsultationMessage {
|
|
id: string;
|
|
session_id: string;
|
|
sender_id: string;
|
|
sender_role: string;
|
|
content_type: string;
|
|
content: string;
|
|
is_read: boolean;
|
|
created_at: string;
|
|
}
|
|
|
|
export async function listConsultations(params?: {
|
|
page?: number;
|
|
page_size?: number;
|
|
}) {
|
|
return api.get<{ data: ConsultationSession[]; total: number }>(
|
|
'/health/consultation-sessions',
|
|
params,
|
|
);
|
|
}
|
|
|
|
export async function getSession(sessionId: string) {
|
|
return api.get<ConsultationSession>(`/health/consultation-sessions/${sessionId}`);
|
|
}
|
|
|
|
export async function listMessages(sessionId: string, params?: {
|
|
page?: number;
|
|
page_size?: number;
|
|
after_id?: string;
|
|
}) {
|
|
return api.get<{ data: ConsultationMessage[]; total: number }>(
|
|
`/health/consultation-sessions/${sessionId}/messages`,
|
|
params,
|
|
);
|
|
}
|
|
|
|
export async function sendMessage(sessionId: string, content: string, contentType = 'text') {
|
|
return api.post<ConsultationMessage>('/health/consultation-messages', {
|
|
session_id: sessionId,
|
|
content_type: contentType,
|
|
content,
|
|
});
|
|
}
|
|
|
|
export async function markSessionRead(sessionId: string) {
|
|
return api.put<void>(`/health/consultation-sessions/${sessionId}/read`);
|
|
}
|
|
|
|
export async function pollMessages(sessionId: string, afterId?: string) {
|
|
const params = new URLSearchParams();
|
|
if (afterId) params.set('after_id', afterId);
|
|
params.set('timeout', '25');
|
|
const query = params.toString();
|
|
const path = `/health/consultation-sessions/${sessionId}/messages/poll${query ? '?' + query : ''}`;
|
|
return requestUnlimited<ConsultationMessage[]>('GET', path, undefined, 30000);
|
|
}
|
|
|
|
export async function createSession(params: {
|
|
patient_id: string;
|
|
doctor_id?: string;
|
|
consultation_type?: string;
|
|
description?: string;
|
|
}) {
|
|
return api.post<ConsultationSession>('/health/consultation-sessions', params);
|
|
}
|