imageActions.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import axiosInstance from './interceptor';
  2. /**
  3. * 发送图像请求参数
  4. */
  5. export interface SendImageRequest {
  6. /** 图像实例 UID */
  7. sop_instance_uid: string;
  8. /** PACS 节点名称 */
  9. pacs_name: string;
  10. }
  11. /**
  12. * 存储响应数据
  13. */
  14. export interface StoreReplyData {
  15. /** 类型标识 */
  16. '@type': string;
  17. /** 是否成功 */
  18. ok: boolean;
  19. /** 输出信息 */
  20. output: string;
  21. }
  22. /**
  23. * 发送图像响应
  24. */
  25. export interface SendImageResponse {
  26. /** 响应码 */
  27. code: string;
  28. /** 描述信息 */
  29. description: string;
  30. /** 解决方案 */
  31. solution: string;
  32. /** 数据内容 */
  33. data: StoreReplyData;
  34. }
  35. /**
  36. * 发送图像到 PACS 节点
  37. * @param sopInstanceUid 图像实例 UID (SOP Instance UID)
  38. * @param pacsName PACS 节点名称
  39. * @returns 发送结果,包含成功状态和输出信息
  40. * @throws 当发送失败时抛出错误
  41. *
  42. * @example
  43. * ```typescript
  44. * const result = await sendImageToPacs(
  45. * '1.2.276.0.1000000.5.1.4.701601461.19649.1749545373.668671',
  46. * 'pacs1'
  47. * );
  48. * console.log('发送成功:', result.data.ok);
  49. * ```
  50. */
  51. export const sendImageToPacs = async (
  52. sopInstanceUid: string,
  53. pacsName: string
  54. ): Promise<SendImageResponse> => {
  55. try {
  56. const response = await axiosInstance.post<SendImageResponse>(
  57. '/auth/scp/store',
  58. {
  59. sop_instance_uid: sopInstanceUid,
  60. pacs_name: pacsName,
  61. }
  62. );
  63. if (response.data.code !== '0x000000') {
  64. throw new Error(`发送图像失败: ${response.data.description}`);
  65. }
  66. return response.data;
  67. } catch (error) {
  68. console.error('Error sending image to PACS:', error);
  69. throw error;
  70. }
  71. };