예제 #1
0
        public string GetOperationList(string operationListJson)
        {
            var operationListDTO = _formListService.GetOperationListDTO();
            var list             = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(operationListJson);

            var MPDListText = "";

            if (list != null)
            {
                foreach (var root in list)
                {
                    foreach (var i in root)
                    {
                        if (i.Key == "id")
                        {
                            var result = Find(operationListDTO.FirstLevels, i.Value);
                            if (result != null)
                            {
                                MPDListText += result.Code + " " + result.Name + "</br>";
                            }
                        }
                        else
                        {
                            if (i.Value != "true" && i.Value != "false")
                            {
                                MPDListText += "\t" + i.Value + "</br>";
                            }
                        }
                    }
                }
            }

            return(MPDListText);
        }
예제 #2
0
        public async Task <ImlLicenseDetailDTO> LicenseDetail(Guid id)
        {
            var model = (await _commonDataService.GetDtoAsync <ImlLicenseDetailDTO>(x => x.Id == id)).FirstOrDefault();

            if (model == null)
            {
                throw new Exception("Ліцензію не знайдено!");
            }

            if (string.IsNullOrEmpty(model.EDRPOU))
            {
                model.OrgName = model.OrgDirector;
            }
            var branchIds             = _commonDataService.GetEntity <ApplicationBranch>(x => x.LimsDocumentId == model.BaseApplicationId).Select(x => x.BranchId).ToList();
            var branches              = _commonDataService.GetEntity <Branch>(x => branchIds.Contains(x.Id)).ToList();
            var listMedicinalForms    = new Dictionary <string, string>();
            var listActiveIngredients = new Dictionary <string, string>();
            var listStorageForms      = new Dictionary <string, string>();
            var listProdResearchDrugs = new Dictionary <string, string>();
            var operationListDTO      = _formListService.GetOperationListDTO();

            foreach (var branch in branches)
            {
                if (branch.OperationListForm == null)
                {
                    continue;
                }
                var list   = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(branch.OperationListForm);
                var result = new Item();
                if (list != null)
                {
                    foreach (var root in list)
                    {
                        foreach (var i in root)
                        {
                            if (i.Key == "id")
                            {
                                result = PrlReportService.Find(operationListDTO.FirstLevels, i.Value);
                                if (result != null)
                                {
                                    if (result.Code.StartsWith('1'))
                                    {
                                        listMedicinalForms.TryAdd(result.Code, result.Name);
                                    }
                                    if (result.Code.StartsWith('2'))
                                    {
                                        listActiveIngredients.TryAdd(result.Code, result.Name);
                                    }
                                    if (result.Code.StartsWith('3'))
                                    {
                                        listStorageForms.TryAdd(result.Code, result.Name);
                                    }
                                    if (result.Code.StartsWith('4'))
                                    {
                                        listProdResearchDrugs.TryAdd(result.Code, result.Name);
                                    }
                                }
                            }
                            else
                            {
                                if (i.Value != "true" && i.Value != "false")
                                {
                                    if (i.Key.StartsWith('1'))
                                    {
                                        listMedicinalForms.Add(i.Key, i.Value);
                                    }
                                    if (i.Key.StartsWith('2'))
                                    {
                                        listActiveIngredients.TryAdd(i.Key, i.Value);
                                    }
                                    if (i.Key.StartsWith('3'))
                                    {
                                        listStorageForms.TryAdd(i.Key, i.Value);
                                    }
                                    if (i.Key.StartsWith('4'))
                                    {
                                        listProdResearchDrugs.TryAdd(i.Key, i.Value);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            foreach (var form in listMedicinalForms)
            {
                model.MedicinalForms += $"{form.Key} {form.Value}</br>";
            }
            foreach (var form in listStorageForms)
            {
                model.StorageForms += $"{form.Key} {form.Value}</br>";
            }
            foreach (var form in listActiveIngredients)
            {
                model.ActiveIngredients += $"{form.Key} {form.Value}</br>";
            }
            foreach (var form in listProdResearchDrugs)
            {
                model.ProdResearchDrugs += $"{form.Key} {form.Value}</br>";
            }



            var limsDocs = _commonDataService.GetEntity <LimsDoc>(limsDoc => limsDoc.OrgUnitId == model.OrgUnitId).ToList();

            Guid?limsDocId = null;
            var  appIds    = new List <Guid>();

            do
            {
                limsDocId = limsDocId ?? model.Id;
                var limsDoc = limsDocs.FirstOrDefault(lic => lic.Id == limsDocId);
                if (limsDoc != null)
                {
                    if (limsDoc.DerivedClass == "ImlLicense")
                    {
                        if (limsDoc.ParentId != null)
                        {
                            limsDocId = limsDoc.ParentId.Value;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else if (limsDoc.DerivedClass == "ImlApplication")
                    {
                        appIds.Add(limsDoc.Id);
                        if (limsDoc.ParentId != null)
                        {
                            limsDocId = limsDoc.ParentId.Value;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        throw new Exception("Виникла помилка");
                    }
                }
                else
                {
                    throw new Exception("Виникла помилка");
                }
            } while (true);

            model.ApplicationList =
                (await _commonDataService.GetDtoAsync <ImlAppListDTO>(app => appIds.Contains(app.Id)))
                .OrderBy(z => z.OrderDate);

            model.FirstAppId = model.ApplicationList.FirstOrDefault(x => x.AppSortEnum == "GetLicenseApplication")?.Id
                               ?? Guid.Empty;
            return(model);
        }
예제 #3
0
        public async Task <IActionResult> Edit(Guid?id, Guid?appId, string sort)
        {
            BranchDetailsDTO         model;
            IEnumerable <EnumRecord> appActivityTypeList = new List <EnumRecord>();

            if (id == null)
            {
                if (appId == null)
                {
                    return(await Task.Run(() => NotFound()));
                }

                model = new BranchDetailsDTO();
                model.ApplicationId = appId.Value;
                //TODO null reference exception
                var apps = await _dataService.GetDtoAsync <ApplicationListDTO>(x => x.Id == appId);

                if (apps != null)
                {
                    model.AppType = apps.SingleOrDefault()?.AppTypeEnum;
                }
                else
                {
                    throw new NullReferenceException("ApplicationListDTO is null");
                }

                model.OrganizationId = new Guid((await _userInfoService.GetCurrentUserInfoAsync()).OrganizationId());

                if ((sort == "AddBranchApplication" && model.AppType == "TRL") || model.AppType == "TRL")
                {
                    appActivityTypeList = _branchService.GetAppActivityTypeList(sort, appId);
                }
            }
            else
            {
                model = (await _dataService.GetDtoAsync <BranchDetailsDTO>()).SingleOrDefault(x => x.Id == id.Value);
                if (model == null)
                {
                    return(NotFound());
                }

                model.AppType = (await _dataService.GetDtoAsync <ApplicationListDTO>()).SingleOrDefault(x => x.Id == model.ApplicationId)?.AppTypeEnum;

                var branchAppTypeModel = _dataService.GetDto <EntityEnumDTO>(x => x.BranchId == model.Id && x.EntityType == "BranchApplication")?.FirstOrDefault();

                model.TrlActivityType = branchAppTypeModel?.EnumCode;

                if ((sort == "AddBranchApplication" && model.AppType == "TRL") || model.AppType == "TRL")
                {
                    appActivityTypeList = _branchService.GetAppActivityTypeList(model.AppType, appId);
                }
            }

            if (model.AppType == "TRL")
            {
                var pharmacyList = _branchService.GetPharmacyList(id, appId);

                ViewBag.PharmacyList = new SelectList(pharmacyList.Select(p => new { p.Id, p.Name }), nameof(BranchListDTO.Id), nameof(BranchListDTO.Name));

                ViewBag.trlActivityTypeList =
                    new SelectList(appActivityTypeList, nameof(EnumRecord.Code), nameof(EnumRecord.Name));
            }

            model.OperationListDTO    = _formListService.GetOperationListDTO();
            ViewBag.OperationListJson = JsonConvert.SerializeObject(model.OperationListDTO);
            ViewBag.AppId             = appId;

            return(View(model));
        }