Beispiel #1
0
        public byte[] Export(bool includeVocabulary = true)
        {
            this.control = new Models.Control();
            this.control.canonicalBase = this.ig.Identifier;

            if (!string.IsNullOrEmpty(this.control.canonicalBase) && this.control.canonicalBase.LastIndexOf("/") == this.control.canonicalBase.Length - 1)
            {
                this.control.canonicalBase = this.control.canonicalBase.Substring(0, this.control.canonicalBase.Length - 1);
            }

            this.zip = GetPackage();

            this.UpdateIGPublisher();

            this.AddImplementationGuide(includeVocabulary);

            this.AddTemplates();

            if (includeVocabulary)
            {
                this.AddValueSets();
            }

            this.AddOverviewPage();

            this.AddAuthorPage();

            this.AddDescriptionPage();

            this.AddCodeSystemsPage();

            this.AddValueSetsPage();

            this.AddExtensionsPage();

            this.AddResourceInstances();

            this.AddExamples();

            this.AddControl();

            this.AddBatch();

            this.UpdateBuildXml();

            try
            {
                string tempFileName = Path.GetTempFileName();
                this.zip.Save(tempFileName);
                byte[] retBytes = File.ReadAllBytes(tempFileName);
                File.Delete(tempFileName);

                return(retBytes);
            }
            catch (Exception ex)
            {
                throw new Exception("Error saving/reading zip package for generated FHIR build", ex);
            }
        }
Beispiel #2
0
        public byte[] Export(bool includeVocabulary = true)
        {
            string npmName = Regex.Replace(this.ig.Name, @"[^0-9a-zA-Z]+", "");

            this.control = new Models.Control("3.0.1");
            this.control.CanonicalBase = this.ig.Identifier;
            this.control.NpmName       = "hl7.fhir.us." + npmName;

            var igDependencies = (from t in templates
                                  join tc in this.tdb.TemplateConstraints.AsNoTracking() on t.Id equals tc.TemplateId
                                  join tcr in this.tdb.TemplateConstraintReferences.AsNoTracking() on tc.Id equals tcr.TemplateConstraintId
                                  join dt in this.tdb.Templates.AsNoTracking() on tcr.ReferenceIdentifier equals dt.Oid
                                  join ig in this.tdb.ImplementationGuides on dt.OwningImplementationGuideId equals ig.Id
                                  where ig.Id != this.ig.Id && ig.Identifier != "http://hl7.org/fhir/" && tcr.ReferenceType == ConstraintReferenceTypes.Template
                                  select ig).Distinct();

            this.control.DependencyList = (from ig in igDependencies
                                           select new Control.Dependency()
            {
                Name = ig.Name.RemoveSpecialCharacters().Replace(" ", "-").ToLower(),
                Location = ig.Identifier
            }).ToList();

            if (!string.IsNullOrEmpty(this.control.CanonicalBase) && this.control.CanonicalBase.LastIndexOf("/") == this.control.CanonicalBase.Length - 1)
            {
                this.control.CanonicalBase = this.control.CanonicalBase.Substring(0, this.control.CanonicalBase.Length - 1);
            }

            this.zip = GetPackage();

            this.AddImplementationGuide(includeVocabulary);

            this.AddProfiles();

            if (includeVocabulary)
            {
                this.AddValueSets();
            }

            this.AddOverviewPage();

            this.AddResourcesPage();

            this.AddAuthorPage();

            this.AddDescriptionPage();

            this.AddCodeSystemsPage();

            this.AddValueSetsPage();

            this.AddExtensionsPage();

            this.AddResourceInstances();

            this.AddExamples();

            this.AddControlAndDataExamples();

            this.AddBatch();

            this.UpdateBuildXml();

            try
            {
                string tempFileName = Path.GetTempFileName();
                this.zip.Save(tempFileName);
                byte[] retBytes = File.ReadAllBytes(tempFileName);
                File.Delete(tempFileName);

                return(retBytes);
            }
            catch (Exception ex)
            {
                throw new Exception("Error saving/reading zip package for generated FHIR build", ex);
            }
        }