import axiosInstance from './interceptor'; /** * 发送图像请求参数 */ export interface SendImageRequest { /** 图像实例 UID */ sop_instance_uid: string; /** PACS 节点名称 */ pacs_name: string; } /** * 存储响应数据 */ export interface StoreReplyData { /** 类型标识 */ '@type': string; /** 是否成功 */ ok: boolean; /** 输出信息 */ output: string; } /** * 发送图像响应 */ export interface SendImageResponse { /** 响应码 */ code: string; /** 描述信息 */ description: string; /** 解决方案 */ solution: string; /** 数据内容 */ data: StoreReplyData; } /** * 发送图像到 PACS 节点 * @param sopInstanceUid 图像实例 UID (SOP Instance UID) * @param pacsName PACS 节点名称 * @returns 发送结果,包含成功状态和输出信息 * @throws 当发送失败时抛出错误 * * @example * ```typescript * const result = await sendImageToPacs( * '1.2.276.0.1000000.5.1.4.701601461.19649.1749545373.668671', * 'pacs1' * ); * console.log('发送成功:', result.data.ok); * ``` */ export const sendImageToPacs = async ( sopInstanceUid: string, pacsName: string ): Promise => { try { const response = await axiosInstance.post( '/auth/scp/store', { sop_instance_uid: sopInstanceUid, pacs_name: pacsName, } ); if (response.data.code !== '0x000000') { throw new Error(`发送图像失败: ${response.data.description}`); } return response.data; } catch (error) { console.error('Error sending image to PACS:', error); throw error; } };