目标
本章节主要练习前台界面开发
- 挂号界面
- 挂号逻辑前后台实现
挂号界面
我选择的是layout下的混合布局
components/neuregist/GuaHao.vue
<template>
<div align="left">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-row :gutter="2">
<el-col :span="6">
<!-- <div class="grid-content bg-purple">门诊挂号管理</div> -->
<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 :gutter="2">
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="发票号:" prop="invoiceNumber">
<el-input v-model="ruleForm.invoiceNumber" size="mini" align="left" ></el-input>
</el-form-item>
</div>
</el-col>
</el-row>
<el-row :gutter="3">
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="病历号:" prop="caseNumber">
<el-input v-model="ruleForm.caseNumber" size="mini" align="left" ></el-input>
</el-form-item>
</div>
</el-col>
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="姓名:" prop="realName">
<el-input v-model="ruleForm.realName" size="mini" align="left"></el-input>
</el-form-item>
</div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple">
<el-form-item label="性别" prop="gender">
<el-select v-model="ruleForm.gender" placeholder="选择">
<el-option v-for="item in genders" :key="item.id" :label="item.constantName" :value="item.id"></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple">
<el-form-item label="年龄:" prop="age" align="left">
<el-input v-model="ruleForm.age" size="mini"></el-input>
</el-form-item>
</div>
</el-col>
<el-col :span="4">
<div class="grid-content bg-purple">
<el-form-item label="岁别" prop="ageType">
<el-select v-model="ruleForm.ageType" placeholder="">
<el-option label="岁" value="岁"></el-option>
<el-option label="月" value="月"></el-option>
<el-option label="天" value="天"></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
</el-row>
<el-row :gutter="3">
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item prop="date1" label="出生日期:">
<el-date-picker type="date" placeholder="出生日期" v-model="ruleForm.birthDate" style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
</el-form-item>
</div>
</el-col>
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="身份证号:" prop="iDnumber" align="left">
<el-input v-model="ruleForm.iDnumber" size="mini"></el-input>
</el-form-item>
</div>
</el-col>
<el-col :span="12">
<div class="grid-content bg-purple">
<el-form-item label="家庭住址:" prop="homeAddress" align="left">
<el-input v-model="ruleForm.homeAddress" size="mini"></el-input>
</el-form-item>
</div>
</el-col>
</el-row>
<el-row :gutter="3">
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="结算类别" prop="ageType">
<el-select v-model="ruleForm.settleId" placeholder="请选择">
<!--这个需要查询库-->
<el-option v-for="item in settles" :key="item.id" :label="item.constantName" :value="item.id"></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
<!--以下级联开始-->
<!-- 1根据看诊日期查午别-->
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item prop="date1" label="看诊日期:">
<el-date-picker type="date" placeholder="看诊日期" value-format="yyyy-MM-dd" v-model="ruleForm.visitDate" style="width: 100%;" @change="kzrq_select()"></el-date-picker>
</el-form-item>
</div>
</el-col>
<!-- 2根据看诊日期、午别查科室 -->
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="午别" prop="noon">
<el-select v-model="ruleForm.noon" placeholder="请选择" @change="noon_select()">
<!--这个需要根据上面的选择动态加载出来-->
<el-option v-for="item in noons" :key="item.noon" :label="item.noon" :value="item.noon"></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
<!-- 3根据看诊日期、午别、科室 查号别-->
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="挂号科室:" prop="noon">
<el-select v-model="ruleForm.deptId" placeholder="请选择" @change="dept_select()">
<!--这个需要根据上面的选择动态加载出来-->
<el-option v-for="item in depts" :key="item.DeptID" :label="item.DeptName" :value="item.DeptID"></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
</el-row>
<el-row :gutter="3">
<!-- 4根据看诊日期、午别、科室、号别查医生-->
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="号别:" prop="registLeId">
<el-select v-model="ruleForm.registLeId" placeholder="请选择" @change="registLe_select()">
<!--这个需要根据上面的选择动态加载出来-->
<el-option v-for="item in registLevels" :key="item.ID" :label="item.RegistName" :value="item.ID"></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
<!--级联
* 5查已用挂号额度,查挂号额度 查挂号费
* -->
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="看诊医生:" prop="userId">
<el-select v-model="ruleForm.userId" placeholder="请选择" @change="user_select()">
<!--这个需要根据上面的选择动态加载出来-->
<el-option v-for="item in users" :key="item.id" :label="item.realName" :value="item.id"></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="初始号额:" prop="cshe">
<el-input v-model="ruleForm.cshe" size="mini" placeholder="初始号额" readonly></el-input>
</el-form-item>
</div>
</el-col>
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="已用号额:" prop="yyhe">
<el-input v-model="ruleForm.yyhe" size="mini" placeholder="已用号额" readonly></el-input>
</el-form-item>
</div>
</el-col>
</el-row>
<el-row :gutter="3">
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="病历本:" prop="isBook">
<input type="checkbox" v-model="ruleForm.isBook" true-value="1" false-value="0" @change="book_select()"></input>
</el-form-item>
</div>
</el-col>
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="应收金额:" prop="fee">
<el-input v-model="ruleForm.fee" size="mini" align="left"></el-input>
</el-form-item>
</div>
</el-col>
<el-col :span="6">
<div class="grid-content bg-purple">
<el-form-item label="收费方式:" prop="feeType">
<el-select v-model="ruleForm.feeType" placeholder="请选择" >
<!--这个需要根据上面的选择动态加载出来-->
<el-option v-for="item in constantTypes" :key="item.id" :label="item.constantName" :value="item.id"></el-option>
</el-select>
</el-form-item>
</div>
</el-col>
</el-row>
</el-form>
</div>
</template>
<script>
export default {
data() {
return {
ruleForm: {
invoiceNumber: '',//发票编号
realName: '',//真实姓名
gender: '',//性别
age: '',//年令
ageType: '',//年令类型
birthDate:'',//出生日期
iDnumber:'',//身份证号
homeAddress:'',//家庭住址
settleId:'',//结算类别 1自费/2市医保
visitDate:'',//看诊日期
noon:'',//午别
deptId:'',//科室id
registLeId:'',//挂号级别id
userId:'',//医生id
cshe:'',//初始号额
yyhe:'',//已用号额
isBook:'0',//病历本要否
fee:0, //应收金额
feeType:51,// 收费方式51-现金52-医保卡
registerId:''//用户编号
},
genders:[],
settles:[],
noons:[],
depts:[],
registLevels:[],
users:[],
constantTypes:[],
rules: {
//todo
}
};
},
methods: {
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
alert('submit!');
alert(this.ruleForm);
} else {
console.log('error submit!!');
return false;
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
},
blhcx(){
//select * from register where casenumber=?
alert("生成病历号");
//根据casenumber到register 表里查询用户基本信息
//如果存在就更新用户住址,真实姓名,身份证号,性别,agetype,age,生日等
},
kzrq_select(){
alert("第一步按排班日期查午别");
},
noon_select(){
alert("第二步根据日期和午别查科室");
},
dept_select(){
alert("第三步根据日期午别 科室查号别");
},
registLe_select(){
alert("第四步根据日期午别 科室 号别查医生");
},
user_select(){
alert("第五步根据日期午别 科室 号别医生查已用挂号额度 挂号额度和挂号费");
},
book_select(){
alert("根据是否选择了病历本计算费用");
}
}
}
</script>
<style>
.el-row {
margin-bottom: 0px;
&:last-child {
margin-bottom: 0;
}
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf;
}
.bg-purple {
background: #d3dce6;
}
.bg-purple-light {
background: #e5e9f2;
}
.grid-content {
border-radius: 4px;
min-height: 20px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc;
}
</style>
详细分析需求
-
初始加载项
1、最大病历号(也可以通过事件触发)
2、性别常量
3、结算类别
4、收费方式 -
级联加载项(6步)
5、kzrq_select(){
alert("第一步按排班日期查午别");
},
6、noon_select(){
alert("第二步根据日期和午别查科室");
},
7、dept_select(){
alert("第三步根据日期午别 科室查号别");
},
8、registLe_select(){
alert("第四步根据日期午别 科室 号别查医生");
},
9、user_select(){
alert("第五步根据日期午别 科室 号别医生查已用挂号额度 挂号额度和挂号费");
},
10、book_select(){
alert("根据是否选择了病历本计算费用");
}
分步开发Register.vue
mounted下增加:
mounted: function() {
let userId = sessionStorage.getItem("userId");
this.ruleForm.registerId = userId;
this.refresh();//初始化变量
}
methods下增加
refresh(){
var $this=this;
//alert("进入初始化程序");
//1、最大病历号(也可以通过事件触发)
//2、性别常量
//3、结算类别
//4、收费方式
}
1、最大病历号(也可以通过事件触发)###
前台Register.vue:##
refresh(){
var $this=this;
//alert("进入初始化程序");
//1、最大病历号(也可以通过事件触发)
this.$axios.get("http://localhost:8082/neureg/register/maxCasenumber")
.then(response=>{
$this.ruleForm.caseNumber=response.data+1;
})
//2、性别常量
//3、收费方式
//4、结算类别
}
后台挂号信息对象 Bean:
package com.neuedu.demo.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.format.annotation.DateTimeFormat;
/**
* 挂号信息对象 Bean
*
*/
@Entity
@Table(name="register")
public class Register {
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Id
private int id;
@Column(name = "realName", nullable = true, length = 64)
private String realName;
@Column(name = "gender", nullable = true, length = 9)
private int gender;
@Column(name = "iDnumber", nullable = true, length = 18)
private String iDnumber;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private String birthDate;
@Column(name = "age", nullable = true, length = 9)
private int age;
@Column(name = "ageType", nullable = true, length = 1)
private String ageType;
@Column(name = "homeAddress", nullable = true, length = 64)
private String homeAddress;
@Column(name = "caseNumber", nullable = true, length = 64)
private String caseNumber;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private String visitDate;
@Column(name = "noon", nullable = true, length = 2)
private String noon;
@Column(name = "deptId", nullable = true, length = 9)
private String deptId;
@Column(name = "userId", nullable = true, length = 9)
private String userId;
@Column(name = "registLeId", nullable = true, length = 9)
private String registLeId;
@Column(name = "settleId", nullable = true, length = 9)
private String settleId;
@Column(name = "isBook", nullable = true, length = 1)
private String isBook;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String registTime;
@Column(name = "registerId", nullable = true, length = 32)
private String registerId;
/*1-已挂号
2-医生接诊
3-看诊结束
4-已退号*/
@Column(name = "visitState", nullable = true, length = 9)
private String visitState="1";
}
controller
package com.neuedu.demo.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neuedu.demo.service.IRegistService;
@RestController
@RequestMapping("/neureg/register")
public class RegisterController {
@Autowired
IRegistService registService;
@RequestMapping("/maxCasenumber")
public int maxCasenumber(){
int max=0;
Object o=registService.getMaxCaseNumber();
if(o!=null&&!o.equals("")){
max=(int) o;
}
return max;
}
}
service略
dao:
package com.neuedu.demo.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import com.neuedu.demo.domain.Register;
public interface RegisterRepository extends JpaRepository<Register, Integer> {
@Query(value="select max(caseNumber) from register",nativeQuery=true)
Object getMaxCaseNumber();
}
2、性别常量3、收费方式4、结算类别
这三类常量信息均从常数项分类表里读取
refresh里新增加
//2、性别常量constantitem表里分类为7的
this.$axios.get('http://localhost:8082/sys/findByType?id=7')
.then(response=>{
$this.genders=response.data;
})
//3、收费方式
this.$axios.get('http://localhost:8082/sys/findByType?id=5')
.then(response=>{
$this.constantTypes=response.data;
})
//4、结算类别
this.$axios.get('http://localhost:8082/sys/findByType?id=17')
.then(response=>{
$this.settles=response.data;
})
5、kzrq_select按排班日期查午别
选择看诊日期后触发
select distinct noon
from scheduling a
where a.SchedDate='2019-04-01'
order by noon
-
前台
kzrq_select(){ alert("第一步按排班日期查午别"); var $this=this; this.$axios.get("http://localhost:8082/neusys/scheduling/getNoon?schedDate="+this.ruleForm.visitDate) .then(response=>{ $this.noons=response.data; }) }
-
后台-关键代码
package com.neuedu.demo.controller;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neuedu.demo.service.ISchedulingServcie;
@RestController
@RequestMapping("/neusys/scheduling")
public class SchedulingController {
@Autowired
ISchedulingServcie schedulingServiceImpl;
@RequestMapping("/getNoon")
public List<Map<String,Object>> getNoon(String schedDate){
List<Map<String,Object>> list=schedulingServiceImpl.getNoon(schedDate);
return list;
}
}
package com.neuedu.demo.dao;
import java.util.List;
import java.util.Map;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import com.neuedu.demo.domain.Register;
public interface SchedulingRepository extends JpaRepository<Register, Integer>{
@Query(value="select distinct noon "+
"from scheduling a "+
"where a.SchedDate=?1 "+
"order by noon",nativeQuery=true)
List<Map<String, Object>> getNoon(String visitDate);
}
6、noon_select根据日期和午别查科室
SELECT distinct a.DeptID,b.DeptName
from scheduling a,department b
where a.DeptID=b.ID
and a.SchedDate='2019-04-01'
and a.Noon='上午'
order by deptid
-
前台
noon_select(){ alert("第二步根据日期和午别查科室"); //scheduling里携带着科室信息 var $this=this; this.$axios.get("http://localhost:8082/neusys/scheduling/getDept?schedDate="+this.ruleForm.visitDate+"&noon="+this.ruleForm.noon) .then(response=>{ $this.depts=response.data; }) }
-
后台-关键代码
-
SchedulingController
@RequestMapping("/getDept")
public List<Map<String,Object>> getDept(String schedDate,String noon){
List<Map<String,Object>> list=schedulingServiceImpl.getDept(schedDate,noon);
return list;
}
-
SchedulingRepository
@Query(value=" SELECT distinct a.DeptID,b.DeptName "+ " from scheduling a,department b "+ " where a.DeptID=b.ID "+ " and a.SchedDate=?1 "+ " and a.Noon=?2 "+ " order by deptid",nativeQuery=true) List<Map<String, Object>> getDept(String schedDate, String noon);
7、dept_select根据日期午别 科室查号别
在用户表 排班表 挂号级别表之间关联基础上,根据日期,午别,科室查号别
SELECT distinct c.RegistName,c.ID
from scheduling a,
user b,
registlevel c
where a.UserID=b.id
and b.registLeid=c.ID
and a.SchedDate='2019-04-01'
and a.noon='上午'
and a.DeptID='1'
and b.isScheduling='true'
- 前台
dept_select(){
alert("第三步根据日期午别 科室查号别");
var $this=this;
this.$axios.get("http://localhost:8082/neusys/scheduling/getRegist?schedDate="+this.ruleForm.visitDate+"&noon="+this.ruleForm.noon+"&deptid="+this.ruleForm.deptId)
.then(response=>{
$this.registLevels=response.data;
})
}
- 后台关键代码
@RequestMapping("/getRegist")
public List<Map<String,Object>> getRegist(String schedDate,String noon,String deptid){
List<Map<String,Object>> list=schedulingServiceImpl.getRegist(schedDate,noon,deptid);
return list;
}
@Query(value=" SELECT c.RegistName,c.ID "+
" from scheduling a, "+
" user b, "+
" registlevel c "+
" where a.UserID=b.id "+
" and b.registLeid=c.ID "+
" and a.SchedDate=?1 "+
" and a.noon=?2 "+
" and a.DeptID=?3 "+
" and b.isScheduling='true'",nativeQuery=true)
List<Map<String, Object>> getRegist(String schedDate, String noon, String deptid);
8、registLe_select根据日期午别 科室 号别查医生
(假设号别选1-专家号)
SELECT b.id,b.realName
from scheduling a,
user b,
registlevel c
where a.UserID=b.id
and b.registLeid=c.ID
and a.SchedDate='2019-04-01'
and a.noon='上午'
and a.DeptID='1'
and b.isScheduling='true'
and c.id='1'
-
前台
registLe_select(){ alert("第四步根据日期午别 科室 号别查医生"); var $this=this; this.$axios.get("http://localhost:8082/neusys/scheduling/getDoc?schedDate="+this.ruleForm.visitDate+"&noon="+this.ruleForm.noon+"&deptid="+this.ruleForm.deptId+"®istLeId="+this.ruleForm.registLeId) .then(response=>{ $this.users=response.data; }) }
-
后台关键代码
@RequestMapping("/getDoc")
public List<Map<String,Object>> getDoc(String schedDate,String noon,String deptid,String registLeId){
List<Map<String,Object>> list=schedulingServiceImpl.getDoc(schedDate,noon,deptid,registLeId);
return list;
}
@Query(value=" SELECT b.id,b.realName "+
" from scheduling a, "+
" user b, "+
" registlevel c "+
" where a.UserID=b.id "+
" and b.registLeid=c.ID "+
" and a.SchedDate=?1 "+
" and a.noon=?2 "+
" and a.DeptID=?3 "+
" and b.isScheduling='true' "+
" and c.id=?4",nativeQuery=true)
List<Map<String, Object>> getDoc(String schedDate, String noon, String deptid, String registLeId);
9、user_select 根据日期午别 科室 号别医生查 挂号限额 已用挂号额度和挂号费
即查询挂号表register里该医生今天已经挂号的记录数量(本次看诊状态不为4)
- 挂号限额(初始号额)
- 挂号费
用户的挂号级别与挂号级别表关联即可查询出每日挂号限额和挂号费
RegistLevel (挂号级别表RegistQuota)
SELECT distinct b.RegistQuota,b.RegistFee
from user a,registlevel b,scheduling c
where a.registLeid=b.ID
and a.id=c.userId
and c.SchedDate='2019-04-01'
and c.Noon='上午'
and a.isScheduling='true'
and a.id=1
RegistQuota为挂号限额
RegistFee为挂号费
- 已用挂号额度
select count(*)
from register
where VisitState<>4
and VisitDate='2019-04-01'
and noon='上午'
and userId='1'
-
前台
user_select(){ alert("第五步根据日期午别 科室 号别医生查挂号额度 已用挂号额度 和挂号费"); var $this=this; //挂号额度和挂号费 this.$axios.get("http://localhost:8082/neusys/scheduling/getRegistDetail?schedDate="+this.ruleForm.visitDate+"&noon="+this.ruleForm.noon+"&userId="+this.ruleForm.userId) .then(response=>{ /* 返回格式[{"RegistFee":50.00,"RegistQuota":20}] */ $this.ruleForm.cshe=response.data[0].RegistQuota; $this.ruleForm.fee=parseInt(response.data[0].RegistFee); }) //已用额度 this.$axios.get("http://localhost:8082/neureg/register/getCountByUserIdAndTime?schedDate="+this.ruleForm.visitDate+"&noon="+this.ruleForm.noon+"&userId="+this.ruleForm.userId) .then(response=>{ $this.ruleForm.yyhe=response.data; }) },
-
后台
-
SchedulingController
@RequestMapping("/getRegistDetail")
public List<Map<String,Object>> getRegistDetail(String schedDate,String noon,String userId){
List<Map<String,Object>> list=schedulingServiceImpl.getRegistDetail(schedDate,noon,userId);
return list;
}
- SchedulingRepository
@Query(value=" SELECT distinct b.RegistQuota,b.RegistFee "+
" from user a,registlevel b,scheduling c "+
" where a.registLeid=b.ID "+
" and a.id=c.userId "+
" and c.SchedDate=?1 "+
" and c.Noon=?2 "+
" and a.isScheduling='true' "+
" and a.id=?3 ",nativeQuery=true)
List<Map<String, Object>> getRegistDetail(String schedDate, String noon, String userId);
-
RegisterController
@RequestMapping("/getCountByUserIdAndTime") public Object getCountByUserIdAndTime(String schedDate,String noon,String userId){ Object o=registService.getCountByUserIdAndTime(schedDate,noon,userId); return o; }
-
RegisterRepository
@Query(value = "select count(*) from register where VisitState<>4 and VisitDate=?1 and noon=?2 and userId=?3", nativeQuery = true)
Object getCountByUserIdAndTime(String schedDate, String noon, String userId);
注意挂号时需要判断已用号额是否达到限制
10、book_select根据是否选择了病历本计算费用
根据该选项的值计算费用
book_select(){
alert("根据是否选择了病历本计算费用,选择了病历本则this.ruleForm.isBook==1");
if(this.ruleForm.fee==0){
this.ruleForm.isBook="";
return;
}
if(this.ruleForm.isBook=="1"){
this.ruleForm.fee=parseFloat(this.ruleForm.fee)+1;
}else{
this.ruleForm.fee=parseFloat(this.ruleForm.fee)-1;
}
}
至此,全部字段填写完毕,可以做真正的挂号了
点击挂号按钮,进行挂号
Register里增加三个字段及get/set,但这三个字段只用于传递值 ,不存库用@Transient (短暂的,暂存之之意)
@Transient
private String feeType;
@Transient
private String invoiceNumber;
@Transient
private String fee;
-
前台
submitForm(formName) { this.$refs[formName].validate((valid) => { if (valid) { //alert('submit!'); //请求后台添加用户axios this.$axios.post('http://localhost:8082/neureg/register/add',this.ruleForm,{headers: { 'Content-Type': 'application/json;charset=UTF-8' }}) .then(response=>{ alert(response.data.msg); }) .catch(error=>{ alert(error); }) } else { console.log('error submit!!'); return false; } }); },
-
后台
-
RegisterController
@RequestMapping("/add")
public ResponseBean add(@RequestBody Register register ) {
ResponseBean resp = new ResponseBean();
System.out.println(register);
//持久化到挂号表、发票表、费用表,返回挂号表记录主键
int id=registService.addRegister(register);
if(id>0){
resp.setCode("0");
resp.setMsg("挂号成功");
}else{
resp.setCode("-1");
resp.setMsg("挂号失败");
}
return resp;
}
@Override
public int addRegister(Register register) {
// 挂号信息存到挂号表
Register reg = registerRepository.save(register);
// 获取刚生成的挂号记录主键,用于后面存储用
int reg_id = reg.getId();
Date reg_time = new Date();
// 费用信息存到费用明细表
// 并获取记录的id
int invo_id = saveInvoice(register, reg_id, reg_time);
int pc = savePatientcost(register, reg_id, invo_id, reg_time);
return reg_id;
}
private int savePatientcost(Register register, int reg_id, int invo_id, Date reg_time) {
Patientcost p = new Patientcost();
p.setRegisterID(reg_id);
p.setInvoiceID(invo_id);
p.setName("挂号费");
p.setPrice(new BigDecimal(register.getFee()));
p.setDeptID(Integer.parseInt(register.getDeptId()));
p.setItemID(1);// 1-挂号费
p.setItemType(1);// 1-非药品 2-药品
p.setAmount(new BigDecimal(1));
p.setCreatetime(reg_time);
p.setPayTime(reg_time);
p.setCreateOperID(Integer.parseInt(register.getRegisterId()));
p.setRegisterID(Integer.parseInt(register.getRegisterId()));
p.setFeeType(Integer.parseInt(register.getFeeType()));
patientcostRepository.save(p);
return 0;
}
private int saveInvoice(Register register, int reg_id, Date reg_time) {
// 发票信息存到发票表(收据表)
Invoice invo = new Invoice();
invo.setInvoiceNum(register.getInvoiceNumber());
invo.setMoney(new BigDecimal(register.getFee()));
invo.setState(3);
invo.setCreationTime(reg_time);
invo.setRegistId(reg_id);
invo.setFeeType(Integer.parseInt(register.getFeeType()));
invo.setDailyState("0");
Invoice db_invo = invoiceRepository.save(invo);
return db_invo.getId();
}
网友评论