request.ts 6.0 KB

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