dateRangeQuery.ts 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. /**
  2. * Mock handlers for date range query testing
  3. * 用于测试按日期范围查询 study 的功能
  4. */
  5. import dayjs from 'dayjs';
  6. // ============ Aliases ============
  7. const aliasOfFetchTodayStudies = 'fetchTodayStudies';
  8. export const FetchTodayStudies = `@${aliasOfFetchTodayStudies}`;
  9. const aliasOfFetch7DaysStudies = 'fetch7DaysStudies';
  10. export const Fetch7DaysStudies = `@${aliasOfFetch7DaysStudies}`;
  11. const aliasOfFetchAllStudies = 'fetchAllStudies';
  12. export const FetchAllStudies = `@${aliasOfFetchAllStudies}`;
  13. const aliasOfFetchCustomRangeStudies = 'fetchCustomRangeStudies';
  14. export const FetchCustomRangeStudies = `@${aliasOfFetchCustomRangeStudies}`;
  15. const aliasOfFetchEmptyResult = 'fetchEmptyResult';
  16. export const FetchEmptyResult = `@${aliasOfFetchEmptyResult}`;
  17. const aliasOfFetchCombinedQuery = 'fetchCombinedQuery';
  18. export const FetchCombinedQuery = `@${aliasOfFetchCombinedQuery}`;
  19. // ============ Mock Functions ============
  20. /**
  21. * Mock: 查询今天的 study(Worklist)
  22. */
  23. export function mockFetchTodayStudiesWorklist() {
  24. const today = dayjs().format('YYYY-MM-DD');
  25. cy.intercept('GET', '/dr/api/v1/auth/study*', (req) => {
  26. const url = new URL(req.url);
  27. const status = url.searchParams.get('status');
  28. const startTime = url.searchParams.get('start_time');
  29. // 只匹配包含今天日期范围的请求
  30. if (status === 'Arrived,InProgress' && startTime?.includes(today)) {
  31. req.reply({
  32. statusCode: 200,
  33. body: {
  34. code: '0x000000',
  35. description: 'Success',
  36. solution: '',
  37. data: {
  38. '@type': 'type.googleapis.com/dr.study.StudyList',
  39. count: 2,
  40. studies: [
  41. {
  42. study_instance_uid: '2.25.TODAY.001',
  43. study_id: 'TODAY001',
  44. public_study_id: '',
  45. specific_character_set: 'ISO_IR 192',
  46. accession_number: 'ACC_TODAY_001',
  47. ref_physician: 'Dr. Wang',
  48. patient_id: 'PT_TODAY_001',
  49. patient_name: '今天患者1',
  50. patient_english_name: 'Today Patient 1',
  51. patient_former_name: '',
  52. patient_size: 'Medium',
  53. other_patient_ids: '',
  54. other_patient_names: '',
  55. patient_age: '35Y',
  56. patient_dob: '1990-01-01T00:00:00Z',
  57. patient_sex: 'M',
  58. sex_neutered: '',
  59. pregnancy_status: '',
  60. patient_state: '',
  61. admitting_time: null,
  62. priority: '',
  63. reg_source: '',
  64. study_description: '',
  65. study_start_datetime: `${today}T08:00:00Z`,
  66. study_end_datetime: null,
  67. scheduled_procedure_step_start_date: null,
  68. performed_physician: '',
  69. study_lock: 'Unlocked',
  70. folder_path: '',
  71. operator_name: 'OP001',
  72. modality: 'DX',
  73. weight: 70,
  74. thickness: 20,
  75. length: 175,
  76. patient_type: 'Human',
  77. study_type: 'Normal',
  78. owner_name: '',
  79. chip_number: '',
  80. variety: '',
  81. is_anaesthesia: false,
  82. is_sedation: false,
  83. mwl: '',
  84. is_exported: false,
  85. is_edited: false,
  86. is_appended: false,
  87. department: '',
  88. mapped_status: false,
  89. qc_result: false,
  90. comment: '今天的检查1',
  91. study_status: 'Arrived',
  92. sort: 0,
  93. product: 'DROS',
  94. series: [],
  95. },
  96. {
  97. study_instance_uid: '2.25.TODAY.002',
  98. study_id: 'TODAY002',
  99. public_study_id: '',
  100. specific_character_set: 'ISO_IR 192',
  101. accession_number: 'ACC_TODAY_002',
  102. ref_physician: 'Dr. Wang',
  103. patient_id: 'PT_TODAY_002',
  104. patient_name: '今天患者2',
  105. patient_english_name: 'Today Patient 2',
  106. patient_former_name: '',
  107. patient_size: 'Medium',
  108. other_patient_ids: '',
  109. other_patient_names: '',
  110. patient_age: '40Y',
  111. patient_dob: '1985-01-01T00:00:00Z',
  112. patient_sex: 'F',
  113. sex_neutered: '',
  114. pregnancy_status: '',
  115. patient_state: '',
  116. admitting_time: null,
  117. priority: '',
  118. reg_source: '',
  119. study_description: '',
  120. study_start_datetime: `${today}T10:00:00Z`,
  121. study_end_datetime: null,
  122. scheduled_procedure_step_start_date: null,
  123. performed_physician: '',
  124. study_lock: 'Unlocked',
  125. folder_path: '',
  126. operator_name: 'OP002',
  127. modality: 'DX',
  128. weight: 65,
  129. thickness: 18,
  130. length: 165,
  131. patient_type: 'Human',
  132. study_type: 'Normal',
  133. owner_name: '',
  134. chip_number: '',
  135. variety: '',
  136. is_anaesthesia: false,
  137. is_sedation: false,
  138. mwl: '',
  139. is_exported: false,
  140. is_edited: false,
  141. is_appended: false,
  142. department: '',
  143. mapped_status: false,
  144. qc_result: false,
  145. comment: '今天的检查2',
  146. study_status: 'InProgress',
  147. sort: 0,
  148. product: 'DROS',
  149. series: [],
  150. },
  151. ],
  152. },
  153. },
  154. });
  155. }
  156. }).as(aliasOfFetchTodayStudies);
  157. }
  158. /**
  159. * Mock: 查询最近7天的 study(Worklist)
  160. */
  161. export function mockFetch7DaysStudiesWorklist() {
  162. const today = dayjs();
  163. const sevenDaysAgo = today.subtract(7, 'day');
  164. cy.intercept('GET', '/dr/api/v1/auth/study*', (req) => {
  165. const url = new URL(req.url);
  166. const status = url.searchParams.get('status');
  167. const startTime = url.searchParams.get('start_time');
  168. // 只匹配包含7天前日期的请求
  169. if (
  170. status === 'Arrived,InProgress' &&
  171. startTime?.includes(sevenDaysAgo.format('YYYY-MM-DD'))
  172. ) {
  173. req.reply({
  174. statusCode: 200,
  175. body: {
  176. code: '0x000000',
  177. description: 'Success',
  178. solution: '',
  179. data: {
  180. '@type': 'type.googleapis.com/dr.study.StudyList',
  181. count: 5,
  182. studies: [
  183. // 今天
  184. {
  185. study_instance_uid: '2.25.7DAYS.001',
  186. study_id: '7DAYS001',
  187. patient_name: '7天患者1',
  188. patient_id: 'PT_7D_001',
  189. accession_number: 'ACC_7D_001',
  190. study_start_datetime: today.format('YYYY-MM-DD') + 'T08:00:00Z',
  191. study_status: 'Arrived',
  192. patient_type: 'Human',
  193. modality: 'DX',
  194. study_lock: 'Unlocked',
  195. product: 'DROS',
  196. series: [],
  197. },
  198. // 3天前
  199. {
  200. study_instance_uid: '2.25.7DAYS.002',
  201. study_id: '7DAYS002',
  202. patient_name: '7天患者2',
  203. patient_id: 'PT_7D_002',
  204. accession_number: 'ACC_7D_002',
  205. study_start_datetime:
  206. today.subtract(3, 'day').format('YYYY-MM-DD') + 'T10:00:00Z',
  207. study_status: 'InProgress',
  208. patient_type: 'Human',
  209. modality: 'DX',
  210. study_lock: 'Unlocked',
  211. product: 'DROS',
  212. series: [],
  213. },
  214. // 5天前
  215. {
  216. study_instance_uid: '2.25.7DAYS.003',
  217. study_id: '7DAYS003',
  218. patient_name: '7天患者3',
  219. patient_id: 'PT_7D_003',
  220. accession_number: 'ACC_7D_003',
  221. study_start_datetime:
  222. today.subtract(5, 'day').format('YYYY-MM-DD') + 'T14:00:00Z',
  223. study_status: 'Arrived',
  224. patient_type: 'Human',
  225. modality: 'DX',
  226. study_lock: 'Unlocked',
  227. product: 'DROS',
  228. series: [],
  229. },
  230. // 6天前
  231. {
  232. study_instance_uid: '2.25.7DAYS.004',
  233. study_id: '7DAYS004',
  234. patient_name: '7天患者4',
  235. patient_id: 'PT_7D_004',
  236. accession_number: 'ACC_7D_004',
  237. study_start_datetime:
  238. today.subtract(6, 'day').format('YYYY-MM-DD') + 'T09:00:00Z',
  239. study_status: 'InProgress',
  240. patient_type: 'Human',
  241. modality: 'DX',
  242. study_lock: 'Unlocked',
  243. product: 'DROS',
  244. series: [],
  245. },
  246. // 7天前
  247. {
  248. study_instance_uid: '2.25.7DAYS.005',
  249. study_id: '7DAYS005',
  250. patient_name: '7天患者5',
  251. patient_id: 'PT_7D_005',
  252. accession_number: 'ACC_7D_005',
  253. study_start_datetime:
  254. today.subtract(7, 'day').format('YYYY-MM-DD') + 'T11:00:00Z',
  255. study_status: 'Arrived',
  256. patient_type: 'Human',
  257. modality: 'DX',
  258. study_lock: 'Unlocked',
  259. product: 'DROS',
  260. series: [],
  261. },
  262. ].map((study) => ({
  263. ...study,
  264. specific_character_set: 'ISO_IR 192',
  265. ref_physician: 'Dr. Li',
  266. patient_english_name: study.patient_name + ' EN',
  267. patient_former_name: '',
  268. patient_size: 'Medium',
  269. other_patient_ids: '',
  270. other_patient_names: '',
  271. patient_age: '35Y',
  272. patient_dob: '1990-01-01T00:00:00Z',
  273. patient_sex: 'M',
  274. sex_neutered: '',
  275. pregnancy_status: '',
  276. patient_state: '',
  277. admitting_time: null,
  278. priority: '',
  279. reg_source: '',
  280. study_description: '',
  281. study_end_datetime: null,
  282. scheduled_procedure_step_start_date: null,
  283. performed_physician: '',
  284. folder_path: '',
  285. operator_name: 'OP001',
  286. weight: 70,
  287. thickness: 20,
  288. length: 175,
  289. study_type: 'Normal',
  290. owner_name: '',
  291. chip_number: '',
  292. variety: '',
  293. is_anaesthesia: false,
  294. is_sedation: false,
  295. mwl: '',
  296. is_exported: false,
  297. is_edited: false,
  298. is_appended: false,
  299. department: '',
  300. mapped_status: false,
  301. qc_result: false,
  302. comment: '',
  303. sort: 0,
  304. public_study_id: '',
  305. })),
  306. },
  307. },
  308. });
  309. }
  310. }).as(aliasOfFetch7DaysStudies);
  311. }
  312. /**
  313. * Mock: 查询所有 study(不限日期)
  314. */
  315. export function mockFetchAllStudiesWorklist() {
  316. cy.intercept('GET', '/dr/api/v1/auth/study*', (req) => {
  317. const url = new URL(req.url);
  318. const status = url.searchParams.get('status');
  319. const startTime = url.searchParams.get('start_time');
  320. const endTime = url.searchParams.get('end_time');
  321. // 匹配不包含日期范围参数的请求
  322. if (status === 'Arrived,InProgress' && !startTime && !endTime) {
  323. req.reply({
  324. statusCode: 200,
  325. body: {
  326. code: '0x000000',
  327. description: 'Success',
  328. solution: '',
  329. data: {
  330. '@type': 'type.googleapis.com/dr.study.StudyList',
  331. count: 10,
  332. studies: Array.from({ length: 10 }, (_, index) => ({
  333. study_instance_uid: `2.25.ALL.${String(index + 1).padStart(3, '0')}`,
  334. study_id: `ALL${String(index + 1).padStart(3, '0')}`,
  335. public_study_id: '',
  336. specific_character_set: 'ISO_IR 192',
  337. accession_number: `ACC_ALL_${String(index + 1).padStart(3, '0')}`,
  338. ref_physician: 'Dr. Zhang',
  339. patient_id: `PT_ALL_${String(index + 1).padStart(3, '0')}`,
  340. patient_name: `所有患者${index + 1}`,
  341. patient_english_name: `All Patient ${index + 1}`,
  342. patient_former_name: '',
  343. patient_size: 'Medium',
  344. other_patient_ids: '',
  345. other_patient_names: '',
  346. patient_age: '35Y',
  347. patient_dob: '1990-01-01T00:00:00Z',
  348. patient_sex: index % 2 === 0 ? 'M' : 'F',
  349. sex_neutered: '',
  350. pregnancy_status: '',
  351. patient_state: '',
  352. admitting_time: null,
  353. priority: '',
  354. reg_source: '',
  355. study_description: '',
  356. study_start_datetime: dayjs()
  357. .subtract(index * 2, 'day')
  358. .format('YYYY-MM-DD') + 'T10:00:00Z',
  359. study_end_datetime: null,
  360. scheduled_procedure_step_start_date: null,
  361. performed_physician: '',
  362. study_lock: 'Unlocked',
  363. folder_path: '',
  364. operator_name: 'OP001',
  365. modality: 'DX',
  366. weight: 70,
  367. thickness: 20,
  368. length: 175,
  369. patient_type: 'Human',
  370. study_type: 'Normal',
  371. owner_name: '',
  372. chip_number: '',
  373. variety: '',
  374. is_anaesthesia: false,
  375. is_sedation: false,
  376. mwl: '',
  377. is_exported: false,
  378. is_edited: false,
  379. is_appended: false,
  380. department: '',
  381. mapped_status: false,
  382. qc_result: false,
  383. comment: `检查记录${index + 1}`,
  384. study_status: index % 2 === 0 ? 'Arrived' : 'InProgress',
  385. sort: 0,
  386. product: 'DROS',
  387. series: [],
  388. })),
  389. },
  390. },
  391. });
  392. }
  393. }).as(aliasOfFetchAllStudies);
  394. }
  395. /**
  396. * Mock: 自定义日期范围查询
  397. */
  398. export function mockFetchCustomRangeStudies(startDate: string, endDate: string) {
  399. cy.intercept('GET', '/dr/api/v1/auth/study*', (req) => {
  400. const url = new URL(req.url);
  401. const status = url.searchParams.get('status');
  402. const startTime = url.searchParams.get('start_time');
  403. // 匹配包含指定日期范围的请求
  404. if (status && startTime?.includes(startDate)) {
  405. req.reply({
  406. statusCode: 200,
  407. body: {
  408. code: '0x000000',
  409. description: 'Success',
  410. solution: '',
  411. data: {
  412. '@type': 'type.googleapis.com/dr.study.StudyList',
  413. count: 3,
  414. studies: [
  415. {
  416. study_instance_uid: '2.25.CUSTOM.001',
  417. study_id: 'CUSTOM001',
  418. patient_name: '自定义范围患者1',
  419. patient_id: 'PT_CUSTOM_001',
  420. accession_number: 'ACC_CUSTOM_001',
  421. study_start_datetime: startDate + 'T08:00:00Z',
  422. study_status: 'Arrived',
  423. patient_type: 'Human',
  424. modality: 'DX',
  425. study_lock: 'Unlocked',
  426. product: 'DROS',
  427. series: [],
  428. },
  429. {
  430. study_instance_uid: '2.25.CUSTOM.002',
  431. study_id: 'CUSTOM002',
  432. patient_name: '自定义范围患者2',
  433. patient_id: 'PT_CUSTOM_002',
  434. accession_number: 'ACC_CUSTOM_002',
  435. study_start_datetime:
  436. dayjs(startDate).add(2, 'day').format('YYYY-MM-DD') + 'T10:00:00Z',
  437. study_status: 'InProgress',
  438. patient_type: 'Human',
  439. modality: 'DX',
  440. study_lock: 'Unlocked',
  441. product: 'DROS',
  442. series: [],
  443. },
  444. {
  445. study_instance_uid: '2.25.CUSTOM.003',
  446. study_id: 'CUSTOM003',
  447. patient_name: '自定义范围患者3',
  448. patient_id: 'PT_CUSTOM_003',
  449. accession_number: 'ACC_CUSTOM_003',
  450. study_start_datetime:
  451. dayjs(startDate).add(5, 'day').format('YYYY-MM-DD') + 'T14:00:00Z',
  452. study_status: 'Arrived',
  453. patient_type: 'Human',
  454. modality: 'DX',
  455. study_lock: 'Unlocked',
  456. product: 'DROS',
  457. series: [],
  458. },
  459. ].map((study) => ({
  460. ...study,
  461. specific_character_set: 'ISO_IR 192',
  462. ref_physician: 'Dr. Custom',
  463. patient_english_name: study.patient_name + ' EN',
  464. patient_former_name: '',
  465. patient_size: 'Medium',
  466. other_patient_ids: '',
  467. other_patient_names: '',
  468. patient_age: '35Y',
  469. patient_dob: '1990-01-01T00:00:00Z',
  470. patient_sex: 'M',
  471. sex_neutered: '',
  472. pregnancy_status: '',
  473. patient_state: '',
  474. admitting_time: null,
  475. priority: '',
  476. reg_source: '',
  477. study_description: '',
  478. study_end_datetime: null,
  479. scheduled_procedure_step_start_date: null,
  480. performed_physician: '',
  481. folder_path: '',
  482. operator_name: 'OP001',
  483. weight: 70,
  484. thickness: 20,
  485. length: 175,
  486. study_type: 'Normal',
  487. owner_name: '',
  488. chip_number: '',
  489. variety: '',
  490. is_anaesthesia: false,
  491. is_sedation: false,
  492. mwl: '',
  493. is_exported: false,
  494. is_edited: false,
  495. is_appended: false,
  496. department: '',
  497. mapped_status: false,
  498. qc_result: false,
  499. comment: '',
  500. sort: 0,
  501. public_study_id: '',
  502. })),
  503. },
  504. },
  505. });
  506. }
  507. }).as(aliasOfFetchCustomRangeStudies);
  508. }
  509. /**
  510. * Mock: 空结果(无数据)
  511. */
  512. export function mockFetchEmptyResult() {
  513. cy.intercept('GET', '/dr/api/v1/auth/study*', {
  514. statusCode: 200,
  515. body: {
  516. code: '0x000000',
  517. description: 'Success',
  518. solution: '',
  519. data: {
  520. '@type': 'type.googleapis.com/dr.study.StudyList',
  521. count: 0,
  522. studies: [],
  523. },
  524. },
  525. }).as(aliasOfFetchEmptyResult);
  526. }
  527. /**
  528. * Mock: 组合查询(日期范围 + 患者名称)
  529. */
  530. export function mockFetchCombinedQuery() {
  531. const today = dayjs().format('YYYY-MM-DD');
  532. cy.intercept('GET', '/dr/api/v1/auth/study*', (req) => {
  533. const url = new URL(req.url);
  534. const status = url.searchParams.get('status');
  535. const startTime = url.searchParams.get('start_time');
  536. const patientName = url.searchParams.get('patient_name');
  537. // 匹配包含日期范围和患者名称的请求
  538. if (status && startTime?.includes(today) && patientName) {
  539. req.reply({
  540. statusCode: 200,
  541. body: {
  542. code: '0x000000',
  543. description: 'Success',
  544. solution: '',
  545. data: {
  546. '@type': 'type.googleapis.com/dr.study.StudyList',
  547. count: 1,
  548. studies: [
  549. {
  550. study_instance_uid: '2.25.COMBINED.001',
  551. study_id: 'COMBINED001',
  552. public_study_id: '',
  553. specific_character_set: 'ISO_IR 192',
  554. accession_number: 'ACC_COMBINED_001',
  555. ref_physician: 'Dr. Combined',
  556. patient_id: 'PT_COMBINED_001',
  557. patient_name: patientName,
  558. patient_english_name: patientName + ' EN',
  559. patient_former_name: '',
  560. patient_size: 'Medium',
  561. other_patient_ids: '',
  562. other_patient_names: '',
  563. patient_age: '35Y',
  564. patient_dob: '1990-01-01T00:00:00Z',
  565. patient_sex: 'M',
  566. sex_neutered: '',
  567. pregnancy_status: '',
  568. patient_state: '',
  569. admitting_time: null,
  570. priority: '',
  571. reg_source: '',
  572. study_description: '',
  573. study_start_datetime: today + 'T09:00:00Z',
  574. study_end_datetime: null,
  575. scheduled_procedure_step_start_date: null,
  576. performed_physician: '',
  577. study_lock: 'Unlocked',
  578. folder_path: '',
  579. operator_name: 'OP001',
  580. modality: 'DX',
  581. weight: 70,
  582. thickness: 20,
  583. length: 175,
  584. patient_type: 'Human',
  585. study_type: 'Normal',
  586. owner_name: '',
  587. chip_number: '',
  588. variety: '',
  589. is_anaesthesia: false,
  590. is_sedation: false,
  591. mwl: '',
  592. is_exported: false,
  593. is_edited: false,
  594. is_appended: false,
  595. department: '',
  596. mapped_status: false,
  597. qc_result: false,
  598. comment: '组合查询结果',
  599. study_status: 'Arrived',
  600. sort: 0,
  601. product: 'DROS',
  602. series: [],
  603. },
  604. ],
  605. },
  606. },
  607. });
  608. }
  609. }).as(aliasOfFetchCombinedQuery);
  610. }
  611. // ============ History Mock Functions ============
  612. /**
  613. * Mock: 查询今天的 study(History - Completed)
  614. */
  615. export function mockFetchTodayStudiesHistory() {
  616. const today = dayjs().format('YYYY-MM-DD');
  617. cy.intercept('GET', '/dr/api/v1/auth/study*', (req) => {
  618. const url = new URL(req.url);
  619. const status = url.searchParams.get('status');
  620. const startTime = url.searchParams.get('start_time');
  621. if (status === 'Completed' && startTime?.includes(today)) {
  622. req.reply({
  623. statusCode: 200,
  624. body: {
  625. code: '0x000000',
  626. description: 'Success',
  627. solution: '',
  628. data: {
  629. '@type': 'type.googleapis.com/dr.study.StudyList',
  630. count: 2,
  631. studies: [
  632. {
  633. study_instance_uid: '2.25.HIST.TODAY.001',
  634. study_id: 'HIST_TODAY001',
  635. patient_name: 'History今天患者1',
  636. patient_id: 'PT_HIST_TODAY_001',
  637. accession_number: 'ACC_HIST_TODAY_001',
  638. study_start_datetime: today + 'T08:00:00Z',
  639. study_status: 'Completed',
  640. is_exported: true,
  641. patient_type: 'Human',
  642. modality: 'DX',
  643. study_lock: 'Unlocked',
  644. product: 'DROS',
  645. series: [],
  646. },
  647. {
  648. study_instance_uid: '2.25.HIST.TODAY.002',
  649. study_id: 'HIST_TODAY002',
  650. patient_name: 'History今天患者2',
  651. patient_id: 'PT_HIST_TODAY_002',
  652. accession_number: 'ACC_HIST_TODAY_002',
  653. study_start_datetime: today + 'T10:00:00Z',
  654. study_status: 'Completed',
  655. is_exported: true,
  656. patient_type: 'Human',
  657. modality: 'DX',
  658. study_lock: 'Unlocked',
  659. product: 'DROS',
  660. series: [],
  661. },
  662. ].map((study) => ({
  663. ...study,
  664. specific_character_set: 'ISO_IR 192',
  665. ref_physician: 'Dr. History',
  666. patient_english_name: study.patient_name + ' EN',
  667. patient_former_name: '',
  668. patient_size: 'Medium',
  669. other_patient_ids: '',
  670. other_patient_names: '',
  671. patient_age: '35Y',
  672. patient_dob: '1990-01-01T00:00:00Z',
  673. patient_sex: 'M',
  674. sex_neutered: '',
  675. pregnancy_status: '',
  676. patient_state: '',
  677. admitting_time: null,
  678. priority: '',
  679. reg_source: '',
  680. study_description: '',
  681. study_end_datetime: null,
  682. scheduled_procedure_step_start_date: null,
  683. performed_physician: '',
  684. folder_path: '',
  685. operator_name: 'OP001',
  686. weight: 70,
  687. thickness: 20,
  688. length: 175,
  689. study_type: 'Normal',
  690. owner_name: '',
  691. chip_number: '',
  692. variety: '',
  693. is_anaesthesia: false,
  694. is_sedation: false,
  695. mwl: '',
  696. is_edited: false,
  697. is_appended: false,
  698. department: '',
  699. mapped_status: true,
  700. qc_result: true,
  701. comment: '',
  702. sort: 0,
  703. public_study_id: '',
  704. })),
  705. },
  706. },
  707. });
  708. }
  709. }).as(aliasOfFetchTodayStudies);
  710. }
  711. /**
  712. * Mock: 查询最近7天的 study(History - Completed)
  713. */
  714. export function mockFetch7DaysStudiesHistory() {
  715. const today = dayjs();
  716. const sevenDaysAgo = today.subtract(7, 'day');
  717. cy.intercept('GET', '/dr/api/v1/auth/study*', (req) => {
  718. const url = new URL(req.url);
  719. const status = url.searchParams.get('status');
  720. const startTime = url.searchParams.get('start_time');
  721. if (
  722. status === 'Completed' &&
  723. startTime?.includes(sevenDaysAgo.format('YYYY-MM-DD'))
  724. ) {
  725. req.reply({
  726. statusCode: 200,
  727. body: {
  728. code: '0x000000',
  729. description: 'Success',
  730. solution: '',
  731. data: {
  732. '@type': 'type.googleapis.com/dr.study.StudyList',
  733. count: 4,
  734. studies: Array.from({ length: 4 }, (_, index) => ({
  735. study_instance_uid: `2.25.HIST.7DAYS.${String(index + 1).padStart(3, '0')}`,
  736. study_id: `HIST_7DAYS${String(index + 1).padStart(3, '0')}`,
  737. public_study_id: '',
  738. specific_character_set: 'ISO_IR 192',
  739. accession_number: `ACC_HIST_7D_${String(index + 1).padStart(3, '0')}`,
  740. ref_physician: 'Dr. History7D',
  741. patient_id: `PT_HIST_7D_${String(index + 1).padStart(3, '0')}`,
  742. patient_name: `History7天患者${index + 1}`,
  743. patient_english_name: `History 7Days Patient ${index + 1}`,
  744. patient_former_name: '',
  745. patient_size: 'Medium',
  746. other_patient_ids: '',
  747. other_patient_names: '',
  748. patient_age: '35Y',
  749. patient_dob: '1990-01-01T00:00:00Z',
  750. patient_sex: 'M',
  751. sex_neutered: '',
  752. pregnancy_status: '',
  753. patient_state: '',
  754. admitting_time: null,
  755. priority: '',
  756. reg_source: '',
  757. study_description: '',
  758. study_start_datetime:
  759. today.subtract(index + 1, 'day').format('YYYY-MM-DD') + 'T10:00:00Z',
  760. study_end_datetime: null,
  761. scheduled_procedure_step_start_date: null,
  762. performed_physician: '',
  763. study_lock: 'Unlocked',
  764. folder_path: '',
  765. operator_name: 'OP001',
  766. modality: 'DX',
  767. weight: 70,
  768. thickness: 20,
  769. length: 175,
  770. study_type: 'Normal',
  771. owner_name: '',
  772. chip_number: '',
  773. variety: '',
  774. is_anaesthesia: false,
  775. is_sedation: false,
  776. mwl: '',
  777. is_exported: true,
  778. is_edited: false,
  779. is_appended: false,
  780. department: '',
  781. mapped_status: true,
  782. qc_result: true,
  783. comment: '',
  784. study_status: 'Completed',
  785. sort: 0,
  786. product: 'DROS',
  787. series: [],
  788. })),
  789. },
  790. },
  791. });
  792. }
  793. }).as(aliasOfFetch7DaysStudies);
  794. }
  795. /**
  796. * Mock: 查询所有 study(History - Completed)
  797. */
  798. export function mockFetchAllStudiesHistory() {
  799. cy.intercept('GET', '/dr/api/v1/auth/study*', (req) => {
  800. const url = new URL(req.url);
  801. const status = url.searchParams.get('status');
  802. const startTime = url.searchParams.get('start_time');
  803. const endTime = url.searchParams.get('end_time');
  804. // 匹配不包含日期范围参数的请求
  805. if (status === 'Completed' && !startTime && !endTime) {
  806. req.reply({
  807. statusCode: 200,
  808. body: {
  809. code: '0x000000',
  810. description: 'Success',
  811. solution: '',
  812. data: {
  813. '@type': 'type.googleapis.com/dr.study.StudyList',
  814. count: 8,
  815. studies: Array.from({ length: 8 }, (_, index) => ({
  816. study_instance_uid: `2.25.HIST.ALL.${String(index + 1).padStart(3, '0')}`,
  817. study_id: `HIST_ALL${String(index + 1).padStart(3, '0')}`,
  818. public_study_id: '',
  819. specific_character_set: 'ISO_IR 192',
  820. accession_number: `ACC_HIST_ALL_${String(index + 1).padStart(3, '0')}`,
  821. ref_physician: 'Dr. HistoryAll',
  822. patient_id: `PT_HIST_ALL_${String(index + 1).padStart(3, '0')}`,
  823. patient_name: `History所有患者${index + 1}`,
  824. patient_english_name: `History All Patient ${index + 1}`,
  825. patient_former_name: '',
  826. patient_size: 'Medium',
  827. other_patient_ids: '',
  828. other_patient_names: '',
  829. patient_age: '35Y',
  830. patient_dob: '1990-01-01T00:00:00Z',
  831. patient_sex: index % 2 === 0 ? 'M' : 'F',
  832. sex_neutered: '',
  833. pregnancy_status: '',
  834. patient_state: '',
  835. admitting_time: null,
  836. priority: '',
  837. reg_source: '',
  838. study_description: '',
  839. study_start_datetime:
  840. dayjs()
  841. .subtract(index * 3, 'day')
  842. .format('YYYY-MM-DD') + 'T10:00:00Z',
  843. study_end_datetime: null,
  844. scheduled_procedure_step_start_date: null,
  845. performed_physician: '',
  846. study_lock: 'Unlocked',
  847. folder_path: '',
  848. operator_name: 'OP001',
  849. modality: 'DX',
  850. weight: 70,
  851. thickness: 20,
  852. length: 175,
  853. patient_type: 'Human',
  854. study_type: 'Normal',
  855. owner_name: '',
  856. chip_number: '',
  857. variety: '',
  858. is_anaesthesia: false,
  859. is_sedation: false,
  860. mwl: '',
  861. is_exported: true,
  862. is_edited: false,
  863. is_appended: false,
  864. department: '',
  865. mapped_status: true,
  866. qc_result: true,
  867. comment: `History检查记录${index + 1}`,
  868. study_status: 'Completed',
  869. sort: 0,
  870. product: 'DROS',
  871. series: [],
  872. })),
  873. },
  874. },
  875. });
  876. }
  877. }).as(aliasOfFetchAllStudies);
  878. }