实现了健康建议功能,患者点击获取健康建议摁扭之后,将医生诊断结果和患者主诉传给后端,后端再传给前端,前端显示得到弹窗上(代码中通过if判断已经处理了诊断结果可能为空的情况)
//健康建议功能代码:
advise(){
this.loadingInstance = ElLoading.service({
fullscreen: true,
text: '加载中,请耐心等待一分钟...',
spinner: 'el-icon-loading',
background: 'rgba(64,34,34,0.36)'
})
if(this.form.dia_result)
{
this.$axios.get("http://localhost:8000/medic/analyse/",
{ params:
{
诊断结果: this.form.dia_result,
主诉: this.form.chief,
}
}).then(
res=>{
console.log(res.data)
this.advice = res.data.advice
this.dialogVisible = false
this.dialogVisible2 = true
this.loadingInstance.close();
this.loadingInstance = null;
}
)
}
else
{
this.$axios.get("http://localhost:8000/medic/analyse/",
{ params:
{
诊断结果: "未诊断",
主诉: this.form.chief,
}
}).then(
res=>{
console.log(res.data)
this.advice = res.data.advice
this.dialogVisible = false
this.dialogVisible2 = true
this.loadingInstance.close();
this.loadingInstance = null;
}
)
}
},
前端美化部分:适当调整前端字体、字的大小、某些容器的规模以及加上一些图标el-icon
使得前端看起来更顺眼
//美化后前端图片:
增强程序健壮性:
(1)病历生成时用户不输入病情描述或是不选择医生(参数为空)怎么办?
判断,判断为空则不发送请求并且前端发送弹窗提醒
const initialDoctorList = async() => {
await axios.get('http://localhost:8000/medic/return_doctor_list/').then(
res => {
//console.log(res.data.doctor_list)
doctorList.value = res.data.doctor_list;
// console.log(doctorList.value);
}
)
}
initialDoctorList()
const handleSubmit = async() => {
console.log(blogForm.value)
if(blogForm.value.content === "")
{
await openAnotherDialog();
}
else if(blogForm.value.doctor === "")
{
await openOtherDialog();
}
else if(blogForm.value.content !== "" && blogForm.value.doctor !== "")
{
//显示加载界面 element-plus
loadingInstance = ElLoading.service({
fullscreen: true,
text: '正在生成病历,预计等待30秒...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
}
)
// 在这里传给后端数据
await axios.post('http://localhost:8000/medic/generate/'+pid.value+'/', querystring.stringify({
message: blogForm.value.content,
doctor_id: blogForm.value.doctor
})).then(res => {
console.log(res.data)
theMessage.value = JSON.parse(JSON.stringify(res.data.message));
console.log(theMessage)
});
await openDialog();
await closeLoading();
}
};