request.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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, ...query}: Record<'id' | 'scene', string>) {
  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 (query.scene) { return Get(`/analysisManage/getHealRepDetailByScene`, { params, transform }); }
  29. return id
  30. ? Get(`/analysisManage/getHealRepDetailById`, { params, transform })
  31. : Post(`/analysisManage/getLastHealRepDetail`, {}, { params, transform })
  32. }
  33. /**
  34. * 获取指标信息
  35. * @param id 健康分析报告
  36. */
  37. export function healthIndexMethod(id?: string) {
  38. const transform = ({ data }: AnyObject) => Array.isArray(data) ? data.map(item => createHealthIndex(item)) : [];
  39. return id
  40. ? Get(`/analysisManage/getLast7Day`, { params: { healthAnalysisReportId: id }, transform })
  41. : Post(`/patientQuota/getCurQuoval`, {}, { transform })
  42. }
  43. export function healthSchemeMethod(id: string) {
  44. const transform = ({ data }: AnyObject) => {
  45. return {
  46. reportTime: dayjs(data?.time).format('YYYY年MM月DD日'),
  47. children: data?.types?.map((item: AnyObject, i: number) => {
  48. return {
  49. title: item?.type || '',
  50. children: item?.groups?.map((item: AnyObject, j: number) => {
  51. return {
  52. title: item?.name || '',
  53. descriptions: item?.attrs?.map((attr: AnyArray, k: number) => {
  54. return { ...attr, id: `description-${i}-${j}-${k}`, }
  55. }) ?? [],
  56. children: item?.items?.map((item: AnyObject, k: number) => {
  57. switch (item?.type) {
  58. case 'img':
  59. return {
  60. id: `${item?.type}-${i}-${j}-${k}`,
  61. type: item.imgUrl ? 'image' : null,
  62. poster: item.imgUrl,
  63. url: item.mediaUrl ?? item.imgUrl,
  64. title: item.name,
  65. description: item.description,
  66. }
  67. case 'video':
  68. return {
  69. id: `${item?.type}-${i}-${j}-${k}`,
  70. type: item.mediaUrl ? 'video' : null,
  71. poster: item.imgUrl,
  72. url: item.mediaUrl,
  73. title: item.name,
  74. description: item.description,
  75. }
  76. case 'acupoint':
  77. return {
  78. id: `${item?.type}-${i}-${j}-${k}`,
  79. type: item.imgUrl ? 'image' : item.name ? 'text' : null,
  80. poster: item.imgUrl,
  81. url: item.mediaUrl ?? item.imgUrl,
  82. title: [item.name, `${item.doase || ''}${item.unit || ''}`].filter(Boolean).join(' '),
  83. description: item.description,
  84. }
  85. case 'medicine':
  86. return {
  87. id: `${item?.type}-${i}-${j}-${k}`,
  88. type: item.imgUrl ? 'image' : item.name ? 'text' : null,
  89. poster: item.imgUrl,
  90. url: item.mediaUrl ?? item.imgUrl,
  91. title: [item.name, `${item.doase || ''}${item.unit || ''}`].filter(Boolean).join(' '),
  92. description: item.description,
  93. }
  94. default:
  95. return {
  96. id: `${item?.type}-${i}-${j}-${k}`,
  97. type: null
  98. }
  99. }
  100. }).filter((item: AnyObject) => item.type) ?? [],
  101. description: item?.description,
  102. }
  103. }) ?? [],
  104. }
  105. }) ?? []
  106. }
  107. };
  108. return Get(`/analysisManage/getCondProgDetailById`, { params: { healthAnalysisReportId: id }, transform })
  109. }
  110. export function getStatusRecordMethod() {
  111. return Post(`/analysisManage/pageHarStatu`, {}, {
  112. transform({ data }: AnyObject) {
  113. return {
  114. total: data.total,
  115. data: data.data?.map((item: AnyObject) => {
  116. return {
  117. reportTime: dayjs(item.analysisEndTime).format('YY/MM/DD'),
  118. ...item
  119. }
  120. })
  121. };
  122. }
  123. })
  124. }