美文网首页
12、医生排班

12、医生排班

作者: wqjcarnation | 来源:发表于2019-11-04 11:13 被阅读0次

目标

  • 查询医生排班
  • 新增排班规则
  • 生成排班计划

重要知识

  • 批量添加

查询医生排班

页面


image.png

1、查询医生排班前台Scheduling.vue

    <template>

        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <span>医生排班管理</span>
            </div>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-row>
                    <el-col :span="6">
                        <el-form-item prop="startDate" label="开始时间">
                            <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.startDate" style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item prop="endDate" label="结束时间">
                            <el-date-picker placeholder="选择时间" v-model="ruleForm.endDate" style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="1">&nbsp;
                    </el-col>
                    <el-col :span="11">
                        <el-button style="float: left; padding: 5px 0" type="primary" @click="findAll()">查询排班医生</el-button>
                        <el-button style="float: left; padding: 5px 0" type="primary" @click="newRule()">新增排班规则</el-button>
                        <el-button style="float: left; padding: 5px 0" type="primary">查询排班规则(生成排班计划)</el-button>
                    </el-col>
                </el-row>
            </el-form>
            <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55">
                </el-table-column>
                <el-table-column prop="SchedDate" label="时间" width="120">
                </el-table-column>
                <el-table-column label="午别" width="120">
                    <template slot-scope="scope">{{ scope.row.Noon }}</template>
                </el-table-column>
                <el-table-column prop="DeptName" label="科室" width="120">
                </el-table-column>
                <el-table-column prop="realName" label="真实姓名" width="120">
                </el-table-column>
            </el-table>
            <el-row>
                <el-col :span="5">
                    <div id="btu">
                        <el-button @click="delBatch" type="danger">批量删除</el-button>
                    </div>
                </el-col>
                <el-col :span="10">
                    <el-pagination background layout="prev, pager, next" @current-change="changePage" :page-size="pageSize" :total="total">
                    </el-pagination>
                </el-col>

            </el-row>
            </div>
            </el-form>
        </el-card>
    </template>
    <script>
        export default {
            data() {
                return {
                    tableData: [],
                    currentPage: 1,
                    pageSize: 5,
                    total: 0,
                    multipleSelection: [],
                    ruleForm: {
                        startDate: '',
                        endDate: ''
                    },
                    rules: {

                    }
                };
            },
            methods: {
                toggleSelection(rows) {
                    if (rows) {
                        rows.forEach(row => {
                            this.$refs.multipleTable.toggleRowSelection(row);
                        });
                    } else {
                        this.$refs.multipleTable.clearSelection();
                    }
                },
                changePage: function(currentPage) {
                    //alert("下一页");
                    //更新当前页页码
                    this.currentPage = currentPage;
                    //再重新请求后台
                    this.findAll();
                },
                handleSelectionChange(val) {
                this.multipleSelection=val;
                        },
                findAll() {
                    //用axios请求后台,查询所有数据
                    this.$axios.get('http://localhost:8082/neusys/scheduling/findAll', {
                            params: {
                                currentPage: this.currentPage,
                                pageSize: this.pageSize,
                                startDate: this.ruleForm.startDate,
                                endDate: this.ruleForm.endDate
                            }
                        })
                        .then(response => {
                            //如果响应成功,把列表数据放到tableData里
                            this.tableData = response.data.list;
                            this.total = response.data.totalCount;
                        })

                },
                delBatch() {
                }
            },
            mounted() {
                //alert("初始加载");
                this.findAll();
            }
        }
    </script>
    <style>
        .text {
            font-size: 14px;
        }

        .item {
            margin-bottom: 5px;
        }

        .box-card {
            width: 100%;
            text-align: left;
        }
    </style>

2、查询医生排班后台

SchedulingController

@RequestMapping("/findAll")
public Map<String,Object> findAll(@RequestParam(value="currentPage",defaultValue="1",required=false)int currentPage,
        @RequestParam(value="pageSize",defaultValue="10",required=false) int pageSize,String startDate,String endDate){
    long totalCount=schedulingServiceImpl.getSchedulingCount(startDate,endDate);
    List<Map<String,Object>> plist=schedulingServiceImpl.findAll(currentPage,pageSize,startDate,endDate);
    Map<String,Object> map=new HashMap<>();
    map.put("totalCount", totalCount);
    map.put("list", plist);
    return map;
    
}

