Пример #1
0
        public static Identifier GetIdentifier(string system, string value, CodeableConcept type = null)
        {
            var Id = new Hl7.Fhir.Model.Identifier();

            if (!string.IsNullOrWhiteSpace(system))
            {
                if (Uri.TryCreate(system, UriKind.Absolute, out Uri uri))
                {
                    Id.System = uri.OriginalString;
                }
                else
                {
                    throw new FormatException($"The Identifier system provided could not be parsed as an absolute uri.");
                }
            }
            else
            {
                throw new FormatException($"The Identifier system provided can not be null or empty string.");
            }
            if (!string.IsNullOrWhiteSpace(value))
            {
                Id.Value = value;
            }
            else
            {
                throw new FormatException($"The Identifier value provided can not be null or empty string.");
            }

            if (type is object)
            {
                Id.Type = type;
            }
            return(Id);
        }
Пример #2
0
        public HttpResponseMessage Get(string id)
        {
            HttpResponseMessage response = null;
            string token = "";

            //load Patient and generated a new PIN Code valid for 48 hours
            model.Patient pat = (model.Patient)_client.LoadResource("Patient/" + id);
            if (pat != null)
            {
                var fbid = pat.Identifier.FirstOrDefault(ident => ident.System == "http://fhirbot.org");
                if (fbid != null)
                {
                    pat.Identifier.Remove(fbid);
                }
                Random r       = new Random();
                int    randNum = r.Next(1000000);
                token = randNum.ToString("D6");
                model.Identifier newid = new model.Identifier("http://fhirbot.org", token);
                newid.Period = new model.Period(model.FhirDateTime.Now(), new model.FhirDateTime(DateTimeOffset.Now.AddDays(2)));
                pat.Identifier.Add(newid);
                _client.SaveResource(pat);
                string respval = "{\"token\":\"" + token + "\"}";
                response         = this.Request.CreateResponse(HttpStatusCode.OK);
                response.Content = new StringContent(respval, Encoding.UTF8, "application/json");
            }
            else
            {
                response         = this.Request.CreateResponse(HttpStatusCode.NotFound);
                response.Content = new StringContent("Can't find patient with id " + id, Encoding.UTF8, "text/html");
            }


            return(response);
        }
        private static Model.Identifier BuildIdentifier(string value, string system)
        {
            var identifier = new Model.Identifier {
                Value = value, System = string.IsNullOrWhiteSpace(system) ? null : system
            };

            return(identifier);
        }
        protected async Task <TResource> CreateResourceByIdentityAsync <TResource>(Model.Identifier identifier, Action <TResource, Model.Identifier> propertySetter)
            where TResource : Model.Resource, new()
        {
            EnsureArg.IsNotNull(identifier, nameof(identifier));
            var resource = new TResource();

            propertySetter?.Invoke(resource, identifier);

            return(await FhirService.CreateResourceAsync(resource).ConfigureAwait(false));
        }
