/** * Study Mock Handlers * 检查信息管理相关的 mock 处理器 */ /** * 登记检查信息 - 成功场景 * * @description 登记新的检查信息 * @method POST * @url /dr/api/v1/auth/study * @access 需要认证 * * @param {Object} requestBody - 请求体(包含患者信息、体位列表等) * * @returns {Object} data - 新创建的检查信息 * @returns {string} data.study_id - 检查ID * @returns {Object[]} data.series - 序列列表 * * @example * mockRegisterStudySuccess(); * cy.wait('@registerStudySuccess'); * * @see docs/DR.md - 章节13 */ export function mockRegisterStudySuccess() { cy.intercept('POST', '/dr/api/v1/auth/study', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.study.Study", study_instance_uid: "1.2.276.0.1000000.5.1.2.701601461.33458.1750833219.482097", study_id: "20250625143339389", patient_name: "Test Patient", patient_id: "PET007", study_status: "Arrived", series: [] } } }).as('registerStudySuccess'); } /** * 获取检查信息 - Arrived状态(简化版) * * @description 根据study_id获取检查详细信息(已到达状态) * @method GET * @url /dr/api/v1/auth/study/{id} * @access 需要认证 * * @param {string} id - 检查ID(study_id),路径参数 * * @returns {Object} data - 检查详细信息 * @returns {string} data.study_status - 检查状态(Arrived/InProgress/Completed) * * @example * mockGetStudyArrived(); * cy.wait('@getStudyArrived'); * * @see docs/DR.md - 章节16 */ export function mockGetStudyArrived() { cy.intercept('GET', '/dr/api/v1/auth/study/*', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { study_id: "250929163817805", patient_name: "Test Patient", study_status: "Arrived", series: [] } } }).as('getStudyArrived'); } /** * 获取检查信息 - 完整详情(未曝光) * * @description 根据study_id获取完整的检查详细信息,所有images为未曝光状态 * @method GET * @url /dr/api/v1/auth/study/{id} * @access 需要认证 * * @param {string} studyId - 检查ID(study_id),路径参数 * * @returns {Object} data - 完整的检查详细信息,包含未曝光的series和images * * @example * mockGetStudyDetailsUnexposed('250929163817805'); * cy.wait('@getStudyDetailsUnexposed'); * * @see docs/测试/进入检查功能测试方案.md */ export function mockGetStudyDetailsUnexposed(studyId: string) { cy.intercept('GET', `/dr/api/v1/auth/study/${studyId}`, { statusCode: 200, body: { code: "0x000000", description: "成功", solution: "", data: { "@type": "type.googleapis.com/dr.study.Study", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", study_id: studyId, public_study_id: "", specific_character_set: "ISO_IR 192", accession_number: "ACC0012345", ref_physician: "Dr. Smith (Vet)", patient_id: "PET007", patient_name: "Buddy (Dog)", patient_english_name: "Buddy en", patient_former_name: "Buddy f", patient_size: "Large", other_patient_ids: "", other_patient_names: "", patient_age: "008Y", patient_dob: "2025-06-10T03:12:36.181739Z", patient_sex: "M", sex_neutered: "", pregnancy_status: "", patient_state: "", admitting_time: null, priority: "", reg_source: "", study_description: "", study_start_datetime: "2025-09-29T08:38:17.283651Z", study_end_datetime: null, scheduled_procedure_step_start_date: null, performed_physician: "", study_lock: "Unlocked", folder_path: "", operator_name: "OP987", modality: "DX", weight: 25, thickness: 15, length: 60, patient_type: "Human", study_type: "Normal", owner_name: "owner1", chip_number: "CHIP123456789", variety: "Golden Retriever", is_anaesthesia: true, is_sedation: true, mwl: "", is_exported: false, is_edited: false, is_appended: false, department: "", mapped_status: false, qc_result: false, comment: "未曝光测试数据", study_status: "Arrived", sort: 0, product: "DROS", create_time: "2025-09-29T08:38:17.353598Z", series: [ { series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", study_id: studyId, procedure_id: "P0-0002", patient_type: "Human", body_part: "Human_SKULL", performed_datetime: null, performed_protocol_code_meaning: "颅骨前后位 + 侧位", performed_protocol_code_value: "P0-0002", sort: 1, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.359308Z", images: [ { sop_instance_uid: "2.25.156.999999.0000.1.4.8323328.269954.1759135097.323786", series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", secondary_sop_uid: "", study_id: studyId, view_id: "View_DX_T_A_SK_AP_00", view_description: "颅骨前后位", patient_type: "Human", body_part_id: "Human_SKULL", anatomic_region: "Skull", image_type: "expose", image_file_path: "", image_file: "", thumbnail_file: "", acquisition_mode: "RAD", acquisition_context: null, img_proc_context: null, comment: "", expose_status: "Unexposed", expose_time: null, judged_status: "NotJudged", send_status: "Unsent", export_status: "NotExported", storage_status: "NotSaved", ticket: "", sort: 1, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.361002Z" }, { sop_instance_uid: "2.25.156.999999.0000.1.4.8323328.269954.1759135097.323787", series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", secondary_sop_uid: "", study_id: studyId, view_id: "View_DX_T_A_SK_LAT_00", view_description: "颅骨左侧位", patient_type: "Human", body_part_id: "Human_SKULL", anatomic_region: "Skull", image_type: "expose", image_file_path: "", image_file: "", thumbnail_file: "", acquisition_mode: "RAD", acquisition_context: null, img_proc_context: null, comment: "", expose_status: "Unexposed", expose_time: null, judged_status: "NotJudged", send_status: "Unsent", export_status: "NotExported", storage_status: "NotSaved", ticket: "", sort: 2, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.362195Z" } ] } ] } } }).as('getStudyDetailsUnexposed'); } /** * 获取检查信息 - 完整详情(已曝光) * * @description 根据study_id获取完整的检查详细信息,所有images为已曝光状态 * @method GET * @url /dr/api/v1/auth/study/{id} * @access 需要认证 * * @param {string} studyId - 检查ID(study_id),路径参数 * * @returns {Object} data - 完整的检查详细信息,包含已曝光的series和images * * @example * mockGetStudyDetailsExposed('250929163817805'); * cy.wait('@getStudyDetailsExposed'); * * @see docs/测试/进入检查功能测试方案.md */ export function mockGetStudyDetailsExposed(studyId: string) { cy.intercept('GET', `/dr/api/v1/auth/study/${studyId}`, { statusCode: 200, body: { code: "0x000000", description: "成功", solution: "", data: { "@type": "type.googleapis.com/dr.study.Study", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", study_id: studyId, public_study_id: "", specific_character_set: "ISO_IR 192", accession_number: "ACC0012345", ref_physician: "Dr. Smith (Vet)", patient_id: "PET007", patient_name: "Buddy (Dog)", patient_english_name: "Buddy en", patient_former_name: "Buddy f", patient_size: "Large", other_patient_ids: "", other_patient_names: "", patient_age: "008Y", patient_dob: "2025-06-10T03:12:36.181739Z", patient_sex: "M", sex_neutered: "", pregnancy_status: "", patient_state: "", admitting_time: null, priority: "", reg_source: "", study_description: "", study_start_datetime: "2025-09-29T08:38:17.283651Z", study_end_datetime: null, scheduled_procedure_step_start_date: null, performed_physician: "", study_lock: "Unlocked", folder_path: "", operator_name: "OP987", modality: "DX", weight: 25, thickness: 15, length: 60, patient_type: "Human", study_type: "Normal", owner_name: "owner1", chip_number: "CHIP123456789", variety: "Golden Retriever", is_anaesthesia: true, is_sedation: true, mwl: "", is_exported: false, is_edited: false, is_appended: false, department: "", mapped_status: false, qc_result: false, comment: "已曝光测试数据", study_status: "Completed", sort: 0, product: "DROS", create_time: "2025-09-29T08:38:17.353598Z", series: [ { series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", study_id: studyId, procedure_id: "P0-0002", patient_type: "Human", body_part: "Human_SKULL", performed_datetime: "2025-09-29T09:00:00.000000Z", performed_protocol_code_meaning: "颅骨前后位 + 侧位", performed_protocol_code_value: "P0-0002", sort: 1, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.359308Z", images: [ { sop_instance_uid: "2.25.156.999999.0000.1.4.8323328.269954.1759135097.323786", series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", secondary_sop_uid: "", study_id: studyId, view_id: "View_DX_T_A_SK_AP_00", view_description: "颅骨前后位", patient_type: "Human", body_part_id: "Human_SKULL", anatomic_region: "Skull", image_type: "expose", image_file_path: "/path/to/image1.dcm", image_file: "/path/to/image1.dcm", thumbnail_file: "/path/to/image1_thumb.jpg", acquisition_mode: "RAD", acquisition_context: null, img_proc_context: null, comment: "", expose_status: "Exposed", expose_time: "2025-09-29T09:00:00.000000Z", judged_status: "NotJudged", send_status: "Unsent", export_status: "NotExported", storage_status: "Saved", ticket: "", sort: 1, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.361002Z" }, { sop_instance_uid: "2.25.156.999999.0000.1.4.8323328.269954.1759135097.323787", series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", secondary_sop_uid: "", study_id: studyId, view_id: "View_DX_T_A_SK_LAT_00", view_description: "颅骨左侧位", patient_type: "Human", body_part_id: "Human_SKULL", anatomic_region: "Skull", image_type: "expose", image_file_path: "/path/to/image2.dcm", image_file: "/path/to/image2.dcm", thumbnail_file: "/path/to/image2_thumb.jpg", acquisition_mode: "RAD", acquisition_context: null, img_proc_context: null, comment: "", expose_status: "Exposed", expose_time: "2025-09-29T09:00:30.000000Z", judged_status: "NotJudged", send_status: "Unsent", export_status: "NotExported", storage_status: "Saved", ticket: "", sort: 2, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.362195Z" } ] } ] } } }).as('getStudyDetailsExposed'); } /** * 获取检查信息 - 完整详情(通用,保持向后兼容) * * @description 根据study_id获取完整的检查详细信息,包含series和images * @method GET * @url /dr/api/v1/auth/study/{id} * @access 需要认证 * * @param {string} id - 检查ID(study_id),路径参数 * * @returns {Object} data - 完整的检查详细信息,包含series和images * * @example * mockGetStudyDetails(); * cy.wait('@getStudyDetails'); * * @see docs/DR.md - 章节19 */ export function mockGetStudyDetails(studyId:string) { cy.intercept('GET', `/dr/api/v1/auth/study/${studyId}`, { statusCode: 200, body: { code: "0x000000", description: "成功", solution: "", data: { "@type": "type.googleapis.com/dr.study.Study", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", study_id: studyId, public_study_id: "", specific_character_set: "ISO_IR 192", accession_number: "ACC0012345", ref_physician: "Dr. Smith (Vet)", patient_id: "PET007", patient_name: "Buddy (Dog)", patient_english_name: "Buddy en", patient_former_name: "Buddy f", patient_size: "Large", other_patient_ids: "", other_patient_names: "", patient_age: "008Y", patient_dob: "2025-06-10T03:12:36.181739Z", patient_sex: "M", sex_neutered: "", pregnancy_status: "", patient_state: "", admitting_time: null, priority: "", reg_source: "", study_description: "", study_start_datetime: "2025-09-29T08:38:17.283651Z", study_end_datetime: null, scheduled_procedure_step_start_date: null, performed_physician: "", study_lock: "Unlocked", folder_path: "", operator_name: "OP987", modality: "DX", weight: 25, thickness: 15, length: 60, patient_type: "Human", study_type: "Normal", owner_name: "owner1", chip_number: "CHIP123456789", variety: "Golden Retriever", is_anaesthesia: true, is_sedation: true, mwl: "", is_exported: false, is_edited: false, is_appended: false, department: "", mapped_status: false, qc_result: false, comment: "一二三四五六七八九十", study_status: "Arrived", sort: 0, product: "DROS", create_time: "2025-09-29T08:38:17.353598Z", series: [ { series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", study_id: studyId, procedure_id: "P0-0002", patient_type: "Human", body_part: "Human_SKULL", performed_datetime: null, performed_protocol_code_meaning: "颅骨前后位 + 侧位", performed_protocol_code_value: "P0-0002", sort: 1, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.359308Z", images: [ { sop_instance_uid: "2.25.156.999999.0000.1.4.8323328.269954.1759135097.323786", series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", secondary_sop_uid: "", study_id: studyId, view_id: "View_DX_T_A_SK_AP_00", view_description: "颅骨前后位", patient_type: "Human", body_part_id: "Human_SKULL", anatomic_region: "Skull", image_type: "expose", image_file_path: "", image_file: "", thumbnail_file: "", acquisition_mode: "RAD", acquisition_context: null, img_proc_context: null, comment: "", expose_status: "Unexposed", expose_time: null, judged_status: "NotJudged", send_status: "Unsent", export_status: "NotExported", storage_status: "NotSaved", ticket: "", sort: 1, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.361002Z" }, { sop_instance_uid: "2.25.156.999999.0000.1.4.8323328.269954.1759135097.323787", series_instance_uid: "2.25.156.999999.0000.1.3.8323328.269954.1759135097.323785", study_instance_uid: "2.25.156.999999.0000.1.2.8323328.269954.1759135097.323784", secondary_sop_uid: "", study_id: studyId, view_id: "View_DX_T_A_SK_LAT_00", view_description: "颅骨左侧位", patient_type: "Human", body_part_id: "Human_SKULL", anatomic_region: "Skull", image_type: "expose", image_file_path: "", image_file: "", thumbnail_file: "", acquisition_mode: "RAD", acquisition_context: null, img_proc_context: null, comment: "", expose_status: "Unexposed", expose_time: null, judged_status: "NotJudged", send_status: "Unsent", export_status: "NotExported", storage_status: "NotSaved", ticket: "", sort: 2, product: "DROS", is_pre_install: true, create_time: "2025-09-29T08:38:17.362195Z" } ] } ] } } }).as('getStudyDetails'); } /** * 获取检查信息状态 - 成功场景 * * @description 获取检查的统计信息(总数、已曝光数) * @method GET * @url /dr/api/v1/auth/study/{id}/stat * @access 需要认证 * * @param {string} id - 检查ID(study_id),路径参数 * * @returns {Object} data - 统计信息 * @returns {number} data.total - 总体位数 * @returns {number} data.exposed - 已曝光数 * * @example * mockGetStudyStatSuccess(); * cy.wait('@getStudyStatSuccess'); * * @see docs/DR.md - 章节17 */ export function mockGetStudyStatSuccess() { cy.intercept('GET', '/dr/api/v1/auth/study/*/stat', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.study.Stat", total: 3, exposed: 1 } } }).as('getStudyStatSuccess'); } /** * 变更登记信息 - 成功场景 * * @description 更新已登记的检查信息 * @method PUT * @url /dr/api/v1/auth/study/{id} * @access 需要认证 * * @param {string} id - 检查ID(study_id),路径参数 * @param {Object} requestBody - 更新的患者信息 * * @returns {Object} data - 更新后的检查信息 * * @example * mockUpdateStudySuccess(); * cy.wait('@updateStudySuccess'); * * @see docs/DR.md - 章节14 */ export function mockUpdateStudySuccess() { cy.intercept('PUT', '/dr/api/v1/auth/study/*', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { study_id: "20250625140057649", patient_name: "Updated Patient", study_status: "Arrived" } } }).as('updateStudySuccess'); } /** * 删除检查信息(批量)- 成功场景 * * @description 批量删除检查信息 * @method DELETE * @url /dr/api/v1/auth/study * @access 需要认证 * * @param {string[]} requestBody - 检查ID列表 * * @returns {Object} 成功响应 * * @example * mockDeleteStudyBatchSuccess(); * cy.wait('@deleteStudyBatchSuccess'); * * @see docs/DR.md - 章节18 */ export function mockDeleteStudyBatchSuccess() { cy.intercept('DELETE', '/dr/api/v1/auth/study', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: {} } }).as('deleteStudyBatchSuccess'); } /** * 存储急诊患者影像 - 成功场景 * * @description 存储拍摄的急诊患者影像 * @method POST * @url /api/v1/auth/study/portrait * @access 需要认证 * * @param {Object} formData - 表单数据 * @param {string} formData.instance_uid - study实例UID * @param {File} formData.data - PNG图片文件 * * @returns {Object} data - DCM文件路径 * @returns {string} data.path - 文件路径 * * @example * mockStorePortraitSuccess(); * cy.wait('@storePortraitSuccess'); * * @see docs/DR.md - 章节19 */ export function mockStorePortraitSuccess() { cy.intercept('POST', '/api/v1/auth/study/portrait', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.task.DcmPath", path: "1.2.276.0.1000000.5.1.5.701601461.33458.1750830395.482043.dcm" } } }).as('storePortraitSuccess'); } /** * 挂起检查 - 成功场景 * * @description 挂起当前检查(状态设为InProgress) * @method POST * @url /api/v1/auth/task/inspection/leave * @access 需要认证 * * @param {Object} requestBody - 请求体 * @param {string} requestBody.study_id - 检查ID * @param {string} requestBody.study_status - 检查状态(InProgress) * * @returns {Object} 成功响应 * * @example * mockLeaveStudyInProgress(); * cy.wait('@leaveStudyInProgress'); * * @see docs/DR.md - 章节35 */ export function mockLeaveStudyInProgress() { cy.intercept('POST', '/api/v1/auth/task/inspection/leave', (req) => { if (req.body.study_status === 'InProgress') { req.reply({ statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: {} } }); } }).as('leaveStudyInProgress'); } /** * 完成检查 - 成功场景 * * @description 完成当前检查(状态设为Completed) * @method POST * @url /api/v1/auth/task/inspection/leave * @access 需要认证 * * @param {Object} requestBody - 请求体 * @param {string} requestBody.study_id - 检查ID * @param {string} requestBody.study_status - 检查状态(Completed) * * @returns {Object} 成功响应 * * @example * mockLeaveStudyCompleted(); * cy.wait('@leaveStudyCompleted'); * * @see docs/DR.md - 章节35 */ export function mockLeaveStudyCompleted() { cy.intercept('POST', '/api/v1/auth/task/inspection/leave', (req) => { if (req.body.study_status === 'Completed') { req.reply({ statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: {} } }); } }).as('leaveStudyCompleted'); }