SchedulingServcieImpl

@Override
public long getSchedulingCount(String startDate, String endDate) {
    long count=0;
    if(startDate==null||endDate==null||startDate.equals("")||endDate.equals("")){
        count=schedulingRepository.getSchedulingCount();
    }else{
        count=schedulingRepository.getSchedulingCount(startDate,endDate);
    }
    return count;
}
@Override
public List<Map<String, Object>> findAll(int currentPage, int pageSize, String startDate, String endDate) {
    int start=(currentPage-1)*pageSize;
    if(startDate==null||endDate==null||startDate.equals("")||endDate.equals("")){
        return schedulingRepository.getSchedulingList(start,pageSize);
    }else{
        return schedulingRepository.getSchedulingList(start,pageSize,startDate,endDate);
    }
}
  • SchedulingRepository

      @Query(value=" select count(*)  "+
              " from scheduling a,user b "+
              " where a.UserID=b.id "+
              " and b.isScheduling='true'",nativeQuery=true)
      long getSchedulingCount();
      @Query(value=" select count(*)  "+
              " from scheduling a,user b "+
              " where a.UserID=b.id "+
              " and b.isScheduling='true'"+
              " and a.SchedDate BETWEEN ?1 and ?2",nativeQuery=true)
      long getSchedulingCount(String startDate, String endDate);
      @Query(value="select a.SchedDate,c.DeptName,b.realName,a.Noon "+
              "from scheduling a,user b,department c,registlevel d   "+
              "where a.UserID=b.id  "+
              "and a.DeptID=c.ID  "+
              "and b.registLeid=d.ID  "+
              "and b.isScheduling='true'  "+
              "order by SchedDate desc limit ?1,?2",nativeQuery=true)
      List<Map<String, Object>> getSchedulingList(int start, int pageSize);
      @Query(value="select a.SchedDate,c.DeptName,b.realName,a.Noon "+
              " from scheduling a,user b,department c,registlevel d   "+
              " where a.UserID=b.id  "+
              " and a.DeptID=c.ID  "+
              " and b.registLeid=d.ID  "+
              " and b.isScheduling='true'  "+
              " and a.SchedDate BETWEEN ?3 and ?4 "+
              " order by SchedDate desc limit ?1,?2",nativeQuery=true)
      List<Map<String, Object>> getSchedulingList(int start, int pageSize, String startDate, String endDate);
    

学生完成以下功能
页面参照


image.png

新增排班规则

image.png

