コード例 #1
0
ファイル: ModelTests.cs プロジェクト: tiloc/fhir-net-api
        public void SimpleValueSupport()
        {
            Conformance c = new Conformance();

            Assert.IsNull(c.Experimental);
            c.Experimental = true;
            Assert.IsTrue(c.Experimental.GetValueOrDefault());
            Assert.IsNotNull(c.Experimental);
            Assert.IsTrue(c.ExperimentalElement.Value.GetValueOrDefault());

            c.PublisherElement = new FhirString("Furore");
            Assert.AreEqual("Furore", c.Publisher);
            c.Publisher = null;
            Assert.IsNull(c.PublisherElement);
            c.Publisher = "Furore";
            Assert.IsNotNull(c.PublisherElement);

            c.Format = new string[] { "json", "xml" };
            Assert.IsNotNull(c.FormatElement);
            Assert.AreEqual(2, c.FormatElement.Count);
            Assert.AreEqual("json", c.FormatElement.First().Value);

            c.FormatElement = new List<Code>();
            c.FormatElement.Add(new Code("csv"));
            Assert.IsNotNull(c.Format);
            Assert.AreEqual(1, c.Format.Count());
        }
コード例 #2
0
ファイル: ConformanceBuilder.cs プロジェクト: Condeti/spark
 public static Conformance AddMultipleResourceComponents(this Conformance conformance, List<String> resourcetypes, Boolean readhistory, Boolean updatecreate, Conformance.ResourceVersionPolicy versioning)
 {
     foreach (var type in resourcetypes)
     {
         AddSingleResourceComponent(conformance, type, readhistory, updatecreate, versioning);
     }
     return conformance;
 }
コード例 #3
0
ファイル: ConformanceBuilder.cs プロジェクト: Condeti/spark
 public static Conformance AddAllCoreResources(this Conformance conformance, Boolean readhistory, Boolean updatecreate, Conformance.ResourceVersionPolicy versioning)
 {
     foreach (var resource in ModelInfo.SupportedResources)
     {
         conformance.AddSingleResourceComponent(resource, readhistory, updatecreate, versioning);
     }
     return conformance;
 }
コード例 #4
0
ファイル: ConformanceBuilder.cs プロジェクト: Condeti/spark
        public static Conformance CreateServer(String server, String serverVersion, String publisher, String fhirVersion)
        {
            Conformance conformance = new Conformance();
            conformance.Name = server;
            conformance.Publisher = publisher;
            conformance.Version = serverVersion;
            conformance.FhirVersion = fhirVersion;
            conformance.AcceptUnknown = Conformance.UnknownContentCode.No;
            conformance.Date = Date.Today().Value;
            conformance.AddServer();
            return conformance;
            //AddRestComponent(true);
            //AddAllCoreResources(true, true, Conformance.ResourceVersionPolicy.VersionedUpdate);
            //AddAllSystemInteractions();
            //AddAllResourceInteractionsAllResources();
            //AddCoreSearchParamsAllResources();

            //return con;
        }
