private async Task <IResource> CreatePatient(IResource input)
        {
            var visiPatient = _resourceMapper.MapViSiPatient(input);

            await _visiContext.Patient.AddAsync(visiPatient);

            await _visiContext.SaveChangesAsync();

            // return the new resource as it was stored by this server
            return(_resourceMapper.MapPatient(_visiContext.Patient.Last()));
        }
Exemple #2
0
        private async Task <SearchResult> SearchPatient(IArgumentCollection arguments, SearchOptions options)
        {
            var query = _queryContext.CreateQuery(new PatientQueryFactory(_visiContext), arguments, options);

            var count = await query.ExecuteCount(_visiContext);

            var patientResources = new List <IResource>();

            if (count > 0)
            {
                var visiPatients = await query.Execute(_visiContext).ToListAsync();

                foreach (var visiPatient in visiPatients)
                {
                    patientResources.Add(_resourceMapper.MapPatient(visiPatient));
                }
            }
            return(new SearchResult(patientResources, query.GetPageSize(), count));
        }