You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.0 KiB

2 weeks ago
const MEDICATIONS_MAP: Record<number, string> = {
1: '没有使用激素',
2: '激素',
3: '免疫抑制剂',
4: '靶向CD19生物制剂',
5: '靶向CD20生物制剂',
99: '其他',
}
const IMMUNOSUPPRESSANT_MAP: Record<number, string> = {
1: '吗替麦考酚酯',
2: '替唑嘌呤',
3: '环磷酰胺',
4: '来氟米特',
5: '甲氨蝶呤',
6: '环孢素A',
7: '他克莫司',
8: '艾拉莫德',
99: '其他',
}
const IMAGE_TYPE_LABELS: Record<string, string> = {
outpatientRecord: '门诊病历及处方',
labReport: '检验报告',
imagingExam: '影像学检查',
pathology: '病理诊断及活检',
immuneFunction: '外周血免疫功能评估',
}
3 weeks ago
Page({
2 weeks ago
data: {
id: 0,
visitDate: '',
nextVisitDate: '',
displayIgG4Value: '' as string | number | null,
medicationsLabel: '',
oralHormoneDosageMg: '' as string | number | null,
2 weeks ago
immunosuppressantLabel: '',
reminderEnabled: 2,
imageGroups: [] as { type: string; label: string; list: string[] }[],
},
onLoad(options: any) {
if (options.id) {
this.setData({ id: Number(options.id) })
this.getDetail()
this.getReminderConfig()
}
},
// ========== API ==========
getDetail() {
wx.ajax({
method: 'GET',
url: '?r=igg4/medical-visit/detail',
data: { id: this.data.id },
}).then((res: any) => {
if (!res) return
const medicationsLabel = (res.medicationsUsed || [])
.map((id: number) => {
if (id === 99 && res.medicationsUsedOtherText) return `其他:${res.medicationsUsedOtherText}`
return MEDICATIONS_MAP[id]
})
.filter(Boolean)
.join('、')
const immunosuppressantLabel = (res.immunosuppressantName || [])
.map((id: number) => {
if (id === 99 && res.immunosuppressantNameOtherText) return `其他:${res.immunosuppressantNameOtherText}`
return IMMUNOSUPPRESSANT_MAP[id]
})
.filter(Boolean)
.join('、')
const imageGroups: { type: string; label: string; list: string[] }[] = []
const images = res.images || {}
for (const type of Object.keys(IMAGE_TYPE_LABELS)) {
const list = (images[type] || []).map((img: any) => img.maskedImageUrl || img.imageUrl)
if (list.length) {
imageGroups.push({ type, label: IMAGE_TYPE_LABELS[type], list })
}
}
this.setData({
visitDate: res.visitDate || '',
nextVisitDate: res.nextVisitDate || '',
displayIgG4Value: res.displayIgG4Value,
medicationsLabel,
oralHormoneDosageMg: res.oralHormoneDosageMg,
2 weeks ago
immunosuppressantLabel,
imageGroups,
})
})
},
getReminderConfig() {
wx.ajax({
method: 'GET',
url: '?r=igg4/medical-visit/get-reminder-config',
}).then((res: any) => {
if (!res) return
this.setData({ reminderEnabled: res.reminderEnabled || 2 })
})
},
saveReminderConfig(e: any) {
const val = e.detail.value ? 1 : 2
this.setData({ reminderEnabled: val })
wx.ajax({
method: 'POST',
url: '?r=igg4/medical-visit/save-reminder-config',
data: { reminderEnabled: val },
})
},
// ========== 操作 ==========
handleDelete() {
wx.showModal({
title: `删除${this.data.visitDate || ''}记录`,
content: `删除后将无法恢复`,
2 weeks ago
confirmText: '确认删除',
confirmColor: '#ee0a24',
success: (res) => {
if (!res.confirm) return
wx.ajax({
method: 'POST',
url: '?r=igg4/medical-visit/delete',
data: { id: this.data.id },
}).then((res: any) => {
if (!res) return
wx.navigateBack()
})
},
})
},
handleEdit() {
wx.navigateTo({ url: `/gift/pages/record/index?id=${this.data.id}` })
},
handlePreviewImage(e: any) {
const { url, type } = e.currentTarget.dataset
const group = this.data.imageGroups.find((g) => g.type === type)
if (!group) return
wx.previewImage({
current: url,
urls: group.list,
})
},
})
3 weeks ago
export {}