feat(mp): 小程序功能完善 — 服务层扩展 + 页面优化
- 新增 actionInbox 服务层(待办事项列表/线程查询) - consultation 服务扩展(会话详情/发送消息) - 多页面代码优化(profile/messages/health/article) - 新增 navigate 工具函数
This commit is contained in:
@@ -60,6 +60,11 @@ export async function getArticleDetail(id: string) {
|
||||
return api.get<Article>(`/health/articles/${id}`);
|
||||
}
|
||||
|
||||
/** 公开文章详情(无需认证) */
|
||||
export async function getPublicArticleDetail(id: string) {
|
||||
return api.get<Article>(`/public/articles/${id}`);
|
||||
}
|
||||
|
||||
export async function listCategories() {
|
||||
return api.get<ArticleCategory[]>('/health/article-categories');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { api } from './request';
|
||||
import { api, requestWithTimeout } from './request';
|
||||
|
||||
export interface ConsultationSession {
|
||||
id: string;
|
||||
@@ -60,3 +60,12 @@ export async function sendMessage(sessionId: string, content: string, contentTyp
|
||||
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 requestWithTimeout<ConsultationMessage[]>('GET', path, undefined, 30000);
|
||||
}
|
||||
|
||||
68
apps/miniprogram/src/services/doctor/actionInbox.ts
Normal file
68
apps/miniprogram/src/services/doctor/actionInbox.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { api } from '../request';
|
||||
import type { ActionItem, ThreadResponse } from '../action-inbox';
|
||||
|
||||
interface WorkbenchStats {
|
||||
pending: number;
|
||||
in_progress: number;
|
||||
completed_today: number;
|
||||
overdue: number;
|
||||
}
|
||||
|
||||
interface NursePatientSummary {
|
||||
patient_id: string;
|
||||
patient_name: string;
|
||||
bed_number?: string;
|
||||
primary_diagnosis?: string;
|
||||
care_plan_status?: string;
|
||||
open_action_count: number;
|
||||
}
|
||||
|
||||
interface TeamOverview {
|
||||
team_name: string;
|
||||
members: {
|
||||
user_id: string;
|
||||
user_name: string;
|
||||
role: string;
|
||||
active_tasks: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
interface PaginatedData {
|
||||
data: ActionItem[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export async function listActionItems(params?: {
|
||||
status?: string;
|
||||
type?: string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
assigned_to_me?: boolean;
|
||||
patient_id?: string;
|
||||
}) {
|
||||
return api.get<PaginatedData>(
|
||||
'/health/action-inbox',
|
||||
params as Record<string, string | number | boolean | undefined>,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getActionThread(sourceRef: string) {
|
||||
return api.get<ThreadResponse>(
|
||||
`/health/action-inbox/${encodeURIComponent(sourceRef)}/thread`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getWorkbenchStats(assignedToMe?: boolean) {
|
||||
return api.get<WorkbenchStats>(
|
||||
'/health/action-inbox/stats',
|
||||
assignedToMe !== undefined ? { assigned_to_me: assignedToMe } : undefined,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getTeamOverview() {
|
||||
return api.get<TeamOverview>('/health/action-inbox/team');
|
||||
}
|
||||
|
||||
export async function getMyPatients() {
|
||||
return api.get<NursePatientSummary[]>('/health/action-inbox/my-patients');
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { api } from '../request';
|
||||
import { api, requestWithTimeout } from '../request';
|
||||
|
||||
// ── Consultation (doctor view) ─────────────────────
|
||||
|
||||
@@ -14,6 +14,7 @@ export interface ConsultationSession {
|
||||
last_message_at: string | null;
|
||||
unread_count_doctor?: number;
|
||||
created_at: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface ConsultationMessage {
|
||||
@@ -60,8 +61,17 @@ export async function markSessionRead(sessionId: string) {
|
||||
return api.put<void>(`/health/consultation-sessions/${sessionId}/read`);
|
||||
}
|
||||
|
||||
export async function closeSession(sessionId: string) {
|
||||
return api.put<void>(`/health/consultation-sessions/${sessionId}/close`);
|
||||
export async function closeSession(sessionId: string, version: number) {
|
||||
return api.put<void>(`/health/consultation-sessions/${sessionId}/close`, { version });
|
||||
}
|
||||
|
||||
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 requestWithTimeout<ConsultationMessage[]>('GET', path, undefined, 30000);
|
||||
}
|
||||
|
||||
export interface ConsultationStats {
|
||||
|
||||
Reference in New Issue
Block a user