出入院-登记入院

该博客展示了如何使用Java实现一个入院登记的控制器功能,包括数据验证、避免重复登记和更新患者信息。同时,提供了相关的前端JS代码用于处理用户输入和调用后台接口。在控制器中,通过对入院日期、诊断日期等关键信息的检查,确保了数据的正确性。
摘要由CSDN通过智能技术生成

控制器代码:

#region 入院登记

 

        public ActionResult SaveRegisterInsert(Patient patient,

            RegisterAdmission registerAdmission)

        {

            ReturnJson RtJson = new ReturnJson();

            try

            {

                //判断数据是否为空

                if ((!String.IsNullOrEmpty(registerAdmission.HealthDiagnosis) ||

                    !String.IsNullOrEmpty(registerAdmission.ClinicDiagnosis)) &&

                    registerAdmission.InpatientWardId > 0 && registerAdmission.DepartmentId > 0 &&

                    registerAdmission.HospitalWayId > 0 && registerAdmission.PayModeId > 0 &&

                    registerAdmission.BedId > 0)

                {

                    //去重复

                    int OldCount = (from tbRegisterAdmission in myModels.RegisterAdmission

                                    where tbRegisterAdmission.RegisterAdmissionId != registerAdmission.RegisterAdmissionId &&

                                   (tbRegisterAdmission.PatientId == patient.PatientId &&

                                   (tbRegisterAdmission.DischargeTime == null ||

                                    tbRegisterAdmission.AdmissionStateId != 2 ||

                                    tbRegisterAdmission.AdmissionStateId != 5 ||

                                    tbRegisterAdmission.AdmissionStateId != 6)) ||

                                    tbRegisterAdmission.BedId == registerAdmission.BedId

                                    select tbRegisterAdmission).Count();

                    if (OldCount == 0)

                    {

                        //Patient dbPatient = new Patient();

                        patient.PatientId = patient.PatientId;

                        patient.DateOfBirth = patient.DateOfBirth;

                        //patient.PatientTypeId = patient.PatientTypeId;

                        patient.AdmissionStateId = 1;

                        //修改

                        myModels.Entry(patient).State = System.Data.Entity.EntityState.Modified;

                        if (myModels.SaveChanges() > 0)

                        {

                            registerAdmission.PatientId = patient.PatientId;

                            registerAdmission.AdmissionStateId = 1;

                            registerAdmission.StaffId = registerAdmission.StaffId;

                            registerAdmission.BedId = registerAdmission.BedId;

                            registerAdmission.OutPatientDoctorId = registerAdmission.OutPatientDoctorId;

                            if (registerAdmission.AdmissionDate == null)

                            {

                                registerAdmission.AdmissionDate = DateTime.Now;

                            }

                            else if (registerAdmission.AdmissionDate < DateTime.Now &&

                                registerAdmission.AdmissionDate != null)

                            {

                                registerAdmission.AdmissionDate = registerAdmission.AdmissionDate;

                            }

                            else if (registerAdmission.AdmissionDate > DateTime.Now)

                            {

                                RtJson.Text = "入院日期大于当前时间!";

                            }

                            if (!String.IsNullOrEmpty(registerAdmission.ClinicDiagnosis))

                            {

                                if (registerAdmission.DiagnosisDate < DateTime.Now &&

                                    registerAdmission.DiagnosisDate != null)

                                {

                                    registerAdmission.DiagnosisDate = registerAdmission.DiagnosisDate;

                                }

                                else if (registerAdmission.DiagnosisDate == null)

                                {

                                    registerAdmission.DiagnosisDate = DateTime.Now;

                                }

                                else if (registerAdmission.DiagnosisDate > DateTime.Now ||

                                    registerAdmission.DiagnosisDate > registerAdmission.AdmissionDate)

                                {

                                    RtJson.Text = "诊断日期大于当前时间或大于入院时间!";

                                }

                                registerAdmission.ClinicDiagnosis = registerAdmission.ClinicDiagnosis;

                            }

                            //新增

                            myModels.RegisterAdmission.Add(registerAdmission);

                            if (myModels.SaveChanges() > 0)

                            {

                                RtJson.State = true;

                                RtJson.Text = "登记入院成功!";

                            }

                        }

                        else

                        {

                            RtJson.State = false;

                            RtJson.Text = "登记入院失败!";

                        }

                    }

                    else

                    {

                        RtJson.Text = "登记信息已重复,请检查是否重复登记!";

                    }

                }

                else

                {

                    RtJson.Text = "请将登记信息填写完整!";

                }

            }

            catch (Exception)

            {

                RtJson.Text = "数据异常!";

            }

            return Json(RtJson, JsonRequestBehavior.AllowGet);

        }

        #endregion

