Exemple #1
0
        public void SaveExternalValueSet(ImportValueSet valueSet)
        {
            BaseValueSetImportProcess <ImportValueSet, ImportValueSetMember> processor;

            if (valueSet.ImportSource == "PHIN VADS")
            {
                processor = new PhinVadsValueSetImportProcessor <ImportValueSet, ImportValueSetMember>();
            }
            else if (valueSet.ImportSource == "HL7 RIM/RoseTree")
            {
                string      roseTreeLocation = AppSettings.HL7RoseTreeLocation;
                XmlDocument roseTreeDoc      = new XmlDocument();
                roseTreeDoc.Load(roseTreeLocation);

                processor = new HL7RIMValueSetImportProcessor <ImportValueSet, ImportValueSetMember>(roseTreeDoc);
            }
            else
            {
                throw new Exception("Cannot identify which external soure the value set came from.");
            }

            processor.SaveValueSet(this.tdb, valueSet);

            this.tdb.SaveChanges();
        }
Exemple #2
0
        public ImportValueSet SearchPhinVads(string oid)
        {
            PhinVadsValueSetImportProcessor <ImportValueSet, ImportValueSetMember> processor =
                new PhinVadsValueSetImportProcessor <ImportValueSet, ImportValueSetMember>();

            ImportValueSet valueSet = processor.FindValueSet(this.tdb, oid);

            return(valueSet);
        }
Exemple #3
0
        public ImportValueSetResponseModel ImportValueSet(ImportValueSetModel model)
        {
            ImportValueSetResponseModel responseModel = new ImportValueSetResponseModel();

            using (IObjectRepository auditedTdb = DBContext.CreateAuditable(CheckPoint.Instance.UserName, CheckPoint.Instance.HostAddress))
            {
                try
                {
                    switch (model.Source)
                    {
                    case ValueSetImportSources.VSAC:
                        if (!CheckPoint.Instance.HasSecurables(SecurableNames.IMPORT_VSAC))
                        {
                            throw new AuthorizationException("You do not have the securable required to import from VSAC");
                        }

                        Logging.Log.For(this).Debug("Starting VSAC import for " + model.Id);

                        User         currentUser = CheckPoint.Instance.GetUser(auditedTdb);
                        VSACImporter importer    = new VSACImporter(auditedTdb);

                        if (string.IsNullOrEmpty(currentUser.UMLSApiKey))
                        {
                            responseModel.Message = "Your profile does not have your UMLS API Key. <a href=\"/Account/MyProfile\">Update your profile</a> to import from VSAC.";
                            Logging.Log.For(this).Debug("User does not have UMLS API Key stored.");
                            break;
                        }

                        if (!importer.Authenticate(currentUser.UMLSApiKey.DecryptStringAES()))
                        {
                            responseModel.Message = "Invalid UMLS username/password associated with your profile.";
                            Logging.Log.For(this).Debug("User's UMLS credentials are invalid for VSAC import");
                            break;
                        }

                        importer.ImportValueSet(model.Id);
                        responseModel.Success = true;

                        break;

                    case ValueSetImportSources.PHINVADS:
                        if (!CheckPoint.Instance.HasSecurables(SecurableNames.IMPORT_PHINVADS))
                        {
                            throw new AuthorizationException("You do not have the securable required to import from PHIN VADS");
                        }

                        Logging.Log.For(this).Debug("Starting PHIN VADS import for " + model.Id);

                        PhinVadsValueSetImportProcessor <ImportValueSet, ImportValueSetMember> processor =
                            new PhinVadsValueSetImportProcessor <ImportValueSet, ImportValueSetMember>();

                        ImportValueSet valueSet = processor.FindValueSet(auditedTdb, model.Id);

                        processor.SaveValueSet(auditedTdb, valueSet);
                        responseModel.Success = true;

                        break;

                    default:
                        responseModel.Message = "Unknown or unsupported source";
                        break;
                    }

                    if (responseModel.Success)
                    {
                        auditedTdb.SaveChanges();
                    }
                }
                catch (WebException wex)
                {
                    Logging.Log.For(this).Error("An error occurred while importing value set " + model.Id + " from " + model.Source, wex);

                    if (wex.Response != null && wex.Response is HttpWebResponse && ((HttpWebResponse)wex.Response).StatusCode == HttpStatusCode.NotFound)
                    {
                        responseModel.Message = string.Format("Value set with identifier \"{0}\" was not found on the terminology server.", model.Id);
                    }
                    else
                    {
                        responseModel.Message = wex.Message;
                    }
                    responseModel.Success = false;
                }
                catch (Exception ex)
                {
                    Logging.Log.For(this).Error("An error occurred while importing value set " + model.Id + " from " + model.Source, ex);

                    responseModel.Message = ex.Message;
                    responseModel.Success = false;
                }
            }

            return(responseModel);
        }