Ejemplo n.º 1
0
        public async Task <ActionResult> Create(CustomPatient customPatient)
        {
            try
            {
                // add new patient to fhir api test server
                var patientToAdd = new Patient();
                var patientName  = new HumanName();
                patientName.Family = customPatient.Name;
                patientName.Given  = customPatient.FirstNames;
                patientToAdd.Name.Add(patientName);

                var identifier = new Identifier("UptSystem", "UPTValue");


                patientToAdd.Identifier.Add(identifier);

                var result = await _client.CreateAsync(patientToAdd);

                return(Created($"{BASEURL}/Patient/{result.Id}", "Created with succes!"));
            }
            catch
            {
                return(BadRequest("Wrong object!"));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <CustomPatient> > > GetPatientsAsync()
        {
            List <CustomPatient> patientList = new List <CustomPatient>();
            var filterParams = new SearchParams()
                               .Where("identifier=UPTValue");

            Bundle result = await _client.SearchAsync <Patient>(filterParams);

            while (result != null)
            {
                foreach (var item in result.Entry)
                {
                    var patientRetrieved = (Patient)item.Resource;
                    var customPatient    = new CustomPatient()
                    {
                        Name       = patientRetrieved.Name.FirstOrDefault().Family,
                        FirstNames = patientRetrieved.Name.FirstOrDefault().Given.ToList(),
                        Id         = patientRetrieved.Id
                    };
                    patientList.Add(customPatient);
                }
                result = _client.Continue(result, PageDirection.Next);
            }

            return(Ok(patientList));
        }