页面样式代码:

 

Js代码:

 

//登记入院

                    $("#AdmissionBtn").click(function () {

                        //判断病人ID是否为空

                        if (obj.data.PatientId > 0) {

                            $.post("/Main/SelectStaff", {}, function (JsonData) {

                                $("#StaffID").val(JsonData.value);

                                $("#staffCode").val(JsonData.text);

                            }, "json");

                            OpenAdmissionModal();

                            //console.log(obj.data);

                            loadDatatoForm("PatientForm>div:hidden", obj.data);

                            $("#dateOfBirth").val(obj.data.Birthday);

                            $("#InpatientWard").val(0);

                            $("#Department").val(0);

                            $("#Bed").val(0);

                            $("#HospitalWay").val(0);

                            $("#PayMode").val(0);

                            $.post("SelectPatientByID",

                                { PatientID: obj.data.PatientId },

                                function (rtMsg) {

                                    //$("#patientTypeID").val(rtMsg.PatientTypeId);

                                    $("#PatientType").val(rtMsg.PatientTypeId);

                                });

                            $("#OutPatientDoctor").attr("disabled", "");

                            $("#clinicDiagnosis").change(function () {

                                var ClDi = $("#clinicDiagnosis").val();

                                if (IsNullorNot(ClDi)) {

                                    $("#OutPatientDoctor").attr("disabled", "");

                                    $("#OutPatientDoctor").val(0);

                                } else {

                                    $("#OutPatientDoctor").removeAttr("disabled", "");

                                }

                            });

                        }

                    });

//打开登记入院的模态框

        function OpenAdmissionModal() {

            //重置表格

            $("#formPatient")[0].reset();

            $("#PatientForm>div").attr("hidden", "");

            //设置模态框标题

            $("#modalPatientTitle").text("登记入院");

            $("#PatientForm>div:gt(25)").removeAttr("hidden", "");

            $("#PatientForm>div:eq(34)>label").text("费用类别");

            $("#PatientForm>div:gt(41)").attr("hidden", "");

            //设置请求路径

            $("#formPatient").prop("action", "SaveRegisterInsert");

            //弹出模态框,设置点击背景&按下Esc的时候不动态关闭模态框

            $("#modalPatient").modal({ backdrop: 'static', keyboard: false });

        }

//保存新增/修改

        function SavePatient() {

            //获取页面填写数据

            var ArrData = $("#formPatient").resize();

            //声明一个变量,对象类型的变量

            var JsonObj = {};

            //创建对象,FormData

            var FmData = new FormData();

            //fmData.append(名称,值);

            //将序列化出来的对象数组转化为JSON对象 for in遍历对象属性

            for (var index in ArrData) {

                //console.log(index);

                //JsonObj[键] = 值;

                JsonObj[ArrData[index].name] = ArrData[index].value;

                //将页面数据传入FormData对象里

                FmData.append(ArrData[index].name, ArrData[index].value);

            }

            //console.log(JsonObj);

            //打开加载层

            var Index = layer.load();

            $("#formPatient").ajaxSubmit(function (RtMsg) {

                //关闭加载层

                layer.close(Index);

                if (RtMsg.State) {

                    //关闭模态框

                    $('#modalPatient').modal("hide");

                    //输出

                    layer.alert(RtMsg.Text, { icon: 1, title: "提示" });

                    //刷新页面

                    //window.location.reload();

                    tabPatient.reload({ page: { curr: 1 } });

                }

                else {

                    layer.alert(RtMsg.Text, { icon: 0, title: "提示" });

                }

            });

        }

效果图:

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值