Beispiel #1
1
        public Bundle SetBundleResult(OrderResponse orderResp, DiagnosticReport diagReport, Observation observ, Practitioner pract)
        {
            Bundle bundle = new Bundle();
            bundle.Meta = new Meta() { Profile = new string[] { MetaBundleResult } };
            bundle.Entry = new List<Bundle.BundleEntryComponent>();
            if (orderResp != null)
            {
                Bundle.BundleEntryComponent component = new Bundle.BundleEntryComponent
                {
                    Resource = orderResp,
                    Transaction = new Bundle.BundleEntryTransactionComponent { Method = Bundle.HTTPVerb.POST, Url = "OrderResponse" }
                };
                bundle.Entry.Add(component);
            }
            if (diagReport != null)
            {
                Bundle.BundleEntryComponent component = new Bundle.BundleEntryComponent
                {
                    Resource = diagReport,
                    Transaction = new Bundle.BundleEntryTransactionComponent() { Method = Bundle.HTTPVerb.POST, Url = "DiagnosticReport" }
                };
                bundle.Entry.Add(component);
            }
            if (observ != null)
            {
                Bundle.BundleEntryComponent component = new Bundle.BundleEntryComponent()
                {
                    Resource = observ,
                    Transaction = new Bundle.BundleEntryTransactionComponent() { Method = Bundle.HTTPVerb.POST, Url = "Observation" }
                };
                bundle.Entry.Add(component);
            }
            //необязательный параметр
            if (pract != null)
            {
                Bundle.BundleEntryComponent component = new Bundle.BundleEntryComponent
                {
                    Resource = pract,
                    Transaction = new Bundle.BundleEntryTransactionComponent { Method = Bundle.HTTPVerb.POST, Url = "Practitioner" }
                };
                bundle.Entry.Add(component);
            }

            return bundle;
        }
Beispiel #2
0
        /// <summary>
        /// Parse OrderResponse
        /// </summary>
        public static Hl7.Fhir.Model.OrderResponse ParseOrderResponse(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.OrderResponse existingInstance = null)
        {
            Hl7.Fhir.Model.OrderResponse result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.OrderResponse();
            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 request
                else if (atName == "request")
                {
                    result.Request = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

                // Parse element who
                else if (atName == "who")
                {
                    result.Who = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element authority
                else if (atName == "authority")
                {
                    result.Authority = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element cost
                else if (atName == "cost")
                {
                    result.Cost = MoneyParser.ParseMoney(reader, errors);
                }

                // Parse element code
                else if (atName == "code")
                {
                    result.CodeElement = CodeParser.ParseCode <Hl7.Fhir.Model.OrderResponse.OrderOutcomeCode>(reader, errors);
                }

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

                // Parse element fulfillment
                else if (atName == "fulfillment")
                {
                    result.Fulfillment = new List <Hl7.Fhir.Model.ResourceReference>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "fulfillment"))
                    {
                        result.Fulfillment.Add(ResourceReferenceParser.ParseResourceReference(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);
        }
Beispiel #3
0
        public static void SerializeOrderResponse(Hl7.Fhir.Model.OrderResponse value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartRootObject("OrderResponse");
            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 request
            if (value.Request != null && !summary)
            {
                writer.WriteStartElement("request");
                ResourceReferenceSerializer.SerializeResourceReference(value.Request, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element who
            if (value.Who != null && !summary)
            {
                writer.WriteStartElement("who");
                ResourceReferenceSerializer.SerializeResourceReference(value.Who, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element authority
            if (value.Authority != null && !summary)
            {
                writer.WriteStartElement("authority");
                ResourceReferenceSerializer.SerializeResourceReference(value.Authority, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element cost
            if (value.Cost != null && !summary)
            {
                writer.WriteStartElement("cost");
                QuantitySerializer.SerializeQuantity(value.Cost, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element code
            if (value.CodeElement != null && !summary)
            {
                writer.WriteStartElement("code");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.OrderResponse.OrderOutcomeCode>(value.CodeElement, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element fulfillment
            if (value.Fulfillment != null && !summary && value.Fulfillment.Count > 0)
            {
                writer.WriteStartArrayElement("fulfillment");
                foreach (var item in value.Fulfillment)
                {
                    writer.WriteStartArrayMember("fulfillment");
                    ResourceReferenceSerializer.SerializeResourceReference(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


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