コード例 #1
0
        public FhirModel.Organization GetResource()
        {
            var Resource = new FhirModel.Organization();

            Resource.Id = GetResourceId();

            IPyroFhirServerCodeSystem.SetProtectedMetaTag(Resource);
            Resource.Meta.LastUpdated = MasterLastUpdated;
            Resource.Identifier       = new List <FhirModel.Identifier>()
            {
                IPyroHealthCodeSystem.GetIdentifier(CodeSystems.PyroHealth.Codes.PyroHealth)
            };
            Resource.Active = true;
            Resource.Name   = GetResourceId();
            var AngusContactDetails = Elements.PyroHealthContactDetailAngusMillar.GetContactDetail();

            Resource.Telecom  = AngusContactDetails.Telecom;
            Resource.Endpoint = new List <FhirModel.ResourceReference>()
            {
                new FhirModel.ResourceReference("https://pyrohealth.net/")
            };
            Resource.Contact = new List <FhirModel.Organization.ContactComponent>();
            var ContactComponent = new FhirModel.Organization.ContactComponent();

            Resource.Contact.Add(ContactComponent);
            ContactComponent.Name      = new FhirModel.HumanName();
            ContactComponent.Name.Text = AngusContactDetails.Name;
            ContactComponent.Telecom   = AngusContactDetails.Telecom;

            return(Resource);
        }
コード例 #2
0
        /// <summary>
        /// Deserialize JSON into a FHIR Organization
        /// </summary>
        public static void DeserializeJsonProperty(this Organization current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Organization 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($"Organization 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 "active":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ActiveElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.ActiveElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

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

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

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

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

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

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

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

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

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

                current.AliasElement = new List <FhirString>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        current.AliasElement.Add(new FhirString());
                        reader.Skip();
                    }
                    else
                    {
                        current.AliasElement.Add(new FhirString(reader.GetString()));
                    }

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

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

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

                int i_alias = 0;

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (i_alias >= current.AliasElement.Count)
                    {
                        current.AliasElement.Add(new FhirString());
                    }
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        reader.Skip();
                    }
                    else
                    {
                        ((Hl7.Fhir.Model.Element)current.AliasElement[i_alias++]).DeserializeJson(ref reader, options);
                    }

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

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

                current.Telecom = new List <ContactPoint>();

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

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

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

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

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

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

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

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

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

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

                current.Contact = new List <Organization.ContactComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Organization.ContactComponent v_Contact = new Hl7.Fhir.Model.Organization.ContactComponent();
                    v_Contact.DeserializeJson(ref reader, options);
                    current.Contact.Add(v_Contact);

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

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

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

                current.Endpoint = new List <ResourceReference>();

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

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

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

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