protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_EBBVPPC_1519 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            P_L6PA_GBBVPfID_1714 getPatientParam = new P_L6PA_GBBVPfID_1714();
            getPatientParam.HEC_PatientID = Parameter.HEC_PatientID;
            L6PA_GBBVPfID_1714 patient = cls_Get_BBV_Patients_For_ID.Invoke(Connection, Transaction, getPatientParam, securityTicket).Result;

            if (patient == null)
            {
                var error = new FR_Guid();
                error.ErrorMessage = "No Such ID";
                error.Status       = FR_Status.Error_Internal;
                return(error);
            }

            ORM_HEC_STU_Study_ParticipatingPatient.Query ppQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query();
            ppQuery.IsDeleted    = false;
            ppQuery.Tenant_RefID = securityTicket.TenantID;
            ppQuery.HEC_STU_Study_ParticipatingPatientID = patient.HEC_STU_Study_ParticipatingPatientID;
            var ppRes = ORM_HEC_STU_Study_ParticipatingPatient.Query.Search(Connection, Transaction, ppQuery);

            ORM_HEC_STU_Study_ParticipatingPatient ParticipatingPatient = ppRes[0];
            ParticipatingPatient.Participation_Comment = Parameter.Comment;
            ParticipatingPatient.Save(Connection, Transaction);

            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_SBBVAFP_1332 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            P_L6PA_GBBVPfID_1714 getPatientParam = new P_L6PA_GBBVPfID_1714();
            getPatientParam.HEC_PatientID = Parameter.HEC_PatientID;
            L6PA_GBBVPfID_1714 patient = cls_Get_BBV_Patients_For_ID.Invoke(Connection, Transaction, getPatientParam, securityTicket).Result;

            if (patient == null)
            {
                var error = new FR_Guid();
                error.ErrorMessage = "No Such ID";
                error.Status       = FR_Status.Error_Internal;
                return(error);
            }

            ORM_CMN_PER_PersonInfo_2_Address.Query query = new ORM_CMN_PER_PersonInfo_2_Address.Query();
            query.CMN_PER_PersonInfo_RefID = patient.CMN_PER_PersonInfoID;
            query.Tenant_RefID             = securityTicket.TenantID;
            query.IsDeleted = false;
            var queryRes = ORM_CMN_PER_PersonInfo_2_Address.Query.Search(Connection, Transaction, query);

            ORM_CMN_Address address = new ORM_CMN_Address();
            if (Parameter.CMN_AddressID != Guid.Empty)
            {
                var result = address.Load(Connection, Transaction, Parameter.CMN_AddressID);
                if (result.Status != FR_Status.Success || address.CMN_AddressID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }
            address.Street_Name     = Parameter.Street_Name;
            address.Street_Number   = Parameter.Street_Number;
            address.City_Name       = Parameter.City_Name;
            address.City_PostalCode = Parameter.City_PostalCode;
            address.Province_Name   = Parameter.Province_Name;
            address.Tenant_RefID    = securityTicket.TenantID;
            address.Save(Connection, Transaction);

            ORM_CMN_PER_PersonInfo_2_Address assignment = queryRes.FirstOrDefault(a => a.CMN_Address_RefID == Parameter.CMN_AddressID);
            if (assignment == null)
            {
                assignment = new ORM_CMN_PER_PersonInfo_2_Address();

                assignment.CMN_Address_RefID        = address.CMN_AddressID;
                assignment.CMN_PER_PersonInfo_RefID = patient.CMN_PER_PersonInfoID;
                assignment.Tenant_RefID             = securityTicket.TenantID;
                if (queryRes.Count == 0)
                {
                    assignment.IsPrimary = true;
                }
                assignment.SequenceNumber = queryRes.Count + 1;
            }

            assignment.Save(Connection, Transaction);

            returnValue.Result = address.CMN_AddressID;
            return(returnValue);

            #endregion UserCode
        }
Example #3
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_SBBVPP_1434 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            P_L6PA_GBBVPfID_1714 getPatientParam = new P_L6PA_GBBVPfID_1714();
            getPatientParam.HEC_PatientID = Parameter.HEC_PatientID;
            L6PA_GBBVPfID_1714 patient = cls_Get_BBV_Patients_For_ID.Invoke(Connection, Transaction, getPatientParam, securityTicket).Result;

            if (patient == null)
            {
                var error = new FR_Guid();
                error.ErrorMessage = "No Such ID";
                error.Status       = FR_Status.Error_Internal;
                return(error);
            }

            ORM_HEC_STU_Study currentStudy;

            ORM_HEC_STU_Study.Query StudyQuer = new ORM_HEC_STU_Study.Query();
            StudyQuer.Tenant_RefID             = securityTicket.TenantID;
            StudyQuer.IsDeleted                = false;
            StudyQuer.GlobalPropertyMatchingID = STLD_Sudies.Sudies_GlobalProperty;
            var studyRes = ORM_HEC_STU_Study.Query.Search(Connection, Transaction, StudyQuer);
            if (studyRes.Count == 0)
            {
                ORM_HEC_STU_Study study = new ORM_HEC_STU_Study();
                study.GlobalPropertyMatchingID = STLD_Sudies.Sudies_GlobalProperty;
                study.Tenant_RefID             = securityTicket.TenantID;
                study.Save(Connection, Transaction);
                currentStudy = study;
            }
            else
            {
                currentStudy = studyRes[0];
            }

            ORM_HEC_STU_Study_ParticipatingPatient.Query ppQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query();
            ppQuery.IsDeleted    = false;
            ppQuery.Tenant_RefID = securityTicket.TenantID;
            ppQuery.HEC_STU_Study_ParticipatingPatientID = patient.HEC_STU_Study_ParticipatingPatientID;
            var ppRes = ORM_HEC_STU_Study_ParticipatingPatient.Query.Search(Connection, Transaction, ppQuery);

            ORM_HEC_STU_Study_ParticipatingPatient ParticipatingPatient = ppRes[0];
            ParticipatingPatient.Study_RefID = currentStudy.HEC_STU_StudyID;
            ParticipatingPatient.Participation_DateOfSigning = DateTime.Now;
            ParticipatingPatient.Save(Connection, Transaction);

            if (Parameter.Documents != null)
            {
                foreach (var doc in Parameter.Documents)
                {
                    ORM_DOC_SLT_DocumentSlot currentSlot;

                    ORM_DOC_SLT_DocumentSlot.Query QueryORM_DOC_SLT_DocumentSlotQuery = new ORM_DOC_SLT_DocumentSlot.Query();
                    QueryORM_DOC_SLT_DocumentSlotQuery.Tenant_RefID             = securityTicket.TenantID;
                    QueryORM_DOC_SLT_DocumentSlotQuery.IsDeleted                = false;
                    QueryORM_DOC_SLT_DocumentSlotQuery.GlobalPropertyMatchingID = doc.DocSlot_GlobalPropertyMatching;
                    var QueryORM_DOC_SLT_DocumentSlotQueryRes = ORM_DOC_SLT_DocumentSlot.Query.Search(Connection, Transaction, QueryORM_DOC_SLT_DocumentSlotQuery);
                    if (QueryORM_DOC_SLT_DocumentSlotQueryRes.Count == 0)
                    {
                        ORM_DOC_SLT_DocumentSlot DocumentSlot = new ORM_DOC_SLT_DocumentSlot();
                        DocumentSlot.GlobalPropertyMatchingID = doc.DocSlot_GlobalPropertyMatching;
                        DocumentSlot.Tenant_RefID             = securityTicket.TenantID;
                        DocumentSlot.Save(Connection, Transaction);
                        currentSlot = DocumentSlot;
                    }
                    else
                    {
                        currentSlot = QueryORM_DOC_SLT_DocumentSlotQueryRes[0];
                    }

                    ORM_HEC_STU_Study_ParticipationRequiredDocument ParticipationRequiredDocument = new ORM_HEC_STU_Study_ParticipationRequiredDocument();
                    ParticipationRequiredDocument.Tenant_RefID = securityTicket.TenantID;
                    ParticipationRequiredDocument.Study_RefID  = currentStudy.HEC_STU_StudyID;
                    ParticipationRequiredDocument.DOC_SLT_DocumentSlot_RefID         = currentSlot.DOC_SLT_DocumentSlotID;
                    ParticipationRequiredDocument.IsRequiredFor_PatientParticipation = true;
                    ParticipationRequiredDocument.Save(Connection, Transaction);

                    ORM_HEC_STU_Study_PatientDocument PatientDocument = new ORM_HEC_STU_Study_PatientDocument();
                    PatientDocument.Tenant_RefID = securityTicket.TenantID;
                    PatientDocument.ParticipatingPatient_RefID          = ParticipatingPatient.HEC_STU_Study_ParticipatingPatientID;
                    PatientDocument.ParticipationRequiredDocument_RefID = ParticipationRequiredDocument.HEC_STU_Study_ParticipatingPatient_RequiredDocumentID;
                    PatientDocument.Document_RefID = Guid.NewGuid();
                    PatientDocument.Save(Connection, Transaction);

                    var document = new ORM_DOC_Document();
                    document.DOC_DocumentID     = PatientDocument.Document_RefID;
                    document.Alias              = doc.File_Name;
                    document.PrimaryType        = doc.File_Extension;
                    document.Creation_Timestamp = DateTime.Now;
                    document.Tenant_RefID       = securityTicket.TenantID;
                    document.Save(Connection, Transaction);

                    var revision = new ORM_DOC_DocumentRevision();
                    revision.DOC_DocumentRevisionID = Guid.NewGuid();
                    revision.Document_RefID         = PatientDocument.Document_RefID;
                    revision.Revision            = 1;
                    revision.IsLastRevision      = true;
                    revision.UploadedByAccount   = securityTicket.AccountID;
                    revision.File_Name           = doc.File_Name;
                    revision.File_ServerLocation = doc.File_ServerLocation;
                    revision.File_Extension      = doc.File_Extension;
                    revision.File_Size_Bytes     = doc.File_Size_Bytes;
                    revision.Creation_Timestamp  = DateTime.Now;
                    revision.Tenant_RefID        = securityTicket.TenantID;
                    revision.Save(Connection, Transaction);
                }
            }

            return(returnValue);

            #endregion UserCode
        }