Пример #5
0
        /// <summary>
        /// Deserialize JSON into a FHIR Practitioner#Qualification
        /// </summary>
        public static void DeserializeJsonProperty(this Practitioner.QualificationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"QualificationComponent 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($"QualificationComponent 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 "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                break;

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

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

            // Complex: qualification, Export: QualificationComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
 //[SprinklerTest("TR10", "Failing data")]
 public void FailingData()
 {
     Patient p = new Patient();
     Identifier item = new Identifier();
     item.Label = "hl7v2";
     item.Value = "PID-55101";
     p.Identifier = new List<Identifier>();
     p.Identifier.Add(item);
     p.BirthDate = "1974-02-20";
     ResourceEntry<Patient> r = client.Create<Patient>(p);
 }
        protected async Task <TResource> GetResourceByIdentityAsync <TResource>(Model.Identifier identifier)
            where TResource : Model.Resource, new()
        {
            EnsureArg.IsNotNull(identifier, nameof(identifier));

            string fhirTypeName = ModelInfo.GetFhirTypeNameForType(typeof(TResource));

            _ = Enum.TryParse(fhirTypeName, out ResourceType resourceType);

            Model.Bundle result = await FhirService.SearchForResourceAsync(resourceType, identifier.ToSearchQueryParameter()).ConfigureAwait(false);

            return(await result.ReadOneFromBundleWithContinuationAsync <TResource>(FhirService));
        }
Пример #8
0
        /// <summary>
        /// { code : identifier-value, system : identifier-system, text : identifier-type }
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        private List <Expression> ToExpressions(FhirModel.Identifier element)
        {
            if (element == null)
            {
                return(null);
            }

            var values = new List <IndexValue>();

            if (element.Value != null)
            {
                values.Add(new IndexValue("code", new StringValue(element.Value)));
            }
            if (element.System != null)
            {
                values.Add(new IndexValue("system", new StringValue(element.System)));
            }
            if (element.Type != null)
            {
                values.Add(new IndexValue("text", new StringValue(element.Type.Text)));
            }

            return(ListOf(new CompositeValue(values)));
        }
Пример #9
0
        private void cmdCreatePatient_Click(object sender, EventArgs e)
        {
            // Code for creating a patient here.
            // Patientidentifier variables
            var MyPatient = new Hl7.Fhir.Model.Patient();

            var PatientName = new Hl7.Fhir.Model.HumanName();

            PatientName.Use = Hl7.Fhir.Model.HumanName.NameUse.Official;

            string patientFirstName = txtFirstName.Text;
            string patientSurname   = txtSurname.Text;
            string patientTitle     = cmbPatientTitle.Text;
            string patientNumber    = txtPatientNum.Text;


            PatientName.Prefix = new string[] { patientTitle };
            PatientName.Given  = new string[] { patientFirstName };
            PatientName.Family = new string[] { patientSurname };

            MyPatient.Name = new List <Hl7.Fhir.Model.HumanName>();
            MyPatient.Name.Add(PatientName);

            // Institution patient identifiers
            var PatientIdentifier = new Hl7.Fhir.Model.Identifier();

            PatientIdentifier.System = "https://medical-test.net";
            PatientIdentifier.Value  = patientNumber;
            MyPatient.Identifier     = new List <Hl7.Fhir.Model.Identifier>();
            MyPatient.Identifier.Add(PatientIdentifier);

            string    xml  = Hl7.Fhir.Serialization.FhirSerializer.SerializeResourceToXml(MyPatient);
            XDocument xDoc = XDocument.Parse(xml);

            txtOutput.Text = xDoc.ToString();
        }
Пример #10
0
        protected virtual async Task <Model.Observation> GetObservationFromServerAsync(Model.Identifier identifier)
        {
            var searchParams = identifier.ToSearchParams();
            var result       = await _client.SearchAsync <Model.Observation>(searchParams).ConfigureAwait(false);

            return(await result.ReadOneFromBundleWithContinuationAsync <Model.Observation>(_client));
        }
        /// <summary>
        /// Deserialize JSON into a FHIR BiologicallyDerivedProduct
        /// </summary>
        public static void DeserializeJsonProperty(this BiologicallyDerivedProduct current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"BiologicallyDerivedProduct 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($"BiologicallyDerivedProduct 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 "productCategory":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ProductCategoryElement = new Code <Hl7.Fhir.Model.BiologicallyDerivedProduct.BiologicallyDerivedProductCategory>();
                    reader.Skip();
                }
                else
                {
                    current.ProductCategoryElement = new Code <Hl7.Fhir.Model.BiologicallyDerivedProduct.BiologicallyDerivedProductCategory>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.BiologicallyDerivedProduct.BiologicallyDerivedProductCategory>(reader.GetString()));
                }
                break;

            case "_productCategory":
                if (current.ProductCategoryElement == null)
                {
                    current.ProductCategoryElement = new Code <Hl7.Fhir.Model.BiologicallyDerivedProduct.BiologicallyDerivedProductCategory>();
                }
                ((Hl7.Fhir.Model.Element)current.ProductCategoryElement).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

            case "quantity":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.QuantityElement = new Integer();
                    reader.Skip();
                }
                else
                {
                    current.QuantityElement = new Integer(reader.GetInt32());
                }
                break;

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

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

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

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

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

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

            case "collection":
                current.Collection = new Hl7.Fhir.Model.BiologicallyDerivedProduct.CollectionComponent();
                ((Hl7.Fhir.Model.BiologicallyDerivedProduct.CollectionComponent)current.Collection).DeserializeJson(ref reader, options);
                break;

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

                current.Processing = new List <BiologicallyDerivedProduct.ProcessingComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.BiologicallyDerivedProduct.ProcessingComponent v_Processing = new Hl7.Fhir.Model.BiologicallyDerivedProduct.ProcessingComponent();
                    v_Processing.DeserializeJson(ref reader, options);
                    current.Processing.Add(v_Processing);

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

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

            case "manipulation":
                current.Manipulation = new Hl7.Fhir.Model.BiologicallyDerivedProduct.ManipulationComponent();
                ((Hl7.Fhir.Model.BiologicallyDerivedProduct.ManipulationComponent)current.Manipulation).DeserializeJson(ref reader, options);
                break;

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

                current.Storage = new List <BiologicallyDerivedProduct.StorageComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.BiologicallyDerivedProduct.StorageComponent v_Storage = new Hl7.Fhir.Model.BiologicallyDerivedProduct.StorageComponent();
                    v_Storage.DeserializeJson(ref reader, options);
                    current.Storage.Add(v_Storage);

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

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

            // Complex: BiologicallyDerivedProduct, Export: BiologicallyDerivedProduct, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #12
0
        protected static async Task <TResource> GetResourceByIdentityAsync <TResource>(IFhirClient client, Model.Identifier identifier)
            where TResource : Model.Resource, new()
        {
            EnsureArg.IsNotNull(client, nameof(client));
            EnsureArg.IsNotNull(identifier, nameof(identifier));
            var searchParams = identifier.ToSearchParams();
            var result       = await client.SearchAsync <TResource>(searchParams).ConfigureAwait(false);

            return(await result.ReadOneFromBundleWithContinuationAsync <TResource>(client));
        }
