request.ts 4.2 KB

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