예제 #1
0
        /// <summary>
        /// 获取窗口名称
        /// </summary>
        public string GetWindowName(string code)
        {
            if (code.IsEmpty())
            {
                throw new Exception("窗口编号为空!");
            }

            var sql = $@"
SELECT      CODENAME 
FROM        TWBAS_BASECODE    
";
            var wb  = new WhereBuilder();

            wb.And("BUSINESS", "药房");
            wb.And("BUN", "窗口");
            wb.And("GBUSE", "0");
            wb.And("NFLAG1", "1");
            wb.And("CODE", code);
            var result = DBaser.QueryValue <string>(sql, wb);

            if (result.IsEmpty())
            {
                throw new Exception($"无法获取到窗口名称{code}");
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 日间手术室已签到未发药 已分配窗口
        /// </summary>
        public string InPatientGetCurrentWindow(string ptno, string orderNo)
        {
            var sql = $@"
SELECT      DISTINCT(CHUANGKOU) CODE
FROM        TWOCS_PRSLIP_CHECK
{{0}}
GROUP BY    CHUANGKOU";

            var wb = new WhereBuilder();

            wb.And("PTNO", ptno, true);
            wb.And("ORDERNO", orderNo, true);
            wb.And("FLAG =1", AnalyzableKind.KeepOriginal);
            //wb.And("GBOUT IS NULL", AnalyzableKind.KeepOriginal);
            //wb.And("STATUS =0", AnalyzableKind.KeepOriginal);
            wb.And($@"BDATE <= TO_DATE('{Environ.SlowTime.ToString("yyyy-MM-dd")}','YYYY-MM-DD') 
    AND BDATE >= TO_DATE('{Environ.SlowTime.AddDays(-2).ToString("yyyy-MM-dd")}', 'YYYY-MM-DD') ", AnalyzableKind.KeepOriginal);
            wb.And("CHECKDATE IS not NULL", AnalyzableKind.KeepOriginal);
            wb.And("CHECKTIME IS not NULL", AnalyzableKind.KeepOriginal);
            wb.And("OUTDATE IS  NULL", AnalyzableKind.KeepOriginal);
            wb.And("OUTTIME IS  NULL", AnalyzableKind.KeepOriginal);
            var windows = DBaser.Query <PharmacyWindow>(sql, wb);

            if (windows.Length > 1)
            {
                return(string.Empty);// throw new Exception("一个处方单被分配到多个窗口!");
            }
            if (windows.Length == 0)
            {
                return(string.Empty);//throw new Exception("未找到窗口记录!");
            }
            return(windows.First()?.Code);
        }
예제 #3
0
        /// <summary>
        /// 获取患者的  处方、预约 处方单状态单
        /// </summary>
        public Prescription[] GetInPresNO(string ptno)
        {
            var sql = $@"
SELECT      DISTINCT(PRESNO) PRESNO,BDATE,PTNO 
FROM        TWOCS_IORDER 
{{0}}
GROUP BY    PRESNO,BDATE,PTNO";
            var wb  = new WhereBuilder();

            wb.And("PTNO", ptno, true);
            wb.And("JUPSU in ('0','1')", AnalyzableKind.KeepOriginal);
            wb.And("BDATE=  TRUNC(SYSDATE)", AnalyzableKind.KeepOriginal);
            var PresNOs = DBaser.Query <Prescription>(sql, wb);

            return(PresNOs);
        }
예제 #4
0
        public void UsingQueryBuilder()
        {
            // subject.
            var posts = new List <Post>()
            {
                new Post {
                    Id = 1, AuthorId = 1, Title = "Hello 1", Content = "World"
                },
                new Post {
                    Id = 2, AuthorId = 1, Title = "Hello 2", Content = "World"
                },
                new Post {
                    Id = 3, AuthorId = 2, Title = "Hello 3", Content = "World"
                },
            };

            // the query.
            var query        = posts.AsQueryable();
            var queryBuilder = new WhereBuilder(query);

            queryBuilder.Compare("AuthorId", ConditionOperators.Equal, 1);
            queryBuilder.And(subQuery =>
            {
                subQuery.Compare("Content", ConditionOperators.Equal, "World");
                subQuery.Or("Title", ConditionOperators.Contains, 3);
            });

            query = (IQueryable <Post>)queryBuilder.Build();
            Assert.AreEqual(2, query.Count());
        }
        public override IAI_MEDICAL_REGISTRATION Insert(PRPA_IN402001UV02 addEntity)
        {
            var data = new IAI_MEDICAL_REGISTRATION()
            {
                encounterevent_id = addEntity.controlActProcess?.subject?.encounterEvent?.id?.extension,
                type_code         = addEntity.controlActProcess?.subject?.encounterEvent?.code?.code,
                effective_time    = addEntity.controlActProcess?.subject?.encounterEvent?.effectiveTime?.value,
                original_text     = addEntity.controlActProcess?.subject?.encounterEvent?.reasonCode?.originalText,
                patient_id        = addEntity.controlActProcess?.subject?.encounterEvent?.subject?.patient?.id.code,
                patient_name      = addEntity.controlActProcess?.subject?.encounterEvent?.subject?.patient?.patientPerson?.name.Value,
                consultant_id     = addEntity.controlActProcess?.subject?.encounterEvent?.admitter?.assignedPerson?.id?.extension,
                consultant_name   = addEntity.controlActProcess?.subject?.encounterEvent?.admitter?.assignedPerson?.assignedPerson?.name,
                location_id       = addEntity.controlActProcess?.subject?.encounterEvent?.location?.serviceDeliveryLocation?.location?.id?.extension,
                location_name     = addEntity.controlActProcess?.subject?.encounterEvent?.location?.serviceDeliveryLocation?.location?.name,
                organization_id   = addEntity.controlActProcess?.subject?.encounterEvent?.location?.serviceDeliveryLocation?.serviceProviderOrganization?.id?.extension,
                medical_type      = EncounterEventTypeCode.ADMITTER.Value(),
            };

            var wb = new WhereBuilder();

            wb.And("encounterevent_id", data.encounterevent_id, true);
            wb.And("medical_type", data.medical_type);

            if (DBaser.QueryValue <int>("select count(*) from IAI_MEDICAL_REGISTRATION", wb) > 0)
            {
                throw new Exception($@"主键冲突{data.consultant_id}已存在。");
            }

            DBaser.Insert("IAI_MEDICAL_REGISTRATION");
            DBaser["encounterevent_id"] = data.encounterevent_id;
            DBaser["type_code"]         = data.type_code;
            DBaser["effective_time"]    = data.effective_time;
            DBaser["original_text"]     = data.original_text;
            DBaser["patient_id"]        = data.patient_id;
            DBaser["patient_name"]      = data.patient_name;
            DBaser["consultant_id"]     = data.consultant_id;
            DBaser["consultant_name"]   = data.consultant_name;
            DBaser["location_id"]       = data.location_id;
            DBaser["location_name"]     = data.location_name;
            DBaser["organization_id"]   = data.organization_id;
            DBaser["medical_type"]      = data.medical_type;



            DBaser.AcceptChanges();
            return(data);
        }
예제 #6
0
        public IAI_PATIENT Select(string id)
        {
            var wb = new WhereBuilder();

            wb.And("patient_id", id, true);

            return(DBaser.Query <IAI_PATIENT>("Select * From IAI_PATIENT", wb).First());
        }
예제 #7
0
        public bool DeleteById(string id)
        {
            var wb = new WhereBuilder();

            wb.And("patient_id", id, true);

            return(DBaser.Delete("IAI_PATIENT", wb) > 0);
        }
예제 #8
0
        /// <summary>
        /// 获取全部窗口
        /// </summary>
        public PharmacyWindow[] GetAllWindow()
        {
            var sql = $@"
SELECT      * 
FROM        TW_HSP_PMPA.TWBAS_BASECODE 
{{0}}
Order       By Code ";
            var wb  = new WhereBuilder();

            wb.And("BUSINESS", "药房");
            wb.And("BUN", "窗口");
            wb.And("GBUSE", "0");
            wb.And("NFLAG1", "1");
            var result = DBaser.Query <PharmacyWindow>(sql, wb);

            return(result);
        }
예제 #9
0
        public override IAI_DICT Select(CodeSystem item)
        {
            var    key     = $"{item.codeSystemName}_{item.code}";
            string myCache = cache[key] as string;

            if (myCache == null)
            {
                CacheItemPolicy policy = new CacheItemPolicy();
                policy.AbsoluteExpiration = DateTime.Now.AddSeconds(60 * 10);

                var wb = new WhereBuilder();
                wb.And("CODE_SYSTEM_NAME", item?.codeSystemName, true);
                wb.And("CODE", item?.code);
                var sql = $@" Select      *
                        From        IAI_DICT ";

                var result = DBaser.Query <IAI_DICT>(sql, wb).First();
                if (result == null)
                {
                    throw new Exception("无记录");
                }
                //return result;
                myCache = result.DISPLAY_NAME;
                cache.Set(key, myCache, policy);
            }
            return(new IAI_DICT
            {
                DISPLAY_NAME = cache.Get(key) as string,
            });


            //var wb = new WhereBuilder();
            //wb.And("CODE_SYSTEM_NAME", item?.codeSystemName, true);
            //wb.And("CODE", item?.code);
            //var sql = $@" Select      *
            //            From        IAI_DICT ";

            //var result = DBaser.Query<IAI_DICT>(sql, wb).First();
            //if (result == null)
            //{
            //    throw new Exception("无记录");
            //}
            //return result;
        }
        public override IAI_MEDICAL_REGISTRATION Insert(PRPA_IN402003UV02 item)
        {
            var data = new IAI_MEDICAL_REGISTRATION()
            {
                encounterevent_id = item.controlActProcess?.subject?.encounterEvent?.id?.extension,
                type_code         = item.controlActProcess?.subject?.encounterEvent?.code?.code,
                effective_time    = item.controlActProcess?.subject?.encounterEvent?.effectiveTime?.value,
                original_text     = item.controlActProcess?.subject?.encounterEvent?.dischargeDispositionCode.code,
                patient_id        = item.controlActProcess?.subject?.encounterEvent?.subject?.patient?.id.code,
                patient_name      = item.controlActProcess?.subject?.encounterEvent?.subject?.patient?.patientPerson?.name.Value,
                consultant_id     = item.controlActProcess?.subject?.encounterEvent?.discharger?.assignedPerson?.id?.extension,
                consultant_name   = item.controlActProcess?.subject?.encounterEvent?.discharger?.assignedPerson?.assignedPerson?.name?.Value,
                medical_type      = (int)EncounterEventTypeCode.DISCHARGE,
            };

            var wb = new WhereBuilder();

            wb.And("encounterevent_id", data.encounterevent_id);
            wb.And("medical_type", data.medical_type);

            var sql = $@"
Select      *
From        IAI_MEDICAL_REGISTRATION
";

            if (DBaser.QueryValue <int>("Select count(*) From IAI_MEDICAL_REGISTRATION", wb) > 0)
            {
                throw new Exception($@"主键冲突{data.encounterevent_id}已存在。");
            }

            DBaser.Insert("IAI_MEDICAL_REGISTRATION");
            DBaser["encounterevent_id"] = data.encounterevent_id;
            DBaser["type_code"]         = data.type_code;
            DBaser["effective_time"]    = data.effective_time;
            DBaser["original_text"]     = data.original_text;
            DBaser["patient_id"]        = data.patient_id;
            DBaser["patient_name"]      = data.patient_name;
            DBaser["consultant_id"]     = data.consultant_id;
            DBaser["consultant_name"]   = data.consultant_name;
            DBaser["medical_type"]      = data.medical_type;
            DBaser.AcceptChanges();

            return(data);
        }
예제 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start(); //  开始监视代码

            using (DNetContext db = new DNetContext())
            {
                var author = db.GetSingle <Author>(m => true, q => q.OrderBy(m => m.AuthorID));

                var book = db.GetSingle <Book>(m => ((DateTime)m.PublishDate).ToString("yyyy-MM-dd") == "2017-11-11");

                var authors = db.GetList <Author>(m => string.IsNullOrEmpty(m.AuthorName) && m.IsValid == true);

                List <dynamic> name = db.GetDistinctList <Author>(m => m.AuthorName.StartsWith("jim") && m.IsValid == true, m => m.AuthorName + "aaa");

                //List<string> name1 = db.GetDistinctList<Author, string>(m => m.AuthorName.IndexOf("jim") == 2 && m.IsValid == true, m => m.AuthorName);

                var books = db.GetList <Book>(m => SubQuery.GetList <Author>(n => n.AuthorID > 10, n => n.AuthorID).Contains(m.AuthorID));

                books = db.GetList <Book>(m => m.AuthorID >= SubQuery.GetSingle <Author>(n => n.AuthorID == 10, n => n.AuthorID));

                var authorid = db.GetMax <Author>(m => (int)m.AuthorID);

                WhereBuilder <Author> where = new WhereBuilder <Author>();
                where.And(m => m.AuthorName.Contains("jim"));
                where.And(m => m.AuthorID == 3);
                where.Or(m => m.IsValid == true);
                db.GetList <Author>(where.WhereExpression);


                PageFilter <Author> page = new PageFilter <Author> {
                    PageIndex = 1, PageSize = 10
                };
                page.And(m => "jim green".Contains(m.AuthorName));
                page.OrderBy(q => q.OrderBy(m => m.AuthorName).OrderByDescending(m => m.AuthorID));
                PageDataSource <Author> pageSource = db.GetPage <Author>(page);
            }
            stopwatch.Stop();                                   //  停止监视
            TimeSpan timespan     = stopwatch.Elapsed;          //  获取当前实例测量得出的总时间
            double   milliseconds = timespan.TotalMilliseconds; //  总毫秒数

            Response.Write("执行时间:" + milliseconds + "毫秒");
        }
예제 #12
0
        public void WhereAnd()
        {
            var q = Builders <MyModel> .Select(x => new { x.Id })
                    .Where(x => x.Id == 1 && x.Name == "test");

            var b = WhereBuilder <MyModel> .And(
                WhereBuilder <MyModel> .FromExpression(x => x.Id == 1),
                WhereBuilder <MyModel> .Eq(x => x.Name, "test"));

            Utils.AssertRawQuery(q, b, @"SELECT ""id"" FROM model WHERE ((""id"") = (1)) AND ((""name"") = ('test'))");
        }
        public override IAI_MEDICAL_REGISTRATION Select(PRPA_IN900300UV02 item)
        {
            var wb = new WhereBuilder();

            wb.And("encounterevent_id", item?.controlActProcess?.queryByParameterPayload?.careEventID?.value?.extension, true);
            wb.And("medical_type", EncounterEventTypeCode.DISCHARGE);

            var sql = $@"
Select      *
From        IAI_MEDICAL_REGISTRATION
";

            var result = DBaser.Query <IAI_MEDICAL_REGISTRATION>(sql, wb).First();

            if (result == null)
            {
                throw new Exception("无记录");
            }
            return(result);
        }
예제 #14
0
        /// <summary>
        /// 获取用户名
        /// </summary>
        public string GetPatientName(string ptno)
        {
            var sql = $@"
SELECT      SNAME 
FROM        TWBAS_PATIENT";

            var wb = new WhereBuilder();

            wb.And("ptno", ptno);

            return(DBaser.QueryValue <string>(sql, wb));
        }
예제 #15
0
        /// <summary>
        /// true 收费 false未收费
        /// </summary>
        /// <param name="presNo">门诊处方号</param>
        public bool IsOrderCharged(string presNo)
        {
            var sql = $@"
SELECT      SUNAP
FROM        TWOCS_OORDER";
            var wb  = new WhereBuilder();

            wb.And("PRESNO", presNo);
            var charged = DBaser.QueryValue <int>(sql, wb);

            return(charged == 1);
        }
예제 #16
0
        /// <summary>
        /// 是否存在患者信息
        /// </summary>
        public bool ExistPatient(string ptno)
        {
            var sql = $@"
SELECT      COUNT(1) COUNT
FROM        TWBAS_PATIENT";
            var wb  = new WhereBuilder();

            wb.And("ptno", ptno);
            var COUNT = DBaser.QueryValue <int>(sql, wb);

            return(COUNT > 0);
        }
예제 #17
0
        public override IAI_PROVIDER Select(PRPM_IN306010UV01 queryEntity)
        {
            var wb = new WhereBuilder();

            wb.And("healthcareprovider_id", queryEntity?.controlActProcess?.queryByParameterPayload?.providerID?.value?.extension, true);
            var result = DBaser.Query <IAI_PROVIDER>("Select * From IAI_PROVIDER", wb).First();

            if (result == null)
            {
                throw new Exception("未查找到结果");
            }
            return(result);
        }
예제 #18
0
        /// <summary>
        /// 存在登记医嘱True;
        /// </summary>
        public bool ExixtOrder(string orderNO)
        {
            var sql = $@"
SELECT      Count(*) Count 
FROM        TWOCS_PRSLIP_CHECK    
";
            var wb  = new WhereBuilder();

            wb.And("ORDERNO", orderNO);

            var Count = DBaser.QueryValue <int>(sql, wb);

            return(Count > 0);
        }
예제 #19
0
        /// <summary>
        /// 更新医嘱表状态为取药预约
        /// </summary>
        /// <param name="ptno">患者编号</param>
        /// <param name="presno">处方号</param>
        public int OrderMedicationAppointment(string ptno, string presno)
        {
            if (ptno.IsEmpty())
            {
                throw new Exception("患者编号为空");
            }
            if (presno.IsEmpty())
            {
                throw new Exception(".");
            }
            var wb = new WhereBuilder();

            wb.And("PTNO", ptno, true);
            wb.And("PRESNO", presno, true);
            wb.And($@"BDATE=  TRUNC(SYSDATE)", AnalyzableKind.KeepOriginal);
            //wb.And("JUPSU", "0", true);
            DBaser.Update("TWOCS_OORDER");
            DBaser["JUPSU"] = "1";
            var count = DBaser.AcceptChanges(wb);

            //if (count <= 0)
            //    throw new Exception($"更新医嘱状态失败", new Exception($"患者编号:{ptno} 处方号:{presno}"));
            return(count);
        }
예제 #20
0
        public override IAI_PATIENT Update(IAI_PATIENT data)
        {
            var wb = new WhereBuilder();

            wb.And("patient_id", data?.patient_id, true);

            DBaser.Update("IAI_PATIENT");
            DBaser["patient_id"]                   = data.patient_id;
            DBaser["id_number"]                    = data.id_number;
            DBaser["name"]                         = data.name;
            DBaser["telecom"]                      = data.telecom;
            DBaser["gender_code"]                  = data.gender_code;
            DBaser["birth_time"]                   = data.birth_time;
            DBaser["street_address_line"]          = data.street_address_line;
            DBaser["state"]                        = data.state;
            DBaser["city"]                         = data.city;
            DBaser["county"]                       = data.county;
            DBaser["street_name_base"]             = data.street_name_base;
            DBaser["street_name"]                  = data.street_name;
            DBaser["house_number"]                 = data.house_number;
            DBaser["postal_code"]                  = data.postal_code;
            DBaser["marital_status_code"]          = data.marital_status_code;
            DBaser["ethnic_group_code"]            = data.ethnic_group_code;
            DBaser["occupation_code"]              = data.occupation_code;
            DBaser["employerorganization_name"]    = data.employerorganization_name;
            DBaser["employerorganization_telecom"] = data.employerorganization_telecom;
            DBaser["asotherids_id1"]               = data.asotherids_id1;
            DBaser["scopingorganization_id1"]      = data.scopingorganization_id1;
            DBaser["asotherids_id2"]               = data.asotherids_id2;
            DBaser["scopingorganization_id2"]      = data.scopingorganization_id2;
            DBaser["personalrelationship_code"]    = data.personalrelationship_code;
            DBaser["personalrelationship_telecom"] = data.personalrelationship_telecom;
            DBaser["relationshipholder1_name"]     = data.relationshipholder1_name;
            DBaser["providerorganization_id"]      = data.providerorganization_id;
            DBaser["providerorganization_name"]    = data.providerorganization_name;
            DBaser["beneficiary_code"]             = data.beneficiary_code;
            if (DBaser.AcceptChanges(wb) <= 0)
            {
                throw new Exception("修改失敗!");
            }

            return(data.Copy());
        }
예제 #21
0
        public override IAI_ORGANIZATION Update(PRPM_IN403010UV01 updateEntity)
        {
            var data = new IAI_ORGANIZATION
            {
                organization_id   = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.id?.extension,
                organization_code = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.code?.code,
                role_name         = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.name,
                addr               = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.addr,
                telecom            = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.telecom?.value,
                effectivetime_high = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.effectiveTime?.high?.value,
                effectivetime_low  = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.effectiveTime?.low?.value,
                name               = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.assignedPrincipalOrganization?.name,
                scoper2_id         = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.assignedPrincipalOrganization?.asAffiliate?.scoper2?.id?.extension,
                scoper2_name       = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.assignedEntity?.assignedPrincipalOrganization?.asAffiliate?.scoper2?.name,
            };

            var wb = new WhereBuilder();

            wb.And("organization_id", data.organization_id, true);

            if (DBaser.QueryValue <int>("select count(*) from IAI_ORGANIZATION", wb) < 0)
            {
                throw new Exception($@"未查找到结果");
            }
            DBaser.Update("IAI_ORGANIZATION");
            DBaser["organization_id"]   = data.organization_id;
            DBaser["organization_code"] = data.organization_code;
            DBaser["role_name"]         = data.role_name;
            DBaser["addr"]               = data.addr;
            DBaser["telecom"]            = data.telecom;
            DBaser["effectivetime_high"] = data.effectivetime_high;
            DBaser["effectivetime_low"]  = data.effectivetime_low;
            DBaser["name"]               = data.name;
            DBaser["scoper2_id"]         = data.scoper2_id;
            DBaser["scoper2_name"]       = data.scoper2_name;
            var ok = DBaser.AcceptChanges(wb);

            if (ok < 1)
            {
                throw new Exception("不存在更改信息");
            }
            return(data);
        }
예제 #22
0
        public override IAI_PROVIDER Insert(PRPM_IN301010UV01 addEntity)
        {
            var data = new IAI_PROVIDER
            {
                healthcareprovider_id   = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.id?.extension,
                healthcareprovider_code = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.code?.code,
                effectivetime_high      = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.effectiveTime?.high?.value,
                effectivetime_low       = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.effectiveTime?.low?.value,
                id_number         = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.id?.extension,
                name              = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.name?.Value,
                gender_code       = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.administrativeGenderCode?.code,
                birth_time        = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.birthTime?.value,
                birth_place       = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.birthplace?.addr,
                organization_id   = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.asAffiliate?.affiliatedPrincipalOrganization?.id?.extension,
                organization_name = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.asAffiliate?.affiliatedPrincipalOrganization?.name,
            };

            var wb = new WhereBuilder();

            wb.And("healthcareprovider_id", data?.healthcareprovider_id, true);

            if (DBaser.QueryValue <int>("select count(*) from IAI_PROVIDER", wb) > 0)
            {
                throw new Exception($@"主键冲突{data.healthcareprovider_id}已存在。");
            }

            DBaser.Insert("IAI_PROVIDER");
            DBaser["healthcareprovider_id"]   = data.healthcareprovider_id;
            DBaser["healthcareprovider_code"] = data.healthcareprovider_code;
            DBaser["effectivetime_high"]      = data.effectivetime_high;
            DBaser["effectivetime_low"]       = data.effectivetime_low;
            DBaser["id_number"]         = data.id_number;
            DBaser["name"]              = data.name;
            DBaser["gender_code"]       = data.gender_code;
            DBaser["birth_time"]        = data.birth_time;
            DBaser["birth_place"]       = data.birth_place;
            DBaser["organization_id"]   = data.organization_id;
            DBaser["organization_name"] = data.organization_name;
            DBaser.AcceptChanges();

            return(data);
        }
예제 #23
0
        /// <summary>
        /// 日间手术室签到
        /// </summary>
        /// <param name="ptno">患者编号</param>
        /// <param name="orderNo">医嘱编号</param>
        public bool InPatientHadCheckedIn2(string ptno, string orderNo)
        {
            var sql = $@"
SELECT      COUNT(*) COUNT 
FROM        TWOCS_PRSLIP_CHECK";
            var wb  = new WhereBuilder();

            wb.And("PTNO", ptno, true);
            wb.And("ORDERNO", orderNo, true);
            wb.And("FLAG =1", AnalyzableKind.KeepOriginal);
            //wb.And("GBOUT IS NULL", AnalyzableKind.KeepOriginal);
            //wb.And("STATUS =0", AnalyzableKind.KeepOriginal);
            wb.And($@"BDATE <= TO_DATE('{Environ.SlowTime.ToString("yyyy-MM-dd")}','YYYY-MM-DD') 
    AND BDATE >= TO_DATE('{Environ.SlowTime.AddDays(-2).ToString("yyyy-MM-dd")}', 'YYYY-MM-DD') ", AnalyzableKind.KeepOriginal);
            wb.And("CHECKDATE IS NOT NULL", AnalyzableKind.KeepOriginal);
            wb.And("CHECKTIME IS NOT NULL", AnalyzableKind.KeepOriginal);
            wb.And("OUTDATE IS  NULL", AnalyzableKind.KeepOriginal);
            wb.And("OUTTIME IS  NULL", AnalyzableKind.KeepOriginal);
            var count = DBaser.QueryValue <string>(sql, wb);

            return(int.TryParse(count, out int result) && result > 0);
        }
예제 #24
0
        public override IAI_PROVIDER Update(PRPM_IN303010UV01 updateEntity)
        {
            var data = new IAI_PROVIDER
            {
                healthcareprovider_id   = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.id?.extension,
                healthcareprovider_code = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.code?.code,
                effectivetime_high      = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.effectiveTime?.high?.value,
                effectivetime_low       = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.effectiveTime?.low?.value,
                id_number         = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.id?.extension,
                name              = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.name?.Value,
                gender_code       = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.administrativeGenderCode?.code,
                birth_time        = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.birthTime?.value,
                birth_place       = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.birthplace?.addr,
                organization_id   = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.asAffiliate?.affiliatedPrincipalOrganization?.id?.extension,
                organization_name = updateEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.healthCareProvider?.healthCarePrincipalPerson?.asAffiliate?.affiliatedPrincipalOrganization?.name,
            };

            var wb = new WhereBuilder();

            wb.And("healthcareprovider_id", data?.healthcareprovider_id, true);

            DBaser.Update("IAI_PROVIDER");
            DBaser["healthcareprovider_id"]   = data.healthcareprovider_id;
            DBaser["healthcareprovider_code"] = data.healthcareprovider_code;
            DBaser["effectivetime_high"]      = data.effectivetime_high;
            DBaser["effectivetime_low"]       = data.effectivetime_low;
            DBaser["id_number"]         = data.id_number;
            DBaser["name"]              = data.name;
            DBaser["gender_code"]       = data.gender_code;
            DBaser["birth_time"]        = data.birth_time;
            DBaser["birth_place"]       = data.birth_place;
            DBaser["organization_id"]   = data.organization_id;
            DBaser["organization_name"] = data.organization_name;
            var ok = DBaser.AcceptChanges(wb);

            if (ok < 1)
            {
                throw new Exception("不存在更改信息");
            }
            return(data);
        }
예제 #25
0
        /// <summary>
        /// 已签到未发药 已分配窗口
        /// </summary>
        public PharmacyWindow[] GetCurrentWindow(string ptno, string presno)
        {
            var sql = $@"
SELECT      DISTINCT(CHUANGKOU) CODE
FROM        TWOCS_PRSLIP
{{0}}
GROUP BY    CHUANGKOU";
            var wb  = new WhereBuilder();

            wb.And("PTNO", ptno, true);
            wb.And("PRESNO", presno, true);
            wb.And("BDATE=  TRUNC(SYSDATE)", AnalyzableKind.KeepOriginal);
            wb.And("CHECKDATE IS NOT NULL", AnalyzableKind.KeepOriginal);
            wb.And("CHECKTIME IS NOT NULL", AnalyzableKind.KeepOriginal);
            wb.And("(GBOUT IS NULL OR GBOUT =0) ", AnalyzableKind.KeepOriginal);

            return(DBaser.Query <PharmacyWindow>(sql, wb));
        }
예제 #26
0
        /// <summary>
        /// 已签到未取药 true
        /// </summary>
        public bool HadCheckedInWindow(string ptno, string presno)
        {
            var sql = $@"
SELECT      COUNT(*) COUNT 
FROM        TWOCS_PRSLIP";
            var wb  = new WhereBuilder();

            wb.And("PTNO", ptno, true);
            wb.And("PRESNO", presno, true);
            wb.And("BDATE=  TRUNC(SYSDATE)", AnalyzableKind.KeepOriginal);
            wb.And("CHECKDATE IS NOT NULL", AnalyzableKind.KeepOriginal);
            wb.And("CHECKTIME IS NOT NULL", AnalyzableKind.KeepOriginal);

            wb.And("(GBOUT IS NULL OR GBOUT =0) ", AnalyzableKind.KeepOriginal);
            var count = DBaser.QueryValue <string>(sql, wb);

            return(int.TryParse(count, out int result) && result > 0);
        }
예제 #27
0
        public override IAI_OBSERVATION Insert(POOR_IN200901UV addEntity)
        {
            var data = new IAI_OBSERVATION
            {
                observation_id           = addEntity?.controlActProcess?.subject?.observationRequest?.id?.extension,
                observation_type         = addEntity?.controlActProcess?.subject?.observationRequest?.code,
                observation_text         = addEntity?.controlActProcess?.subject?.observationRequest?.text,
                effectivetime_high       = addEntity.controlActProcess?.subject?.observationRequest?.effectiveTime?.high?.value,
                effectivetime_low        = addEntity.controlActProcess?.subject?.observationRequest?.effectiveTime?.low?.value,
                prioritycode             = addEntity?.controlActProcess?.subject?.observationRequest?.priorityCode?.code,
                specimen_id              = addEntity?.controlActProcess?.subject?.observationRequest?.specimen?.specimen?.id.extension,
                specimen_code            = addEntity?.controlActProcess?.subject?.observationRequest?.specimen?.specimen?.code,
                specimen_desc            = addEntity?.controlActProcess?.subject?.observationRequest?.specimen?.specimen?.specimenNatural.desc,
                additive3                = addEntity?.controlActProcess?.subject?.observationRequest?.specimen?.specimen?.specimenNatural?.additive?.additive3?.desc?.Value,
                productOf_time           = addEntity?.controlActProcess?.subject?.observationRequest?.specimen?.specimen?.productOf.time.value,
                specimenProcessStep_time = addEntity?.controlActProcess?.subject?.observationRequest?.specimen?.specimen?.productOf?.specimenProcessStep?.effectiveTime?.value,


                recordtarget                 = addEntity?.controlActProcess?.subject?.observationRequest?.recordTarget?.patient?.id[0].extension,
                author_time                  = addEntity?.controlActProcess?.subject?.observationRequest?.author?.time.value,
                signaturetext                = addEntity?.controlActProcess?.subject?.observationRequest?.author?.signatureText,
                author_assignedentity_id     = addEntity?.controlActProcess?.subject?.observationRequest?.author?.assignedEntity?.id.extension,
                assignedperson_name          = addEntity?.controlActProcess?.subject?.observationRequest?.author?.assignedEntity?.assignedPerson?.name.Value,
                representedorganization_id   = addEntity?.controlActProcess?.subject?.observationRequest?.author?.assignedEntity?.representedOrganization?.id.extension,
                representedorganization_name = addEntity?.controlActProcess?.subject?.observationRequest?.author?.assignedEntity?.representedOrganization?.name,
                verifier_time                = addEntity?.controlActProcess?.subject?.observationRequest?.verifier?.time.value,
                verifier_signaturetext       = addEntity?.controlActProcess?.subject?.observationRequest?.verifier?.signatureText,
                verifier_assignedentity_id   = addEntity?.controlActProcess?.subject?.observationRequest?.verifier?.assignedEntity?.id.extension,
                verifier_assignedperson_name = addEntity?.controlActProcess?.subject?.observationRequest?.verifier?.assignedEntity?.assignedPerson?.name.Value,
                goal_text                     = addEntity?.controlActProcess?.subject?.observationRequest?.goal?.observationEventCriterion?.text,
                goal_reason                   = addEntity?.controlActProcess?.subject?.observationRequest?.reason[0].observation.value.Value,
                annotation_text               = addEntity?.controlActProcess?.subject?.observationRequest?.subjectOf6?.annotation?.text,
                annotation_author_id          = addEntity?.controlActProcess?.subject?.observationRequest?.subjectOf6?.annotation?.author?.assignedEntity?.id.extension,
                annotation_author_name        = addEntity?.controlActProcess?.subject?.observationRequest?.subjectOf6?.annotation?.author?.assignedEntity?.assignedPerson?.name.Value,
                represented_organization_id   = addEntity?.controlActProcess?.subject?.observationRequest?.subjectOf6?.annotation?.author?.assignedEntity?.representedOrganization?.id.extension,
                represented_organization_name = addEntity?.controlActProcess?.subject?.observationRequest?.subjectOf6?.annotation?.author?.assignedEntity?.representedOrganization?.name,

                encounter_id = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.componentOf1?.encounter?.id,
            };


            var wb = new WhereBuilder();

            wb.And("observation_id", data.observation_id, true);
            if (DBaser.QueryValue <int>("select count(*) from IAI_OBSERVATION", wb) > 0)
            {
                throw new Exception($@"主键冲突{data.observation_id}已存在。");
            }
            DBaser.Insert("IAI_OBSERVATION");
            DBaser["observation_id"]                = data.observation_id;
            DBaser["observation_type"]              = data.observation_type;
            DBaser["observation_text"]              = data.observation_text;
            DBaser["effectivetime_high"]            = data.effectivetime_high;
            DBaser["effectivetime_low"]             = data.effectivetime_low;
            DBaser["prioritycode"]                  = data.prioritycode;
            DBaser["specimen_id"]                   = data.specimen_id;
            DBaser["specimen_code"]                 = data.specimen_code;
            DBaser["specimen_desc"]                 = data.specimen_desc;
            DBaser["additive3"]                     = data.additive3;
            DBaser["productOf_time"]                = data.productOf_time;
            DBaser["specimenProcessStep_time"]      = data.specimenProcessStep_time;
            DBaser["recordtarget"]                  = data.recordtarget;
            DBaser["author_time"]                   = data.author_time;
            DBaser["signaturetext"]                 = data.signaturetext;
            DBaser["author_assignedentity_id"]      = data.author_assignedentity_id;
            DBaser["assignedperson_name"]           = data.assignedperson_name;
            DBaser["representedorganization_id"]    = data.representedorganization_id;
            DBaser["representedorganization_name"]  = data.representedorganization_name;
            DBaser["verifier_time"]                 = data.verifier_time;
            DBaser["verifier_signaturetext"]        = data.verifier_signaturetext;
            DBaser["verifier_assignedentity_id"]    = data.verifier_assignedentity_id;
            DBaser["verifier_assignedperson_name"]  = data.verifier_assignedperson_name;
            DBaser["goal_text"]                     = data.goal_text;
            DBaser["goal_reason"]                   = data.goal_reason;
            DBaser["annotation_text"]               = data.annotation_text;
            DBaser["annotation_author_id"]          = data.annotation_author_id;
            DBaser["annotation_author_name"]        = data.annotation_author_name;
            DBaser["represented_organization_id"]   = data.represented_organization_id;
            DBaser["represented_organization_name"] = data.represented_organization_name;
            DBaser.AcceptChanges();
            return(data);
        }
예제 #28
0
        public override IAI_ORDER Insert(POOR_IN200901UV addEntity)
        {
            string _effectivetime_high = "", _effectivetime_low = "", _effectivetime_period = "", _effectivetime_unit = "";

            if (addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime.Count() >= 1)
            {
                _effectivetime_high = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime[0]?.high?.value;
                _effectivetime_low  = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime[0]?.low?.value;
            }
            if (addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime.Count() >= 2)
            {
                _effectivetime_period = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime[1]?.period?.value;
                _effectivetime_unit   = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime[1]?.period?.unit;
            }
            var data = new IAI_ORDER
            {
                order_id                     = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.id?.extension,
                order_type_code              = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.code?.code,
                text                         = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.text,
                effectivetime_high           = _effectivetime_high,   // addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime[0]?.high?.value,
                effectivetime_low            = _effectivetime_low,    //addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime[0]?.low?.value,
                effectivetime_period         = _effectivetime_period, //addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime[1]?.period?.value,
                effectivetime_unit           = _effectivetime_unit,   // addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.effectiveTime[1]?.period?.unit,
                route_code                   = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.routeCode?.code,
                dose_quantity                = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.doseQuantity?.value,
                dose_quantity_unit           = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.doseQuantity?.unit,
                numertor                     = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.doseCheckQuantity?.numerator?.value,
                denominator                  = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.doseCheckQuantity?.denominator?.value,
                unit_code                    = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.administrationUnitCode?.code,
                medicine_name                = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.consumable2?.medication1?.administerableMedicine?.name,
                capacity_quantity            = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.consumable2?.medication1?.administerableMedicine?.asContent?.containerPackagedMedicine?.capacityQuantity?.value,
                patient_id                   = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.componentOf1?.encounter?.subject?.patient?.patientPerson?.id?.extension,
                author_time                  = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.author?.time?.value,
                signature_text               = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.author?.signatureText,
                assignedentity_id            = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.author?.assignedEntity?.id.extension,
                assignedperson_name          = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.author?.assignedEntity?.assignedPerson?.name?.Value,
                organization_id              = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.author?.assignedEntity?.representedOrganization?.id?.extension,
                organization_name            = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.author?.assignedEntity?.representedOrganization?.name,
                verifier_time                = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.verifier?.time?.value,
                verifier_assignedentity_id   = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.verifier?.assignedEntity?.id?.extension,
                verifier_assignedentity_name = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.verifier?.assignedEntity?.assignedPerson?.name?.Value,
                annotion_text                = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.subjectOf6?.annotation?.text,
                annotion_status_code         = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.subjectOf6?.annotation?.statusCode.code,
                annotion_author_id           = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.subjectOf6?.annotation?.author?.assignedEntity?.id?.extension,
                annotion_author_name         = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.subjectOf6?.annotation?.author?.assignedEntity?.assignedPerson?.name?.Value,
                annotion_organization_id     = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.subjectOf6?.annotation?.author?.assignedEntity?.representedOrganization?.id?.extension,
                annotion_organization_name   = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.subjectOf6?.annotation?.author?.assignedEntity?.representedOrganization?.name,
                encounter_id                 = addEntity.controlActProcess?.subject?.substanceAdministrationRequest?.componentOf1?.encounter?.id,
            };


            var wb = new WhereBuilder();

            wb.And("order_id", data.order_id, true);
            if (DBaser.QueryValue <int>("select count(*) from IAI_ORDER", wb) > 0)
            {
                throw new Exception($@"主键冲突{data.order_id}已存在。");
            }
            DBaser.Insert("IAI_ORDER");
            DBaser["order_id"]             = data.order_id;
            DBaser["order_type_code"]      = data.order_type_code;
            DBaser["text"]                 = data.text;
            DBaser["effectivetime_high"]   = data.effectivetime_high;
            DBaser["effectivetime_low"]    = data.effectivetime_low;
            DBaser["effectivetime_period"] = data.effectivetime_period;
            DBaser["effectivetime_unit"]   = data.effectivetime_unit;
            DBaser["route_code"]           = data.route_code;
            DBaser["dose_quantity"]        = data.dose_quantity;
            DBaser["dose_quantity_unit"]   = data.dose_quantity_unit;
            DBaser["numertor"]             = data.numertor;
            DBaser["denominator"]          = data.denominator;
            DBaser["unit_code"]            = data.unit_code;
            DBaser["medicine_name"]        = data.medicine_name;
            DBaser["capacity_quantity"]    = data.capacity_quantity;
            DBaser["patient_id"]           = data.patient_id;
            DBaser["author_time"]          = data.author_time;


            DBaser["signature_text"] = data.signature_text;

            DBaser["assignedentity_id"]   = data.assignedentity_id;
            DBaser["assignedperson_name"] = data.assignedperson_name;
            DBaser["organization_id"]     = data.organization_id;

            DBaser["organization_name"] = data.organization_name;
            DBaser["verifier_time"]     = data.verifier_time;

            DBaser["verifier_assignedentity_id"]   = data.verifier_assignedentity_id;
            DBaser["verifier_assignedentity_name"] = data.verifier_assignedentity_name;
            DBaser["annotion_text"]              = data.annotion_text;
            DBaser["annotion_status_code"]       = data.annotion_status_code;
            DBaser["annotion_author_id"]         = data.annotion_author_id;
            DBaser["annotion_author_name"]       = data.annotion_author_name;
            DBaser["annotion_organization_id"]   = data.annotion_organization_id;
            DBaser["annotion_organization_name"] = data.annotion_organization_name;
            DBaser["encounter_id"] = data.encounter_id;
            DBaser.AcceptChanges();
            return(data);
        }
예제 #29
0
        public override IAI_PATIENT Insert(PRPA_IN201311UV02 addEntity)
        {
            var asOtherIDs = addEntity.controlActProcess.subject.registrationRequest.subject1.patient.patientPerson.asOtherIDs;
            var data       = new IAI_PATIENT()
            {
                patient_id                   = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.id?.extension,
                id_number                    = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.id?.extension,
                name                         = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.name?.Value,
                telecom                      = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.telecom?.value,
                gender_code                  = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.administrativeGenderCode?.code,
                birth_time                   = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.birthTime?.value,
                street_address_line          = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.addr?.streetAddressLine?.Value,
                state                        = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.addr?.state?.Value,
                city                         = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.addr?.city,
                county                       = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.addr?.county,
                street_name_base             = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.addr?.streetNameBase,
                street_name                  = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.addr?.streetName,
                house_number                 = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.addr?.houseNumber,
                postal_code                  = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.addr?.postalCode,
                marital_status_code          = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.maritalStatusCode?.code,
                ethnic_group_code            = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.ethnicGroupCode?.code,
                occupation_code              = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.asEmployee?.occupationCode?.code,
                employerorganization_name    = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.asEmployee?.employerOrganization?.name,
                employerorganization_telecom = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.asEmployee?.employerOrganization?.contactParty?.telecom?.value,
                asotherids_id1               = asOtherIDs?.Length >= 1 ? asOtherIDs[0]?.id?.extension : "",
                scopingorganization_id1      = asOtherIDs?.Length >= 1 ? asOtherIDs[0]?.scopingOrganization?.id?.extension : "",
                asotherids_id2               = asOtherIDs?.Length >= 2 ? asOtherIDs[1]?.id?.extension : "",
                scopingorganization_id2      = asOtherIDs?.Length >= 2 ? asOtherIDs[1]?.scopingOrganization?.id?.extension : "",
                personalrelationship_code    = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.personalRelationship?.code,
                personalrelationship_telecom = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.personalRelationship?.telecom?.value,
                relationshipholder1_name     = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.patientPerson?.personalRelationship?.relationshipHolder1?.name,
                providerorganization_id      = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.providerOrganization?.id?.extension,
                providerorganization_name    = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.providerOrganization?.name?.Value,
                beneficiary_code             = addEntity?.controlActProcess?.subject?.registrationRequest?.subject1?.patient?.coveredPartyOf?.coverageRecord?.beneficiary?.beneficiary?.code?.code,
            };

            var wb = new WhereBuilder();

            wb.And("patient_id", data?.patient_id, true);

            if (DBaser.QueryValue <int>("select count(*) from IAI_PATIENT", wb) > 0)
            {
                throw new Exception($@"主键冲突{data.patient_id}已存在。");
            }

            DBaser.Insert("IAI_PATIENT");
            DBaser["patient_id"]                   = data.patient_id;
            DBaser["id_number"]                    = data.id_number;
            DBaser["name"]                         = data.name;
            DBaser["telecom"]                      = data.telecom;
            DBaser["gender_code"]                  = data.gender_code;
            DBaser["birth_time"]                   = data.birth_time;
            DBaser["street_address_line"]          = data.street_address_line;
            DBaser["state"]                        = data.state;
            DBaser["city"]                         = data.city;
            DBaser["county"]                       = data.county;
            DBaser["street_name_base"]             = data.street_name_base;
            DBaser["street_name"]                  = data.street_name;
            DBaser["house_number"]                 = data.house_number;
            DBaser["postal_code"]                  = data.postal_code;
            DBaser["marital_status_code"]          = data.marital_status_code;
            DBaser["ethnic_group_code"]            = data.ethnic_group_code;
            DBaser["occupation_code"]              = data.occupation_code;
            DBaser["employerorganization_name"]    = data.employerorganization_name;
            DBaser["employerorganization_telecom"] = data.employerorganization_telecom;
            DBaser["asotherids_id1"]               = data.asotherids_id1;
            DBaser["scopingorganization_id1"]      = data.scopingorganization_id1;
            DBaser["asotherids_id2"]               = data.asotherids_id2;
            DBaser["scopingorganization_id2"]      = data.scopingorganization_id2;
            DBaser["personalrelationship_code"]    = data.personalrelationship_code;
            DBaser["personalrelationship_telecom"] = data.personalrelationship_telecom;
            DBaser["relationshipholder1_name"]     = data.relationshipholder1_name;
            DBaser["providerorganization_id"]      = data.providerorganization_id;
            DBaser["providerorganization_name"]    = data.providerorganization_name;
            DBaser["beneficiary_code"]             = data.beneficiary_code;
            DBaser.AcceptChanges();

            return(data);
        }