study.ts 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /**
  2. * Study Mock Handlers
  3. * 检查信息管理相关的 mock 处理器
  4. */
  5. /**
  6. * 登记检查信息 - 成功场景
  7. *
  8. * @description 登记新的检查信息
  9. * @method POST
  10. * @url /dr/api/v1/auth/study
  11. * @access 需要认证
  12. *
  13. * @param {Object} requestBody - 请求体(包含患者信息、体位列表等)
  14. *
  15. * @returns {Object} data - 新创建的检查信息
  16. * @returns {string} data.study_id - 检查ID
  17. * @returns {Object[]} data.series - 序列列表
  18. *
  19. * @example
  20. * mockRegisterStudySuccess();
  21. * cy.wait('@registerStudySuccess');
  22. *
  23. * @see docs/DR.md - 章节13
  24. */
  25. export function mockRegisterStudySuccess() {
  26. cy.intercept('POST', '/dr/api/v1/auth/study', {
  27. statusCode: 200,
  28. body: {
  29. code: "0x000000",
  30. description: "Success",
  31. solution: "",
  32. data: {
  33. "@type": "type.googleapis.com/dr.study.Study",
  34. study_instance_uid: "1.2.276.0.1000000.5.1.2.701601461.33458.1750833219.482097",
  35. study_id: "20250625143339389",
  36. patient_name: "Test Patient",
  37. patient_id: "PET007",
  38. study_status: "Arrived",
  39. series: []
  40. }
  41. }
  42. }).as('registerStudySuccess');
  43. }
  44. /**
  45. * 获取检查信息 - Arrived状态
  46. *
  47. * @description 根据study_id获取检查详细信息(已到达状态)
  48. * @method GET
  49. * @url /dr/api/v1/auth/study/{id}
  50. * @access 需要认证
  51. *
  52. * @param {string} id - 检查ID(study_id),路径参数
  53. *
  54. * @returns {Object} data - 检查详细信息
  55. * @returns {string} data.study_status - 检查状态(Arrived/InProgress/Completed)
  56. *
  57. * @example
  58. * mockGetStudyArrived();
  59. * cy.wait('@getStudyArrived');
  60. *
  61. * @see docs/DR.md - 章节16
  62. */
  63. export function mockGetStudyArrived() {
  64. cy.intercept('GET', '/dr/api/v1/auth/study/*', {
  65. statusCode: 200,
  66. body: {
  67. code: "0x000000",
  68. description: "Success",
  69. solution: "",
  70. data: {
  71. study_id: "250929163817805",
  72. patient_name: "Test Patient",
  73. study_status: "Arrived",
  74. series: []
  75. }
  76. }
  77. }).as('getStudyArrived');
  78. }
  79. /**
  80. * 获取检查信息状态 - 成功场景
  81. *
  82. * @description 获取检查的统计信息(总数、已曝光数)
  83. * @method GET
  84. * @url /dr/api/v1/auth/study/{id}/stat
  85. * @access 需要认证
  86. *
  87. * @param {string} id - 检查ID(study_id),路径参数
  88. *
  89. * @returns {Object} data - 统计信息
  90. * @returns {number} data.total - 总体位数
  91. * @returns {number} data.exposed - 已曝光数
  92. *
  93. * @example
  94. * mockGetStudyStatSuccess();
  95. * cy.wait('@getStudyStatSuccess');
  96. *
  97. * @see docs/DR.md - 章节17
  98. */
  99. export function mockGetStudyStatSuccess() {
  100. cy.intercept('GET', '/dr/api/v1/auth/study/*/stat', {
  101. statusCode: 200,
  102. body: {
  103. code: "0x000000",
  104. description: "Success",
  105. solution: "",
  106. data: {
  107. "@type": "type.googleapis.com/dr.study.Stat",
  108. total: 3,
  109. exposed: 1
  110. }
  111. }
  112. }).as('getStudyStatSuccess');
  113. }
  114. /**
  115. * 变更登记信息 - 成功场景
  116. *
  117. * @description 更新已登记的检查信息
  118. * @method PUT
  119. * @url /dr/api/v1/auth/study/{id}
  120. * @access 需要认证
  121. *
  122. * @param {string} id - 检查ID(study_id),路径参数
  123. * @param {Object} requestBody - 更新的患者信息
  124. *
  125. * @returns {Object} data - 更新后的检查信息
  126. *
  127. * @example
  128. * mockUpdateStudySuccess();
  129. * cy.wait('@updateStudySuccess');
  130. *
  131. * @see docs/DR.md - 章节14
  132. */
  133. export function mockUpdateStudySuccess() {
  134. cy.intercept('PUT', '/dr/api/v1/auth/study/*', {
  135. statusCode: 200,
  136. body: {
  137. code: "0x000000",
  138. description: "Success",
  139. solution: "",
  140. data: {
  141. study_id: "20250625140057649",
  142. patient_name: "Updated Patient",
  143. study_status: "Arrived"
  144. }
  145. }
  146. }).as('updateStudySuccess');
  147. }
  148. /**
  149. * 删除检查信息(批量)- 成功场景
  150. *
  151. * @description 批量删除检查信息
  152. * @method DELETE
  153. * @url /dr/api/v1/auth/study
  154. * @access 需要认证
  155. *
  156. * @param {string[]} requestBody - 检查ID列表
  157. *
  158. * @returns {Object} 成功响应
  159. *
  160. * @example
  161. * mockDeleteStudyBatchSuccess();
  162. * cy.wait('@deleteStudyBatchSuccess');
  163. *
  164. * @see docs/DR.md - 章节18
  165. */
  166. export function mockDeleteStudyBatchSuccess() {
  167. cy.intercept('DELETE', '/dr/api/v1/auth/study', {
  168. statusCode: 200,
  169. body: {
  170. code: "0x000000",
  171. description: "Success",
  172. solution: "",
  173. data: {}
  174. }
  175. }).as('deleteStudyBatchSuccess');
  176. }
  177. /**
  178. * 存储急诊患者影像 - 成功场景
  179. *
  180. * @description 存储拍摄的急诊患者影像
  181. * @method POST
  182. * @url /api/v1/auth/study/portrait
  183. * @access 需要认证
  184. *
  185. * @param {Object} formData - 表单数据
  186. * @param {string} formData.instance_uid - study实例UID
  187. * @param {File} formData.data - PNG图片文件
  188. *
  189. * @returns {Object} data - DCM文件路径
  190. * @returns {string} data.path - 文件路径
  191. *
  192. * @example
  193. * mockStorePortraitSuccess();
  194. * cy.wait('@storePortraitSuccess');
  195. *
  196. * @see docs/DR.md - 章节19
  197. */
  198. export function mockStorePortraitSuccess() {
  199. cy.intercept('POST', '/api/v1/auth/study/portrait', {
  200. statusCode: 200,
  201. body: {
  202. code: "0x000000",
  203. description: "Success",
  204. solution: "",
  205. data: {
  206. "@type": "type.googleapis.com/dr.task.DcmPath",
  207. path: "1.2.276.0.1000000.5.1.5.701601461.33458.1750830395.482043.dcm"
  208. }
  209. }
  210. }).as('storePortraitSuccess');
  211. }
  212. /**
  213. * 挂起检查 - 成功场景
  214. *
  215. * @description 挂起当前检查(状态设为InProgress)
  216. * @method POST
  217. * @url /api/v1/auth/task/inspection/leave
  218. * @access 需要认证
  219. *
  220. * @param {Object} requestBody - 请求体
  221. * @param {string} requestBody.study_id - 检查ID
  222. * @param {string} requestBody.study_status - 检查状态(InProgress)
  223. *
  224. * @returns {Object} 成功响应
  225. *
  226. * @example
  227. * mockLeaveStudyInProgress();
  228. * cy.wait('@leaveStudyInProgress');
  229. *
  230. * @see docs/DR.md - 章节35
  231. */
  232. export function mockLeaveStudyInProgress() {
  233. cy.intercept('POST', '/api/v1/auth/task/inspection/leave', (req) => {
  234. if (req.body.study_status === 'InProgress') {
  235. req.reply({
  236. statusCode: 200,
  237. body: {
  238. code: "0x000000",
  239. description: "Success",
  240. solution: "",
  241. data: {}
  242. }
  243. });
  244. }
  245. }).as('leaveStudyInProgress');
  246. }
  247. /**
  248. * 完成检查 - 成功场景
  249. *
  250. * @description 完成当前检查(状态设为Completed)
  251. * @method POST
  252. * @url /api/v1/auth/task/inspection/leave
  253. * @access 需要认证
  254. *
  255. * @param {Object} requestBody - 请求体
  256. * @param {string} requestBody.study_id - 检查ID
  257. * @param {string} requestBody.study_status - 检查状态(Completed)
  258. *
  259. * @returns {Object} 成功响应
  260. *
  261. * @example
  262. * mockLeaveStudyCompleted();
  263. * cy.wait('@leaveStudyCompleted');
  264. *
  265. * @see docs/DR.md - 章节35
  266. */
  267. export function mockLeaveStudyCompleted() {
  268. cy.intercept('POST', '/api/v1/auth/task/inspection/leave', (req) => {
  269. if (req.body.study_status === 'Completed') {
  270. req.reply({
  271. statusCode: 200,
  272. body: {
  273. code: "0x000000",
  274. description: "Success",
  275. solution: "",
  276. data: {}
  277. }
  278. });
  279. }
  280. }).as('leaveStudyCompleted');
  281. }