import dayjs from 'dayjs' const app = getApp() let echarts: any = null Page({ data: { toastShow: false, toastType: 'patientDetailSafeDoctor', toastParams: {} as any, showTel: false, doctor: {}, hospital: {}, id: '', remark: '', detail: {} as any, popupRemarkShow: false, remarkFocus: false, popupEditShow: false, antibodyTypeRangeList: [ { id: '1', value: 'AchR', }, { id: '2', value: 'MuSK', }, { id: '3', value: 'LRP4', }, { id: '4', value: 'RyR', }, ], thyroidAbnormalRangeList: [ { id: '1', value: '是', }, { id: '2', value: '否', }, ], previousConvulsionRangeList: [ { id: '1', value: '是', }, { id: '2', value: '否', }, ], traditionalImmunosuppressantRangeList: [ { id: '1', value: '他克莫司', }, { id: '2', value: '硫唑嘌呤', }, { id: '3', value: '吗替麦考酚酯', }, { id: '4', value: '其它', }, ], medicalInsuranceTypeRangeList: [ { id: '1', value: '城市职工', }, { id: '2', value: '城市居民', }, { id: '3', value: '新农合', }, ], ageRangeMap: { 1: '<40岁', 2: '40-49岁', 3: '50-59岁', 4: '60-69岁', 5: '70-79岁', 6: '80岁以上', }, diagnosisTimeRangeMap: { 1: '6个月以内', 2: '6个月-3年', 3: '3年以上', }, caseReportList: [ { icon: 'icon142.png', name: '门诊病历及处方', content: '医生手写或电脑打印的病历、处方', }, { icon: 'icon127.png', name: '检验报告', content: '抽血检测的IgG4、IgG、ESR等' }, { icon: 'icon128.png', name: '影像学检查', content: '超声/CT/MRI的描述结论、电子胶片' }, { icon: 'icon129.png', name: '病理诊断及活检', content: '受累组织穿刺或切除免疫组化报告' }, { icon: 'icon130.png', name: '外周血免疫功能评估', content: '免疫细胞亚群、淋巴细胞比例测定' }, ], }, ecDataTrendComponent: null as any, async onLoad(option) { this.setData({ id: option.id, }) echarts = await require.async('../../../resource/components/echart/echarts.js') this.ecDataTrendComponent = this.selectComponent('#chart1') this.initChart() app.waitLogin().then(async (_res) => { this.getDoctorDetail() await this.getDetail() }) }, initChart(defaultList = []) { const list: any = [ ...defaultList, { Date: '2026-7-7', TotalScore: 100, InjectionBottles: false }, { Date: '2026-7-8', TotalScore: 1000, InjectionBottles: false }, ] return new Promise((reslove) => { this.ecDataTrendComponent.init((canvas, width, height, dpr) => { const chart = echarts.init(canvas, null, { width, height, devicePixelRatio: dpr, // new }) canvas.setChart(chart) const option: any = { tooltip: { show: false, trigger: 'axis', axisPointer: { type: 'shadow', }, confine: true, backgroundColor: 'rgba(0, 0, 0, 0.5)', textStyle: { color: '#fff', fontSize: 10, }, order: 'seriesDesc', }, grid: { top: '30', left: '0', right: '0', bottom: '10', containLabel: true, }, xAxis: [ { type: 'category', axisTick: { alignWithLabel: true, }, axisLine: { lineStyle: { color: 'rgba(34, 34, 34, 0.20)', type: 'dashed', }, }, data: list.map((item) => dayjs(item.Date).format('MM-DD')), }, ], yAxis: [ { type: 'value', minInterval: 1, axisLabel: { color: 'rgba(34, 34, 34, 0.40)', }, splitLine: { lineStyle: { color: 'rgba(34, 34, 34, 0.20)', type: 'dashed', }, }, }, ], series: [ { name: '总分', data: list.length ? list.map((item) => item.TotalScore) : [25], barWidth: '16', label: { show: true, position: 'top', color: 'rgba(22, 121, 203, 1)', }, type: 'line', symbol: 'circle', symbolSize: 8, showSymbol: list.length >= 1, connectNulls: true, z: 10, itemStyle: { color: 'rgba(22, 121, 203, 1)', }, markLine: { symbol: ['none', 'none'], data: [ { name: '135 安全区', yAxis: 135, label: { formatter: '{b}', position: 'insideMiddle', color: 'rgba(22, 121, 203, 1)', fontSize: '10', }, lineStyle: { cap: '', color: 'rgba(22, 121, 203, 1)', type: 'dashed', }, }, ], }, markArea: { itemStyle: { color: 'rgba(22, 121, 203, 0.16)', }, data: [ [ { yAxis: 0, }, { yAxis: 135, }, ], ], }, }, ], dataZoom: { type: 'inside', // 有type这个属性,滚动条在最下面,也可以不行,写y:36,这表示距离顶端36px,一般就是在图上面。 startValue: 0, endValue: 4, filterMode: 'none', }, } chart.setOption(option) reslove(chart) return chart }) }) }, getDoctorDetail() { wx.ajax({ method: 'GET', url: '?r=igg4/doctor/account/info', data: {}, }).then((res) => { this.setData({ doctor: res.doctor, hospital: res.hospital, toastShow: true, toastType: 'patientDetailSafeDoctor', toastParams: { Name: res.doctor.Name, HospitalName: res.hospital.Name, }, }) }) }, getDetail() { return wx .ajax({ method: 'GET', url: '?r=igg4/doctor/patient/info', data: { patientId: this.data.id }, }) .then((res) => { if (res.LastAdlTime) { res.LastAdlTimeName = dayjs(res.LastAdlTime).from(dayjs().format('YYYY-MM-DD')).replace(' ', '') } if (res.LastUseDrugsTime) { res.LastUseDrugsTimeName = dayjs().format('YYYY-MM-DD') === res.LastUseDrugsTime ? '' : dayjs(res.LastUseDrugsTime).from(dayjs().format('YYYY-MM-DD')).replace(' ', '') } res.AgeRangeName = this.data.ageRangeMap[res.AgeRange] || '' res.DiagnosisTimeRangeName = this.data.diagnosisTimeRangeMap[res.DiagnosisTimeRange] || '' if (res.HealthQA && res.HealthQA.hasSubmitted && res.HealthQA.questions) { res.HealthQA.questions.forEach((q: any) => { q.isAnswerArray = Array.isArray(q.AnswerText) if (q.isAnswerArray) { q.AnswerTextArr = q.AnswerText.filter((a: any) => a !== null && a !== undefined) q.AnswerTextStr = q.AnswerTextArr.join('、') + (q.OtherText ? `(${q.OtherText})` : '') } else { q.AnswerTextStr = q.AnswerText || '' if (q.AnswerTextStr && q.OtherText) { q.AnswerTextStr += `(${q.OtherText})` } } }) } this.setData({ detail: { ...res, hideName: res.Name.length <= 2 ? res.Name.charAt(0) + '*' : res.Name.charAt(0) + '*' + res.Name.charAt(res.Name.length - 1), hideTelephone: res.Telephone ? res.Telephone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') : '', }, }) }) }, handleRemark() { this.setData({ popupRemarkShow: true, remark: this.data.detail.DoctorRemark, }) setTimeout(() => { this.setData({ remarkFocus: true, }) }, 300) }, handleRemarkClose() { this.setData({ popupRemarkShow: false, remarkFocus: false, remark: '', }) }, handleRemarkSubmit() { if (!this.data.remark) { wx.showToast({ icon: 'none', title: '请输入备注', }) return } wx.ajax({ method: 'POST', url: '?r=igg4/doctor/patient/remark', data: { PatientId: this.data.id, DoctorRemark: this.data.remark, }, }).then((_res) => { this.handleRemarkClose() this.getDetail() }) }, handleEditUser() { this.setData({ popupEditShow: true, }) }, handleUserCancel() { this.setData({ popupEditShow: false, }) }, handleUserSubmit() { this.handleUserCancel() this.handlePatientUpdate() }, handleRadio(e) { const { id, key } = e.currentTarget.dataset this.setData({ [`detail.${key}`]: id, }) }, handlePatientUpdate() { const { detail } = this.data wx.ajax({ method: 'POST', url: '?r=igg4/doctor/patient/update', data: { PatientId: detail.PatientId, AntibodyType: detail.AntibodyType, ThyroidAbnormal: detail.ThyroidAbnormal, PreviousConvulsion: detail.PreviousConvulsion, TraditionalImmunosuppressant: detail.TraditionalImmunosuppressant, MedicalInsuranceType: detail.MedicalInsuranceType, }, }).then(() => { wx.showToast({ icon: 'none', title: '更新成功', }) this.getDetail() }) }, handleSend() { wx.navigateTo({ url: `/doctor/pages/d_interactiveDoctor/index?patientId=${this.data.detail.PatientId}`, }) }, handleToggleTel() { this.setData({ showTel: !this.data.showTel, }) }, handleToastOk() { this.setData({ toastShow: false, }) }, handleToastCancel() { wx.navigateBack() }, })