request.ts 4.9 KB

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