request.ts 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. import { Get, Post } from "../../lib/request/method";
  2. import { createHealthIndex } from "./tools/health-index";
  3. import dayjs from "dayjs";
  4. import { getFullImageUrl } from "../../utils/util";
  5. import { healthAnalysisModel, healthReportModel } from "./model/health.model";
  6. export function healthPatientMethod() {
  7. return Post(`/patientInfoManage/getPatientInfoDetail`, {}, { transform({ data }) { return data } });
  8. }
  9. export function healthReportListMethod() {
  10. const transform = ({ data }: AnyObject) => {
  11. return Array.isArray(data) ? data.map(item => {
  12. return {
  13. id: item.healthAnalysisReportId,
  14. reportTime: item.time3,
  15. description: [item.willillStateName, item.willillDegreeName, item.willillSocialName, item.willillFunctionName].filter(Boolean).join(',')
  16. }
  17. }) : []
  18. }
  19. return Get(`/analysisManage/getHarsTid`, { transform })
  20. }
  21. export function healthReportMethod({ id, scene, ...query }: Record<'id' | 'scene', string | void>): Promise<ReturnType<typeof healthReportModel>> {
  22. const transform = ({ data }: AnyObject) => healthReportModel(data);
  23. let params = { ...query } as any;
  24. if (id) { params.healthAnalysisReportId = id; }
  25. if (scene) {
  26. params.scene = decodeURIComponent(scene);
  27. return Get(`/analysisManage/getHealRepDetailByScene`, { params, transform });
  28. }
  29. return id
  30. ? Get(`/analysisManage/getHealRepDetailById`, { params, transform })
  31. : Post(`/analysisManage/getLastHealRepDetail`, {}, { params, transform })
  32. }
  33. export function healthAnalysisMethod({ id, scene, ...query }: Record<'id' | 'scene', string | void>): Promise<ReturnType<typeof healthAnalysisModel>> {
  34. const transform = ({ data }: AnyObject) => healthAnalysisModel(data);
  35. let params = { ...query } as any;
  36. if (id) { params.tonguefaceAnalysisReportId = id; }
  37. if (scene) {
  38. params.scene = decodeURIComponent(scene);
  39. return Get(`/analysisManage/getTofRepDetailByScene`, { params, transform });
  40. }
  41. return id
  42. ? Get(`/analysisManage/getTofRepDetailById`, { params, transform })
  43. : Post(`/analysisManage/getLastTofRepDetail`, {}, { params, transform })
  44. }
  45. export function healthAnalysisListMethod() {
  46. const transform = ({ data }: AnyObject) => {
  47. return Array.isArray(data) ? data.map(item => {
  48. return {
  49. id: item.id,
  50. reportTime: item.time3,
  51. description: item.content || '',
  52. }
  53. }) : []
  54. }
  55. return Get(`/analysisManage/getTofsTid`, { transform })
  56. }
  57. /**
  58. * 获取指标信息
  59. * @param id 健康分析报告
  60. */
  61. export function healthIndexMethod(id?: string) {
  62. const transform = ({ data }: AnyObject) => Array.isArray(data) ? data.map(item => createHealthIndex(item)) : [];
  63. return id
  64. ? Get(`/analysisManage/getLast7Day`, { params: { healthAnalysisReportId: id }, transform })
  65. : Post(`/patientQuota/getCurQuoval`, {}, { transform })
  66. }
  67. export function healthSchemeMethod(id: string) {
  68. const transform = ({ data }: AnyObject) => {
  69. return {
  70. reportTime: dayjs(data?.time).format('YYYY年MM月DD日'),
  71. children: data?.types?.map((item: AnyObject, i: number) => {
  72. return {
  73. title: item?.type || '',
  74. children: item?.groups?.map((item: AnyObject, j: number) => {
  75. return {
  76. buyUrl: item?.buyUrl || '',
  77. buyType: item?.buyType || '',
  78. shortImageUrl: getFullImageUrl(item?.miniprogram),
  79. title: item?.name || '',
  80. descriptions: item?.attrs?.map((attr: AnyArray, k: number) => {
  81. return { ...attr, id: `description-${i}-${j}-${k}`, }
  82. }) ?? [],
  83. children: item?.items?.map((item: AnyObject, k: number) => {
  84. switch (item?.type) {
  85. case 'img':
  86. return {
  87. id: `${item?.type}-${i}-${j}-${k}`,
  88. type: item.imgUrl ? 'image' : null,
  89. poster: getFullImageUrl(item.imgUrl),
  90. url: getFullImageUrl(item.mediaUrl ?? item.imgUrl),
  91. title: item.name,
  92. description: item.description,
  93. }
  94. case 'video':
  95. return {
  96. id: `${item?.type}-${i}-${j}-${k}`,
  97. type: item.mediaUrl ? 'video' : null,
  98. poster: getFullImageUrl(item.imgUrl),
  99. url: getFullImageUrl(item.mediaUrl),
  100. title: item.name,
  101. description: item.description,
  102. }
  103. case 'acupoint':
  104. return {
  105. id: `${item?.type}-${i}-${j}-${k}`,
  106. type: item.imgUrl ? 'image' : item.name ? 'text' : null,
  107. poster: getFullImageUrl(item.imgUrl),
  108. url: getFullImageUrl(item.mediaUrl ?? item.imgUrl),
  109. title: [item.name, `${item.doase || ''}${item.unit || ''}`].filter(Boolean).join(' '),
  110. description: item.description,
  111. }
  112. case 'medicine':
  113. return {
  114. id: `${item?.type}-${i}-${j}-${k}`,
  115. type: item.imgUrl ? 'image' : item.name ? 'text' : null,
  116. poster: getFullImageUrl(item.imgUrl),
  117. url: getFullImageUrl(item.mediaUrl ?? item.imgUrl),
  118. title: [item.name, `${item.doase || ''}${item.unit || ''}`].filter(Boolean).join(' '),
  119. description: item.description,
  120. }
  121. default:
  122. return {
  123. id: `${item?.type}-${i}-${j}-${k}`,
  124. type: null
  125. }
  126. }
  127. }).filter((item: AnyObject) => item.type) ?? [],
  128. description: item?.description,
  129. }
  130. }) ?? [],
  131. }
  132. }) ?? []
  133. }
  134. };
  135. return Get(`/analysisManage/getCondProgDetailById`, { params: { healthAnalysisReportId: id }, transform })
  136. }
  137. export function getStatusRecordMethod() {
  138. return Post(`/analysisManage/pageHarStatu`, {}, {
  139. transform({ data }: AnyObject) {
  140. return {
  141. total: data.total,
  142. data: data.data?.map((item: AnyObject) => {
  143. return {
  144. reportTime: dayjs(item.analysisEndTime).format('YY/MM/DD'),
  145. ...item
  146. }
  147. })
  148. };
  149. }
  150. })
  151. }
  152. // 获取随访评估列表
  153. export function getFollowEvaluationListMethod() {
  154. return Post(`/followupTaskManage/pageFollowupTaskGroup`, {}, {
  155. transform({ data }: AnyObject) {
  156. return data;
  157. }
  158. })
  159. }
  160. // 获取随访记录列表
  161. export function getFollowRecordListMethod() {
  162. return Post(`/followupTaskManage/pageFollowupTask`, {}, {
  163. transform({ data }: AnyObject) {
  164. return data;
  165. }
  166. })
  167. }
  168. // 获取调养记录列表
  169. export function getCareRecordListMethod(status: string) {
  170. return Post(`/patientCrManage/pagePcrs`, {status}, {
  171. transform({ data }: AnyObject) {
  172. return data;
  173. }
  174. })
  175. }
  176. // 线下非药物治疗
  177. export function getOfflineTreatmentListMethod(progress: string) {
  178. return Post(`/patientCrManage/pagePofflineCp`, {progress}, {
  179. transform({ data }: AnyObject) {
  180. return data;
  181. }
  182. })
  183. }
  184. // 核销记录
  185. // export function getVerifyRecordMethod(id: number) {
  186. // console.log(id, "核销记录");
  187. // // return Post(`/patientCrManage/pofflineCp`, {id}, {
  188. // // transform({ data }: AnyObject) {
  189. // // return data;
  190. // // }
  191. // // })
  192. // }
  193. // 获取调理中的调理记录
  194. export function getCareRecordMethod() {
  195. return Post(`/patientCrManage/getPcing`, {}, {
  196. transform({ data }: AnyObject) {
  197. return data;
  198. }
  199. })
  200. }