Exemplo n.º 1
0
        /// <summary>
        /// Deserialize JSON into a FHIR Invoice#LineItem
        /// </summary>
        public static void DeserializeJsonProperty(this Invoice.LineItemComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "sequence":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.SequenceElement = new PositiveInt();
                    reader.Skip();
                }
                else
                {
                    current.SequenceElement = new PositiveInt(reader.GetInt32());
                }
                break;

            case "_sequence":
                if (current.SequenceElement == null)
                {
                    current.SequenceElement = new PositiveInt();
                }
                ((Hl7.Fhir.Model.Element)current.SequenceElement).DeserializeJson(ref reader, options);
                break;

            case "chargeItemReference":
                current.ChargeItem = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.ChargeItem).DeserializeJson(ref reader, options);
                break;

            case "chargeItemCodeableConcept":
                current.ChargeItem = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.ChargeItem).DeserializeJson(ref reader, options);
                break;

            case "priceComponent":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"LineItemComponent error reading 'priceComponent' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.PriceComponent = new List <Invoice.PriceComponentComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Invoice.PriceComponentComponent v_PriceComponent = new Hl7.Fhir.Model.Invoice.PriceComponentComponent();
                    v_PriceComponent.DeserializeJson(ref reader, options);
                    current.PriceComponent.Add(v_PriceComponent);

                    if (!reader.Read())
                    {
                        throw new JsonException($"LineItemComponent error reading 'priceComponent' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.PriceComponent.Count == 0)
                {
                    current.PriceComponent = null;
                }
                break;

            // Complex: lineItem, Export: LineItemComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserialize JSON into a FHIR Invoice
        /// </summary>
        public static void DeserializeJsonProperty(this Invoice current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Invoice error reading 'identifier' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Identifier = new List <Identifier>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Identifier v_Identifier = new Hl7.Fhir.Model.Identifier();
                    v_Identifier.DeserializeJson(ref reader, options);
                    current.Identifier.Add(v_Identifier);

                    if (!reader.Read())
                    {
                        throw new JsonException($"Invoice error reading 'identifier' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Identifier.Count == 0)
                {
                    current.Identifier = null;
                }
                break;

            case "status":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.Invoice.InvoiceStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.Invoice.InvoiceStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.Invoice.InvoiceStatus>(reader.GetString()));
                }
                break;

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.Invoice.InvoiceStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options);
                break;

            case "cancelledReason":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.CancelledReasonElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.CancelledReasonElement = new FhirString(reader.GetString());
                }
                break;

            case "_cancelledReason":
                if (current.CancelledReasonElement == null)
                {
                    current.CancelledReasonElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.CancelledReasonElement).DeserializeJson(ref reader, options);
                break;

            case "type":
                current.Type = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Type).DeserializeJson(ref reader, options);
                break;

            case "subject":
                current.Subject = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Subject).DeserializeJson(ref reader, options);
                break;

            case "recipient":
                current.Recipient = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Recipient).DeserializeJson(ref reader, options);
                break;

            case "date":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.DateElement = new FhirDateTime();
                    reader.Skip();
                }
                else
                {
                    current.DateElement = new FhirDateTime(reader.GetString());
                }
                break;

            case "_date":
                if (current.DateElement == null)
                {
                    current.DateElement = new FhirDateTime();
                }
                ((Hl7.Fhir.Model.Element)current.DateElement).DeserializeJson(ref reader, options);
                break;

            case "participant":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Invoice error reading 'participant' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Participant = new List <Invoice.ParticipantComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Invoice.ParticipantComponent v_Participant = new Hl7.Fhir.Model.Invoice.ParticipantComponent();
                    v_Participant.DeserializeJson(ref reader, options);
                    current.Participant.Add(v_Participant);

                    if (!reader.Read())
                    {
                        throw new JsonException($"Invoice error reading 'participant' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Participant.Count == 0)
                {
                    current.Participant = null;
                }
                break;

            case "issuer":
                current.Issuer = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Issuer).DeserializeJson(ref reader, options);
                break;

            case "account":
                current.Account = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Account).DeserializeJson(ref reader, options);
                break;

            case "lineItem":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Invoice error reading 'lineItem' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.LineItem = new List <Invoice.LineItemComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Invoice.LineItemComponent v_LineItem = new Hl7.Fhir.Model.Invoice.LineItemComponent();
                    v_LineItem.DeserializeJson(ref reader, options);
                    current.LineItem.Add(v_LineItem);

                    if (!reader.Read())
                    {
                        throw new JsonException($"Invoice error reading 'lineItem' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.LineItem.Count == 0)
                {
                    current.LineItem = null;
                }
                break;

            case "totalPriceComponent":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Invoice error reading 'totalPriceComponent' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.TotalPriceComponent = new List <Invoice.PriceComponentComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Invoice.PriceComponentComponent v_TotalPriceComponent = new Hl7.Fhir.Model.Invoice.PriceComponentComponent();
                    v_TotalPriceComponent.DeserializeJson(ref reader, options);
                    current.TotalPriceComponent.Add(v_TotalPriceComponent);

                    if (!reader.Read())
                    {
                        throw new JsonException($"Invoice error reading 'totalPriceComponent' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.TotalPriceComponent.Count == 0)
                {
                    current.TotalPriceComponent = null;
                }
                break;

            case "totalNet":
                current.TotalNet = new Hl7.Fhir.Model.Money();
                ((Hl7.Fhir.Model.Money)current.TotalNet).DeserializeJson(ref reader, options);
                break;

            case "totalGross":
                current.TotalGross = new Hl7.Fhir.Model.Money();
                ((Hl7.Fhir.Model.Money)current.TotalGross).DeserializeJson(ref reader, options);
                break;

            case "paymentTerms":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.PaymentTerms = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.PaymentTerms = new Markdown(reader.GetString());
                }
                break;

            case "_paymentTerms":
                if (current.PaymentTerms == null)
                {
                    current.PaymentTerms = new Markdown();
                }
                ((Hl7.Fhir.Model.Element)current.PaymentTerms).DeserializeJson(ref reader, options);
                break;

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Invoice error reading 'note' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Note = new List <Annotation>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Annotation v_Note = new Hl7.Fhir.Model.Annotation();
                    v_Note.DeserializeJson(ref reader, options);
                    current.Note.Add(v_Note);

                    if (!reader.Read())
                    {
                        throw new JsonException($"Invoice error reading 'note' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Note.Count == 0)
                {
                    current.Note = null;
                }
                break;

            // Complex: Invoice, Export: Invoice, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }