Beispiel #1
0
        private bool CanCloseStage(EXP_ExpertiseStage stage, int[] nextDicStageIds)
        {
            var nextStages = AppContext.EXP_DIC_Stage.AsNoTracking().Where(e => nextDicStageIds.Contains(e.Id)).ToList();

            switch (stage.EXP_DIC_Stage.Code)
            {
            case EXP_DIC_Stage.PharmaceuticalExp:
                return(!nextStages.Any(e => e.Code == EXP_DIC_Stage.AnalyticalExp));

            case EXP_DIC_Stage.Translate:
                return(AppContext.EXP_ExpertiseStage.Any(e => e.DeclarationId == stage.DeclarationId &&
                                                         e.EXP_DIC_Stage.Code == EXP_DIC_Stage
                                                         .SafetyConclusion && !e.IsHistory));

            case EXP_DIC_Stage.SafetyConclusion:
                return(!AppContext.EXP_ExpertiseStage.Any(e => e.DeclarationId == stage.DeclarationId &&
                                                          e.EXP_DIC_Stage.Code == EXP_DIC_Stage.Translate && !e.IsHistory &&
                                                          e.EXP_DIC_StageStatus.Code != EXP_DIC_StageStatus.Completed));
            }
            return(true);
        }
        private string GetStageText(EXP_ExpertiseStage expertiseStage, EXP_DIC_Type type, bool termless = false, bool isKz = false)
        {
            //  expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.Matches ? ;
            string outStr = string.Empty;

            const string positive = "Положительное";
            const string negative = "Отрицательное";

            const string protocolPositive = "Положительное";  //"{дата протокола} и {№ протокола}, положительное";
            const string protocolNegative = "Отрицательное";  //"{дата протокола} и {№ протокола}, отрицательное";

            const string recommendationsRegistrationPositive5   = "Рекомендована государственная регистрация сроком на 5 лет";
            const string recommendationsReRegistrationPositive5 = "Рекомендована государственная перерегистрация сроком на 5 лет";
            const string recommendationsReRegistrationPositive  = "Рекомендована государственная перерегистрация с выдачей бессрочного регистрационного удостоверения";
            const string recommendationsNegative   = "Отказ в государственной регистрации";
            const string recommendationsReNegative = "Отказ в государственной перерегистрации";


            const string conclusionPositive5 = "Материалы и документы регистрационного досье на лекарственное средство, предоставленные для государственной регистрации в Республике Казахстан, соответствуют установленным требованиям, безопасность, эффективность и качество лекарственного средства подтверждены соответствующими материалами и проведенными испытаниями. Лекарственное средство может быть зарегистрировано в Республике Казахстан сроком на 5 лет.";

            const string conclusionPositiveKz5 = "Қазақстан Республикасында мемлекеттік тіркеуге ұсынылған дәрілік затқа берілген материалдар мен тіркеу дерекнамасының құжаттары белгіленген талаптарға сәйкес келеді, дәрілік заттың қауіпсіздігі, тиімділігі және сапасы тиісті материалдармен және жүргізілген сынақтармен дәлелденді. Дәрілік затты Қазақстан Республикасында 5 жыл мерзімге тіркеуге болады";
            const string conclusionPositive    = "Материалы и документы регистрационного досье на лекарственное средство, предоставленные для государственной перерегистрации в Республике Казахстан, соответствуют установленным требованиям, безопасность, эффективность и качество лекарственного средства подтверждены соответствующими материалами и проведенными испытаниями. Лекарственное средство может быть перезарегистрировано в Республике Казахстан с выдачей бессрочного регистрационного удостворения.";
            const string conclusionNegative    = "Проведенная экспертиза регистрационного досье, представленного для государственной регистрации, в Республике Казахстан показала, что лекарственное средство не соответствует требованиям по безопасности, эффективности и качеству по следующим показателям: ________________ и не может быть зарегистрирован в Республике Казахстан.";


            const string conclutionA = "Материалы и документы регистрационного досье на лекарственное средство, предоставленные для внесения изменений в регистрационное досье, соответствуют установленным требованиям, безопасность, эффективность и качество лекарственного средства подтверждены соответствующими материалами и проведенными испытаниями. Вносимые изменения могут быть зарегистрированы с выдачей нового регистрационного удостворения.";

            switch (expertiseStage.EXP_DIC_Stage.Code)
            {
            case EXP_DIC_Stage.PrimaryExp:
                if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode)
                {
                    return(positive);
                }
                else
                {
                    return(negative);
                }
                break;

            case EXP_DIC_Stage.PharmaceuticalExp:
            case EXP_DIC_Stage.PharmacologicalExp:
                switch (type.Code)
                {
                case TypeCodeConts.Registration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode || expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.RecommendedCode)
                    {
                        return(recommendationsRegistrationPositive5);
                    }
                    else
                    {
                        return(recommendationsNegative);
                    }
                    break;

                case TypeCodeConts.ReRegistration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode || expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.RecommendedCode)
                    {
                        if (termless)
                        {
                            return(recommendationsReRegistrationPositive);
                        }
                        return(recommendationsReRegistrationPositive5);
                    }
                    else
                    {
                        return(recommendationsReNegative);
                    }
                    break;

                case TypeCodeConts.Alteration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode || expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.RecommendedCode)
                    {
                        if (termless)
                        {
                            return(recommendationsReRegistrationPositive);
                        }
                        return(recommendationsRegistrationPositive5);
                    }
                    else
                    {
                        return(recommendationsNegative);
                    }
                    break;
                }
                break;

            case EXP_DIC_Stage.AnalyticalExp:
                switch (type.Code)
                {
                case TypeCodeConts.Registration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode)
                    {
                        return(protocolPositive);
                    }
                    else
                    {
                        return(protocolNegative);
                    }
                    break;

                case TypeCodeConts.ReRegistration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode)
                    {
                        return(protocolPositive);
                    }
                    else
                    {
                        return(protocolNegative);
                    }
                    break;

                case TypeCodeConts.Alteration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode)
                    {
                        return(protocolPositive);
                    }
                    else
                    {
                        return(protocolNegative);
                    }
                    break;
                }
                break;

            case EXP_DIC_Stage.SafetyConclusion:
                switch (type.Code)
                {
                case TypeCodeConts.Registration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode)
                    {
                        if (isKz)
                        {
                            return(conclusionPositiveKz5);
                        }
                        return(conclusionPositive5);
                    }
                    else
                    {
                        return(conclusionNegative);
                    }
                    break;

                case TypeCodeConts.ReRegistration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode)
                    {
                        if (termless)
                        {
                            return(conclusionPositive);
                        }
                        return(conclusionPositive5);
                    }
                    else
                    {
                        return(conclusionNegative);
                    }
                    break;

                case TypeCodeConts.Alteration:
                    if (expertiseStage.EXP_DIC_StageResult.Code == EXP_DIC_StageResult.MatchesCode)
                    {
                        return(conclutionA);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                    break;
                }
                break;
            }

            return(outStr);
        }
