Ejemplo n.º 1
0
        [HttpPost]//
        public async Task <ActionResult <OrganizationCreationResponse> > Post(OrganizationForCreation model)
        {
            try
            {
                var result = await _orgRepository.CreateAsync(model);

                return(Ok(result));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Organization resource could not be retreived"));
            }
        }
Ejemplo n.º 2
0
 private static List <Address> GetFHIROrgAddresses(OrganizationForCreation org)
 {
     return((from OrgAddress in org.Address
             let address = new Address
     {
         Use = OrgAddress.Use.ToEnum <AddressUse>(),
         Type = OrgAddress.Type.ToEnum <AddressType>(),
         Line = OrgAddress.Line,
         City = OrgAddress.City,
         State = OrgAddress.State,
         PostalCode = OrgAddress.PostalCode,
         Country = OrgAddress.Country
     }
             select address).ToList());
 }
Ejemplo n.º 3
0
 private static List <ContactPoint> GetFHIROrgTelecoms(OrganizationForCreation org)
 {
     if (org.Telecom != null)
     {
         return((from telecom in org.Telecom
                 let contactPoint = new ContactPoint
         {
             System = telecom.System.ToEnum <ContactPointSystem>(),
             Value = telecom.Value,
         }
                 select contactPoint).ToList());
     }
     else
     {
         return(new List <ContactPoint>());
     }
 }
Ejemplo n.º 4
0
        public async Task <OrganizationCreationResponse> CreateAsync(OrganizationForCreation org)
        {
            var Result = new OrganizationCreationResponse {
                Data = new NewOrganization()
            };
            Organization organization = new Organization
            {
                Name    = org.name,
                Address = GetFHIROrgAddresses(org),
                Telecom = GetFHIROrgTelecoms(org),
                Type    = GetFHIROrgType(org)
            };

            Organization FHIROrganization = await _client.CreateAsync(organization).ConfigureAwait(false);

            Result.Data.OrganizationId = FHIROrganization.Id;//1ce02b5e-a9ae-4f4a-a2b9-cc0a8d4c987b

            return(Result);
        }
Ejemplo n.º 5
0
        public async Task <OrganizationCreationResponse> UpdateAsync(Guid id, OrganizationForCreation org)
        {
            var Result = new OrganizationCreationResponse {
                Data = new NewOrganization()
            };

            Organization organization = await GetOrganizationFromFHIRAsync(id.ToString()).ConfigureAwait(false);

            organization.Name    = org.name;
            organization.Address = GetFHIROrgAddresses(org);
            organization.Telecom = GetFHIROrgTelecoms(org);
            organization.Type    = GetFHIROrgType(org);

            Organization FHIROrganization = await _client.UpdateAsync(organization).ConfigureAwait(false);

            Result.Data.OrganizationId = FHIROrganization.Id;//48fc2852-f0c3-4e94-af17-2bf57917eeb9

            return(Result);
        }
Ejemplo n.º 6
0
        private static List <CodeableConcept> GetFHIROrgType(OrganizationForCreation org)
        {
            List <CodeableConcept> Result = new List <CodeableConcept>
            {
                new CodeableConcept
                {
                    Coding = new List <Coding>
                    {
                        new Coding
                        {
                            System  = org.type.System,
                            Code    = org.type.Code,
                            Display = org.type.Display
                        },
                    },
                }
            };

            return(Result);
        }