| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import { Get, Post } from "../../lib/request/method";
- import { createHealthIndex, transformHealthIndex2Chart } from "./tools/health-index";
- import dayjs from "dayjs";
- export function healthPatientMethod() {
- return Post(`/patientInfoManage/getPatientInfoDetail`, {}, { transform({ data }) { return data } });
- }
- export function healthReportListMethod() {
- const transform = ({ data }: AnyObject) => {
- return Array.isArray(data) ? data.map(item => {
- return {
- id: item.healthAnalysisReportId,
- reportTime: item.time3,
- description: [item.willillStateName, item.willillDegreeName, item.willillSocialName, item.willillFunctionName].filter(Boolean).join(',')
- }
- }) : []
- }
- return Get(`/analysisManage/getHarsTid`, { transform })
- }
- export function healthReportMethod({id, ...query}: Record<'id' | 'scene', string>) {
- const transform = ({ data }: AnyObject) => {
- if (Array.isArray(data?.conditProgram?.types)) {
- data.conditProgram.types = data.conditProgram.types.map((item: AnyObject) => (item.summary = item.summary?.replace(/null/g, '') || '', item))
- }
- return data;
- };
- let params = { ...query } as any;
- if (id) { params.healthAnalysisReportId = id; }
- if (query.scene) { return Get(`/analysisManage/getHealRepDetailByScene`, { params, transform }); }
- return id
- ? Get(`/analysisManage/getHealRepDetailById`, { params, transform })
- : Post(`/analysisManage/getLastHealRepDetail`, {}, { params, transform })
- }
- /**
- * 获取指标信息
- * @param id 健康分析报告
- */
- export function healthIndexMethod(id?: string) {
- const transform = ({ data }: AnyObject) => Array.isArray(data) ? data.map(item => createHealthIndex(item)) : [];
- return id
- ? Get(`/analysisManage/getLast7Day`, { params: { healthAnalysisReportId: id }, transform })
- : Post(`/patientQuota/getCurQuoval`, {}, { transform })
- }
- export function healthSchemeMethod(id: string) {
- const transform = ({ data }: AnyObject) => {
- return {
- reportTime: dayjs(data?.time).format('YYYY年MM月DD日'),
- children: data?.types?.map((item: AnyObject, i: number) => {
- return {
- title: item?.type || '',
- children: item?.groups?.map((item: AnyObject, j: number) => {
- return {
- title: item?.name || '',
- descriptions: item?.attrs?.map((attr: AnyArray, k: number) => {
- return { ...attr, id: `description-${i}-${j}-${k}`, }
- }) ?? [],
- children: item?.items?.map((item: AnyObject, k: number) => {
- switch (item?.type) {
- case 'img':
- return {
- id: `${item?.type}-${i}-${j}-${k}`,
- type: item.imgUrl ? 'image' : null,
- poster: item.imgUrl,
- url: item.mediaUrl ?? item.imgUrl,
- title: item.name,
- description: item.description,
- }
- case 'video':
- return {
- id: `${item?.type}-${i}-${j}-${k}`,
- type: item.mediaUrl ? 'video' : null,
- poster: item.imgUrl,
- url: item.mediaUrl,
- title: item.name,
- description: item.description,
- }
- case 'acupoint':
- return {
- id: `${item?.type}-${i}-${j}-${k}`,
- type: item.imgUrl ? 'image' : item.name ? 'text' : null,
- poster: item.imgUrl,
- url: item.mediaUrl ?? item.imgUrl,
- title: [item.name, `${item.doase || ''}${item.unit || ''}`].filter(Boolean).join(' '),
- description: item.description,
- }
- case 'medicine':
- return {
- id: `${item?.type}-${i}-${j}-${k}`,
- type: item.imgUrl ? 'image' : item.name ? 'text' : null,
- poster: item.imgUrl,
- url: item.mediaUrl ?? item.imgUrl,
- title: [item.name, `${item.doase || ''}${item.unit || ''}`].filter(Boolean).join(' '),
- description: item.description,
- }
- default:
- return {
- id: `${item?.type}-${i}-${j}-${k}`,
- type: null
- }
- }
- }).filter((item: AnyObject) => item.type) ?? [],
- description: item?.description,
- }
- }) ?? [],
- }
- }) ?? []
- }
- };
- return Get(`/analysisManage/getCondProgDetailById`, { params: { healthAnalysisReportId: id }, transform })
- }
- export function getStatusRecordMethod() {
- return Post(`/analysisManage/pageHarStatu`, {}, {
- transform({ data }: AnyObject) {
- return {
- total: data.total,
- data: data.data?.map((item: AnyObject) => {
- return {
- reportTime: dayjs(item.analysisEndTime).format('YY/MM/DD'),
- ...item
- }
- })
- };
- }
- })
- }
|