import dayjs from 'dayjs' const app = getApp() 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年以上', }, }, onLoad(option) { this.setData({ id: option.id, }) app.waitLogin().then(async (_res) => { this.getDoctorDetail() await this.getDetail() }) }, 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() }, })