Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 是否存在毒麻药品
        /// </summary>
        public bool HasDMOrder(string PRESNO)
        {
            var sql = $@"
SELECT      COUNT(*) C FROM (
SELECT      (CASE WHEN P.BUN IN ('E0','E1') AND P.GBHIGH IS NULL THEN 'K'  
            WHEN P.BUN IN ('E2') AND P.GBHIGH IS NULL THEN 'Z'  
            WHEN P.BUN IN ('F0','F1') THEN 'C' 
            WHEN P.GBHIGH ='N' AND SLIPNO NOT IN ('1132','2132') THEN 'D' 
            WHEN P.GBHIGH ='N' AND SLIPNO IN ('1132','2132') THEN 'D2' ELSE  '0' END) DM FROM TWOCS_PRSLIP P
            WHERE PRESNO='{PRESNO}' )K WHERE K.DM ='D' ";
            var wb  = new WhereBuilder();
            var r   = DBaser.QueryValue <int>(sql, wb);

            return(r > 0);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取发药编号
        /// </summary>
        /// <returns></returns>
        public int GetTuyakNo()
        {
            var sql = $@"
SELECT      TW_HSP_PMPA.SEQ_TUYAK.NEXTVAL TUYAK 
FROM        DUAL";

            var wb = new WhereBuilder();
            var No = DBaser.QueryValue <int>(sql, wb);

            if (No < 1)
            {
                throw new Exception("错误编号");
            }

            return(No);
        }
        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);
        }
Exemplo n.º 9
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);
        }
        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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 日间手术 已签到未取药 true
        /// </summary>
        public bool InPatientHadCheckedIn(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);
            var count = DBaser.QueryValue <string>(sql, wb);

            int.TryParse(count, out int result);
            return(result > 0);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 已签到未取药 true
        /// </summary>
        public bool HadCheckedIn(string ptno, string presno)
        {
            var sql = $@"
SELECT      COUNT(*) COUNT 
FROM        TWOCS_PRSLIP
where BDATE > TRUNC(SYSDATE-3)
and PTNO= '{ptno}'
and PRESNO='{presno}'
and CHECKDATE IS NOT NULL
and CHECKTIME IS NOT NULL";

            var wb = new WhereBuilder();
            //wb.And("PTNO", ptno, true);
            //wb.And("PRESNO", presno, true);
            //wb.And("FLAG =1", AnalyzableKind.KeepOriginal);
            //wb.And("GBOUT IS NULL", AnalyzableKind.KeepOriginal);
            //wb.And("STATUS =0", AnalyzableKind.KeepOriginal);
            //wb.And("BDATE > TRUNC(SYSDATE-3)", AnalyzableKind.KeepOriginal);
            //wb.And("CHECKDATE IS NOT NULL", AnalyzableKind.KeepOriginal);
            //wb.And("CHECKTIME IS NOT NULL", AnalyzableKind.KeepOriginal);
            var count = DBaser.QueryValue <string>(sql, wb);

            return(int.TryParse(count, out int result) && result > 0);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
        }