Пример #13
0
        public static IActionResult Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "linkresource/{res}/{id}")] HttpRequest req,
            ILogger log, ClaimsPrincipal principal, string res, string id)
        {
            FhirJsonParser _parser = new FhirJsonParser();

            _parser.Settings.AcceptUnknownMembers   = true;
            _parser.Settings.AllowUnrecognizedEnums = true;
            log.LogInformation("SecureLink Function Invoked");
            //Is the principal authenticated
            if (!principal.Identity.IsAuthenticated)
            {
                return(new ContentResult()
                {
                    Content = "User is not Authenticated", StatusCode = (int)System.Net.HttpStatusCode.Unauthorized
                });
            }
            //Is the prinicipal a FHIR Server Administrator
            ClaimsIdentity ci = (ClaimsIdentity)principal.Identity;

            if (!ci.IsInFHIRRole(Environment.GetEnvironmentVariable("ADMIN_ROLE")))
            {
                return(new ContentResult()
                {
                    Content = "User does not have suffiecient rights (Administrator required)", StatusCode = (int)System.Net.HttpStatusCode.Unauthorized
                });
            }
            string aadten = ci.Tenant();
            //Custom Headers for User Audit in FHIR
            List <HeaderParm> auditheaders = new List <HeaderParm>();

            auditheaders.Add(new HeaderParm("X-MS-AZUREFHIR-AUDIT-USERID", principal.Identity.Name));
            auditheaders.Add(new HeaderParm("X-MS-AZUREFHIR-AUDIT-TENANT", aadten));
            auditheaders.Add(new HeaderParm("X-MS-AZUREFHIR-AUDIT-SOURCE", req.HttpContext.Connection.RemoteIpAddress.ToString()));
            auditheaders.Add(new HeaderParm("X-MS-AZUREFHIR-AUDIT-PROXY", "FHIRProxy-LinkResource"));
            //Are we linking the correct resource type
            if (string.IsNullOrEmpty(res) || !allowedresources.Any(res.ToLower().Contains))
            {
                return(new BadRequestObjectResult("Linked resource must be Patient,Practitioner or RelatedPerson"));
            }
            string name = req.Query["name"];

            if (string.IsNullOrEmpty(name))
            {
                return(new BadRequestObjectResult("Linked resource must have principal name specified in parameters (e.g. ?name=)"));
            }
            //Get/update/check current bearer token to talk to authenticate to FHIR Server
            if (_bearerToken == null || FHIRClient.isTokenExpired(_bearerToken))
            {
                lock (_lock)
                {
                    log.LogInformation($"Obtaining new OAUTH2 Bearer Token for access to FHIR Server");
                    _bearerToken = FHIRClient.GetOAUTH2BearerToken(System.Environment.GetEnvironmentVariable("FS_TENANT_NAME"), System.Environment.GetEnvironmentVariable("FS_RESOURCE"),
                                                                   System.Environment.GetEnvironmentVariable("FS_CLIENT_ID"), System.Environment.GetEnvironmentVariable("FS_SECRET"));
                }
            }
            //Get a FHIR Client so we can talk to the FHIR Server
            log.LogInformation($"Instanciating FHIR Client Proxy");
            FHIRClient fhirClient = new FHIRClient(System.Environment.GetEnvironmentVariable("FS_URL"), _bearerToken);

            int.TryParse(System.Environment.GetEnvironmentVariable("LINK_DAYS"), out int i_link_days);
            //Load the resource to Link
            var fhirresp = fhirClient.LoadResource(res + "/" + id, null, false, auditheaders.ToArray());
            var lres     = _parser.Parse <Resource>((string)fhirresp.Content);

            if (lres.ResourceType == Hl7.Fhir.Model.ResourceType.OperationOutcome)
            {
                return(new BadRequestObjectResult(lres.ToString()));
            }
            //Add Link to AAD Tenent in Identifiers
            if (lres.ResourceType == Hl7.Fhir.Model.ResourceType.Practitioner)
            {
                var tr   = (Hl7.Fhir.Model.Practitioner)lres;
                var fbid = tr.Identifier.FirstOrDefault(ident => ident.System == aadten);
                if (fbid != null)
                {
                    tr.Identifier.Remove(fbid);
                }
                Hl7.Fhir.Model.Identifier newid = new Hl7.Fhir.Model.Identifier(aadten, name);
                newid.Period = new Hl7.Fhir.Model.Period(Hl7.Fhir.Model.FhirDateTime.Now(), new Hl7.Fhir.Model.FhirDateTime(DateTimeOffset.Now.AddDays(i_link_days)));
                tr.Identifier.Add(newid);
                FhirJsonSerializer serializer = new FhirJsonSerializer();
                string             srv        = serializer.SerializeToString(tr);
                var saveresult = fhirClient.SaveResource(Enum.GetName(typeof(ResourceType), tr.ResourceType), srv, "PUT", auditheaders.ToArray());
                if (saveresult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    return(new OkObjectResult($"Identity: {name} in directory {aadten} is now linked to {res}/{id}"));
                }
                else
                {
                    return(new BadRequestObjectResult($"Unable to link Identity: {name} in directory {aadten}:{saveresult.StatusCode}"));
                }
            }
            else if (lres.ResourceType == Hl7.Fhir.Model.ResourceType.Patient)
            {
                var tr   = (Hl7.Fhir.Model.Patient)lres;
                var fbid = tr.Identifier.FirstOrDefault(ident => ident.System == aadten);
                if (fbid != null)
                {
                    tr.Identifier.Remove(fbid);
                }
                Hl7.Fhir.Model.Identifier newid = new Hl7.Fhir.Model.Identifier(aadten, name);
                newid.Period = new Hl7.Fhir.Model.Period(Hl7.Fhir.Model.FhirDateTime.Now(), new Hl7.Fhir.Model.FhirDateTime(DateTimeOffset.Now.AddDays(i_link_days)));
                tr.Identifier.Add(newid);
                FhirJsonSerializer serializer = new FhirJsonSerializer();
                string             srv        = serializer.SerializeToString(tr);
                var saveresult = fhirClient.SaveResource(Enum.GetName(typeof(ResourceType), tr.ResourceType), srv, "PUT", auditheaders.ToArray());
                if (saveresult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    return(new OkObjectResult($"Identity: {name} in directory {aadten} is now linked to {res}/{id}"));
                }
                else
                {
                    return(new BadRequestObjectResult($"Unable to link Identity: {name} in directory {aadten}:{saveresult.StatusCode}"));
                }
            }

            return(new OkObjectResult($"No action taken Identity: {name}"));
        }
        public void Write(Definition definition, Identifier identifier)
        {
            string system = (identifier.System != null) ? identifier.System.ToString() : null;
            string code = (identifier.Value != null) ? identifier.Value : null;

            BsonDocument value = new BsonDocument()
                {
                    { "system", system },
                    { "code", code },
                    // eigenlijk moet het ook een Display bevatten (om dat search daarop kan zoeken bij een token)
                };
            document.Write(definition.ParamName, value);
        }
