Esempio n. 1
0
        //新增更新操作
        public ActionResult AddAndUpdate()
        {
            string id = Request["id"];
            string fill_community_code = Request["community_code"];
            string worker = Request["worker"];
            Chronic_disease_Comm_Diagnostic entity = new Chronic_disease_Comm_Diagnostic();

            if (string.IsNullOrEmpty(id))
            {
                entity.id          = Guid.NewGuid().ToString();
                entity.create_time = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(DateTime.Now.ToString("yyyy-MM-dd")));
            }
            else
            {
                entity.id          = id;
                entity.create_time = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(DateTime.Now.ToString("yyyy-MM-dd")));
            }
            //根据身份证号查询个人信息表中是否存在此人信息,如果存在,则使用个人信息中的健康档案号,如果不存在,则创建一个新的17位的健康档案号
            string id_card_number = CommonFunc.SafeGetStringFromObj(Request["id_card_number"]);
            string ddlCommunity   = CommonFunc.SafeGetStringFromObj(Request["ddlCommunity"]);
            string residentId     = CommonFunc.SafeGetStringFromObj(residentFileService.LoadEntityAsNoTracking(t => t.id_card_number == id_card_number).Select(t => t.resident_id).FirstOrDefault());

            if (string.IsNullOrEmpty(residentId))
            {
                entity.resident_id = residentFileService.GetNumberByCode1(ddlCommunity);
            }
            else
            {
                entity.resident_id = residentId;
            }
            entity.names          = Request["name"];
            entity.sex            = Request["sex"];
            entity.age            = Request["age"];
            entity.id_card_number = Request["id_card_number"];
            entity.birth_date     = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["birth_date"]));
            entity.address        = Request["perment_community_address"];
            entity.phone          = Request["phone"];
            if (string.IsNullOrEmpty(Request["time1"]))
            {
                entity.data1 = null;
            }
            else
            {
                entity.data1 = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["time1"]));
            }
            if (string.IsNullOrEmpty(Request["time2"]))
            {
                entity.data2 = null;
            }
            else
            {
                entity.data2 = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["time2"]));
            }
            if (string.IsNullOrEmpty(Request["time3"]))
            {
                entity.data3 = null;
            }
            else
            {
                entity.data3 = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["time3"]));
            }
            if (string.IsNullOrEmpty(Request["time4"]))
            {
                entity.data4 = null;
            }
            else
            {
                entity.data4 = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["time4"]));
            }
            if (string.IsNullOrEmpty(Request["time5"]))
            {
                entity.data5 = null;
            }
            else
            {
                entity.data5 = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["time5"]));
            }
            entity.name1 = Request["name1"];
            entity.name2 = Request["name2"];
            entity.name3 = Request["name3"];
            entity.name4 = Request["name4"];
            entity.name5 = Request["name5"];

            entity.numb1 = Request["numb1"];
            entity.numb2 = Request["numb2"];
            entity.numb3 = Request["numb3"];
            entity.numb4 = Request["numb4"];
            entity.numb5 = Request["numb5"];

            entity.hospital1 = Request["hospital1"];
            entity.hospital2 = Request["hospital2"];
            entity.hospital3 = Request["hospital3"];
            entity.hospital4 = Request["hospital4"];
            entity.hospital5 = Request["hospital5"];

            entity.doctor1        = Request["doctor1"];
            entity.doctor2        = Request["doctor2"];
            entity.doctor3        = Request["doctor3"];
            entity.doctor4        = Request["doctor4"];
            entity.doctor5        = Request["doctor5"];
            entity.type           = Enum.GetName(typeof(Model.Enum.EntityTypeEnum), 1);
            entity.worker         = worker;
            entity.community_code = Request["ddlCommunity"];


            List <Chronic_disease_Comm_DiagnosticAdd> subjectiveList = new List <Chronic_disease_Comm_DiagnosticAdd>();

            for (int i = 1; i < 100; i++)
            {
                if (!string.IsNullOrEmpty(Request["name_" + i]))
                {
                    Chronic_disease_Comm_DiagnosticAdd entity1 = new Chronic_disease_Comm_DiagnosticAdd();
                    entity1.id      = Guid.NewGuid().ToString();
                    entity1.diag_id = entity.id;
                    if (string.IsNullOrEmpty(Request["time_" + i]))
                    {
                        entity1.data = null;
                    }
                    else
                    {
                        entity1.data = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["time_" + i]));
                    }
                    entity1.name     = Request["name_" + i];
                    entity1.numb     = Request["numb_" + i];
                    entity1.hospital = Request["hospital_" + i];
                    entity1.doctor   = Request["doctor_" + i];

                    if (entity1.name != null)
                    {
                        subjectiveList.Add(entity1);
                    }
                }
            }

            //判断个人信息表中是否存在此人信息 2015-06-18 娄帅
            var dt = residentFileService.LoadEntityAsNoTracking(t => t.id_card_number == id_card_number);

            Comm_ResidentFile resident = new Comm_ResidentFile();

            resident.id = CommonFunc.SafeGetStringFromObj(dt.Select(t => t.id).FirstOrDefault());

            resident.resident_id            = entity.resident_id;
            resident.resident_name          = Request["name"];
            resident.sex                    = Request["sex"];
            resident.id_card_number         = Request["id_card_number"];
            resident.birth_date             = entity.birth_date;
            resident.community_code         = Request["ddlCommunity"];
            resident.individual_phone       = Request["phone"];
            resident.permanent_home_address = Request["perment_community_address"];
            resident.nationality_name       = "中国";
            resident.nationality_code       = "156";

            if (dt.Count() < 1)
            {
                resident.id             = Guid.NewGuid().ToString();
                resident.community_code = Request["ddlCommunity"];
                if (entity.create_time == null)
                {
                    resident.create_time = CommonFunc.SafeGetDateTimeFromObj(DateTime.Now.ToString("yyyy-MM-dd"));
                }
                else
                {
                    resident.create_time = CommonFunc.SafeGetDateTimeFromObj(entity.create_time);
                }

                resident.worker_user_name = worker;

                residentFileService.AddEntity(resident);

                // 添加摘要

                Comm_EHR_Abstract ehr1 = new Comm_EHR_Abstract();
                ehr1.id             = Guid.NewGuid().ToString();
                ehr1.resident_id    = entity.resident_id;
                ehr1.community_code = entity.community_code;
                ehr1.create_time    = DateTime.Now;
                ehr1.item_id        = resident.id;
                ehr1.item_type      = Model.Enum.EHRAbstractTypeEnum.ResidentInfo.ToString();

                eHRAbstractService.AddEntity(ehr1);
            }
            else
            {
                /** 根据身份证号查询个人信息表中是否存在此人信息,存在获取行政区划代码,与现在填写的常住地址作比较,不相同则将其添加到Comm_ResidentFile_Change_Address表中
                 */

                string code = CommonFunc.SafeGetStringFromObj(residentFileService.LoadEntityAsNoTracking(t => t.id_card_number == id_card_number).Select(t => t.community_code).FirstOrDefault());

                if (Request["ddlCommunity"] != code)
                {
                    Comm_ResidentFile_Change_Address address = new Comm_ResidentFile_Change_Address();
                    address.id                  = Guid.NewGuid().ToString();
                    address.contact_id          = entity.id;
                    address.resident_id         = entity.resident_id;
                    address.community_code      = code;
                    address.fill_community_code = fill_community_code;
                    address.fill_person         = worker;
                    address.permanent_address   = CommonFunc.SafeGetStringFromObj(residentFileService.LoadEntityAsNoTracking(t => t.id_card_number == id_card_number).Select(t => t.permanent_home_address).FirstOrDefault());
                    address.create_time         = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(DateTime.Now.ToString("yyyy-MM-dd")));

                    residentFileChangeAddressService.AddEntity(address);
                }
                //resident.id = dt.Select(t=>t.id).ToString();
                string[] propertyName = new string[] { "resident_name", "sex", "id_card_number", "community_code", "individual_phone", "permanent_home_address" };
                residentFileService.UpdatePartialPropertity(resident, propertyName);
            }
            string msg = "";

            if (string.IsNullOrEmpty(id))
            {
                if (disease_Comm_DiagnosticService.AddEntity(entity) && disease_Comm_DiagnosticAddService.UpdateSubjective(subjectiveList, entity.id))
                {
                    Comm_EHR_Abstract ehr = new Comm_EHR_Abstract();
                    ehr.id             = Guid.NewGuid().ToString();
                    ehr.resident_id    = entity.resident_id;
                    ehr.community_code = entity.community_code;
                    ehr.create_time    = DateTime.Now;
                    ehr.item_id        = entity.id;
                    ehr.item_type      = Model.Enum.EHRAbstractTypeEnum.DiaInfo.ToString();

                    if (eHRAbstractService.AddEntity(ehr))
                    {
                        msg = "提交成功";
                    }
                    else
                    {
                        msg = "提交失败";
                    }
                }
            }
            else
            {
                if (disease_Comm_DiagnosticService.UpdateEntity(entity) && disease_Comm_DiagnosticAddService.UpdateSubjective(subjectiveList, entity.id))
                {
                    msg = "修改成功";
                }
            }
            return(Content(msg + ',' + entity.id));
        }
        //提交
        public ActionResult Sure()
        {
            string id = Request["id"];
            string fill_community_code = Request["community_code"];
            string worker = Request["worker"];
            Chronic_disease_Hospitalization entity = new Chronic_disease_Hospitalization();
            //将诊断信息放到诊断信息表中
            Chronic_disease_Comm_Diagnostic dia = new Chronic_disease_Comm_Diagnostic();

            if (string.IsNullOrEmpty(id))
            {
                entity.id          = Guid.NewGuid().ToString();
                entity.create_time = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(DateTime.Now.ToString("yyyy-MM-dd")));
                entity.sign        = "1";
            }
            else
            {
                entity.id          = id;
                entity.create_time = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(DateTime.Now.ToString("yyyy-MM-dd")));
                entity.sign        = "1";
            }
            //根据身份证号查询个人信息表中是否存在此人信息,如果存在,则使用个人信息中的健康档案号,如果不存在,则创建一个新的17位的健康档案号
            string id_card_number = CommonFunc.SafeGetStringFromObj(Request["id_card_number"]);
            string ddlCommunity   = CommonFunc.SafeGetStringFromObj(Request["ddlCommunity"]);
            string residentId     = CommonFunc.SafeGetStringFromObj(residentFileService.LoadEntityAsNoTracking(t => t.id_card_number == id_card_number).Select(t => t.resident_id).FirstOrDefault());

            if (string.IsNullOrEmpty(residentId))
            {
                entity.resident_id = residentFileService.GetNumberByCode1(ddlCommunity);
            }
            else
            {
                entity.resident_id = residentId;
            }

            entity.name           = Request["name"];
            entity.sex            = Request["sex"];
            entity.id_card_number = Request["id_card_number"];
            if (string.IsNullOrEmpty(Request["birth_date"]))
            {
                entity.birth_date = null;
            }
            else
            {
                entity.birth_date = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["birth_date"]));
            }

            entity.permanent_address = Request["perment_community_address"];
            entity.post_code         = Request["zipCode"];
            entity.community_code    = Request["ddlCommunity"];

            entity.nationality    = Request["nationality"];
            entity.nation         = Request["ddlNation"];
            entity.marriage       = Request["ddlMarrigeState"];
            entity.blood_group    = Request["ddlABOBloodType"];
            entity.culture        = Request["ddlEducationQualification"];
            entity.phone          = Request["txtIndividualPhone"];
            entity.contact_person = Request["txtcontact_name"];
            entity.email          = Request["txtEmail"];
            entity.contact_phone  = Request["txtcontact_phone"];
            entity.relationship   = Request["ddlcontact_my_relationship"];
            if (string.IsNullOrEmpty(Request["data"]))
            {
                entity.hospitalization_date = null;
            }
            else
            {
                entity.hospitalization_date = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(Request["data"]));
            }

            entity.hospitalization_number = Request["number"];
            entity.bed_number             = Request["bed_number"];
            entity.hospital   = Request["hospital"];
            entity.department = Request["department"];

            entity.zs    = Request["zs"];
            entity.xbs   = Request["xbs"];
            entity.jws   = Request["jws"];
            entity.t     = Request["t"];
            entity.p     = Request["p"];
            entity.r     = Request["r"];
            entity.ssy1  = Request["ssy"];
            entity.szy1  = Request["szy"];
            entity.ssy2  = Request["ssy1"];
            entity.szy2  = Request["szy1"];
            entity.other = Request["other"];

            entity.type             = Enum.GetName(typeof(Model.Enum.EntityTypeEnum), 1);
            entity.worker_user_name = worker;
            entity.sign             = "1";

            //判断个人信息表中是否存在此人信息 2015-06-18 娄帅
            var dt = residentFileService.LoadEntityAsNoTracking(t => t.id_card_number == id_card_number);

            Comm_ResidentFile resident = new Comm_ResidentFile();

            resident.id = CommonFunc.SafeGetStringFromObj(dt.Select(t => t.id).FirstOrDefault());

            resident.resident_id            = entity.resident_id;
            resident.resident_name          = Request["name"];
            resident.sex                    = Request["sex"];
            resident.id_card_number         = Request["id_card_number"];
            resident.birth_date             = entity.birth_date;
            resident.community_code         = Request["ddlCommunity"];
            resident.individual_phone       = Request["phone"];
            resident.permanent_home_address = Request["perment_community_address"];
            resident.nationality_name       = "中国";
            resident.nationality_code       = "156";

            if (dt.Count() < 1)
            {
                resident.id             = Guid.NewGuid().ToString();
                resident.community_code = Request["ddlCommunity"];
                if (entity.create_time == null)
                {
                    resident.create_time = CommonFunc.SafeGetDateTimeFromObj(DateTime.Now.ToString("yyyy-MM-dd"));
                }
                else
                {
                    resident.create_time = CommonFunc.SafeGetDateTimeFromObj(entity.create_time);
                }

                resident.worker_user_name = worker;

                residentFileService.AddEntity(resident);

                // 添加摘要

                Comm_EHR_Abstract ehr1 = new Comm_EHR_Abstract();
                ehr1.id             = Guid.NewGuid().ToString();
                ehr1.resident_id    = entity.resident_id;
                ehr1.community_code = entity.community_code;
                ehr1.create_time    = DateTime.Now;
                ehr1.item_id        = resident.id;
                ehr1.item_type      = Model.Enum.EHRAbstractTypeEnum.ResidentInfo.ToString();

                eHRAbstractService.AddEntity(ehr1);
            }
            else
            {
                /** 根据身份证号查询个人信息表中是否存在此人信息,存在获取行政区划代码,与现在填写的常住地址作比较,不相同则将其添加到Comm_ResidentFile_Change_Address表中
                 */

                string code = CommonFunc.SafeGetStringFromObj(residentFileService.LoadEntityAsNoTracking(t => t.id_card_number == id_card_number).Select(t => t.community_code).FirstOrDefault());

                if (Request["ddlCommunity"] != code)
                {
                    Comm_ResidentFile_Change_Address address = new Comm_ResidentFile_Change_Address();
                    address.id                  = Guid.NewGuid().ToString();
                    address.contact_id          = entity.id;
                    address.resident_id         = entity.resident_id;
                    address.community_code      = code;
                    address.fill_community_code = fill_community_code;
                    address.fill_person         = worker;
                    address.permanent_address   = CommonFunc.SafeGetStringFromObj(residentFileService.LoadEntityAsNoTracking(t => t.id_card_number == id_card_number).Select(t => t.permanent_home_address).FirstOrDefault());
                    address.create_time         = CommonFunc.SafeGetDateTimeFromObj(CommonFunc.SafeGetStringFromObj(DateTime.Now.ToString("yyyy-MM-dd")));

                    residentFileChangeAddressService.AddEntity(address);
                }
                //resident.id = dt.Select(t=>t.id).ToString();
                string[] propertyName = new string[] { "resident_name", "sex", "id_card_number", "community_code", "individual_phone", "permanent_home_address" };
                residentFileService.UpdatePartialPropertity(resident, propertyName);
            }

            string msg = "";

            if (string.IsNullOrEmpty(id))
            {
                if (disease_HospitalizationService.AddEntity(entity))
                {
                    Comm_EHR_Abstract ehr = new Comm_EHR_Abstract();
                    ehr.id             = Guid.NewGuid().ToString();
                    ehr.resident_id    = entity.resident_id;
                    ehr.community_code = entity.community_code;
                    ehr.create_time    = DateTime.Now;
                    ehr.item_id        = entity.id;
                    ehr.item_type      = Model.Enum.EHRAbstractTypeEnum.Hospitalization.ToString();

                    if (eHRAbstractService.AddEntity(ehr))
                    {
                        msg = "提交成功";
                    }
                    else
                    {
                        msg = "提交失败";
                    }
                }
            }
            else
            {
                if (disease_HospitalizationService.UpdateEntity(entity))
                {
                    msg = "提交成功";
                }
            }
            return(Content(msg + ',' + entity.id));
        }