コード例 #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR MedicinalProductAuthorization
        /// </summary>
        public static void DeserializeJson(this MedicinalProductAuthorization current, ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            string propertyName;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return;
                }

                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    propertyName = reader.GetString();
                    if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug)
                    {
                        Console.WriteLine($"MedicinalProductAuthorization >>> MedicinalProductAuthorization.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"MedicinalProductAuthorization: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
コード例 #2
0
        /// <summary>
        /// Serialize a FHIR MedicinalProductAuthorization into JSON
        /// </summary>
        public static void SerializeJson(this MedicinalProductAuthorization current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            writer.WriteString("resourceType", "MedicinalProductAuthorization");
            // Complex: MedicinalProductAuthorization, Export: MedicinalProductAuthorization, Base: DomainResource (DomainResource)
            ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false);

            if ((current.Identifier != null) && (current.Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();
                foreach (Identifier val in current.Identifier)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.Subject != null)
            {
                writer.WritePropertyName("subject");
                current.Subject.SerializeJson(writer, options);
            }

            if ((current.Country != null) && (current.Country.Count != 0))
            {
                writer.WritePropertyName("country");
                writer.WriteStartArray();
                foreach (CodeableConcept val in current.Country)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.Jurisdiction != null) && (current.Jurisdiction.Count != 0))
            {
                writer.WritePropertyName("jurisdiction");
                writer.WriteStartArray();
                foreach (CodeableConcept val in current.Jurisdiction)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.Status != null)
            {
                writer.WritePropertyName("status");
                current.Status.SerializeJson(writer, options);
            }

            if (current.StatusDateElement != null)
            {
                if (!string.IsNullOrEmpty(current.StatusDateElement.Value))
                {
                    writer.WriteString("statusDate", current.StatusDateElement.Value);
                }
                if (current.StatusDateElement.HasExtensions() || (!string.IsNullOrEmpty(current.StatusDateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_statusDate", false, current.StatusDateElement.Extension, current.StatusDateElement.ElementId);
                }
            }

            if (current.RestoreDateElement != null)
            {
                if (!string.IsNullOrEmpty(current.RestoreDateElement.Value))
                {
                    writer.WriteString("restoreDate", current.RestoreDateElement.Value);
                }
                if (current.RestoreDateElement.HasExtensions() || (!string.IsNullOrEmpty(current.RestoreDateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_restoreDate", false, current.RestoreDateElement.Extension, current.RestoreDateElement.ElementId);
                }
            }

            if (current.ValidityPeriod != null)
            {
                writer.WritePropertyName("validityPeriod");
                current.ValidityPeriod.SerializeJson(writer, options);
            }

            if (current.DataExclusivityPeriod != null)
            {
                writer.WritePropertyName("dataExclusivityPeriod");
                current.DataExclusivityPeriod.SerializeJson(writer, options);
            }

            if (current.DateOfFirstAuthorizationElement != null)
            {
                if (!string.IsNullOrEmpty(current.DateOfFirstAuthorizationElement.Value))
                {
                    writer.WriteString("dateOfFirstAuthorization", current.DateOfFirstAuthorizationElement.Value);
                }
                if (current.DateOfFirstAuthorizationElement.HasExtensions() || (!string.IsNullOrEmpty(current.DateOfFirstAuthorizationElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_dateOfFirstAuthorization", false, current.DateOfFirstAuthorizationElement.Extension, current.DateOfFirstAuthorizationElement.ElementId);
                }
            }

            if (current.InternationalBirthDateElement != null)
            {
                if (!string.IsNullOrEmpty(current.InternationalBirthDateElement.Value))
                {
                    writer.WriteString("internationalBirthDate", current.InternationalBirthDateElement.Value);
                }
                if (current.InternationalBirthDateElement.HasExtensions() || (!string.IsNullOrEmpty(current.InternationalBirthDateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_internationalBirthDate", false, current.InternationalBirthDateElement.Extension, current.InternationalBirthDateElement.ElementId);
                }
            }

            if (current.LegalBasis != null)
            {
                writer.WritePropertyName("legalBasis");
                current.LegalBasis.SerializeJson(writer, options);
            }

            if ((current.JurisdictionalAuthorization != null) && (current.JurisdictionalAuthorization.Count != 0))
            {
                writer.WritePropertyName("jurisdictionalAuthorization");
                writer.WriteStartArray();
                foreach (MedicinalProductAuthorization.JurisdictionalAuthorizationComponent val in current.JurisdictionalAuthorization)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.Holder != null)
            {
                writer.WritePropertyName("holder");
                current.Holder.SerializeJson(writer, options);
            }

            if (current.Regulator != null)
            {
                writer.WritePropertyName("regulator");
                current.Regulator.SerializeJson(writer, options);
            }

            if (current.Procedure != null)
            {
                writer.WritePropertyName("procedure");
                current.Procedure.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
コード例 #3
0
        /// <summary>
        /// Deserialize JSON into a FHIR MedicinalProductAuthorization
        /// </summary>
        public static void DeserializeJsonProperty(this MedicinalProductAuthorization current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"MedicinalProductAuthorization 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($"MedicinalProductAuthorization 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 "subject":
                current.Subject = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Subject).DeserializeJson(ref reader, options);
                break;

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

                current.Country = new List <CodeableConcept>();

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

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

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

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

                current.Jurisdiction = new List <CodeableConcept>();

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

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

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

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

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

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

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

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

            case "validityPeriod":
                current.ValidityPeriod = new Hl7.Fhir.Model.Period();
                ((Hl7.Fhir.Model.Period)current.ValidityPeriod).DeserializeJson(ref reader, options);
                break;

            case "dataExclusivityPeriod":
                current.DataExclusivityPeriod = new Hl7.Fhir.Model.Period();
                ((Hl7.Fhir.Model.Period)current.DataExclusivityPeriod).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

                current.JurisdictionalAuthorization = new List <MedicinalProductAuthorization.JurisdictionalAuthorizationComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.MedicinalProductAuthorization.JurisdictionalAuthorizationComponent v_JurisdictionalAuthorization = new Hl7.Fhir.Model.MedicinalProductAuthorization.JurisdictionalAuthorizationComponent();
                    v_JurisdictionalAuthorization.DeserializeJson(ref reader, options);
                    current.JurisdictionalAuthorization.Add(v_JurisdictionalAuthorization);

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

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

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

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

            case "procedure":
                current.Procedure = new Hl7.Fhir.Model.MedicinalProductAuthorization.ProcedureComponent();
                ((Hl7.Fhir.Model.MedicinalProductAuthorization.ProcedureComponent)current.Procedure).DeserializeJson(ref reader, options);
                break;

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