Example #1
0
        public static string GetContextScript()
        {
            string script = @"
<script language=""javascript"">
    var contexts = [";

            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                var contexts = (from tc in tdb.TemplateConstraints
                                select tc.Context).Distinct();

                foreach (string cContext in contexts)
                {
                    script += "\"" + cContext + "\", ";
                }

                script = script.Remove(script.Length - 2);
            }

            script += @"
    ];
</script>";

            return(script);
        }
Example #2
0
 /// <summary>
 /// Gets a list of all templates in the database, excluding the specified template.
 /// </summary>
 /// <param name="excludeTemplate">The template instance that should not be returned as part of the list</param>
 public static List <LookupTemplate> GetTemplatesExcluding(int excludeTemplateId)
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(GetTemplatesExcluding(tdb, excludeTemplateId));
     }
 }
Example #3
0
        public List <PublishStatus> GetPublishStatusesForTemplate(int?implementationGuideId)
        {
            if (implementationGuideId == null)
            {
                return(GetFilteredPublishStatuses(null));
            }

            List <string> excludedStatuses = new List <string>();

            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                ImplementationGuide ig    = tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId);
                var excludedStatusObjects = tdb.PublishStatuses.Where(y =>
                                                                      y.Id != ig.PublishStatusId &&
                                                                      y.Status != PublishStatus.DEPRECATED_STATUS &&
                                                                      y.Status != PublishStatus.RETIRED_STATUS);

                foreach (PublishStatus current in excludedStatusObjects)
                {
                    excludedStatuses.Add(current.Status);
                }
            }

            return(GetFilteredPublishStatuses(String.Join(",", excludedStatuses)));
        }
 public static List <LookupTemplateType> GetTemplateTypes(int implementationGuideId)
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(GetTemplateTypes(tdb, implementationGuideId));
     }
 }
 public List <ValidationDocument> GetValidationPackage(int implementationGuideId, GenerationOptions options, DateTime?lastRetrieveDate)
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(GetValidationPackage(tdb, implementationGuideId, options, lastRetrieveDate));
     }
 }
 public List <ValidationProfile> GetValidationProfiles()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(GetValidationProfiles(tdb));
     }
 }
 public static List <LookupTemplateType> GetTemplateTypes()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(GetTemplateTypes(tdb));
     }
 }
Example #8
0
 public static List <LookupValueSet> GetValuesets()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(GetValuesets(tdb));
     }
 }
 public static List <LookupOrganization> GetOrganizations()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(GetOrganizations(tdb));
     }
 }
 public static List <LookupImplementationGuide> GetImplementationGuides(bool aIncludePublishedGuides = true)
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(GetImplementationGuides(tdb, aIncludePublishedGuides));
     }
 }
Example #11
0
 public List <PublishStatus> GetPublishStatusAll()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return(tdb.PublishStatuses.ToList());
     }
 }
Example #12
0
 public static void SaveAuditEntry(string type, string note, string userName = null, string organizationName = null)
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         CreateAuditEntry(tdb, type, note, userName, organizationName);
         tdb.SaveChanges();
     }
 }
Example #13
0
 public static List <SimplifiedSchemaObject> GetComplexTypesFromSchema(long implementationGuideTypeId)
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         ImplementationGuideType igType = tdb.ImplementationGuideTypes.Single(y => y.Id == implementationGuideTypeId);
         SimplifiedSchema        schema = new SimplifiedSchema(
             Helper.GetIGSchema(igType));
         return(schema.ComplexTypes);
     }
 }
 public List <ValidationImplementationGuide> GetValidationImplementationGuides()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return((from ig in tdb.ImplementationGuides
                 select new ValidationImplementationGuide()
         {
             ImplementationGuideId = ig.Id,
             Name = ig.Name
         }).ToList());
     }
 }
Example #15
0
 public static List <LookupImplementationGuideType> GetImplementationGuideTypes()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return((from igt in tdb.ImplementationGuideTypes
                 select new LookupImplementationGuideType()
         {
             Id = igt.Id,
             Name = igt.Name
         }).ToList());
     }
 }
Example #16
0
 public static List <LookupCodeSystem> GetCodeSystems()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return((from cs in tdb.CodeSystems
                 select new LookupCodeSystem()
         {
             Id = cs.Id,
             Name = cs.Name,
             Oid = cs.Oid
         }).ToList());
     }
 }
Example #17
0
        /// <summary>
        /// Checks if the authenticated user has a "Login" audit within the last 24 hours. If not, creates a
        /// Login audit.
        /// </summary>
        /// <remarks>
        /// When user is logged in via "remember me", Login does not have to occur.
        /// </remarks>
        private void AuditLogin()
        {
            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                DateTime minDate  = DateTime.Now.AddHours(-24);
                string   userName = string.Format("{0} ({1})", CheckPoint.Instance.UserName, CheckPoint.Instance.OrganizationName);

                // Determine if a login audit has been recorded in the last 24 hours
                if (tdb.AuditEntries.Count(y => y.AuditDate > minDate && y.Username == userName && y.Type == "Login") == 0)
                {
                    AuditEntryExtension.SaveAuditEntry("Login", "Success");
                }
            }
        }
Example #18
0
        public static void Delete(LookupGreenTemplate lookupGreenTemplate)
        {
            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                GreenTemplate greenTemplate = tdb.GreenTemplates.Single(y => y.Id == lookupGreenTemplate.Id);

                // Remove all green constraints associated with the green template
                greenTemplate.ChildGreenConstraints.ToList().ForEach(y => tdb.GreenConstraints.DeleteObject(y));

                // Remove the green template
                tdb.GreenTemplates.DeleteObject(greenTemplate);

                tdb.SaveChanges();
            }
        }
Example #19
0
 public static List <LookupGreenTemplate> GetAll()
 {
     using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
     {
         return((from gt in tdb.GreenTemplates
                 select new LookupGreenTemplate()
         {
             Id = gt.Id,
             Name = gt.Name,
             TemplateName = gt.Template.Name,
             TemplateOid = gt.Template.Oid,
             TemplateType = gt.Template.TemplateType.Name,
             TemplateIgType = gt.Template.TemplateType.ImplementationGuideType.Name
         }).ToList());
     }
 }
        public static List <LookupImplementationGuide> GetImplementationGuidesExcluding(int?excludedImplementationGuideId)
        {
            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                if (!CheckPoint.Instance.IsAuthenticated)
                {
                    return(new List <LookupImplementationGuide>());
                }

                List <ImplementationGuide> implementationGuides = tdb.ImplementationGuides
                                                                  .Where(y => excludedImplementationGuideId == null || y.Id != excludedImplementationGuideId.Value)
                                                                  .ToList();

                return(ConvertAndFilter(tdb, implementationGuides));
            }
        }
Example #21
0
        /// <summary>
        /// Gets a list of templates that match the specified template type.
        /// </summary>
        /// <param name="templateTypeId">The template type that should be used to filter the return list of templates.</param>
        /// <param name="excludedTemplateId">The template that should be excluded from the return list.</param>
        public static List <LookupTemplate> GetTemplateTypeTemplatesExcluding(int?templateTypeId, int?excludedTemplateId)
        {
            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                if (!CheckPoint.Instance.IsAuthenticated)
                {
                    return(new List <LookupTemplate>());
                }

                var templates = (from t in tdb.ViewTemplates
                                 where (templateTypeId == null || t.TemplateTypeId == templateTypeId) &&
                                 (excludedTemplateId == null || t.Id != excludedTemplateId)
                                 select t);

                return(FilterAndConvertTemplates(tdb, templates));
            }
        }