Пример #15
0
        internal static Organization CreateOrganizationResource()
        {
            // Create new Organization resource
            Organization res = new Organization();

            // Allocate the logical resource Id - this is what the resource is referenced by
            res.Id = "13daadee-26e1-4d6a-9e6a-7f4af9b58878";

            // Add the profile for this resource (from the FGM DMS)
            Meta metadata = new Meta();
            metadata.Profile = new string[] { "urn:fhir.nhs.uk:profile/NHS-FGM-Organization" };
            res.Meta = metadata;

            // Add the business idetifier for the organisation, plus the organisation name
            res.Identifier = new List<Identifier>();
            Identifier id = new Identifier("urn:fhir.nhs.uk/id/ODSOrganisationCode", "RKE");
            res.Identifier.Add(id);
            res.Name = "THE WHITTINGTON HOSPITAL NHS TRUST";

            return res;
        }
Пример #16
0
        /// <summary>
        /// Deserialize JSON into a FHIR EnrollmentRequest
        /// </summary>
        public static void DeserializeJsonProperty(this EnrollmentRequest current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"EnrollmentRequest 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($"EnrollmentRequest 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.FinancialResourceStatusCodes>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.FinancialResourceStatusCodes>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.FinancialResourceStatusCodes>(reader.GetString()));
                }
                break;

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

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

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

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

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

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

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

            // Complex: EnrollmentRequest, Export: EnrollmentRequest, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #17
0
        internal static Practitioner CreatePractitionerResource()
        {
            // Create new Practitioner resource
            Practitioner res = new Practitioner();

            // Allocate the logical resource Id - this is what the resource is referenced by
            res.Id = "41fe704c-18e5-11e5-b60b-1697f925ec7b";

            // Add the profile for this resource (from the FGM DMS)
            Meta metadata = new Meta();
            metadata.Profile = new string[] { "urn:fhir.nhs.uk:profile/NHS-FGM-Practitioner" };
            res.Meta = metadata;

            // Add the business idetifier for the SDS User Id
            res.Identifier = new List<Identifier>();
            Identifier id1 = new Identifier("urn:fhir.nhs.uk/id/SDSUserID", "G12345678");
            id1.Use = Identifier.IdentifierUse.Official;
            res.Identifier.Add(id1);

            // Add the business idetifier for the SDS Role Profile Id
            Identifier id2 = new Identifier("urn:fhir.nhs.uk/id/SDSRoleProfileID", "PT1234");
            id2.Use = Identifier.IdentifierUse.Official;
            res.Identifier.Add(id2);

            // Add the name of the practitioner
            res.Name = HumanName.ForFamily("Wood").WithGiven("Town");
            res.Name.Use = HumanName.NameUse.Official;
            res.Name.Prefix = new String[] { "Dr." };

            // Add details about the practitioner's role
            Practitioner.PractitionerPractitionerRoleComponent pr = new Practitioner.PractitionerPractitionerRoleComponent();
            Coding code = new Coding("urn:fhir.nhs.uk:vs/SDSJobRoleName", "R0090");
            code.Display = "Hospital Practitioner";

            pr.Role = new CodeableConcept();
            pr.Role.Coding = new List<Coding>();
            pr.Role.Coding.Add(code);

            // Add details about the practitioner's managing organisation
            pr.ManagingOrganization =
                new ResourceReference()
                { Reference = "Organization/41fe704c-18e5-11e5-b60b-1697f925ec7b" };

            res.PractitionerRole.Add(pr);
            return res;
        }