コード例 #5
0
        /// <summary>
        /// Parse Conformance
        /// </summary>
        public static Hl7.Fhir.Model.Conformance ParseConformance(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Conformance existingInstance = null)
        {
            Hl7.Fhir.Model.Conformance result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Conformance();
            string currentElementName         = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "extension"))
                    {
                        result.Extension.Add(ExtensionParser.ParseExtension(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element language
                else if (atName == "language")
                {
                    result.LanguageElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element text
                else if (atName == "text")
                {
                    result.Text = NarrativeParser.ParseNarrative(reader, errors);
                }

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "contained"))
                    {
                        result.Contained.Add(ParserUtils.ParseContainedResource(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element identifier
                else if (atName == "identifier")
                {
                    result.IdentifierElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element version
                else if (atName == "version")
                {
                    result.VersionElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element name
                else if (atName == "name")
                {
                    result.NameElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element publisher
                else if (atName == "publisher")
                {
                    result.PublisherElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element telecom
                else if (atName == "telecom")
                {
                    result.Telecom = new List <Hl7.Fhir.Model.Contact>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "telecom"))
                    {
                        result.Telecom.Add(ContactParser.ParseContact(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element description
                else if (atName == "description")
                {
                    result.DescriptionElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element status
                else if (atName == "status")
                {
                    result.StatusElement = CodeParser.ParseCode <Hl7.Fhir.Model.Conformance.ConformanceStatementStatus>(reader, errors);
                }

                // Parse element experimental
                else if (atName == "experimental")
                {
                    result.ExperimentalElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

                // Parse element date
                else if (atName == "date")
                {
                    result.DateElement = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                }

                // Parse element software
                else if (atName == "software")
                {
                    result.Software = ConformanceParser.ParseConformanceSoftwareComponent(reader, errors);
                }

                // Parse element implementation
                else if (atName == "implementation")
                {
                    result.Implementation = ConformanceParser.ParseConformanceImplementationComponent(reader, errors);
                }

                // Parse element fhirVersion
                else if (atName == "fhirVersion")
                {
                    result.FhirVersionElement = IdParser.ParseId(reader, errors);
                }

                // Parse element acceptUnknown
                else if (atName == "acceptUnknown")
                {
                    result.AcceptUnknownElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

                // Parse element format
                else if (atName == "format")
                {
                    result.FormatElement = new List <Hl7.Fhir.Model.Code>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "format"))
                    {
                        result.FormatElement.Add(CodeParser.ParseCode(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element rest
                else if (atName == "rest")
                {
                    result.Rest = new List <Hl7.Fhir.Model.Conformance.ConformanceRestComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "rest"))
                    {
                        result.Rest.Add(ConformanceParser.ParseConformanceRestComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element messaging
                else if (atName == "messaging")
                {
                    result.Messaging = new List <Hl7.Fhir.Model.Conformance.ConformanceMessagingComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "messaging"))
                    {
                        result.Messaging.Add(ConformanceParser.ParseConformanceMessagingComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element document
                else if (atName == "document")
                {
                    result.Document = new List <Hl7.Fhir.Model.Conformance.ConformanceDocumentComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "document"))
                    {
                        result.Document.Add(ConformanceParser.ParseConformanceDocumentComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                else
                {
                    errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                    reader.SkipSubElementsFor(currentElementName);
                    result = null;
                }
            }

            reader.LeaveElement();
            return(result);
        }
コード例 #6
0
ファイル: ConformanceBuilder.cs プロジェクト: Condeti/spark
 public static Conformance AddSingleResourceComponent(this Conformance conformance, String resourcetype, Boolean readhistory, Boolean updatecreate, Conformance.ResourceVersionPolicy versioning, ResourceReference profile = null)
 {
     var resource = new Conformance.ConformanceRestResourceComponent();
     resource.Type = resourcetype;
     resource.Profile = profile;
     resource.ReadHistory = readhistory;
     resource.UpdateCreate = updatecreate;
     resource.Versioning = versioning;
     conformance.Server().Resource.Add(resource);
     return conformance;
 }
コード例 #7
0
ファイル: ConformanceBuilder.cs プロジェクト: Condeti/spark
        public static void AddSystemInteraction(this Conformance conformance, Conformance.SystemRestfulInteraction code)
        {
            var interaction = new Conformance.SystemInteractionComponent();

            interaction.Code = code;

            conformance.Rest().Interaction.Add(interaction);
        }
コード例 #8
0
ファイル: ConformanceBuilder.cs プロジェクト: Condeti/spark
        public static Conformance.ResourceInteractionComponent AddSingleResourceInteraction(Conformance.ConformanceRestResourceComponent resourcecomp, Conformance.TypeRestfulInteraction type)
        {
            var interaction = new Conformance.ResourceInteractionComponent();
            interaction.Code = type;
            return interaction;

        }
コード例 #9
0
ファイル: ConformanceBuilder.cs プロジェクト: Condeti/spark
 public static Conformance.ConformanceRestResourceComponent AddAllResourceInteractions(Conformance.ConformanceRestResourceComponent resourcecomp)
 {
     foreach (Conformance.TypeRestfulInteraction type in Enum.GetValues(typeof(Conformance.TypeRestfulInteraction)))
     {
         var interaction = AddSingleResourceInteraction(resourcecomp, type);
         resourcecomp.Interaction.Add(interaction);
     }
     return resourcecomp;
 }
コード例 #10
0
ファイル: ConformanceBuilder.cs プロジェクト: Condeti/spark
        public static Conformance.ConformanceRestResourceComponent AddCoreSearchParamsResource(Conformance.ConformanceRestResourceComponent resourcecomp)
        {
            var parameters = ModelInfo.SearchParameters.Where(sp => sp.Resource == resourcecomp.Type)
                            .Select(sp => new Conformance.ConformanceRestResourceSearchParamComponent
                            {
                                Name = sp.Name,
                                Type = sp.Type,
                                Documentation = sp.Description,
                                
                            });

            resourcecomp.SearchParam.AddRange(parameters);
            return resourcecomp;
        }
コード例 #11
0
        public static void SerializeConformance(Hl7.Fhir.Model.Conformance value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartRootObject("Conformance");
            writer.WriteStartComplexContent();

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element language
            if (value.LanguageElement != null && !summary)
            {
                writer.WriteStartElement("language");
                CodeSerializer.SerializeCode(value.LanguageElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element text
            if (value.Text != null && !summary)
            {
                writer.WriteStartElement("text");
                NarrativeSerializer.SerializeNarrative(value.Text, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element contained
            if (value.Contained != null && !summary && value.Contained.Count > 0)
            {
                writer.WriteStartArrayElement("contained");
                foreach (var item in value.Contained)
                {
                    writer.WriteStartArrayMember("contained");
                    FhirSerializer.SerializeResource(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element identifier
            if (value.IdentifierElement != null)
            {
                writer.WriteStartElement("identifier");
                FhirStringSerializer.SerializeFhirString(value.IdentifierElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element version
            if (value.VersionElement != null)
            {
                writer.WriteStartElement("version");
                FhirStringSerializer.SerializeFhirString(value.VersionElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element name
            if (value.NameElement != null)
            {
                writer.WriteStartElement("name");
                FhirStringSerializer.SerializeFhirString(value.NameElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element publisher
            if (value.PublisherElement != null)
            {
                writer.WriteStartElement("publisher");
                FhirStringSerializer.SerializeFhirString(value.PublisherElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element telecom
            if (value.Telecom != null && value.Telecom.Count > 0)
            {
                writer.WriteStartArrayElement("telecom");
                foreach (var item in value.Telecom)
                {
                    writer.WriteStartArrayMember("telecom");
                    ContactSerializer.SerializeContact(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element description
            if (value.DescriptionElement != null)
            {
                writer.WriteStartElement("description");
                FhirStringSerializer.SerializeFhirString(value.DescriptionElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element status
            if (value.StatusElement != null)
            {
                writer.WriteStartElement("status");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.Conformance.ConformanceStatementStatus>(value.StatusElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element experimental
            if (value.ExperimentalElement != null)
            {
                writer.WriteStartElement("experimental");
                FhirBooleanSerializer.SerializeFhirBoolean(value.ExperimentalElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element date
            if (value.DateElement != null)
            {
                writer.WriteStartElement("date");
                FhirDateTimeSerializer.SerializeFhirDateTime(value.DateElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element software
            if (value.Software != null)
            {
                writer.WriteStartElement("software");
                ConformanceSerializer.SerializeConformanceSoftwareComponent(value.Software, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element implementation
            if (value.Implementation != null)
            {
                writer.WriteStartElement("implementation");
                ConformanceSerializer.SerializeConformanceImplementationComponent(value.Implementation, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element fhirVersion
            if (value.FhirVersionElement != null)
            {
                writer.WriteStartElement("fhirVersion");
                IdSerializer.SerializeId(value.FhirVersionElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element acceptUnknown
            if (value.AcceptUnknownElement != null && !summary)
            {
                writer.WriteStartElement("acceptUnknown");
                FhirBooleanSerializer.SerializeFhirBoolean(value.AcceptUnknownElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element format
            if (value.FormatElement != null && !summary && value.FormatElement.Count > 0)
            {
                writer.WriteStartArrayElement("format");
                foreach (var item in value.FormatElement)
                {
                    writer.WriteStartArrayMember("format");
                    CodeSerializer.SerializeCode(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element rest
            if (value.Rest != null && !summary && value.Rest.Count > 0)
            {
                writer.WriteStartArrayElement("rest");
                foreach (var item in value.Rest)
                {
                    writer.WriteStartArrayMember("rest");
                    ConformanceSerializer.SerializeConformanceRestComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element messaging
            if (value.Messaging != null && !summary && value.Messaging.Count > 0)
            {
                writer.WriteStartArrayElement("messaging");
                foreach (var item in value.Messaging)
                {
                    writer.WriteStartArrayMember("messaging");
                    ConformanceSerializer.SerializeConformanceMessagingComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element document
            if (value.Document != null && !summary && value.Document.Count > 0)
            {
                writer.WriteStartArrayElement("document");
                foreach (var item in value.Document)
                {
                    writer.WriteStartArrayMember("document");
                    ConformanceSerializer.SerializeConformanceDocumentComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
            writer.WriteEndRootObject();
        }