Beispiel #3
0
        /// <summary>
        /// Перевод заявления на следующий этап
        /// </summary>
        /// <param name="declaration"></param>
        /// <param name="stageCode"></param>
        public bool ToNextStage(Guid declarationId, Guid?fromStageId, int[] nextStageIds, out string resultDescription)
        {
            resultDescription = null;
            string[] activeStageCodes =
            {
                EXP_DIC_StageStatus.New, EXP_DIC_StageStatus.InWork,
                EXP_DIC_StageStatus.InReWork
            };
            var declaration = AppContext.EXP_DrugDeclaration.FirstOrDefault(e => e.Id == declarationId);

            if (declaration.EXP_DIC_Type.Code != EXP_DIC_Type.Registration)
            {
                return(ToNextStage(declaration, fromStageId, nextStageIds, out resultDescription));
            }
            var currentStage = fromStageId != null
                ? AppContext.EXP_ExpertiseStage.FirstOrDefault(e => e.Id == fromStageId)
                : AppContext.EXP_ExpertiseStage.FirstOrDefault(
                e => e.DeclarationId == declarationId && activeStageCodes.Contains(e.EXP_DIC_StageStatus.Code));

            var dosageIds = AppContext.EXP_DrugDosage.Where(e => e.DrugDeclarationId == declarationId)
                            .Select(e => e.Id)
                            .ToList();
            var stageStatusNew = GetStageStatusByCode(EXP_DIC_StageStatus.New);

            //закрываем предыдущий этап
            if (currentStage != null && CanCloseStage(currentStage, nextStageIds))
            {
                currentStage.StatusId    = GetStageStatusByCode(EXP_DIC_StageStatus.Completed).Id;
                currentStage.FactEndDate = DateTime.Now;
            }
            var isAnalitic = false;

            foreach (var nextStageId in nextStageIds)
            {
                if (!CanSendToStep(declarationId, fromStageId, nextStageId, out resultDescription))
                {
                    return(false);
                }
                //если имеется уже выполняющийся этап то продолжаем его дальше
                if (AppContext.EXP_ExpertiseStage.Any(e => e.DeclarationId == declarationId &&
                                                      e.StageId == nextStageId &&
                                                      e.EXP_DIC_StageStatus.Code != EXP_DIC_StageStatus.Completed &&
                                                      !e.IsHistory))
                {
                    continue;
                }
                var daysOnStage = GetExpStageDaysOnExecution(declaration.TypeId, nextStageId);
                var startDate   = DateTime.Now;
                var newStage    = new EXP_ExpertiseStage()
                {
                    Id            = Guid.NewGuid(),
                    DeclarationId = declarationId,
                    StageId       = nextStageId,
                    ParentStageId = currentStage != null ? (Guid?)currentStage.Id : null,
                    StatusId      = stageStatusNew.Id,
                    StartDate     = startDate,
                    EndDate       = daysOnStage != null ? (DateTime?)startDate.AddDays(daysOnStage.Value) : null
                };
                //todo брать руководителя цоз из настроек
                newStage.Executors.Add(GetExecutorByDicStageId(nextStageId));
                foreach (var dosageId in dosageIds)
                {
                    newStage.EXP_ExpertiseStageDosage.Add(new EXP_ExpertiseStageDosage()
                    {
                        Id                 = Guid.NewGuid(),
                        DosageId           = dosageId,
                        EXP_ExpertiseStage = newStage
                    });
                }
                AppContext.EXP_ExpertiseStage.Add(newStage);
                if (nextStageId == CodeConstManager.STAGE_ANALITIC)
                {
                    isAnalitic = true;
                }
            }
            AppContext.SaveChanges();
            if (isAnalitic)
            {
                CreateDirectionMaterial(declarationId, GetExecutorByDicStageId(CodeConstManager.STAGE_ANALITIC));
            }
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Возвращать на предыдущий этап
        /// </summary>
        /// <param name="declarationId"></param>
        /// <param name="fromStageId"></param>
        /// <param name="nextStageIds"></param>
        /// <param name="resultDescription"></param>
        /// <returns></returns>
        public bool ToBackStage(Guid declarationId, Guid?fromStageId, int[] nextStageIds, out string resultDescription)
        {
            resultDescription = null;
            var stageStatusInRework = GetStageStatusByCode(EXP_DIC_StageStatus.InReWork);

            string[] activeStageCodes = { EXP_DIC_StageStatus.InWork, EXP_DIC_StageStatus.InReWork };
            var      currentStage     = fromStageId != null?AppContext.EXP_ExpertiseStage.FirstOrDefault(e => e.Id == fromStageId)
                                            : AppContext.EXP_ExpertiseStage.FirstOrDefault(e => e.DeclarationId == declarationId && activeStageCodes.Contains(e.EXP_DIC_StageStatus.Code));

            if (currentStage != null)
            {
                currentStage.StatusId    = GetStageStatusByCode(EXP_DIC_StageStatus.Completed).Id;
                currentStage.FactEndDate = DateTime.Now;
            }

            foreach (var nextStageId in nextStageIds)
            {
                if (!CanSendToStep(declarationId, fromStageId, nextStageId, out resultDescription))
                {
                    return(false);
                }

                var oldStage = AppContext.EXP_ExpertiseStage.FirstOrDefault(es => es.IsHistory == false &&
                                                                            es.DeclarationId == declarationId && es.StageId == nextStageId);
                var dosageIds = AppContext.EXP_DrugDosage.Where(e => e.DrugDeclarationId == declarationId)
                                .Select(e => e.Id)
                                .ToList();

                if (oldStage != null)
                {
                    var newStage = new EXP_ExpertiseStage()
                    {
                        Id            = Guid.NewGuid(),
                        DeclarationId = declarationId,
                        StageId       = nextStageId,
                        ParentStageId = oldStage?.Id,
                        StatusId      = stageStatusInRework.Id,
                        OtdIds        = oldStage.OtdIds
                    };
                    newStage.Executors = oldStage.Executors;
                    AppContext.EXP_ExpertiseStage.Add(newStage);

                    oldStage.IsHistory = true;

                    foreach (var dosageId in dosageIds)
                    {
                        var newDosageStage = new EXP_ExpertiseStageDosage()
                        {
                            Id                 = Guid.NewGuid(),
                            DosageId           = dosageId,
                            EXP_ExpertiseStage = newStage
                        };
                        newStage.EXP_ExpertiseStageDosage.Add(newDosageStage);

                        switch (oldStage.EXP_DIC_Stage.Code)
                        {
                        case EXP_DIC_Stage.PharmacologicalExp:
                            var oldpcolFinalDoc = AppContext.EXP_ExpertisePharmacologicalFinalDoc.FirstOrDefault(
                                pc =>
                                pc.EXP_ExpertiseStageDosage.DosageId == dosageId &&
                                pc.EXP_ExpertiseStageDosage.StageId == oldStage.Id);
                            if (oldpcolFinalDoc != null)
                            {
                                var newpcolFinalDoc = new EXP_ExpertisePharmacologicalFinalDoc(oldpcolFinalDoc);
                                newpcolFinalDoc.DosageStageId            = newDosageStage.Id;
                                newpcolFinalDoc.EXP_ExpertiseStageDosage = newDosageStage;
                                newDosageStage.EXP_ExpertisePharmacologicalFinalDoc.Add(newpcolFinalDoc);
                            }
                            break;

                        case EXP_DIC_Stage.PharmaceuticalExp:
                            var oldpceuFinalDoc = AppContext.EXP_ExpertisePharmaceuticalFinalDoc.FirstOrDefault(
                                pc =>
                                pc.EXP_ExpertiseStageDosage.DosageId == dosageId &&
                                pc.EXP_ExpertiseStageDosage.StageId == oldStage.Id);
                            if (oldpceuFinalDoc != null)
                            {
                                var newpceulFinalDoc = new EXP_ExpertisePharmaceuticalFinalDoc(oldpceuFinalDoc);
                                newpceulFinalDoc.DosageStageId            = newDosageStage.Id;
                                newpceulFinalDoc.EXP_ExpertiseStageDosage = newDosageStage;
                                newDosageStage.EXP_ExpertisePharmaceuticalFinalDoc.Add(newpceulFinalDoc);
                            }
                            break;
                        }
                    }
                    AppContext.EXP_ExpertiseStage.Add(newStage);
                }
            }
            AppContext.SaveChanges();
            return(true);
        }
Beispiel #5
0
        private bool ToNextStage(EXP_DrugDeclaration declaration, Guid?fromStageId, int[] nextStageIds, out string resultDescription)
        {
            resultDescription = null;
            string[] activeStageCodes = { EXP_DIC_StageStatus.New, EXP_DIC_StageStatus.InWork, EXP_DIC_StageStatus.InReWork };
            var      currentStage     = fromStageId != null?AppContext.EXP_ExpertiseStage.FirstOrDefault(e => e.Id == fromStageId)
                                            : AppContext.EXP_ExpertiseStage.FirstOrDefault(e => e.DeclarationId == declaration.Id && activeStageCodes.Contains(e.EXP_DIC_StageStatus.Code));

            var dosageIds = AppContext.EXP_DrugDosage.Where(e => e.DrugDeclarationId == declaration.Id)
                            .Select(e => e.Id)
                            .ToList();
            var stageStatusNew    = GetStageStatusByCode(EXP_DIC_StageStatus.New);
            var stageStatusRework = GetStageStatusByCode(EXP_DIC_StageStatus.InReWork);

            //закрываем предыдущий этап
            if (currentStage != null)
            {
                currentStage.StatusId    = GetStageStatusByCode(EXP_DIC_StageStatus.Completed).Id;
                currentStage.FactEndDate = DateTime.Now;
            }
            foreach (var nextStageId in nextStageIds)
            {
                if (!CanSendToStep(declaration.Id, fromStageId, nextStageId, out resultDescription))
                {
                    return(false);
                }
                //если имеется уже выполняющийся этап то продолжаем его дальше
                if (AppContext.EXP_ExpertiseStage.Any(e => e.DeclarationId == declaration.Id &&
                                                      e.StageId == nextStageId && e.EXP_DIC_StageStatus.Code != EXP_DIC_StageStatus.Completed && !e.IsHistory))
                {
                    continue;
                }
                var oldStage = AppContext.EXP_ExpertiseStage.FirstOrDefault(es => es.IsHistory == false &&
                                                                            es.DeclarationId == declaration.Id && es.StageId == nextStageId);
                if (oldStage == null)
                {
                    var daysOnStage = GetExpStageDaysOnExecution(declaration.TypeId, nextStageId);
                    var startDate   = DateTime.Now;
                    var newStage    = new EXP_ExpertiseStage()
                    {
                        Id            = Guid.NewGuid(),
                        DeclarationId = declaration.Id,
                        StageId       = nextStageId,
                        ParentStageId = currentStage != null ? (Guid?)currentStage.Id : null,
                        StatusId      = stageStatusNew.Id,
                        StartDate     = startDate,
                        EndDate       = daysOnStage != null ? (DateTime?)startDate.AddDays(daysOnStage.Value) : null
                    };
                    //todo брать руководителя цоз из настроек
                    newStage.Executors.Add(GetExecutorByDicStageId(nextStageId));
                    foreach (var dosageId in dosageIds)
                    {
                        newStage.EXP_ExpertiseStageDosage.Add(new EXP_ExpertiseStageDosage()
                        {
                            Id                 = Guid.NewGuid(),
                            DosageId           = dosageId,
                            EXP_ExpertiseStage = newStage
                        });
                    }
                    AppContext.EXP_ExpertiseStage.Add(newStage);
                }
                else
                {
                    var reworkStage = new EXP_ExpertiseStage()
                    {
                        Id            = Guid.NewGuid(),
                        DeclarationId = declaration.Id,
                        StageId       = nextStageId,
                        ParentStageId = currentStage != null ? (Guid?)currentStage.Id : null,
                        StatusId      = stageStatusRework.Id,
                        StartDate     = oldStage.StartDate,
                        EndDate       = oldStage.EndDate,
                        OtdIds        = oldStage.OtdIds,
                        OtdRemarks    = oldStage.OtdRemarks
                    };
                    reworkStage.Executors.AddRange(oldStage.Executors);
                    foreach (var dossageStage in oldStage.EXP_ExpertiseStageDosage)
                    {
                        var reworkDosage = new EXP_ExpertiseStageDosage()
                        {
                            Id                 = Guid.NewGuid(),
                            DosageId           = dossageStage.DosageId,
                            EXP_ExpertiseStage = reworkStage
                        };
                        foreach (var primaryFinalDoc in dossageStage.PrimaryFinalDocs)
                        {
                            var docClone = new EXP_ExpertisePrimaryFinalDoc(primaryFinalDoc);
                            docClone.Id = Guid.NewGuid();
                            docClone.EXP_ExpertiseStageDosage = reworkDosage;
                            docClone.DosageStageId            = reworkStage.Id;
                            reworkDosage.PrimaryFinalDocs.Add(docClone);
                        }
                        foreach (var pharmaceuticalFinalDoc in dossageStage.EXP_ExpertisePharmaceuticalFinalDoc)
                        {
                            var docClone = new EXP_ExpertisePharmaceuticalFinalDoc(pharmaceuticalFinalDoc);
                            docClone.Id = Guid.NewGuid();
                            docClone.EXP_ExpertiseStageDosage = reworkDosage;
                            docClone.DosageStageId            = reworkStage.Id;
                            reworkDosage.EXP_ExpertisePharmaceuticalFinalDoc.Add(docClone);
                        }
                        foreach (var pharmacologicalFinalDoc in dossageStage.EXP_ExpertisePharmacologicalFinalDoc)
                        {
                            var docClone = new EXP_ExpertisePharmacologicalFinalDoc(pharmacologicalFinalDoc);
                            docClone.Id = Guid.NewGuid();
                            docClone.EXP_ExpertiseStageDosage = reworkDosage;
                            docClone.DosageStageId            = reworkStage.Id;
                            reworkDosage.EXP_ExpertisePharmacologicalFinalDoc.Add(docClone);
                        }
                        foreach (var safetyreportFinalDoc in dossageStage.EXP_ExpertiseSafetyreportFinalDoc)
                        {
                            var docClone = new EXP_ExpertiseSafetyreportFinalDoc(safetyreportFinalDoc);
                            docClone.Id = Guid.NewGuid();
                            docClone.EXP_ExpertiseStageDosage = reworkDosage;
                            docClone.DosageStageId            = reworkStage.Id;
                            reworkDosage.EXP_ExpertiseSafetyreportFinalDoc.Add(docClone);
                        }
                        foreach (var analiseIndicator in dossageStage.EXP_DrugAnaliseIndicator)
                        {
                            var docClone = new EXP_DrugAnaliseIndicator(analiseIndicator);
                            docClone.Id = Guid.NewGuid();
                            docClone.EXP_ExpertiseStageDosage = reworkDosage;
                            docClone.DosageStageId            = reworkStage.Id;
                            reworkDosage.EXP_DrugAnaliseIndicator.Add(docClone);
                        }
                        reworkStage.EXP_ExpertiseStageDosage.Add(reworkDosage);
                    }
                    AppContext.EXP_ExpertiseStage.Add(reworkStage);
                    oldStage.IsHistory = true;
                }
            }
            AppContext.SaveChanges();
            return(true);
        }