Пример #18
0
        /// <summary>
        /// Deserialize JSON into a FHIR DetectedIssue
        /// </summary>
        public static void DeserializeJsonProperty(this DetectedIssue current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"DetectedIssue 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($"DetectedIssue 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.ObservationStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.ObservationStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.ObservationStatus>(reader.GetString()));
                }
                break;

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

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

            case "severity":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.SeverityElement = new Code <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>();
                    reader.Skip();
                }
                else
                {
                    current.SeverityElement = new Code <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>(reader.GetString()));
                }
                break;

            case "_severity":
                if (current.SeverityElement == null)
                {
                    current.SeverityElement = new Code <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>();
                }
                ((Hl7.Fhir.Model.Element)current.SeverityElement).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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

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

                current.Evidence = new List <DetectedIssue.EvidenceComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.DetectedIssue.EvidenceComponent v_Evidence = new Hl7.Fhir.Model.DetectedIssue.EvidenceComponent();
                    v_Evidence.DeserializeJson(ref reader, options);
                    current.Evidence.Add(v_Evidence);

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

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

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

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

            case "reference":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ReferenceElement = new FhirUri();
                    reader.Skip();
                }
                else
                {
                    current.ReferenceElement = new FhirUri(reader.GetString());
                }
                break;

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

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

                current.Mitigation = new List <DetectedIssue.MitigationComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.DetectedIssue.MitigationComponent v_Mitigation = new Hl7.Fhir.Model.DetectedIssue.MitigationComponent();
                    v_Mitigation.DeserializeJson(ref reader, options);
                    current.Mitigation.Add(v_Mitigation);

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

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

            // Complex: DetectedIssue, Export: DetectedIssue, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #19
0
        /// <summary>
        /// Deserialize JSON into a FHIR DocumentReference
        /// </summary>
        public static void DeserializeJsonProperty(this DocumentReference current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "masterIdentifier":
                current.MasterIdentifier = new Hl7.Fhir.Model.Identifier();
                ((Hl7.Fhir.Model.Identifier)current.MasterIdentifier).DeserializeJson(ref reader, options);
                break;

            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"DocumentReference 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($"DocumentReference 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.DocumentReferenceStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.DocumentReferenceStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.DocumentReferenceStatus>(reader.GetString()));
                }
                break;

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

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

            case "_docStatus":
                if (current.DocStatusElement == null)
                {
                    current.DocStatusElement = new Code <Hl7.Fhir.Model.CompositionStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.DocStatusElement).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 "category":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"DocumentReference error reading 'category' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                current.RelatesTo = new List <DocumentReference.RelatesToComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.DocumentReference.RelatesToComponent v_RelatesTo = new Hl7.Fhir.Model.DocumentReference.RelatesToComponent();
                    v_RelatesTo.DeserializeJson(ref reader, options);
                    current.RelatesTo.Add(v_RelatesTo);

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

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

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

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

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

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

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

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

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

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

                current.Content = new List <DocumentReference.ContentComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.DocumentReference.ContentComponent v_Content = new Hl7.Fhir.Model.DocumentReference.ContentComponent();
                    v_Content.DeserializeJson(ref reader, options);
                    current.Content.Add(v_Content);

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

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

            case "context":
                current.Context = new Hl7.Fhir.Model.DocumentReference.ContextComponent();
                ((Hl7.Fhir.Model.DocumentReference.ContextComponent)current.Context).DeserializeJson(ref reader, options);
                break;

            // Complex: DocumentReference, Export: DocumentReference, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #20
0
        /// <summary>
        /// Deserialize JSON into a FHIR CatalogEntry
        /// </summary>
        public static void DeserializeJsonProperty(this CatalogEntry current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"CatalogEntry 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($"CatalogEntry 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 "type":
                current.Type = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Type).DeserializeJson(ref reader, options);
                break;

            case "orderable":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.OrderableElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.OrderableElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.PublicationStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).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 "validTo":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ValidToElement = new FhirDateTime();
                    reader.Skip();
                }
                else
                {
                    current.ValidToElement = new FhirDateTime(reader.GetString());
                }
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                current.RelatedEntry = new List <CatalogEntry.RelatedEntryComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.CatalogEntry.RelatedEntryComponent v_RelatedEntry = new Hl7.Fhir.Model.CatalogEntry.RelatedEntryComponent();
                    v_RelatedEntry.DeserializeJson(ref reader, options);
                    current.RelatedEntry.Add(v_RelatedEntry);

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

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

            // Complex: CatalogEntry, Export: CatalogEntry, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #21
0
        public void IdentifierMapTest()
        {
            var input = new Identifier();
            input.SystemElement = new FhirUri("id-system");
            input.ValueElement = new FhirString("id-value");

            var result = sut.Map(input);

            Assert.AreEqual(1, result.Count());
            Assert.IsInstanceOfType(result[0], typeof(CompositeValue));
            var comp = (CompositeValue)result[0];

            CheckCoding(comp, code: "id-value", system: "id-system", text: null);
        }
Пример #22
0
        /// <summary>
        /// Deserialize JSON into a FHIR GuidanceResponse
        /// </summary>
        public static void DeserializeJsonProperty(this GuidanceResponse current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "requestIdentifier":
                current.RequestIdentifier = new Hl7.Fhir.Model.Identifier();
                ((Hl7.Fhir.Model.Identifier)current.RequestIdentifier).DeserializeJson(ref reader, options);
                break;

            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"GuidanceResponse 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($"GuidanceResponse 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 "moduleUri":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Module = new FhirUri();
                    reader.Skip();
                }
                else
                {
                    current.Module = new FhirUri(reader.GetString());
                }
                break;

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

            case "moduleCanonical":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Module = new Canonical();
                    reader.Skip();
                }
                else
                {
                    current.Module = new Canonical(reader.GetString());
                }
                break;

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

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

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

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.GuidanceResponse.GuidanceResponseStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).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 "encounter":
                current.Encounter = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Encounter).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"GuidanceResponse 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($"GuidanceResponse 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;

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

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

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

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

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

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

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

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

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

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

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

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

            // Complex: GuidanceResponse, Export: GuidanceResponse, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #23
0
 public void Uri_Canonical()
 {
     var identifier = new Identifier("http://nhi.health.nz", "123");
     Assert.AreEqual("123", identifier.Value);
     Assert.AreEqual("http://nhi.health.nz", identifier.System);
 }
Пример #24
0
        /// <summary>
        /// Deserialize JSON into a FHIR Flag
        /// </summary>
        public static void DeserializeJsonProperty(this Flag current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Flag 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($"Flag 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.Flag.FlagStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.Flag.FlagStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.Flag.FlagStatus>(reader.GetString()));
                }
                break;

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

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

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

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

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

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

            case "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).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 "period":
                current.Period = new Hl7.Fhir.Model.Period();
                ((Hl7.Fhir.Model.Period)current.Period).DeserializeJson(ref reader, options);
                break;

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

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

            // Complex: Flag, Export: Flag, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #25
0
        /// <summary>
        /// Deserialize JSON into a FHIR Goal
        /// </summary>
        public static void DeserializeJsonProperty(this Goal current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Goal 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($"Goal 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 "lifecycleStatus":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.LifecycleStatusElement = new Code <Hl7.Fhir.Model.Goal.GoalLifecycleStatus>();
                    reader.Skip();
                }
                else
                {
                    current.LifecycleStatusElement = new Code <Hl7.Fhir.Model.Goal.GoalLifecycleStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.Goal.GoalLifecycleStatus>(reader.GetString()));
                }
                break;

            case "_lifecycleStatus":
                if (current.LifecycleStatusElement == null)
                {
                    current.LifecycleStatusElement = new Code <Hl7.Fhir.Model.Goal.GoalLifecycleStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.LifecycleStatusElement).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

            case "description":
                current.Description = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Description).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 "startDate":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Start = new Date();
                    reader.Skip();
                }
                else
                {
                    current.Start = new Date(reader.GetString());
                }
                break;

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

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

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

                current.Target = new List <Goal.TargetComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Goal.TargetComponent v_Target = new Hl7.Fhir.Model.Goal.TargetComponent();
                    v_Target.DeserializeJson(ref reader, options);
                    current.Target.Add(v_Target);

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

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

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

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

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

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

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

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

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

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

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

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

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Goal 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($"Goal 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;

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

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

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

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

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

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

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

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

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

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

            // Complex: Goal, Export: Goal, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #26
0
        protected static async Task <TResource> CreateResourceByIdentityAsync <TResource>(IFhirClient client, Model.Identifier identifier, Action <TResource, Model.Identifier> propertySetter)
            where TResource : Model.Resource, new()
        {
            EnsureArg.IsNotNull(client, nameof(client));
            EnsureArg.IsNotNull(identifier, nameof(identifier));
            var resource = new TResource();

            propertySetter?.Invoke(resource, identifier);

            return(await client.CreateAsync <TResource>(resource).ConfigureAwait(false));
        }
Пример #27
0
        /// <summary>
        /// Deserialize JSON into a FHIR MeasureReport
        /// </summary>
        public static void DeserializeJsonProperty(this MeasureReport current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"MeasureReport 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($"MeasureReport 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.MeasureReport.MeasureReportStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.MeasureReport.MeasureReportStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.MeasureReport.MeasureReportStatus>(reader.GetString()));
                }
                break;

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

            case "type":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.MeasureReport.MeasureReportType>();
                    reader.Skip();
                }
                else
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.MeasureReport.MeasureReportType>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.MeasureReport.MeasureReportType>(reader.GetString()));
                }
                break;

            case "_type":
                if (current.TypeElement == null)
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.MeasureReport.MeasureReportType>();
                }
                ((Hl7.Fhir.Model.Element)current.TypeElement).DeserializeJson(ref reader, options);
                break;

            case "measure":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.MeasureElement = new Canonical();
                    reader.Skip();
                }
                else
                {
                    current.MeasureElement = new Canonical(reader.GetString());
                }
                break;

            case "_measure":
                if (current.MeasureElement == null)
                {
                    current.MeasureElement = new Canonical();
                }
                ((Hl7.Fhir.Model.Element)current.MeasureElement).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 "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 "reporter":
                current.Reporter = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Reporter).DeserializeJson(ref reader, options);
                break;

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

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

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

                current.Group = new List <MeasureReport.GroupComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.MeasureReport.GroupComponent v_Group = new Hl7.Fhir.Model.MeasureReport.GroupComponent();
                    v_Group.DeserializeJson(ref reader, options);
                    current.Group.Add(v_Group);

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

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

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

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

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

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

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

            // Complex: MeasureReport, Export: MeasureReport, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #28
0
        /// <summary>
        /// Deserialize JSON into a FHIR MedicationDispense
        /// </summary>
        public static void DeserializeJsonProperty(this MedicationDispense current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"MedicationDispense 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($"MedicationDispense 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 "partOf":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"MedicationDispense error reading 'partOf' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

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

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

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

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

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

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

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

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

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

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

            case "medicationReference":
                current.Medication = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Medication).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 "context":
                current.Context = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Context).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

                current.Performer = new List <MedicationDispense.PerformerComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.MedicationDispense.PerformerComponent v_Performer = new Hl7.Fhir.Model.MedicationDispense.PerformerComponent();
                    v_Performer.DeserializeJson(ref reader, options);
                    current.Performer.Add(v_Performer);

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

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

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

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

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

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

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

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

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

            case "quantity":
                current.Quantity = new Hl7.Fhir.Model.Quantity();
                ((Hl7.Fhir.Model.Quantity)current.Quantity).DeserializeJson(ref reader, options);
                break;

            case "daysSupply":
                current.DaysSupply = new Hl7.Fhir.Model.Quantity();
                ((Hl7.Fhir.Model.Quantity)current.DaysSupply).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"MedicationDispense 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($"MedicationDispense 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;

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

                current.DosageInstruction = new List <Dosage>();

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

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

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

            case "substitution":
                current.Substitution = new Hl7.Fhir.Model.MedicationDispense.SubstitutionComponent();
                ((Hl7.Fhir.Model.MedicationDispense.SubstitutionComponent)current.Substitution).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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

            // Complex: MedicationDispense, Export: MedicationDispense, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #29
0
        /// <summary>
        /// Deserialize JSON into a FHIR DeviceRequest
        /// </summary>
        public static void DeserializeJsonProperty(this DeviceRequest current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"DeviceRequest 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($"DeviceRequest 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 "instantiatesCanonical":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"DeviceRequest error reading 'instantiatesCanonical' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.InstantiatesCanonicalElement = new List <Canonical>();

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

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

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

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

                int i_instantiatesCanonical = 0;

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

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

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

                current.InstantiatesUriElement = new List <FhirUri>();

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

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

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

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

                int i_instantiatesUri = 0;

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

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

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

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

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

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

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

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

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

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

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

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

            case "groupIdentifier":
                current.GroupIdentifier = new Hl7.Fhir.Model.Identifier();
                ((Hl7.Fhir.Model.Identifier)current.GroupIdentifier).DeserializeJson(ref reader, options);
                break;

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

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

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

            case "_intent":
                if (current.IntentElement == null)
                {
                    current.IntentElement = new Code <Hl7.Fhir.Model.RequestIntent>();
                }
                ((Hl7.Fhir.Model.Element)current.IntentElement).DeserializeJson(ref reader, options);
                break;

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

            case "_priority":
                if (current.PriorityElement == null)
                {
                    current.PriorityElement = new Code <Hl7.Fhir.Model.RequestPriority>();
                }
                ((Hl7.Fhir.Model.Element)current.PriorityElement).DeserializeJson(ref reader, options);
                break;

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

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

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

                current.Parameter = new List <DeviceRequest.ParameterComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.DeviceRequest.ParameterComponent v_Parameter = new Hl7.Fhir.Model.DeviceRequest.ParameterComponent();
                    v_Parameter.DeserializeJson(ref reader, options);
                    current.Parameter.Add(v_Parameter);

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

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

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

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

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

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

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

            case "occurrenceTiming":
                current.Occurrence = new Hl7.Fhir.Model.Timing();
                ((Hl7.Fhir.Model.Timing)current.Occurrence).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"DeviceRequest 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($"DeviceRequest 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;

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

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

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

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

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

            // Complex: DeviceRequest, Export: DeviceRequest, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #30
0
        public virtual Model.Observation GenerateObservation(ILookupTemplate <IFhirTemplate> config, IObservationGroup grp, Model.Identifier observationId, IDictionary <ResourceType, string> ids)
        {
            EnsureArg.IsNotNull(grp, nameof(grp));
            EnsureArg.IsNotNull(observationId, nameof(observationId));
            EnsureArg.IsNotNull(ids, nameof(ids));

            var patientId = Ensure.String.IsNotNullOrWhiteSpace(ids[ResourceType.Patient], nameof(ResourceType.Patient));
            var deviceId  = Ensure.String.IsNotNullOrWhiteSpace(ids[ResourceType.Device], nameof(ResourceType.Device));

            var observation = _fhirTemplateProcessor.CreateObservation(config, grp);

            observation.Subject    = patientId.ToReference <Model.Patient>();
            observation.Device     = deviceId.ToReference <Model.Device>();
            observation.Identifier = new List <Model.Identifier> {
                observationId
            };

            if (ids.TryGetValue(ResourceType.Encounter, out string encounterId))
            {
                observation.Encounter = encounterId.ToReference <Model.Encounter>();
            }

            return(observation);
        }
Пример #31
0
        /// <summary>
        /// Deserialize JSON into a FHIR Media
        /// </summary>
        public static void DeserializeJsonProperty(this Media current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Media 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($"Media 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 "basedOn":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Media error reading 'basedOn' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

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

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

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

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

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

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

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

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

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

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

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.EventStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).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 "modality":
                current.Modality = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Modality).DeserializeJson(ref reader, options);
                break;

            case "view":
                current.View = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.View).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 "encounter":
                current.Encounter = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Encounter).DeserializeJson(ref reader, options);
                break;

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

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

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

            case "issued":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.IssuedElement = new Instant();
                    reader.Skip();
                }
                else
                {
                    current.IssuedElement = new Instant(DateTimeOffset.Parse(reader.GetString()));
                }
                break;

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

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

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

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

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

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

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

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

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

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

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

            case "height":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.HeightElement = new PositiveInt();
                    reader.Skip();
                }
                else
                {
                    current.HeightElement = new PositiveInt(reader.GetInt32());
                }
                break;

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

            case "width":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.WidthElement = new PositiveInt();
                    reader.Skip();
                }
                else
                {
                    current.WidthElement = new PositiveInt(reader.GetInt32());
                }
                break;

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

            case "frames":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.FramesElement = new PositiveInt();
                    reader.Skip();
                }
                else
                {
                    current.FramesElement = new PositiveInt(reader.GetInt32());
                }
                break;

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

            case "duration":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.DurationElement = new FhirDecimal();
                    reader.Skip();
                }
                else
                {
                    current.DurationElement = new FhirDecimal(reader.GetDecimal());
                }
                break;

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

            case "content":
                current.Content = new Hl7.Fhir.Model.Attachment();
                ((Hl7.Fhir.Model.Attachment)current.Content).DeserializeJson(ref reader, options);
                break;

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Media 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($"Media 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: Media, Export: Media, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #32
0
        /// <summary>
        /// Deserialize JSON into a FHIR Group
        /// </summary>
        public static void DeserializeJsonProperty(this Group current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Group 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($"Group 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.Null)
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.Group.GroupType>();
                    reader.Skip();
                }
                else
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.Group.GroupType>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.Group.GroupType>(reader.GetString()));
                }
                break;

            case "_type":
                if (current.TypeElement == null)
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.Group.GroupType>();
                }
                ((Hl7.Fhir.Model.Element)current.TypeElement).DeserializeJson(ref reader, options);
                break;

            case "actual":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ActualElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.ActualElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

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

            case "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                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 "quantity":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.QuantityElement = new UnsignedInt();
                    reader.Skip();
                }
                else
                {
                    current.QuantityElement = new UnsignedInt(reader.GetInt32());
                }
                break;

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

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

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

                current.Characteristic = new List <Group.CharacteristicComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Group.CharacteristicComponent v_Characteristic = new Hl7.Fhir.Model.Group.CharacteristicComponent();
                    v_Characteristic.DeserializeJson(ref reader, options);
                    current.Characteristic.Add(v_Characteristic);

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

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

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

                current.Member = new List <Group.MemberComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Group.MemberComponent v_Member = new Hl7.Fhir.Model.Group.MemberComponent();
                    v_Member.DeserializeJson(ref reader, options);
                    current.Member.Add(v_Member);

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

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

            // Complex: Group, Export: Group, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #33
0
        /// <summary>
        /// Deserialize JSON into a FHIR AppointmentResponse
        /// </summary>
        public static void DeserializeJsonProperty(this AppointmentResponse current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"AppointmentResponse 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($"AppointmentResponse 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 "appointment":
                current.Appointment = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Appointment).DeserializeJson(ref reader, options);
                break;

            case "start":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.StartElement = new Instant();
                    reader.Skip();
                }
                else
                {
                    current.StartElement = new Instant(DateTimeOffset.Parse(reader.GetString()));
                }
                break;

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

            case "end":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.EndElement = new Instant();
                    reader.Skip();
                }
                else
                {
                    current.EndElement = new Instant(DateTimeOffset.Parse(reader.GetString()));
                }
                break;

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

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

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

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

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

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

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

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

            case "_participantStatus":
                if (current.ParticipantStatusElement == null)
                {
                    current.ParticipantStatusElement = new Code <Hl7.Fhir.Model.ParticipationStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.ParticipantStatusElement).DeserializeJson(ref reader, options);
                break;

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

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

            // Complex: AppointmentResponse, Export: AppointmentResponse, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
        /// <summary>
        /// Parse Identifier
        /// </summary>
        public static Hl7.Fhir.Model.Identifier ParseIdentifier(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Identifier existingInstance = null)
        {
            Hl7.Fhir.Model.Identifier result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Identifier();
            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 _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element use
                else if (atName == "use")
                {
                    result.UseElement = CodeParser.ParseCode <Hl7.Fhir.Model.Identifier.IdentifierUse>(reader, errors);
                }

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

                // Parse element system
                else if (atName == "system")
                {
                    result.SystemElement = FhirUriParser.ParseFhirUri(reader, errors);
                }

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

                // Parse element period
                else if (atName == "period")
                {
                    result.Period = PeriodParser.ParsePeriod(reader, errors);
                }

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

                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);
        }
Пример #35
0
 public void RenderIdentifier()
 {
     var i = new Identifier("http://somesystem.nl/ssn", "123456");
     Assert.AreEqual("123456@http://somesystem.nl/ssn", i.ForDisplay());
 }
Пример #36
0
        /// <summary>
        /// Deserialize JSON into a FHIR Basic
        /// </summary>
        public static void DeserializeJsonProperty(this Basic current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Basic 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($"Basic 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 "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).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 "created":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.CreatedElement = new Date();
                    reader.Skip();
                }
                else
                {
                    current.CreatedElement = new Date(reader.GetString());
                }
                break;

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

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

            // Complex: Basic, Export: Basic, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #37
0
        /// <summary>
        /// Deserialize JSON into a FHIR MedicationStatement
        /// </summary>
        public static void DeserializeJsonProperty(this MedicationStatement current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"MedicationStatement 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($"MedicationStatement 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 "basedOn":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"MedicationStatement error reading 'basedOn' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case "medicationReference":
                current.Medication = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Medication).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 "context":
                current.Context = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Context).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"MedicationStatement 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($"MedicationStatement 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;

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

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

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

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

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

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