request.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import { Get, Post } from "../../lib/request/method";
  2. import { createHealthIndex, transformHealthIndex2Chart } from "./tools/health-index";
  3. import dayjs from "dayjs";
  4. export function healthPatientMethod() {
  5. return Post(`/patientInfoManage/getPatientInfoDetail`, {}, { transform({ data }) { return data } });
  6. }
  7. export function healthReportListMethod() {
  8. const transform = ({ data }: AnyObject) => {
  9. return Array.isArray(data) ? data.map(item => {
  10. return {
  11. id: item.healthAnalysisReportId,
  12. reportTime: item.time3,
  13. description: [item.willillStateName, item.willillDegreeName, item.willillSocialName, item.willillFunctionName].filter(Boolean).join(',')
  14. }
  15. }) : []
  16. }
  17. return Get(`/analysisManage/getHarsTid`, { transform })
  18. }
  19. export function healthReportMethod({ id, scene, ...query }: Record<'id' | 'scene', string | void>) {
  20. const transform = ({ data }: AnyObject) => {
  21. if (Array.isArray(data?.conditProgram?.types)) {
  22. data.conditProgram.types = data.conditProgram.types.map((item: AnyObject) => (item.summary = item.summary?.replace(/null/g, '') || '', item))
  23. }
  24. return data;
  25. };
  26. let params = { ...query } as any;
  27. if (id) { params.healthAnalysisReportId = id; }
  28. if (scene) {
  29. params.scene = decodeURIComponent(scene);
  30. return Get(`/analysisManage/getHealRepDetailByScene`, { params, transform });
  31. }
  32. return id
  33. ? Get(`/analysisManage/getHealRepDetailById`, { params, transform })
  34. : Post(`/analysisManage/getLastHealRepDetail`, {}, { params, transform })
  35. }
  36. /**
  37. * 获取指标信息
  38. * @param id 健康分析报告
  39. */
  40. export function healthIndexMethod(id?: string) {
  41. const transform = ({ data }: AnyObject) => Array.isArray(data) ? data.map(item => createHealthIndex(item)) : [];
  42. return id
  43. ? Get(`/analysisManage/getLast7Day`, { params: { healthAnalysisReportId: id }, transform })
  44. : Post(`/patientQuota/getCurQuoval`, {}, { transform })
  45. }
  46. export function healthSchemeMethod(id: string) {
  47. const transform = ({ data }: AnyObject) => {
  48. return {
  49. reportTime: dayjs(data?.time).format('YYYY年MM月DD日'),
  50. children: data?.types?.map((item: AnyObject, i: number) => {
  51. return {
  52. title: item?.type || '',
  53. children: item?.groups?.map((item: AnyObject, j: number) => {
  54. return {
  55. title: item?.name || '',
  56. descriptions: item?.attrs?.map((attr: AnyArray, k: number) => {
  57. return { ...attr, id: `description-${i}-${j}-${k}`, }
  58. }) ?? [],
  59. children: item?.items?.map((item: AnyObject, k: number) => {
  60. switch (item?.type) {
  61. case 'img':
  62. return {
  63. id: `${item?.type}-${i}-${j}-${k}`,
  64. type: item.imgUrl ? 'image' : null,
  65. poster: item.imgUrl,
  66. url: item.mediaUrl ?? item.imgUrl,
  67. title: item.name,
  68. description: item.description,
  69. }
  70. case 'video':
  71. return {
  72. id: `${item?.type}-${i}-${j}-${k}`,
  73. type: item.mediaUrl ? 'video' : null,
  74. poster: item.imgUrl,
  75. url: item.mediaUrl,
  76. title: item.name,
  77. description: item.description,
  78. }
  79. case 'acupoint':
  80. return {
  81. id: `${item?.type}-${i}-${j}-${k}`,
  82. type: item.imgUrl ? 'image' : item.name ? 'text' : null,
  83. poster: item.imgUrl,
  84. url: item.mediaUrl ?? item.imgUrl,
  85. title: [item.name, `${item.doase || ''}${item.unit || ''}`].filter(Boolean).join(' '),
  86. description: item.description,
  87. }
  88. case 'medicine':
  89. return {
  90. id: `${item?.type}-${i}-${j}-${k}`,
  91. type: item.imgUrl ? 'image' : item.name ? 'text' : null,
  92. poster: item.imgUrl,
  93. url: item.mediaUrl ?? item.imgUrl,
  94. title: [item.name, `${item.doase || ''}${item.unit || ''}`].filter(Boolean).join(' '),
  95. description: item.description,
  96. }
  97. default:
  98. return {
  99. id: `${item?.type}-${i}-${j}-${k}`,
  100. type: null
  101. }
  102. }
  103. }).filter((item: AnyObject) => item.type) ?? [],
  104. description: item?.description,
  105. }
  106. }) ?? [],
  107. }
  108. }) ?? []
  109. }
  110. };
  111. return Get(`/analysisManage/getCondProgDetailById`, { params: { healthAnalysisReportId: id }, transform })
  112. }
  113. export function getStatusRecordMethod() {
  114. return Post(`/analysisManage/pageHarStatu`, {}, {
  115. transform({ data }: AnyObject) {
  116. return {
  117. total: data.total,
  118. data: data.data?.map((item: AnyObject) => {
  119. return {
  120. reportTime: dayjs(item.analysisEndTime).format('YY/MM/DD'),
  121. ...item
  122. }
  123. })
  124. };
  125. }
  126. })
  127. }