Example #22
0
        /// <summary>
        /// Gets all templates that are owned by the specified implementation guide
        /// </summary>
        /// <param name="implementationGuideId">The id of the implementation guide that templates should be returned for.</param>
        public static List <LookupTemplate> GetImplementationGuideTemplates(int?implementationGuideId)
        {
            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                if (implementationGuideId == null)
                {
                    return(new List <LookupTemplate>());
                }

                var templates = (from t in tdb.ViewTemplates
                                 where implementationGuideId == null || t.OwningImplementationGuideId == implementationGuideId.Value
                                 orderby t.Name
                                 select t);

                return(FilterAndConvertTemplates(tdb, templates));
            }
        }
        /// <summary>
        /// Validates each of the contents and returns the validation results
        /// </summary>
        /// <param name="profile">The profile to validate the content against</param>
        /// <param name="contents">The content to validate against the profile</param>
        /// <returns></returns>
        public List <ValidationResult> ValidateDocument(int profileId, List <ValidationContent> contents)
        {
            List <ValidationResult> results = new List <ValidationResult>();

            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                // Get the requested profile
                ValidationProfile profile = null;

                try
                {
                    profile = GetValidationProfile(tdb, profileId);
                }
                catch (Exception ex)
                {
                    results.Add(new ValidationResult()
                    {
                        ErrorMessage = "Preparing validation package failed with the following error: " + ex.Message,
                        Severity     = "Critical"
                    });

                    return(results);
                }

                foreach (ValidationContent cContent in contents)
                {
                    try
                    {
                        // Validate the document with the profile
                        results.AddRange(ValidateInputXml(cContent, profile));
                    }
                    catch (Exception ex)
                    {
                        results.Add(new ValidationResult()
                        {
                            ErrorMessage = "Validating document resulted in a critical system error: " + ex.Message,
                            FileName     = cContent.FileName,
                            Severity     = "Critical"
                        });
                    }
                }
            }

            return(results);
        }
Example #24
0
        public List <PublishStatus> GetFilteredPublishStatuses(string aExcludeStatuses)
        {
            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                List <PublishStatus> lStatuses = tdb.PublishStatuses.ToList();

                if (!string.IsNullOrEmpty(aExcludeStatuses))
                {
                    foreach (string lRemovedStatus in aExcludeStatuses.Split(','))
                    {
                        PublishStatus lStatus = lStatuses.DefaultIfEmpty(null).SingleOrDefault(s => s.Status == lRemovedStatus);
                        if (lStatus != null)
                        {
                            lStatuses.Remove(lStatus);
                        }
                    }
                }

                return(lStatuses);
            }
        }
Example #25
0
        public static List <LookupTemplate> GetImplementationGuideTemplates(bool?includeInferred, int?implementationGuideId, bool includeDeprecated = true)
        {
            if (includeInferred == null || implementationGuideId == null)
            {
                return(new List <LookupTemplate>());
            }

            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                ImplementationGuide ig          = tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId);
                List <Template>     igTemplates = ig.GetRecursiveTemplates(tdb, inferred: includeInferred == true);

                if (!includeDeprecated)
                {
                    string lDeprecatedStatus = PublishStatuses.Deprecated.ToString();
                    igTemplates.RemoveAll(t => t.Status != null && t.Status.Status == lDeprecatedStatus);
                }

                return(FilterAndConvertTemplates(tdb, igTemplates));
            }
        }
