Beispiel #1
0
        private TermMaster GetTermMaster(TermMaster request)
        {
            var        id    = request?.Id;
            TermMaster ret   = null;
            var        query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <TermMaster>(currentUser, "TermMaster", request.Select);

            DocEntityTermMaster entity = null;

            if (id.HasValue)
            {
                entity = DocEntityTermMaster.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No TermMaster found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
Beispiel #2
0
        public TermMaster Post(TermMasterCopy request)
        {
            TermMaster ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityTermMaster.Get(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pBioPortal = entity.BioPortal;
                    if (!DocTools.IsNullOrEmpty(pBioPortal))
                    {
                        pBioPortal += " (Copy)";
                    }
                    var pCategories = entity.Categories.ToList();
                    var pCUI        = entity.CUI;
                    if (!DocTools.IsNullOrEmpty(pCUI))
                    {
                        pCUI += " (Copy)";
                    }
                    var pEnum   = entity.Enum;
                    var pMedDRA = entity.MedDRA;
                    if (!DocTools.IsNullOrEmpty(pMedDRA))
                    {
                        pMedDRA += " (Copy)";
                    }
                    var pName = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var pRxNorm = entity.RxNorm;
                    if (!DocTools.IsNullOrEmpty(pRxNorm))
                    {
                        pRxNorm += " (Copy)";
                    }
                    var pSNOWMED = entity.SNOWMED;
                    if (!DocTools.IsNullOrEmpty(pSNOWMED))
                    {
                        pSNOWMED += " (Copy)";
                    }
                    var pSynonyms = entity.Synonyms.ToList();
                    var pTUI      = entity.TUI;
                    if (!DocTools.IsNullOrEmpty(pTUI))
                    {
                        pTUI += " (Copy)";
                    }
                    var pURI = entity.URI;
                    if (!DocTools.IsNullOrEmpty(pURI))
                    {
                        pURI += " (Copy)";
                    }
                    var copy = new DocEntityTermMaster(ssn)
                    {
                        Hash        = Guid.NewGuid()
                        , BioPortal = pBioPortal
                        , CUI       = pCUI
                        , Enum      = pEnum
                        , MedDRA    = pMedDRA
                        , Name      = pName
                        , RxNorm    = pRxNorm
                        , SNOWMED   = pSNOWMED
                        , TUI       = pTUI
                        , URI       = pURI
                    };
                    foreach (var item in pCategories)
                    {
                        entity.Categories.Add(item);
                    }

                    foreach (var item in pSynonyms)
                    {
                        entity.Synonyms.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }