public async Task <Status> GetAsync(string statusId) { var tweet = await Auth.ExecuteOperationWithCredentials( this.credentials, () => TweetAsync.GetTweet(long.Parse(statusId))); var mapper = new StatusMapper(); return(mapper.Map(tweet, new Status())); }
public List <PatientDemographyModel> Search(out int dataCount, string facilityId, string term = null) { try { var patientEntites = new List <PatientDemography>(); if (!string.IsNullOrEmpty(term)) { patientEntites = _context.PatientDemography.Include("PatientRegimen").Where(m => m.FacilityId == facilityId && m.PatientIdentifier.ToLower().Contains(term.ToLower().Trim())).ToList(); } else { patientEntites = _context.PatientDemography.ToList(); } if (!patientEntites.Any()) { dataCount = 0; return(new List <PatientDemographyModel>()); } var PatientModels = new List <PatientDemographyModel>(); patientEntites.ForEach(m => { var patientModel = mapper.Map <PatientDemography, PatientDemographyModel>(m); patientModel.DateOfBirthStr = patientModel.PatientDateOfBirth?.ToShortDateString() ?? "NA"; patientModel.Status = "Unknown"; if (m.PatientRegimen.Any()) { var maxVisitDate = m.PatientRegimen.Max(s => s.VisitDate); var maxDuration = m.PatientRegimen.Max(s => s.PrescribedRegimenDuration); patientModel.VisitDateStr = maxVisitDate?.ToShortDateString() ?? "NA"; patientModel.AppointmentDateStr = (maxVisitDate.Value.AddDays(maxDuration)).ToShortDateString() ?? "NA"; patientModel.Status = StatusMapper.GetClientStatus2(maxVisitDate, maxDuration); } patientModel.ArtstartDateStr = m.ArtstartDate.Value.ToShortDateString() ?? "NA"; patientModel.FacilityName = m.FacilityName; PatientModels.Add(patientModel); }); dataCount = _context.PatientDemography.Count(m => m.FacilityId == facilityId && m.PatientIdentifier.ToLower().Contains(term.ToLower().Trim())); return(PatientModels); } catch (Exception ex) { dataCount = 0; return(new List <PatientDemographyModel>()); } }
public Worker(string filePath) { this.filePath = filePath; _parser = new Parser(); _analogMapper = new AnalogMapper(); _connectionMapper = new ConnectionMapper(); _legacyNameMapper = new LegacyNameMapper(); _messageMapper = new MessageMapper(); _multistateMapper = new MultistateMapper(); _rateMapper = new RateMapper(); _remConnJoinMapper = new RemConnJoinMapper(); _remoteMapper = new RemoteMapper(); _stationMapper = new StationMapper(); _statusMapper = new StatusMapper(); _templateMapper = new CGLTemplateMapper(); _CGLMapper = new CGLMapper(); }
public List <PatientDemographyModel> GetPatientsBySite(int itemsPerPage, int pageNumber, int siteId, out int dataCount) { try { var patientEntites = _context.PatientDemography.Where(p => p.SiteId == siteId) .Include("PatientRegimen") .OrderByDescending(m => m.Id).Skip((pageNumber - 1) * itemsPerPage).Take(itemsPerPage).ToList(); if (!patientEntites.Any()) { dataCount = 0; return(new List <PatientDemographyModel>()); } var PatientModels = new List <PatientDemographyModel>(); patientEntites.ForEach(m => { var patientModel = mapper.Map <PatientDemography, PatientDemographyModel>(m); patientModel.DateOfBirthStr = patientModel.PatientDateOfBirth?.ToShortDateString() ?? "NA"; patientModel.Status = "Unknown"; if (m.PatientRegimen.Any()) { var maxVisitDate = m.PatientRegimen.Max(s => s.VisitDate); var maxDuration = m.PatientRegimen.Max(s => s.PrescribedRegimenDuration); patientModel.VisitDateStr = maxVisitDate?.ToShortDateString() ?? "NA"; patientModel.AppointmentDateStr = (maxVisitDate.Value.AddDays(maxDuration)).ToShortDateString() ?? "NA"; patientModel.Status = StatusMapper.GetClientStatus2(maxVisitDate, maxDuration); } patientModel.ArtstartDateStr = m.ArtstartDate.Value.ToShortDateString() ?? "NA"; patientModel.FacilityName = m.FacilityName; PatientModels.Add(patientModel); }); dataCount = _context.PatientDemography.Count(p => p.SiteId == siteId); return(PatientModels); } catch (Exception ex) { dataCount = 0; return(new List <PatientDemographyModel>()); } }
public async Task <IEnumerable <StatusModel> > GetAllSavedAsync(StatusListParamsModel statusListParams) { if (statusListParams == null) { throw new ArgumentNullException("statusListParams"); } var mapper = new StatusMapper(); var paramsMapper = new StatusListParamsMapper(); var paramsModel = paramsMapper.Map(statusListParams, new StatusListParams()); var savedStatuses = await this.statusStoreRepository.GetAllSavedAsync(paramsModel); var statusModels = savedStatuses.Select(x => mapper.Map(x, new StatusModel())).ToList(); statusModels.ForEach(x => { x.IsSaved = true; x.CreatedAt = x.CreatedAt.ToLocalTime(); }); return(statusModels); }
public async Task <IEnumerable <StatusModel> > GetUserTimelineAsync(StatusListParamsModel statusListParams) { if (statusListParams == null) { throw new ArgumentNullException("statusListParams"); } var mapper = new StatusMapper(); var paramsMapper = new StatusListParamsMapper(); var paramsModel = paramsMapper.Map(statusListParams, new StatusListParams()); var statuses = await this.statusRepository.GetUserTimelineAsync(paramsModel); var statusModels = statuses .Select(x => mapper.Map(x, new StatusModel())) .ToList(); var savedStatusIds = await this.statusStoreRepository.GetSavedStatusIdsAsync(); var savedStatusIdsList = savedStatusIds.ToList(); statusModels.ForEach(x => x.IsSaved = savedStatusIdsList.Contains(x.Id)); return(statusModels); }
public virtual async Task <IEnumerable <Status> > GetUserTimelineAsync(StatusListParams statusListParams) { var userTimelineParam = new UserTimelineParameters { MaximumNumberOfTweetsToRetrieve = statusListParams.Count ?? 100, IncludeRTS = true }; if (!string.IsNullOrEmpty(statusListParams.MaxId)) { userTimelineParam.MaxId = long.Parse(statusListParams.MaxId) - 1; } var userId = new UserIdentifier(long.Parse(statusListParams.CreatedByUserId)); var tweets = await Auth.ExecuteOperationWithCredentials( this.credentials, () => TimelineAsync.GetUserTimeline(userId, userTimelineParam)); tweets = tweets ?? Enumerable.Empty <ITweet>(); var mapper = new StatusMapper(); return(tweets.Select(x => mapper.Map(x, new Status()))); }
public StatusMapperTests() { this.mapper = new StatusMapper(); }
private StatusMapper CreateSut() { var sut = new StatusMapper(); return(sut); }
public void Mapping_internal(InternalStatus internalStatus, ExternalStatus externalStatus) { var mappedStatus = StatusMapper.MapFrom(internalStatus); Assert.Equal(externalStatus, mappedStatus); }
public int QueryOrder() { RestAPI rest = new RestAPI("https://www.ne-ararsan.com/wp-json/wc/v2/", "ck_6c2e256b3a1fc9857e78d095dadc6dcd47d7df57", "cs_d83dea91af83a7a92fc014300d9472475ef78fe6"); WCObject wc = new WCObject(rest); var counter = 0; long billingId; long shippingId; var orders = wc.Order.GetAll(); orders.Wait(); var count = orders.Result.Count; var query = _repository.Query <EntityModel.Order>(); var list = query.ToList(); //Tolist yerine query result count kullanılabilir. StatusMapper statusMapper = new StatusMapper(); if (list.Count == 0) { var orderInstance = orders.Result[0]; billingId = _repository.Save <Billing>(new Billing { First_name = orderInstance.billing.first_name, Last_name = orderInstance.billing.last_name, Address_1 = orderInstance.billing.address_1, Address_2 = orderInstance.billing.address_2, City = orderInstance.billing.city, Country = orderInstance.billing.country, Company = orderInstance.billing.company, Email = orderInstance.billing.email, Phone = orderInstance.billing.phone, Postcode = orderInstance.billing.postcode, State = orderInstance.billing.state }); shippingId = _repository.Save <Shipping>(new Shipping { First_name = orderInstance.shipping.first_name, Last_name = orderInstance.shipping.last_name, Address_1 = orderInstance.shipping.address_1, Address_2 = orderInstance.shipping.address_2, City = orderInstance.shipping.city, Country = orderInstance.shipping.country, Company = orderInstance.shipping.company, Postcode = orderInstance.shipping.postcode, State = orderInstance.shipping.state }); _repository.Save <EntityModel.Order>(new EntityModel.Order { BillingId = billingId, ShippingId = shippingId, RefId = Convert.ToInt64(orderInstance.id), CreatedDate = DateTime.Now.ToDateTime(), IsLast = true, Status = Status.Active, Total = orderInstance.total, Currency = orderInstance.currency, CustomerIpAddress = orderInstance.customer_ip_address, Discount = orderInstance.discount_total, SetPaid = orderInstance.set_paid, ShippingTotal = orderInstance.shipping_total, PaymentMethod = orderInstance.payment_method, OrderStatus = statusMapper.Map(orderInstance.status) }); for (int i = 1; i < count; i++) { orderInstance = orders.Result[i]; billingId = _repository.Save <Billing>(new Billing { First_name = orderInstance.billing.first_name, Last_name = orderInstance.billing.last_name, Address_1 = orderInstance.billing.address_1, Address_2 = orderInstance.billing.address_2, City = orderInstance.billing.city, Country = orderInstance.billing.country, Company = orderInstance.billing.company, Email = orderInstance.billing.email, Phone = orderInstance.billing.phone, Postcode = orderInstance.billing.postcode, State = orderInstance.billing.state }); shippingId = _repository.Save <Shipping>(new Shipping { First_name = orderInstance.shipping.first_name, Last_name = orderInstance.shipping.last_name, Address_1 = orderInstance.shipping.address_1, Address_2 = orderInstance.shipping.address_2, City = orderInstance.shipping.city, Country = orderInstance.shipping.country, Company = orderInstance.shipping.company, Postcode = orderInstance.shipping.postcode, State = orderInstance.shipping.state }); _repository.Save <EntityModel.Order>(new EntityModel.Order { BillingId = billingId, ShippingId = shippingId, RefId = Convert.ToInt64(orderInstance.id), CreatedDate = DateTime.Now.ToDateTime(), IsLast = false, Status = Status.Active, Total = orderInstance.total, Currency = orderInstance.currency, CustomerIpAddress = orderInstance.customer_ip_address, Discount = orderInstance.discount_total, SetPaid = orderInstance.set_paid, ShippingTotal = orderInstance.shipping_total, PaymentMethod = orderInstance.payment_method, OrderStatus = statusMapper.Map(orderInstance.status) }); } counter = count; } else { var lastDate = list.Max(x => x.CreatedDate); var lastOrders = list.Where(x => x.CreatedDate == lastDate); var lastOrder = lastOrders.Where(x => x.IsLast == true).FirstOrDefault(); var idOfLastOrder = orders.Result[0].id; //int vs long if (idOfLastOrder == lastOrder.RefId) { } else { var index = orders.Result.FindIndex(x => x.id == lastOrder.RefId); if (index < 0) { throw new Exception("Cant find results in db"); } var orderInstance = orders.Result[0]; for (int i = index - 1; i >= 1; i--) { counter = counter + 1; orderInstance = orders.Result[i]; billingId = _repository.Save <Billing>(new Billing { First_name = orderInstance.billing.first_name, Last_name = orderInstance.billing.last_name, Address_1 = orderInstance.billing.address_1, Address_2 = orderInstance.billing.address_2, City = orderInstance.billing.city, Country = orderInstance.billing.country, Company = orderInstance.billing.company, Email = orderInstance.billing.email, Phone = orderInstance.billing.phone, Postcode = orderInstance.billing.postcode, State = orderInstance.billing.state }); shippingId = _repository.Save <Shipping>(new Shipping { First_name = orderInstance.shipping.first_name, Last_name = orderInstance.shipping.last_name, Address_1 = orderInstance.shipping.address_1, Address_2 = orderInstance.shipping.address_2, City = orderInstance.shipping.city, Country = orderInstance.shipping.country, Company = orderInstance.shipping.company, Postcode = orderInstance.shipping.postcode, State = orderInstance.shipping.state }); _repository.Save <EntityModel.Order>(new EntityModel.Order { BillingId = billingId, ShippingId = shippingId, RefId = Convert.ToInt64(orderInstance.id), CreatedDate = DateTime.Now.ToDateTime(), IsLast = false, Status = Status.Active, Total = orderInstance.total, Currency = orderInstance.currency, CustomerIpAddress = orderInstance.customer_ip_address, Discount = orderInstance.discount_total, SetPaid = orderInstance.set_paid, ShippingTotal = orderInstance.shipping_total, PaymentMethod = orderInstance.payment_method, OrderStatus = statusMapper.Map(orderInstance.status) }); } counter = counter + 1; orderInstance = orders.Result[0]; billingId = _repository.Save <Billing>(new Billing { First_name = orderInstance.billing.first_name, Last_name = orderInstance.billing.last_name, Address_1 = orderInstance.billing.address_1, Address_2 = orderInstance.billing.address_2, City = orderInstance.billing.city, Country = orderInstance.billing.country, Company = orderInstance.billing.company, Email = orderInstance.billing.email, Phone = orderInstance.billing.phone, Postcode = orderInstance.billing.postcode, State = orderInstance.billing.state }); shippingId = _repository.Save <Shipping>(new Shipping { First_name = orderInstance.shipping.first_name, Last_name = orderInstance.shipping.last_name, Address_1 = orderInstance.shipping.address_1, Address_2 = orderInstance.shipping.address_2, City = orderInstance.shipping.city, Country = orderInstance.shipping.country, Company = orderInstance.shipping.company, Postcode = orderInstance.shipping.postcode, State = orderInstance.shipping.state }); _repository.Save <EntityModel.Order>(new EntityModel.Order { BillingId = billingId, ShippingId = shippingId, RefId = Convert.ToInt64(orderInstance.id), CreatedDate = DateTime.Now.ToDateTime(), IsLast = true, Status = Status.Active, Total = orderInstance.total, Currency = orderInstance.currency, CustomerIpAddress = orderInstance.customer_ip_address, Discount = orderInstance.discount_total, SetPaid = orderInstance.set_paid, ShippingTotal = orderInstance.shipping_total, PaymentMethod = orderInstance.payment_method, OrderStatus = statusMapper.Map(orderInstance.status) }); lastOrder.IsLast = false; _repository.Save <EntityModel.Order>(lastOrder); //orderInstance =cu } } return(counter); }
public PatientDemographyModel GetPatientById(long patientId) { try { var patientList = _context.PatientDemography .Include("HivEncounter") .Include("LaboratoryReport") .Include("PatientRegimen") .Where(c => c.Id == patientId && (c.PatientRegimen.Any() || c.HivEncounter.Any())).ToList(); if (!patientList.Any()) { return(new PatientDemographyModel()); } var patientEntity = patientList[0]; var patientModel = mapper.Map <PatientDemography, PatientDemographyModel> (patientEntity); if (patientModel.Id < 1) { return(new PatientDemographyModel()); } var artVisit = new List <HivEncounterModel>(); var drugPickups = new List <PatientRegimenModel>(); var labResult = new List <LaboratoryReportModel>(); patientModel.FacilityName = patientEntity.Site.Name; patientModel.StateCode = patientEntity.Site.StateCode; patientModel.Status = "Unknown Status"; patientModel.DateOfBirthStr = patientModel.PatientDateOfBirth.Value.ToShortDateString(); if (patientEntity.PatientRegimen.Any()) { var maxVisitDate = patientEntity.PatientRegimen.Max(s => s.VisitDate); var maxDuration = patientEntity.PatientRegimen.Max(s => s.PrescribedRegimenDuration); patientModel.Status = StatusMapper.GetClientStatus2(maxVisitDate, maxDuration); patientEntity.PatientRegimen.ToList().ForEach(v => { var regimen = mapper.Map <PatientRegimen, PatientRegimenModel>(v); regimen.VisitDateStr = v.VisitDate != null ? v.VisitDate.Value.ToShortDateString() : "NA"; regimen.AppointmentDateStr = v.VisitDate != null && v.PrescribedRegimenDuration > 0 ? v.VisitDate.Value.AddDays(v.PrescribedRegimenDuration).ToShortDateString() : "NA"; drugPickups.Add(regimen); }); drugPickups = drugPickups.OrderByDescending(g => g.VisitDate).ToList(); } if (patientEntity.LaboratoryReport.Any()) { patientEntity.LaboratoryReport.ToList().ForEach(v => { var lab = mapper.Map <LaboratoryReport, LaboratoryReportModel>(v); lab.VisitDateStr = v.VisitDate.Value.ToShortDateString(); lab.CollectionDateStr = v.VisitDate.Value.ToShortDateString(); lab.OrderedTestDateStr = v.VisitDate.Value.ToShortDateString(); lab.ResultedTestDateStr = v.VisitDate.Value.ToShortDateString(); labResult.Add(lab); }); labResult = labResult.OrderByDescending(g => g.OrderedTestDate).ToList(); } if (patientEntity.HivEncounter.Any()) { patientEntity.HivEncounter.ToList().ForEach(v => { var encounter = mapper.Map <HivEncounter, HivEncounterModel>(v); encounter.VisitDateStr = v.VisitDate.ToShortDateString(); encounter.NextAppointmentDateStr = v.NextAppointmentDate.Value.ToShortDateString(); artVisit.Add(encounter); }); artVisit = artVisit.OrderByDescending(g => g.VisitDate).ToList(); } return(patientModel); } catch (Exception ex) { return(new PatientDemographyModel()); } }