Example #26
0
        /// <summary>
        /// Gets templates that can be used with the specified list of data types. Only templates that can be used with the specified
        /// data-types (by derivation or directly) will be returned.
        /// </summary>
        /// <param name="dataTypes">List of data-types that should be used to filter the return list of templates.</param>
        /// <param name="excludedTemplateId">Excludes the specified template id from the return list</param>
        public static List <LookupTemplate> GetTemplateDataTypeTemplatesExcluding(List <string> dataTypes, int?excludedTemplateId)
        {
            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                if (!CheckPoint.Instance.IsAuthenticated)
                {
                    return(new List <LookupTemplate>());
                }

                var excludedTemplates = (from t in tdb.ViewTemplates
                                         where excludedTemplateId == null || t.Id != excludedTemplateId
                                         select t);
                var templates = excludedTemplates;

                if (dataTypes != null && dataTypes.Count > 0 && !dataTypes.Contains("ANY"))
                {
                    templates = templates.Where(y => y.PrimaryContext != null && dataTypes.Contains(y.PrimaryContext));
                }

                return(FilterAndConvertTemplates(tdb, templates));
            }
        }
        public ActionResult SaveProfile(UserProfile aProfile)
        {
            using (DB.TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                DB.User lUser = CheckPoint.Instance.GetUser(tdb);

                lUser.Use(u =>
                {
                    u.FirstName                = aProfile.firstName;
                    u.LastName                 = aProfile.lastName;
                    u.Phone                    = aProfile.phone;
                    u.Email                    = aProfile.email;
                    u.OkayToContact            = aProfile.okayToContact;
                    u.ExternalOrganizationName = aProfile.organization;
                    u.ExternalOrganizationType = aProfile.organizationType;
                    u.ApiKey                   = aProfile.apiKey;
                });

                tdb.SaveChanges();

                return(ProfileData());
            }
        }
Example #28
0
        public static List <LookupTemplate> GetAvailablePreviousTemplates(int implementationGuideId)
        {
            List <LookupTemplate> lAvailableTemplates = new List <LookupTemplate>();

            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                ImplementationGuide lSelectedGuide = tdb.ImplementationGuides.SingleOrDefault(ig => ig.Id == implementationGuideId);

                if (lSelectedGuide == null)
                {
                    return(new List <LookupTemplate>());
                }

                if (!lSelectedGuide.PreviousVersionImplementationGuideId.HasValue)
                {
                    return(lAvailableTemplates);
                }
                ImplementationGuide lPreviousVersion = tdb.ImplementationGuides.Single(ig => ig.Id == lSelectedGuide.PreviousVersionImplementationGuideId);

                List <Template> lFirstGenerationTemplates = new List <Template>();

                foreach (Template lChildTemplate in lPreviousVersion.ChildTemplates)
                {
                    IEnumerable <Template> lNewerVersions = from t in tdb.Templates
                                                            where t.OwningImplementationGuideId == lPreviousVersion.Id &&
                                                            t.PreviousVersionTemplateId == lChildTemplate.Id
                                                            select t;
                    if (lNewerVersions.Count() == 0)
                    {
                        lFirstGenerationTemplates.Add(lChildTemplate);
                    }
                }

                return(FilterAndConvertTemplates(tdb, lFirstGenerationTemplates));
            }
        }
Example #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                var user = CheckPoint.Instance.GetUser(tdb);

                if (user != null)
                {
                    this.Securables = (from ur in user.Roles
                                       join ras in tdb.RoleAppSecurables on ur.RoleId equals ras.RoleId
                                       select ras.AppSecurable.Name).ToList();

                    if (CheckPoint.Instance.IsDataAdmin)
                    {
                        this.DatabaseLabel = string.Format("{0}/{1}", tdb.Connection.DataSource, tdb.Connection.Database);
                    }
                }
            }

            this.VersionLabel = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            // Only make the HL7 logo visible to users who are authenticated by the HL7
            //this.HL7LogoImage.Visible = CheckPoint.Instance.OrganizationName == "HL7";
        }
Example #30
0
        public static string GetCodeSystemScript()
        {
            string script = @"
<script language=""javascript"">
    var codesystems = [";

            using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource())
            {
                foreach (CodeSystem cCodeSystem in tdb.CodeSystems)
                {
                    string oid  = cCodeSystem.Oid.Replace("\r", "").Replace("\n", "");
                    string name = cCodeSystem.Name.Replace("\r", "").Replace("\n", "");
                    script += "\"" + oid + "\", \"" + name + "\", ";
                }

                script = script.Remove(script.Length - 2);
            }

            script += @"
    ];
</script>";

            return(script);
        }