request.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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/getQuovalByHarId`, { 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. types: Array.isArray(data?.types) ? data.types.map((item: AnyObject) => {
  45. return {
  46. type: item.type || '',
  47. summary: item.summary?.replace(/null/g, '') || '',
  48. groups: item.groups?.map((group: AnyObject) => {
  49. const descriptions = group.description?.split('\n').filter(Boolean) ?? [];
  50. const media = [] as any[];
  51. const items = group.items;
  52. if (Array.isArray(items)) {
  53. let medicine = [] as any[];
  54. const fn = () => {
  55. const str = medicine.map(item => [item.name, [item.doase, item.unit].filter(Boolean).join('')].filter(Boolean).join(' ')).join('; ')
  56. descriptions.push(`${str}`)
  57. medicine = [];
  58. }
  59. for (const item of items) {
  60. const { type, imgUrl, mediaUrl, name, description } = item;
  61. if (type !== 'medicine' && medicine.length) fn();
  62. switch (type) {
  63. case 'img':
  64. if (mediaUrl || imgUrl) media.push({
  65. type: 'picture',
  66. mediaUrl: mediaUrl ?? imgUrl,
  67. imgUrl: imgUrl ?? mediaUrl,
  68. name: name ?? '',
  69. description: description ?? ''
  70. })
  71. break;
  72. case 'video':
  73. if (mediaUrl) media.push({
  74. type: 'video',
  75. mediaUrl: mediaUrl,
  76. imgUrl: imgUrl,
  77. name: name ?? '',
  78. description: description ?? ''
  79. });
  80. break;
  81. case 'text':
  82. descriptions.push(`${name}: ${description}`)
  83. break;
  84. case 'medicine':
  85. medicine.push(item);
  86. break;
  87. }
  88. }
  89. if (medicine.length) fn();
  90. }
  91. return {
  92. name: group.name,
  93. descriptions, media,
  94. }
  95. })
  96. }
  97. }) : []
  98. }
  99. };
  100. return Get(`/analysisManage/getCondProgDetailById`, { params: { healthAnalysisReportId: id }, transform })
  101. }