public void Process(Document input, Stage output)
 {
     var pkp = new ProfileKnowledgeProvider(input.Name, input.Context.Target.Directory);
     var generator = new DictHtmlGenerator(pkp);
     var profile = (Profile)FhirParser.ParseResourceFromXml(input.Text);
     Document result = input.CloneMetadata();
     var xmldoc = generator.Generate(profile);
     result.SetFilename(pkp.GetLinkForProfileDict(profile));
     result.Text = xmldoc.ToString(SaveOptions.DisableFormatting);
     output.Post(result);
 }
        public void PublishLipidProfile()
        {
            //var profile = (Profile)FhirParser.ParseResourceFromXml(File.ReadAllText(@"TestData\lipid.profile.xml"));
            var profile = (Profile)FhirParser.ParseResourceFromXml(File.ReadAllText(@"TestData\profile.hvlabresult.xml"));
            var pkp = new ProfileKnowledgeProvider("hvlabres", @"c:\temp\dist\images");

            {
                var publisher = new ProfileTableGenerator(pkp);

                var result = File.ReadAllText(@"TestData\publish-header.cshtml");
                result += publisher.Generate(profile, false).ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
                result += File.ReadAllText(@"TestData\publish-footer.cshtml");

                File.WriteAllText(@"c:\temp\publisher\" + pkp.GetLinkForProfileTable(profile), result);
            }

            {
                var publisher = new StructureGenerator(pkp);

                foreach (var structure in profile.Structure)
                {
                    var result = File.ReadAllText(@"TestData\publish-header.cshtml");
                    result += publisher.generateStructureTable(structure, false, profile)
                            .ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
                    result += File.ReadAllText(@"TestData\publish-footer.cshtml");

                    File.WriteAllText(@"c:\temp\publisher\" + pkp.GetLinkForLocalStructure(profile, structure), result);
                }
            }

            {
                var dictgen = new DictHtmlGenerator(pkp);
                var result = File.ReadAllText(@"TestData\publish-header.cshtml");
                result += dictgen.Generate(profile)
                            .ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
                result += File.ReadAllText(@"TestData\publish-footer.cshtml");

                File.WriteAllText(@"c:\temp\publisher\" + pkp.GetLinkForProfileDict(profile), result);
            }

            {
                var vs = (ValueSet)FhirParser.ParseResourceFromXml(File.ReadAllText(@"TestData\hv-laboratory-result-interpretation-v1.xml"));

                var vsGen = new ValueSetGenerator(pkp);

                var result = File.ReadAllText(@"TestData\publish-header.cshtml");
                result += vsGen.generate(vs)
                            .ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
                result += File.ReadAllText(@"TestData\publish-footer.cshtml");

                File.WriteAllText(@"c:\temp\publisher\" + "hv-laboratory-result-interpretation-v1.html", result);
            }
        }
        public void Process(Document input, Stage output)
        {
            var pkp = new ProfileKnowledgeProvider(input.Name, input.Context.Target.Directory);
            var generator = new StructureGenerator(pkp);

            var profile = (Profile)FhirParser.ParseResourceFromXml(input.Text);

            foreach (var structure in profile.Structure)
            {
                var result = generator
                        .generateStructureTable(structure, false, profile)
                        .ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

                Document document = output.CloneAndPost(input);
                document.SetFilename(pkp.GetLinkForLocalStructure(profile, structure));
                document.Text = result;
            }
        }      
        internal static string ForHtml(this Profile.ElementDefinitionBindingComponent binding, ProfileKnowledgeProvider pkp = null)
        {
            if (binding.Reference == null || pkp == null) 
                return binding.Description;

            var reference = binding.Reference is FhirUri ? ((FhirUri)binding.Reference).Value 
                    : ((ResourceReference)binding.Reference).Reference;

            var vs = pkp.GetValueSet(reference);

            if (vs != null)
                return binding.Description +  "<br/>" + conf(binding) + "<a href=\"" + reference + "\">"+ vs.Name + "</a>" +confTail(binding);
            
            if (reference.StartsWith("http:") || reference.StartsWith("https:"))
                return binding.Description + "<br/>" + conf(binding) + " <a href=\""+reference+"\">"+reference+"</a>"+ confTail(binding);
            else
                return binding.Description + "<br/>" + conf(binding)+" ?? Broken Reference to "+reference+" ??" + confTail(binding);

        }
 internal ValueSetGenerator(ProfileKnowledgeProvider pkp)
 {
     _pkp = pkp;
 }
 public HierarchicalTableGenerator(ProfileKnowledgeProvider pkp)
 {
     _pkp = pkp;
 }
 public ProfileTableGenerator(ProfileKnowledgeProvider pkp)
 {
     _pkp = pkp;
 }
 internal StructureGenerator(ProfileKnowledgeProvider pkp)
 {
     _pkp = pkp;
 }
 public DictHtmlGenerator(ProfileKnowledgeProvider pkp)
 {
     _pkp = pkp;
 }
 public StructureGenerator()
 {
     _pkp = new ProfileKnowledgeProvider("http://www.hl7.org/implement/standards/fhir/");
 }