public byte[] Export(DB.IObjectRepository tdb, SimpleSchema schema, ExportFormats format, IGSettingsManager igSettings, List <string> categories, List <DB.Template> templates, bool includeVocabulary, bool returnJson = true) { var uri = HttpContext.Current != null && HttpContext.Current.Request != null ? HttpContext.Current.Request.Url : new Uri(AppSettings.DefaultBaseUrl); switch (format) { case ExportFormats.FHIR_Bundle: ImplementationGuideExporter exporter = new ImplementationGuideExporter(tdb, schema, uri.Scheme, uri.Authority); fhir_dstu2.Hl7.Fhir.Model.Bundle bundle = exporter.GetImplementationGuides(include: "ImplementationGuide:resource", implementationGuideId: igSettings.ImplementationGuideId); return(ConvertToBytes(fhir_dstu2.Hl7.Fhir.Serialization.FhirSerializer.SerializeResourceToXml(bundle))); case ExportFormats.Native_XML: NativeExporter proprietaryExporter = new NativeExporter(tdb, templates, igSettings, true, categories); if (returnJson) { return(ConvertToBytes(proprietaryExporter.GenerateJSONExport())); } else { return(ConvertToBytes(proprietaryExporter.GenerateXMLExport())); } case ExportFormats.Templates_DSTU_XML: DecorExporter decorExporter = new DecorExporter(templates, tdb, igSettings.ImplementationGuideId); return(ConvertToBytes(decorExporter.GenerateXML())); default: throw new Exception("Invalid export format for the specified implementation guide type"); } }
public static void Setup(TestContext context) { ExportTests.tdb = new MockObjectRepository(); TrifoliaImporter importer = new TrifoliaImporter(ExportTests.tdb); ExportTests.tdb.InitializeFHIR3Repository(); ExportTests.tdb.InitializeLCGAndLogin(); string importContent = Helper.GetSampleContents(IMPORT_XML); var importModel = ImportModel.Deserialize(importContent); var importStatus = importer.Import(importModel); Assert.IsTrue(importStatus.Success, "Expected import to succeed"); Assert.AreNotEqual(importStatus.ImplementationGuides.Count, 0, "Expected import to include implementation guides"); ImplementationGuide ig = ExportTests.tdb.ImplementationGuides.SingleOrDefault(y => y.Id == importStatus.ImplementationGuides.First().InternalId); var schema = ig.ImplementationGuideType.GetSimpleSchema(); ImplementationGuideExporter exporter = new ImplementationGuideExporter(ExportTests.tdb, schema, "localhost", "http"); ExportTests.exportedBundle = exporter.GetImplementationGuides(implementationGuideId: ig.Id, include: "ImplementationGuide:resource"); ExportTests.exportedXml = FhirSerializer.SerializeResourceToXml(ExportTests.exportedBundle); Assert.IsNotNull(ExportTests.exportedXml); }
public HttpResponseMessage GetImplementationGuides( [FromUri(Name = "_format")] string format = null, [FromUri(Name = "_summary")] fhir_stu3.Hl7.Fhir.Rest.SummaryType?summary = null, [FromUri(Name = "_include")] string include = null, [FromUri(Name = "_id")] int?implementationGuideId = null, [FromUri(Name = "name")] string name = null) { var uri = HttpContext.Current != null && HttpContext.Current.Request != null ? HttpContext.Current.Request.Url : new Uri(AppSettings.DefaultBaseUrl); SimpleSchema schema = SimplifiedSchemaContext.GetSimplifiedSchema(HttpContext.Current.Application, this.implementationGuideType); ImplementationGuideExporter exporter = new ImplementationGuideExporter(this.tdb, schema, uri.Scheme, uri.Authority); var bundle = exporter.GetImplementationGuides(summary, include, implementationGuideId, name); return(Shared.GetResponseMessage(this.Request, format, bundle)); }