前台 Scheduling.vue新增

           <!--新增排班规则开始-->
                            <el-dialog title="新增排班规则" :visible.sync="dialogVisible" width="90%">
        <el-form :model="ruleForm1" :rules="rules" ref="ruleForm1" label-width="100px" class="demo-ruleForm">
            <el-row :gutter="3">
                <el-col :span="5">
                    <el-form-item label="科室选择:" prop="noon">
                        <el-select v-model="ruleForm1.deptId" placeholder="请选择">
                            <!--这个需要根据上面的选择动态加载出来-->
                            <el-option v-for="item in depts" :key="item.id" :label="item.deptName" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="5">
                    <el-form-item label="挂号级别:" prop="registLeId">
                        <el-select v-model="ruleForm1.registLeId" placeholder="请选择">
                            <!--这个需要根据上面的选择动态加载出来-->
                            <el-option v-for="item in registLevels" :key="item.registName" :label="item.registName" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm1')">查询</el-button>
                        <el-button @click="resetForm('ruleForm1')">清空</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        
        <!--排班星期多选 -->
        <el-table ref="multipleTable" :data="tableData2" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55">
            </el-table-column>
            <el-table-column label="医生编号" width="100" prop="id">
            </el-table-column>
            <el-table-column label="医生名称" width="100" prop="realName">
            </el-table-column>
            <el-table-column label="一上" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X10" v-model="tableData2[scope.$index].X10" true-value='1' false-value="0" />
                </template>
            </el-table-column>

            <el-table-column label="一下" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X11" v-model="tableData2[scope.$index].X11" true-value='1' false-value="0" />
                </template>
            </el-table-column>
            <el-table-column label="二上" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X20" v-model="tableData2[scope.$index].X20" true-value='1' false-value="0" />
                </template>
            </el-table-column>
            <el-table-column label="二下" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X21" v-model="tableData2[scope.$index].X21" true-value='1' false-value="0" />
                </template>
            </el-table-column>

            <el-table-column label="三上" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X30"  v-model="tableData2[scope.$index].X30"true-value='1' false-value="0" />
                </template>
            </el-table-column>

            <el-table-column label="三下" width="70"  align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X31" v-model="tableData2[scope.$index].X31" true-value='1' false-value="0" />
                </template>
            </el-table-column>


            <el-table-column label="四上" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X40"  v-model="tableData2[scope.$index].X40" true-value='1' false-value="0" />
                </template> </el-table-column>

            <el-table-column label="四下" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X41"  v-model="tableData2[scope.$index].X41" true-value='1' false-value="0" />
                </template> </el-table-column>


            <el-table-column label="五上" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X50"  v-model="tableData2[scope.$index].X50"  true-value='1' false-value="0" />
                </template> </el-table-column>


            <el-table-column label="五下" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X51"  v-model="tableData2[scope.$index].X51" true-value='1' false-value="0" />
                </template> </el-table-column>


            <el-table-column label="六上" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X60" v-model="tableData2[scope.$index].X60"  true-value='1' false-value="0" />
                </template> </el-table-column>
            <el-table-column label="六下" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X61"  v-model="tableData2[scope.$index].X61" true-value='1' false-value="0" />
                </template> </el-table-column>
            <el-table-column label="日上" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X70"  v-model="tableData2[scope.$index].X70"  true-value='1' false-value="0" />
                </template> </el-table-column>
            <el-table-column label="日下" width="70" align="center">
                <template slot-scope="scope">
                    <input type="checkbox" prop="X71"  v-model="tableData2[scope.$index].X71" true-value='1' false-value="0" />
                </template> </el-table-column>
        </el-table><br>
              规则名称:
                <el-input size="mini" placeholder="规则名称" v-model="ruleForm1.gzmc" align="left" style="width:120px"></el-input>
            <br>
                <el-button type="primary" @click="gzSave()">保存</el-button>
                <el-button @click="resetForm('ruleForm1')">清空</el-button>
        <!-- -->
      </el-form>
    </el-dialog>
    <!--新增排班规则结束-->
    。。。。。。

