import request from '~/api/request'; import uploadFileToOSS from '~/api/upload'; import { getOcr } from '~/api/ocr'; import { getBOcr } from '~/api/BOcr'; Page({ /** * 页面的初始数据 */ // 凝血酶原时间(s)/国际标准化比/活化的部分凝血酶时间(s) data: { style: 'border: 2rpx solid #efefef;border-radius: 12rpx;', form: { follow_name: '', liver_function_image: [], b_mode_image: [], blood_routine_image: [], coagulation_function_image: [], mdt_image: [], nutritional_indicator_image: [] }, isName: true, isTime: true, isDoctor: true, isHeight: true, isWeight: true, personInfo: { name: '', gender: 0, birth: '', address: [], introduction: '', yearType: 0, // photos: [], }, mode: '', dateVisible: false, dateText: '', startTimePicker: String(new Date().getFullYear()), filter(type, options) { if (type === 'year') { return options.sort((a, b) => b.value - a.value); } return options; }, popupProps: { usingCustomNavbar: true, }, formatter(item, index) { if (index === 1) { const label = item.label.slice(0, -1); return { value: item.value, label: calendarMonth[Number(label) - 1], }; } if (index === 2) { const [dateValue, weekValue] = item.label.split(' '); const dateSuffixes = { 1: 'st', 2: 'nd', 3: 'rd', }; const weekMap = { 周一: 'Mon.', 周二: 'Tues.', 周三: 'Wed.', 周四: 'Thurs.', 周五: 'Fri.', 周六: 'Sat.', 周日: 'Sun.', }; const label = dateValue.slice(0, -1); return { value: item.value, label: `${label}${dateSuffixes[label] || 'th'} ${weekMap[weekValue]}`, }; } return { value: item.value, label: item.label.slice(0, -1), }; }, originFiles: [ { url: 'https://tdesign.gtimg.com/mobile/demos/example4.png', name: 'uploaded1.png', type: 'image', removeBtn: true, }, { url: 'https://tdesign.gtimg.com/mobile/demos/example6.png', name: 'uploaded2.png', type: 'image', removeBtn: true, }, { url: 'https://tdesign.gtimg.com/mobile/demos/example5.png', name: 'uploaded3.png', type: 'image', removeBtn: true, }, ], gridConfig: { column: 4, width: 160, height: 160, }, config: { count: 1, }, imageVisible: false, imageList: [], imageIndex: 1, }, onInput(e) { const { key, tips } = e.currentTarget.dataset; if (e.detail.value) { this.setData({ [tips]: true, [`form.${key}`]: e.detail.value }); } else { this.setData({ [tips]: false, [`form.${key}`]: e.detail.value }) } }, onInputTime(e) { const { tips } = e.currentTarget.dataset; if (e.detail.value) { this.setData({ [tips]: true, }); } else { this.setData({ [tips]: false, }) } }, showPicker(e) { const { mode } = e.currentTarget.dataset; this.setData({ [`${mode}Visible`]: true, }); }, onPickerChange(e) { if (e.detail.value) { this.setData({ isTime: true, ['form.follow_date']: e.detail.value }) } else { this.setData({ isTime: false, ['form.follow_date']: e.detail.value }) } }, handleSuccess(e) { const { files } = e.detail; this.setData({ originFiles: files, }); }, handleRemove(e) { const { index } = e.detail; const { originFiles } = this.data; originFiles.splice(index, 1); this.setData({ originFiles, }); }, handleClick(e) { console.log(e.detail.file); }, planId: '', questionnaire_id: '', async toQuestionnaire() { let valid = true; // 必填项校验 if (!this.data.form.follow_name) { this.setData({ isName: false }); valid = false; } if (!this.data.form.follow_date) { this.setData({ isTime: false }); valid = false; } if (!this.data.form.follow_hospital) { this.setData({ isDoctor: false }); valid = false; } if (!this.data.form.height) { this.setData({ isHeight: false }); valid = false; } if (!this.data.form.weight) { this.setData({ isWeight: false }); valid = false; } if (!valid) return const data = this.data.form data.liver_function_image = data.liver_function_image.length > 0 ? data.liver_function_image.join(',') : '' data.b_mode_image = data.b_mode_image.length > 0 ? data.b_mode_image.join(',') : '', data.blood_routine_image = data.blood_routine_image.length > 0 ? data.blood_routine_image.join(',') : '', data.coagulation_function_image = data.coagulation_function_image.length > 0 ? data.coagulation_function_image.join(',') : '', data.mdt_image = data.mdt_image.length > 0 ? data.mdt_image.join(',') : '', data.nutritional_indicator_image = data.nutritional_indicator_image.length > 0 ? data.nutritional_indicator_image.join(',') : '' data.is_have_cyst = data.is_have_cyst ? Number(data.is_have_cyst) : 0 data.is_have_ascites = data.is_have_ascites ? Number(data.is_have_ascites) : 0 await request('patient/follow_questionnaire', 'post', { plan_id: Number(this.planId), questionnaire_id: Number(this.questionnaire_id), ...data }) wx.showToast({ title: '提交成功', icon: 'success', duration: 2000, complete: () => { wx.navigateBack({ delta: 1 }) } }) }, handleChangeGroup(e) { const { mode } = e.currentTarget.dataset this.setData({ [`form.${mode}`]: e.detail.value }) }, handleUpload(e) { const { mode } = e.currentTarget.dataset; if (this.data.form[mode].length >= 9) { wx.showToast({ title: '最多上传9张图片!', icon: 'none' }); return } uploadFileToOSS().then((imageUrl) => { const { mode } = e.currentTarget.dataset; let arr = this.data.form[mode] arr.unshift(imageUrl) this.setData({ [`form.${mode}`]: arr }) if(mode == 'mdt_image'){ wx.showToast({ title: '上传成功!', icon: 'none' }); } else if(mode == 'b_mode_image'){ wx.showToast({ title: '上传成功,正在识别内容!', icon: 'none' }); getBOcr(imageUrl).then(ocrRes => { console.log(ocrRes) wx.showToast({ title: '识别完成!', icon: 'none' }) this.setFormData(ocrRes, mode) }) } else{ wx.showToast({ title: '上传成功,正在识别内容!', icon: 'none' }); getOcr(imageUrl).then(ocrRes => { console.log(ocrRes) wx.showToast({ title: '识别完成!', icon: 'none' }) this.setFormData(ocrRes, mode) }) } }) }, imageKey: '', handleImagePreview(e) { const { mode, index } = e.currentTarget.dataset; this.imageKey = mode this.setData({ imageList: this.data.form[mode], imageIndex: index, imageVisible: true }) }, onClose() { this.setData({ imageVisible: false }) }, handleDelete(e) { const { mode, index } = e.currentTarget.dataset; let arr = this.data.form[mode] arr.splice(index, 1) this.setData({ [`form.${mode}`]: arr }) }, onDelete(e) { let arr = this.data.form[this.imageKey] arr.splice(e.detail.index, 1) // let imageList = this.data.imageList // imageList.splice(this.data.imageIndex, 1) let imageIndex = e.detail.index this.setData({ // imageIndex: imageIndex - 1, [`form.${this.imageKey}`]: arr, imageList: arr, imageVisible: arr.length != 0 }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.planId = options.planId this.questionnaire_id = options.questionnaire_id this.setData({ ['form.follow_name']: options.name, ['form.follow_date']: options.time }) if (options.questionnaire_id != 0) { this.getDetail() } }, async getDetail() { const res = await request('patient/questionnaire_info', 'post', { patient_id: 0, questionnaire_id: Number(this.questionnaire_id) }) const data = res data.liver_function_image = data.liver_function_image ? data.liver_function_image.split(',') : [] data.b_mode_image = data.b_mode_image ? data.b_mode_image.split(',') : [] data.blood_routine_image = data.blood_routine_image ? data.blood_routine_image.split(',') : [] data.coagulation_function_image = data.coagulation_function_image ? data.coagulation_function_image.split(',') : [] data.mdt_image = data.mdt_image ? data.mdt_image.split(',') : [] data.nutritional_indicator_image = data.nutritional_indicator_image ? data.nutritional_indicator_image.split(',') : [] this.setData({ form: data }) }, // 遍历识别结果,填充字段 setFormData(ocrs, mode) { ocrs.forEach(ocr => { // 血常规 if (mode == 'blood_routine_image') { if (ocr.name == '血红蛋白' || ocr.name == '血红蛋白检查') { this.setData({ [`form.hemoglobin`]: ocr.value }) } if (ocr.name == '血小板' || ocr.name == '血小板计数') { this.setData({ [`form.platelets`]: ocr.value }) } if (ocr.name == '白细胞' || ocr.name == '白细胞计数') { this.setData({ [`form.white_blood_cells`]: ocr.value }) } if (ocr.name == '红细胞' || ocr.name == '红细胞计数') { this.setData({ [`form.red_blood_cells`]: ocr.value }) } } // 凝血功能 if (mode == 'coagulation_function_image') { if (ocr.name == 'C-反应蛋白' || ocr.name == 'c-反应蛋白' || ocr.name == 'CRP') { this.setData({ [`form.crp`]: ocr.value }) } if (ocr.name == 'DDR' || ocr.name == 'ddr') { this.setData({ [`form.ddr`]: ocr.value }) } if (ocr.name == '凝血酶原时间' || ocr.name == 'Pt') { this.setData({ [`form.pt`]: ocr.value }) } if (ocr.name == '凝血酶原活动度' || ocr.name == 'Pt-a' || ocr.name == 'PtA') { this.setData({ [`form.pta`]: ocr.value }) } if (ocr.name == '国际标准化比值' || ocr.name == 'INR') { this.setData({ [`form.inr`]: ocr.value }) } if (ocr.name == '活化部分凝血活酶时间' || ocr.name == 'APTT') { this.setData({ [`form.aptt`]: ocr.value }) } if (ocr.name == '凝血酶时间' || ocr.name == 'TT') { this.setData({ [`form.tt`]: ocr.value }) } if (ocr.name == '纤维蛋白原' || ocr.name == 'FIB') { this.setData({ [`form.fib`]: ocr.value }) } if (ocr.name == 'NPDP' || ocr.name == 'npdp') { this.setData({ [`form.npdp`]: ocr.value }) } if (ocr.name == 'MMP-7' || ocr.name == 'MMP7' || ocr.name == '基质金属蛋白酶-7') { this.setData({ [`form.mmp_7`]: ocr.value }) } } // 肝功能 if (mode == 'liver_function_image') { if (ocr.name == '总胆红素') { this.setData({ [`form.total_bilirubin`]: ocr.value }) } if (ocr.name == '直接胆红素') { this.setData({ [`form.direct_bilirubin`]: ocr.value }) } if (ocr.name == '总胆汁酸') { this.setData({ [`form.total_bile_acid`]: ocr.value }) } if (ocr.name == '白蛋白') { this.setData({ [`form.albumin`]: ocr.value }) } if (ocr.name == '谷草' || ocr.name == '谷草转氨酶') { this.setData({ [`form.grain_grass`]: ocr.value }) } if (ocr.name == '谷丙' || ocr.name == '谷丙转氨酶') { this.setData({ [`form.gu_bing`]: ocr.value }) } if (ocr.name == 'γ-谷氨酰转肽酶' || ocr.name == '谷氨酰转肽酶') { this.setData({ [`form.ggt`]: ocr.value }) } if (ocr.name == '碱性磷酸酶') { this.setData({ [`form.alp`]: ocr.value }) } } // 营养指数 if (mode == 'nutritional_indicator_image') { if (ocr.name == '25-羟基维生素D3' || ocr.name == '25-OH-Vitamin D3' || ocr.name == '25(OH)D3') { this.setData({ [`form.oh_d3`]: ocr.value }) } if (ocr.name == '25-羟基维生素D2' || ocr.name == '25-OH-Vitamin D2' || ocr.name == '25(OH)D2') { this.setData({ [`form.oh_d2`]: ocr.value }) } if (ocr.name == '25-羟基维生素D' || ocr.name == '25-OH-Vitamin D' || ocr.name == '25(OH)D') { this.setData({ [`form.oh_d`]: ocr.value }) } if (ocr.name == '维生素A' || ocr.name == '维生素a' || ocr.name == 'vitamin a' || ocr.name == 'vit A') { this.setData({ [`form.vitamin_a`]: ocr.value }) } if (ocr.name == '维生素K' || ocr.name == '维生素k' || ocr.name == 'vitamin k' || ocr.name == 'vit K') { this.setData({ [`form.vitamin_k`]: ocr.value }) } if (ocr.name == '维生素E' || ocr.name == '维生素e' || ocr.name == 'vitamin e' || ocr.name == 'vit E') { this.setData({ [`form.vitamin_e`]: ocr.value }) } } // B超 if (mode == 'b_mode_image') { if(ocr.name == '肝肋下'){ this.setData({ [`form.under_the_liver_rib`]: ocr.value }) } if(ocr.name == '肝剑突下'){ this.setData({ [`form.under_the_xiphoid_liver`]: ocr.value }) } if(ocr.name == '脾肋下'){ this.setData({ [`form.spleen_rib_area`]: ocr.value }) } if(ocr.name == '门静脉主干内径'){ this.setData({ [`form.main_portal_vein`]: ocr.value }) } if(ocr.name == '肝回声'){ this.setData({ [`form.liver_echo`]: ocr.value }) } if(ocr.name == '胆囊大小'){ this.setData({ [`form.gallbladder_size`]: ocr.value }) } if(ocr.name == '胆总管'){ this.setData({ [`form.common_bile_duct`]: ocr.value }) } if(ocr.name == '纤维块大小'){ this.setData({ [`form.fiber_block_size`]: ocr.value }) } if(ocr.name == '门静脉流速' || ocr.name == 'PVV' || ocr.name == 'PVV流速' || ocr.name == 'pvv'){ this.setData({ [`form.pvv`]: ocr.value }) } if(ocr.name == '肝弹性值'){ this.setData({ [`form.liver_elasticity_value`]: ocr.value }) } if(ocr.name == '有无肝囊肿'){ this.setData({ [`form.is_have_cyst`]: ocr.value == '无' ? '2' : '1' }) } if(ocr.name == '有无腹水'){ this.setData({ [`form.is_have_ascites`]: ocr.value == '无' ? '2' : '1' }) } if(ocr.name == '弹性成像最小值'){ this.setData({ [`form.elastography_minimum`]: ocr.value }) } if(ocr.name == '弹性成像最大值'){ this.setData({ [`form.elastography_maximum`]: ocr.value }) } if(ocr.name == '弹性成像中位数'){ this.setData({ [`form.elastography_median`]: ocr.value }) } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })