挂号
2021-01-14 本文已影响0人
wqjcarnation
页面展示
image.png前台Register.vue
<template>
<div>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<!-- 第一行-->
<el-row>
<el-col :span="5">
<el-form-item label="发票号" prop="invoiceNum" >
<el-input v-model="ruleForm.invoiceNum" size="mini"></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')">挂号</el-button>
<el-button @click="resetForm('ruleForm')">清空</el-button>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="2">
<h2>挂号信息</h2>
</el-col>
</el-row>
<!-- 第3行-->
<hr>
<el-row>
<el-col :span="5">
<el-form-item label="病历号" prop="caseNumber">
<el-input v-model="ruleForm.caseNumber" size="mini"></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="姓名" prop="realName">
<el-input v-model="ruleForm.realName" size="mini"></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="身份证号" >
<el-input v-model="ruleForm.iDnumber" size="mini" @change="getOther"></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="出生日期" >
<el-date-picker type="date" placeholder="出生日期" v-model="ruleForm.birthDate" size="mini" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
<!-- 第4行-->
<el-row>
<el-col :span="5">
<el-form-item label="性别" prop="sex">
<el-select v-model="ruleForm.sex" placeholder="请选择性别" size="mini">
<el-option v-for="item in sexoptions" :key="item.id" :value="item.id" :label="item.constantName" ></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="年龄">
<el-input v-model="ruleForm.age" size="mini"></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="岁别" prop="ageType">
<el-select v-model="ruleForm.ageType" size="mini">
<el-option v-for="item in ageTypeoptions" :key="item.key" :value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="家庭住址" prop="address" >
<el-input v-model="ruleForm.address" size="mini"></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 下一行-->
<el-row>
<el-col :span="5">
<el-form-item label="结算类型" prop="settleID">
<el-select v-model="ruleForm.settleID" placeholder="请选择结算类别" size="mini">
<el-option v-for="item in settleIDTypeoptions" :key="item.id" :value="item.id" :label="item.constantName"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="看诊日期" prop="visitDate">
<el-date-picker v-model="ruleForm.visitDate" type="date" placeholder="选择日期" size="mini" format="yyyy-MM-dd" value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="" prop="noon">
<el-select v-model="ruleForm.noon" placeholder="请选择午别" size="mini">
<el-option v-for="item in noonTypeoptions" :key="item.key" :value="item.value" ></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="挂号科室" prop="deptID" style="float: right;width=50px">
<el-select v-model="ruleForm.deptCataId" placeholder="请选择科室" size="mini" @change="getDept">
<el-option key="0" value="" label="请选择"></el-option>
<el-option v-for="item in deptCataIdoptions" :key="item.id" :value="item.id" :label="item.constantName"></el-option>
</el-select>
<el-select v-model="ruleForm.deptID" placeholder="请选择科室" size="mini">
<el-option v-for="item in deptIDTypeoptions" :key="item.id" :value="item.id" :label="item.deptName"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<!-- -->
<el-row>
<el-col :span="5">
<el-form-item label="号别" prop="registLeID">
<el-select v-model="ruleForm.registLeID" placeholder="请选择号别" size="mini" @change="getDoc">
<el-option key="0" value="" label="请选择"></el-option>
<el-option v-for="item in registLeIDTypeoptions" :key="item.id" :value="item.id" :label="item.registName"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="看诊医生" prop="userId">
<el-select v-model="ruleForm.userId" placeholder="请选择医生" size="mini" @change="getMaxNum">
<el-option key="0" value="" label="请选择"></el-option>
<el-option v-for="item in userIdTypeoptions" :key="item.id" :value="item.id" :label="item.realName"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="初始号额" prop="startRegistQuota">
<el-input v-model="ruleForm.startRegistQuota" placeholder="初始号额" size="mini"></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="已用号额" prop="usedRegistQuota" style="float: right;">
<el-input v-model="ruleForm.usedRegistQuota" placeholder="已用号额" size="mini"></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- -->
<el-row>
<el-col :span="5">
<el-form-item label="病历本" prop="isBook" style="float: left;">
<el-radio-group v-model="ruleForm.isBook" @change="changeFee">
<el-radio label="1">需要</el-radio>
<el-radio label="0">不需要</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="应收金额">
<el-input v-model="ruleForm.fee" placeholder="应收金额" size="mini"></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="收费方式" prop="method">
<el-select v-model="ruleForm.method" placeholder="请选择收费方式" size="mini">
<el-option v-for="item in methodTypeoptions" :key="item.id" :value="item.id" :label="item.constantName"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
</template>
<script>
//5、选择看诊医生,计算出已用号额 判断是否可以挂号
//6、选择是否要病历本,计算出最终的应收金额
//@Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
export default{
data(){
return{
ruleForm:{
invoiceNum:'',//存到发票表里
caseNumber:'',//病历号 挂号表里
realName:'',//真实姓名 挂号表里
iDnumber:'',//身份证号 挂号表里
birthDate:'',
sex:'',
age:'',
ageType:'',
address:'',
settleID:'',
visitDate:'',
noon:'',
deptID:'',
registLeID: '',
userId: '',
startRegistQuota: '',
usedRegistQuota: '',
isBook:'0',
fee:'',
method:'',
deptCataId:''
},
sexoptions: [],
ageTypeoptions: [{ key: 1,value: '岁'},{key: 2,value: '月'},{key: 3,value: '天'}],
settleIDTypeoptions: [],
methodTypeoptions:[],
deptCataIdoptions:[],//科室一级分类,方便科室二级分类选择
deptIDTypeoptions: [],
noonTypeoptions: [{key:'1',value:'上午'},{key:'2',value:'下午'}],
registLeIDTypeoptions:[],
userIdTypeoptions:[],
rules: {
invoiceNum:[{ required: true, message: '请输入发票号', trigger: 'blur' },
{ min: 2, max: 64, message: '长度在 10 到 64 个字符', trigger: 'blur' }],
caseNumber:[{ required: true, message: '请输入病历号', trigger: 'blur' },
{ min: 2, max: 64, message: '长度在 10 到 64 个字符', trigger: 'blur' }],
realName:[{ required: true, message: '请输入真实姓名', trigger: 'blur' },
{ min: 2, max: 64, message: '长度在 10 到 64 个字符', trigger: 'blur' }]
}
}
},
methods: {
//3、科室做一个下拉 1节课
getDept(){
//alert(this.ruleForm.deptCataId);
let typeId=this.ruleForm.deptCataId;
//选择一级科室,读取该科室下的二级科室
this.$axios.get("http://localhost:8080/sys/dept/findByTypeId?typeId="+typeId)
.then(res=>{
this.deptIDTypeoptions=res.data;
})
},
//选择号别,获取看诊医生
getDoc(){
//4.1选择号别后自动计算应收金额registFee、初始号额registQuota
//alert("号别编号:"+this.ruleForm.registLeID);
let levelid=this.ruleForm.registLeID;//获取用户选择的挂号级别的id
let registLevels=this.registLeIDTypeoptions;//数组类型
//循环页面缓存里的挂号级别数组
for(let i=0;i<registLevels.length;i++){
//用户选择的挂号级别id如果等于指定这条数据的id
if(registLevels[i].id==levelid){
//将选中的挂号级别信息的挂号费和初始号额填充到对应字段中
//alert(registLevels[i].registFee);
//alert(registLevels[i].registQuota);
this.ruleForm.fee=registLevels[i].registFee;
this.ruleForm.startRegistQuota=registLevels[i].registQuota;
}
}
//4.2选择号别后(请求后台)根据日期 午别 科室 号别 查询出看诊医生
// SELECT u.*
// FROM USER u,scheduling s
// WHERE u.id = s.userid
// AND s.schedDate ='2021-01-12'
// AND s.noon ='上午'
// AND u.deptID =1
// AND u.registLeID=1
let visitDate=this.ruleForm.visitDate;
let noon=this.ruleForm.noon;
let deptid=this.ruleForm.deptID;
//let levelid=this.ruleForm.registLeID;
this.$axios.get("http://localhost:8080/user/findUserByParams?schedDate="+visitDate+"&noon="+noon+"&deptID="+deptid+"®istLeID="+levelid
)
.then(res=>{
this.userIdTypeoptions=res.data;
})
},
//选择医生 ,查询这个医生,当天指定午别下的已挂号数量
getMaxNum(){
//获取挂号限额
let max=this.ruleForm.startRegistQuota;
//调用后台进行查询 (汇总挂号信息表)
this.$axios.post("http://localhost:8080/reg/countByParams",this.ruleForm)
.then(res=>{
let count=res.data;
alert(count);
if(count==max){
//提示挂号数量达到限额,不能挂号
this.$message('挂号数量已经达到限额');
}else{
//用这个数量更新已用号额
this.ruleForm.usedRegistQuota=count;
}
})
},
//是否选择病历本
changeFee(){
//alert(this.ruleForm.isBook);
if(this.ruleForm.isBook==1){
this.ruleForm.fee+=5;
}else{
this.ruleForm.fee-=5;
}
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
//alert('submit!');
this.$axios.post("http://localhost:8080/reg/save",this.ruleForm)
.then(res=>{
})
} else {
console.log('error submit!!');
return false;
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
},
datedifference(sDate1, sDate2) { //sDate1和sDate2是2006-12-18格式
var dateSpan,tempDate,iDays;
sDate1 = Date.parse(sDate1);
sDate2 = Date.parse(sDate2);
dateSpan = sDate2 - sDate1;
dateSpan = Math.abs(dateSpan);
iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
return iDays
},
getOther(){
//alert(this.ruleForm.iDnumber);
//1、输入身份证号:联想出出生日期,年令 岁别
//出生日期yyyy-mm-dd
//alert(this.ruleForm.birthDate);
//210111197909290643
let idnumber=this.ruleForm.iDnumber;
let year=idnumber.substring(6,10);
let month=idnumber.substring(10,12);
let day=idnumber.substring(12,14);
let birthday_str=year+"-"+month+"-"+day;
//alert(birthday_str);
this.ruleForm.birthDate=birthday_str;
//思路是计算当前日期和出生日期之间相差的天数
//当前日期的一个yyyy-MM-dd形式
let now=new Date();
let curdate_str=now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
//计算当前日期和出生日期相差的天数
let days=this.datedifference(curdate_str,birthday_str);
//alert(days);
//1、判断这个数是否大于365
if(days>365){//如果大于365 岁别:岁 days/365
this.ruleForm.ageType="岁";
this.ruleForm.age=Math.floor(days/365);
}else{
//2、如果小于365,判断是否大于30天
if(days>30){//如果大于30天,岁别:月 days/30
this.ruleForm.ageType="月";
this.ruleForm.age=Math.floor(days/30);
}else{
//如果小于30,岁别:天 days
this.ruleForm.ageType="天";
this.ruleForm.age=days;
}
}
}
},
mounted() {
//2、性别 结算类型 收费方式 科室一级分类(内科外科)做一个统一接口(常数项分类表) 一节课
//http://localhost:8080/sys/constantItem/findByTypeName?typeName=%E6%80%A7%E5%88%AB%E7%B1%BB%E5%9E%8B
//[{"id":71,"constantTypeID":7,"constantCode":"NAN","constantName":"男","delMark":1},{"id":72,"constantTypeID":7,"constantCode":"NV","constantName":"女","delMark":1}]
this.$axios.get("http://localhost:8080/sys/constantItem/findByTypeName?typeName=性别类型")
.then(res=>{
this.sexoptions=res.data;
})
this.$axios.get("http://localhost:8080/sys/constantItem/findByTypeName?typeName=结算类型")
.then(res=>{
this.settleIDTypeoptions=res.data;
})
this.$axios.get("http://localhost:8080/sys/constantItem/findByTypeName?typeName=收费方式")
.then(res=>{
this.methodTypeoptions=res.data;
})
//科室一级分类deptCataIdoptions
this.$axios.get("http://localhost:8080/sys/constantItem/findByTypeName?typeName=科室分类")
.then(res=>{
this.deptCataIdoptions=res.data;
})
//registLeIDTypeoptions
//4、号别下拉
this.$axios.get("http://localhost:8080/sys/registlevel/findAll")
.then(res=>{
this.registLeIDTypeoptions=res.data;
})
}
}
</script>
<style>
</style>
后台关键代码
- 存储后立刻拿到id
public interface RegisterMapper {
@Select(" select count(1) "+
" from register "+
" where visitState<>4 "+
" and userId=#{userId} "+
" and visitDate=#{visitDate} "+
" and noon=#{noon}")
int countByParams(Map<String, Object> map);
@Insert("insert into register values(null,#{caseNumber},#{realName},#{gender},#{iDnumber},#{birthDate},#{age},#{ageType},#{homeAddress},#{visitDate},#{noon},#{deptID},#{userID},#{registLeID},#{settleID},#{isBook},#{registTime},#{registerID},#{visitState})")
@Options(useGeneratedKeys=true,keyProperty="id",keyColumn="id")
int save(Register reg);
}
- 事务(待完成)
step 1 主启动类加@EnableTransactionManagement
step 2service实现类加@Transactional(rollbackFor={RuntimeException.class,Exception.class})
step 3改造service方法,捕获异常时抛出
@Override
public ResponseBean save(Map<String, Object> map) throws Exception {
ResponseBean res=null;
try {
//跟挂号信息相关的存储到挂号信息表
Register reg=new Register();
reg.setAge((Integer) map.get("age"));
reg.setAgeType( (String) map.get("ageType"));
reg.setBirthDate((String) map.get("birthDate"));
reg.setCaseNumber((String) map.get("caseNumber"));
reg.setDeptID((Integer) map.get("deptID"));
reg.setGender((Integer) map.get("sex"));
reg.setHomeAddress((String) map.get("address"));
reg.setiDnumber((String) map.get("iDnumber"));
reg.setIsBook((String) map.get("isBook"));
reg.setNoon((String) map.get("noon"));
reg.setRealName((String) map.get("realName"));
//reg.setRegisterID(registerID);
reg.setRegistLeID((Integer) map.get("registLeID"));
reg.setRegistTime(new Date());
reg.setSettleID((Integer) map.get("settleID"));
reg.setUserID((Integer) map.get("userId"));
reg.setVisitDate(new Date());
int i=mapper.save(reg);
int regist_id=reg.getId();
System.out.println(regist_id);
//int j=0;
//double k=1/j;
//跟发票相关的存到收据表
//跟费用明细相关的存储到费用明细表
} catch (Exception e) {
throw new Exception(e.getMessage());
}
return res;
}