data() {
        return {
            dialogVisible: false,
            tableData: [],
            tableData2: [], //排班选框
            currentPage: 1,
            pageSize: 5,
            total: 0,
            multipleSelection: [],
            ruleForm: {
                startDate: '',
                endDate: ''
            },
            ruleForm1: {
                deptId: '',
                registLeId: '',
                gzmc: ''
            },
            depts: [],
            registLevels: [],
            weeks:[],
            rules: {

            }
        };

初始化加载科室和挂号级别

methods里新增:

            newRule(){
            //"加载科室"
            var $this=this;
            this.$axios.get("http://localhost:8082/department/findDepartment")
            .then(response=>{
                $this.depts=response.data;
            })
            this.$axios.get("http://localhost:8082/registlevel/getRegistlevels")
            .then(response=>{
                $this.registLevels=response.data;
            })
            //加载挂号级别
            this.dialogVisible=true;
            
        }

点击查询按钮执行:submitForm

根据部门编号和挂号级别查询医生信息
相关查询语句:

    SELECT a.*,
    "0" X10,
    "0" X11,
    "0" X20,
    "0" X21,
    "0" X30,
    "0" X31,
    "0" X40,
    "0" X41,
    "0" X50,
    "0" X51,
    "0" X60,
    "0" X61,
    "0" X70,
    "0" X71
    from user a
    where a.deptId='1'
    and a.registLeid='1'
    and delMark='1'


        submitForm(formName) {
            var $this = this;
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    //alert("科室id"+this.ruleForm1.deptId);
                    //alert("挂号级别"+this.ruleForm1.registLeId)
                    //查询完更新tabledata2的内容
                    this.$axios.get("http://localhost:8082/reg/findUserByDeptAndRegistLeId?deptId=" + this.ruleForm1.deptId +
                            "&registLeId=" + this.ruleForm1.registLeId)
                        .then(response => {
                            $this.tableData2 = response.data;
                        })

                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        }

@RequestMapping("/findUserByDeptAndRegistLeId")
public List<Map<String,Object>> findUserByDeptAndRegistLeId(String deptId,String registLeId) {
    List<Map<String,Object>> result=hisUserRepository.findUserByDeptAndRegistLeId(deptId,registLeId);
    return result;

}

     @Query(value=" SELECT a.*, "+
        " '0' X10, "+
        " '0' X11, "+
        " '0' X20, "+
        " '0' X21, "+
        " '0' X30, "+
        " '0' X31, "+
        " '0' X40, "+
        " '0' X41, "+
        " '0' X50, "+
        " '0' X51, "+
        " '0' X60, "+
        " '0' X61, "+
        " '0' X70, "+
        " '0' X71 "+
        " from user a "+
        " where a.deptId=?1 "+
        " and a.registLeid=?1 "+
        " and delMark='1'",nativeQuery=true)
List<Map<String, Object>> findUserByDeptAndRegistLeId(String deptId, String registLeId);

排班规则保存gzSave()
待完成......

批量添加排班规则到数据库rule表

前台

        gzSave() {
              //alert("规则名称"+this.ruleForm1.gzmc);
              //alert("挂号级别:"+this.ruleForm1.registLeId)
              //alert("deptId:"+this.ruleForm1.deptId)
              let selItems=this.multipleSelection;//选中的排班人员
              var $this=this;
              this.gzArrays=[];//清空用于入库的规则对象数组
              for(var i=0;i<selItems.length;i++){
                  $this.weeks[i]="";
                  $this.weeks[i]=selItems[i].X10+selItems[i].X11+selItems[i].X20+selItems[i].X21+selItems[i].X30+selItems[i].X31+selItems[i].X40+selItems[i].X41+selItems[i].X50+selItems[i].X51+selItems[i].X60+selItems[i].X61+selItems[i].X70+selItems[i].X71;
                   //alert("拼装后的串:"+$this.weeks[i]);
                   //alert("用户编号:"+selItems[i].id);
                  $this.gzArrays.push({"deptID":1,"ruleName":$this.ruleForm1.gzmc,"userID":1,"week":$this.weeks[i]});
              }
              //挂号规则入库
             this.$axios.post('http://localhost:8082/neusys/rule/add', {rules:$this.gzArrays},{headers: {
                     'Content-Type': 'application/json;charset=UTF-8'
                 }})
              .then(response => {
                alert(response.data.msg);
              })
        }

后台

@RestController
@RequestMapping("/neusys/rule")
public class RuleController {
    @Autowired
    IRuleService RuleServcieImpl;

    @RequestMapping("/add")
    public ResponseBean add(@RequestBody RulesVo vo) {
        ResponseBean result = new ResponseBean();
        int i = RuleServcieImpl.addBatch(vo);
        if(i==vo.getRules().size()){
        result.setCode("0");
        result.setMsg("添加成功");
        }else{
            result.setCode("-1");
            result.setMsg("添加失败");
        }
        return result;

    }
}

package com.neuedu.demo.domain;

import java.util.List;

public class RulesVo {
private List<Rule> rules;

public List<Rule> getRules() {
    return rules;
}

public void setRules(List<Rule> rules) {
    this.rules = rules;
}
public static void main(String[] args) {
    int i=0,j=10;
    do{
        if(i++>--j)
            continue;
        
    }while(i<5);
    System.out.println(i);
    System.out.println(j);
}

}

package com.neuedu.demo.domain;

import java.io.Serializable;
import javax.persistence.*;

/**

  • The persistent class for the rule database table.

  • 排班规则表
    */
    @Entity
    @NamedQuery(name="Rule.findAll", query="SELECT r FROM Rule r")
    public class Rule implements Serializable {
    private static final long serialVersionUID = 1L;

    private int delMark=1;

    private int deptID;
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Id
    private int id;

    private String ruleName;

    private int userID;

    private String week;

    public Rule() {
    }

    public int getDelMark() {
    return this.delMark;
    }

    public void setDelMark(int delMark) {
    this.delMark = delMark;
    }

    public int getDeptID() {
    return this.deptID;
    }

    public void setDeptID(int deptID) {
    this.deptID = deptID;
    }

    public int getId() {
    return this.id;
    }

    public void setId(int id) {
    this.id = id;
    }

    public String getRuleName() {
    return this.ruleName;
    }

    public void setRuleName(String ruleName) {
    this.ruleName = ruleName;
    }

    public int getUserID() {
    return this.userID;
    }

    public void setUserID(int userID) {
    this.userID = userID;
    }

    public String getWeek() {
    return this.week;
    }

    public void setWeek(String week) {
    this.week = week;
    }

}

@Service
@Transactional(rollbackFor = Exception.class)
public class RuleServiceImpl implements IRuleService {
    @Autowired
    RuleRepository ruleRepository;
    @Override
    public int addBatch(RulesVo vo) {
        List<Rule> list=ruleRepository.saveAll(vo.getRules());
        return list.size();
    }

}


    public interface RuleRepository extends JpaRepository<Rule, Integer> {

    }

生成排班计划

学生分组完成

image.png

工具类(作者蔡鑫):

    //  获取周几
public static int setTime(String time){
    //String weekd="7123456";
    SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
    Date datet = null;
    Calendar calendar = Calendar.getInstance();
    try {
        datet = f.parse(time);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    calendar.setTime(datet);
    int day = calendar.get(Calendar.DAY_OF_WEEK);
    //String i=weekd.substring(day-1,day);
    System.out.println("这天是星期"+(day-1));
    return day-1;
}
  //获取间隔
public static long setDate(String endDate,String startDate){
     SimpleDateFormat formatter =   new SimpleDateFormat( "yyyy-MM-dd");
    Date start=null;
    Date end = null;
    Long l = 0L;
    try {
        end = formatter.parse(endDate);
        long ts = end.getTime();
        start =  formatter.parse(startDate);
        long ts1 = start.getTime();
        l = (ts - ts1) / (1000 * 60 * 60 * 24);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return l.intValue()+1;
}
    //  新日期
public static String addDate(String date,long i){
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
    Date d1=null;
    String time=new String();
    try {
        d1 = sdf.parse(date);
         long ts = d1.getTime();
         long day=i*24*60*60*1000;
         long ts_new=ts+day;
        Date new_date=new Date(ts_new);
        time =sdf.format(new_date);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return time;
}

相关文章

  • 12、医生排班

    目标 查询医生排班 新增排班规则 生成排班计划 重要知识 批量添加 查询医生排班 页面 1、查询医生排班前台Sch...

  • 医生排班

    医院内科有A,B,C,D,E,F,G共7位医生,没人在一周内要值一次夜班,排班的要求是:(1)A医生值日比C医生晚...

  • 9、排班规则

    目标 需求整理 需求整理 医生门诊排班信息临床科室参与排班(*)医技科室不参与排班 流程上分两步1、设置排班规则时...

  • 2019-04-09

    2019-04-09 1. 事件:书记打电话过来说,科室张勇医生反应给他排班多了,而我对自己的排班很宽松。让我注意...

  • 医院就诊卡接口规范(业务:029)

    业务编号:029业务说明:排班医生更替处理存储过程:usp_m_schedule_replace_doctor文档...

  • 功能制排班和责任制排班优劣分析

    功能制排班 功能制排班以疾病和处理医嘱为中心,护理工作从属和附着于医疗,护士是医生的助手,护理只是简单的执行医嘱和...

  • 排班

    国庆的前三天,我全天待在家里涂涂写写,捣实捣实,不知不觉就这么浑浑噩噩的过去了。为啥我这三天不出去溜达溜达呢?因为...

  • 排班

    这边的护理员多多少少来干这个工作,都是因为金钱的压力比较大,今天早上就听到,护理员在那里诉说着什么? 一听说又是排...

  • 排班

    【本故事纯属虚构,如有雷同,纯属巧合,请勿对号入座!】 A队“一把手”王小波出差已经第三天了,这几天,队里...

  • 医疗场景交易平台战略设计&战术落地思考

    需求整理 背景 问诊平台可以看作是电商场景下的交易平台,患者是买家,医生是卖家,医生的排班可以看作是库存,医患沟通...

网友评论

      本文标题:12、医生排班

      本文链接:https://www.haomeiwen.com/subject/afwrbctx.html