/// <summary> /// Builds a list of telecoms for a patient. /// </summary> /// <param name="patient">The patient for which to build the telecoms.</param> /// <returns>Returns a list of telecoms for a patient.</returns> private static LIST <TEL> BuildTelecoms(Demographic patient) { var telecoms = new LIST <TEL>(); if (patient.TelecomOptions.EmailAddresses.Count == 0) { // TODO: supply random email address telecoms.Add(new TEL("*****@*****.**", TelecommunicationAddressUse.Direct)); } if (patient.TelecomOptions.PhoneNumbers.Count == 0) { // TODO: supply random telephone number telecoms.Add(new TEL("9055751212", TelecommunicationAddressUse.WorkPlace)); } foreach (var email in patient.TelecomOptions.EmailAddresses) { telecoms.Add(new TEL(email, TelecommunicationAddressUse.Direct)); } foreach (var phone in patient.TelecomOptions.PhoneNumbers) { telecoms.Add(new TEL(phone)); } return(telecoms); }
public float Appeal(Demographic demographic) { //Audience appeal rises from 0.4 to 1.0 of `peak` over PEAK_AUDIENCE_TURNS turns. //Then sites at peak until PEAK_DECAY_TURNS //After the PEAK_DECAY_TURNS peak, it decays exponentially with a half-life of `longevity` var fractionToPeak = weeksShowing / PEAK_AUDIENCE_TURNS; var afterPeak = weeksShowing - PEAK_DECAY_TURNS; var scale = (weeksShowing <= PEAK_AUDIENCE_TURNS) ? 0.4 * (1.0 - fractionToPeak) + fractionToPeak: (weeksShowing > PEAK_DECAY_TURNS) ? 1.0 / Math.Pow(2.0, afterPeak / longevity): 1.0; try { return((float)(concept.demographicAppeal[demographic] * peak * scale)); } catch (Exception e) { Debug.Log(demographic.name); Debug.Log(concept.demographicAppeal.Count); foreach (var a in concept.demographicAppeal) { Debug.Log(a.Key.name); } throw e; } }
public void Add(Demographic item) { lock (_session) { _session.Store(item); } }
/// <summary> /// send as an asynchronous operation. /// </summary> /// <param name="options">The options.</param> /// <returns>Task.</returns> public async Task SendAsync(Demographic options) { await Task.Factory.StartNew(() => { this.Send(options); }); }
public async Task <IActionResult> Index(string county, string population, int?value, string?valueStr) { Demographic modRecord = dbContext.Demographics .Where(d => d.county.CountyName == county & d.population.PopTypeName == population) .First(); if (modRecord.Value == value) { UpdateRecord updRecord = new UpdateRecord(); updRecord.County = county; updRecord.Population = population; updRecord.Value = (int)value; updRecord.origValue = value; return(View(updRecord)); } else { modRecord.Value = Convert.ToInt32(valueStr); dbContext.Demographics.Update(modRecord); await dbContext.SaveChangesAsync(); UpdateRecord updRecord = new UpdateRecord(); updRecord.County = county; updRecord.Population = population; updRecord.Value = dbContext.Demographics .Where(d => d.county.CountyName == county & d.population.PopTypeName == population) .Select(v => v.Value) .First(); updRecord.origValue = value; return(View(updRecord)); } }
public void Facebook_GetFanDemographicsAndInsertQueue() { FacebookFanInfo fg = new FacebookFanInfo(); string accountId = XMLUtility.GetTextFromAccountNode(fg.Xml, "id"); string accessToken = XMLUtility.GetTextFromAccountNode(fg.Xml, "accesstoken"); Demographic <Country> country = _graph.GetFanDemographics <Demographic <Country> >(accountId, accessToken, "page_fans_country"); if (!Object.Equals(country, null)) //fg.Context.MSMQManager.AddToQueue(country, "country"); { } Demographic <Locale> locale = _graph.GetFanDemographics <Demographic <Locale> >(accountId, accessToken, "page_fans_locale"); if (!Object.Equals(locale, null)) //fg.Context.MSMQManager.AddToQueue(locale, "locale"); { } Demographic <Gender> gender = _graph.GetFanDemographics <Demographic <Gender> >(accountId, accessToken, "page_fans_gender_age"); if (!Object.Equals(gender, null)) //fg.Context.MSMQManager.AddToQueue(gender, "gender"); { } Assert.IsNotNull(fg); }
public ActionResult Create([Bind(Include = "NIN,Given_Name,Midle_Name,Family_Name,Gender,Date_of_Birth,Address,Phone_Number,District,Division,Parish,Village,Id,ImagePath,Full_Name,Marital_status")] Demographic demographic, HttpPostedFileBase upload) { demographic.Marital_status = DataModels.DataProcess.Replace_(demographic.Marital_status); if (ModelState.IsValid) { //Check the exisitence of user ID in other records if (DataModels.DataProcess.Exists(demographic.Id)) { ModelState.AddModelError("", "Email already exists"); } else { if (upload != null && upload.ContentLength > 0) { string ext = Path.GetExtension(upload.FileName).ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".jpeg") { var uploadpath = Path.Combine(Server.MapPath("~/Images/People"), demographic.Id + ".jpg"); var path = @"~/Images/People" + @"/" + demographic.Id + ".jpg"; demographic.ImagePath = path; upload.SaveAs(uploadpath); } } demographic.Full_Name = DataModels.DataProcess.RemoveSpace(demographic.Given_Name + " " + demographic.Midle_Name + " " + demographic.Family_Name); db.Demographics.Add(demographic); db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.Id = new SelectList(db.AspNetUsers, "Id", "UserName", demographic.Id); return(View(demographic)); }
/// <summary> /// Builds a list of addresses for a patient. /// </summary> /// <param name="patient">The patient for which to build the addresses.</param> /// <returns>Returns a list of addresses for a patient.</returns> private static LIST <AD> BuildAddresses(Demographic patient) { var addresses = new LIST <AD>(); foreach (var item in patient.Addresses) { var city = item.City == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.City, AddressPartType.City); var country = item.Country == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.Country, AddressPartType.Country); var postal = item.ZipPostalCode == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.ZipPostalCode, AddressPartType.PostalCode); var state = item.StateProvince == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.StateProvince, AddressPartType.State); var street = item.StreetAddress == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.StreetAddress, AddressPartType.StreetAddressLine); addresses.Add(new AD(new[] { city, country, postal, state, street })); } return(addresses); }
/// <summary> /// Generates patients using the provided options. /// </summary> /// <param name="options">The options to use to generate patients.</param> /// <returns>Returns a GenerationResponse.</returns> public GenerationResponse GeneratePatients(Demographic options) { GenerationResponse response = new GenerationResponse(); IEnumerable <IResultDetail> details = ValidationUtil.ValidateMessage(options); if (details.Count(x => x.Type == ResultDetailType.Error) > 0) { response.Messages.AddRange(details.Select(x => x.Message)); response.HasErrors = true; } else { // no validation errors, save the options persistenceService?.Save(options); // send to fhir endpoints fhirSenderService?.Send(options); // send to hl7v2 endpoints hl7v2SenderService?.Send(options); // send to hl7v3 endpoints hl7v3SenderService?.Send(options); } return(response); }
public void PostFacebookCountryDemographicToRest() { string result = string.Empty; requestPost = (HttpWebRequest)WebRequest.Create("http://localhost/BIdataApi/api/facebook/country"); requestPost.Method = "POST"; requestPost.ContentType = "application/json"; requestPost.UseDefaultCredentials = true; Demographic <Country> country = GetCountryDemographic(); string requestData = new JavaScriptSerializer().Serialize(country); byte[] data = Encoding.UTF8.GetBytes(requestData); using (Stream dataStream = requestPost.GetRequestStream()) dataStream.Write(data, 0, data.Length); HttpWebResponse response = requestPost.GetResponse() as HttpWebResponse; result = new StreamReader(response.GetResponseStream()).ReadToEnd(); Assert.AreEqual(response.StatusCode, HttpStatusCode.Created); response.Close(); }
public void Update(Demographic demographic) { lock (_session) { _session.Store(demographic); } }
private static AlgorithmConfiguration MakeAlgorithmConfiguration( CognitiveLevel cognitiveLevel, Demographic demographic, IEnumerable <Probability> probabilities) { return(new AlgorithmConfiguration { CognitiveLevel = cognitiveLevel, DemographicConfiguration = new DemographicProcessesConfiguration { AdoptionProbability = demographic.AdoptionProbability, BirthProbability = demographic.BirthProbability, DeathProbability = demographic.DeathProbability, HomosexualTypeRate = demographic.HomosexualTypeRate, MinimumAgeForHouseholdHead = demographic.MinimumAgeForHouseholdHead, PairingAgeMax = demographic.PairingAgeMax, PairingAgeMin = demographic.PairingAgeMin, PairingProbability = demographic.PairingProbability, SexualOrientationRate = demographic.SexualOrientationRate, YearsBetweenBirths = demographic.YearsBetweenBirths, MaximumAge = demographic.MaximumAge }, ProbabilitiesConfiguration = probabilities.Select(p => new ProbabilitiesConfiguration { FilePath = p.FileName, Variable = p.VariableParameter, VariableType = p.VariableType, WithHeader = p.IgnoreFirstLine // ignore first line means there is a header }).ToArray(), UseDimographicProcesses = demographic.DemographicChange }); }
protected override void UseDemographic() { base.UseDemographic(); demographic = new Demographic <Site>(_configuration.AlgorithmConfiguration.DemographicConfiguration, probabilities.GetProbabilityTable <int>(AlgorithmProbabilityTables.BirthProbabilityTable), probabilities.GetProbabilityTable <int>(AlgorithmProbabilityTables.DeathProbabilityTable)); }
public ActionResult DeleteConfirmed(string id) { Demographic demographic = db.Demographics.Find(id); db.Demographics.Remove(demographic); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Add(Demographic item) { List <Demographic> items = new List <Demographic>() { item }; InsertItems(_folder, _type, items, items.ConvertAll(i => i.Id.ToString())); }
private void OnDetach(Demographic entity) { entity.PropertyChanged -= On_demographic_propertyChanged; if (!ReferenceEquals(null, entity.Customers)) { entity.Customers.CollectionChanged -= On_demographic_customers_collectionChanged; } }
/// <summary> /// Generates the candidate registry. /// </summary> /// <param name="options">The options.</param> /// <returns>IMessage.</returns> public static IMessage GenerateCandidateRegistry(Demographic options) { var message = CreateBaseMessage(options.Metadata) as ADT_A01; var pid = message.PID; var cx = pid.GetPatientIdentifierList(0); cx.ID.Value = options.PersonIdentifier; cx.AssigningAuthority.UniversalID.Value = options.Metadata.AssigningAuthority; cx.AssigningAuthority.UniversalIDType.Value = "ISO"; pid.Sex.Value = options.Gender; if (options.DateOfBirthOptions?.Exact != null) { pid.DateTimeOfBirth.TimeOfAnEvent.SetShortDate(options.DateOfBirthOptions.Exact.Value); } for (var i = 0; i < options.OtherIdentifiers.Count; i++) { pid.GetAlternatePatientIDPID(i).ID.Value = options.OtherIdentifiers[i].Value; pid.GetAlternatePatientIDPID(i).AssigningAuthority.UniversalID.Value = options.OtherIdentifiers[i].AssigningAuthority; pid.GetAlternatePatientIDPID(i).AssigningAuthority.UniversalIDType.Value = options.OtherIdentifiers[i].Type; } for (var i = 0; i < options.Names.Count; i++) { pid.GetPatientName(i).GivenName.Value = options.Names.ToArray()[i].FirstName; pid.GetPatientName(i).FamilyLastName.FamilyName.Value = options.Names.ToArray()[i].LastName; pid.GetPatientName(i).PrefixEgDR.Value = options.Names.ToArray()[i].Prefix; pid.GetPatientName(i).SuffixEgJRorIII.Value = options.Names.ToArray()[i].Suffixes.FirstOrDefault(); var middleNames = options.Names.Select(x => x.MiddleNames).ToArray()[i]; if (middleNames.Count > 0) { pid.GetPatientName(i).MiddleInitialOrName.Value = middleNames.Aggregate((a, b) => a + " " + b); } } for (var i = 0; i < options.Addresses.Count; i++) { pid.GetPatientAddress(i).StreetAddress.Value = options.Addresses.ToArray()[i].StreetAddress; pid.GetPatientAddress(i).City.Value = options.Addresses.ToArray()[i].City; pid.GetPatientAddress(i).StateOrProvince.Value = options.Addresses.ToArray()[i].StateProvince; pid.GetPatientAddress(i).ZipOrPostalCode.Value = options.Addresses.ToArray()[i].ZipPostalCode; pid.GetPatientAddress(i).Country.Value = options.Addresses.ToArray()[i].Country; } for (var i = 0; i < options.TelecomOptions.PhoneNumbers.Count; i++) { pid.GetPhoneNumberHome(i).AnyText.Value = options.TelecomOptions.PhoneNumbers[i]; } return(message); }
public void GivenDemographicForAnyAgeAndSpecificState_WhenCheckingIfTheDemographicAppliesToAMember_ThenReturnTrueOnlyIfMemberIsInThatState ([ValueSource(nameof(AllStates))] State memberState, [ValueSource(nameof(AllStates))] State demographicState) { var member = new Member("Name", memberState, new DateTime(1970, 1, 1)); var demographic = new Demographic(demographicState, null, null); var applies = demographic.Contains(member, DateTime.UtcNow); Assert.That(applies, Is.EqualTo(memberState == demographicState)); }
// Start is called before the first frame update void Start() { test = new Demographic(minPopulation, maxPopulation); restaurant = FindObjectOfType <Restaurant_Script>(); displayPopulation(test); displayHousehold(test); displayAdults(test); displayChildren(test); displayIncome(test); }
public void Update(Demographic demographic) { var entity = _dbContext.Find <Entities.Tenant.Demographic>(demographic.Id); if (entity != null) { _mapper.Map(demographic, entity); _dbContext.Update(entity, post => post.MapTo(demographic), _mapper); } }
public void GivenDemographicWithStateAndAgeRange_WhenCheckingIfTheDemographicAppliesToAMember_ThenReturnTrueOnlyIfTheMemberConformsToAllParameters ([Range(1, 25)] int age, [ValueSource(nameof(AllStates))] State state) { var now = DateTime.UtcNow; var member = new Member("Name", state, now.AddYears(-age)); var demographic = new Demographic(State.Wa, 18, 19); var applies = demographic.Contains(member, now); Assert.That(applies, Is.EqualTo(state == State.Wa && (age == 18 || age == 19))); }
public void GivenDemographicForAnyStateWithMaximumAgeAndMemberOlderThanThatAge_WhenCheckingIfTheDemographicAppliesToAMember_ThenReturnTrueOnlyIfMemberIsThatAgeOrYounger ([Range(1, 25)] int memberAge, [Range(1, 25)] int maximumAge) { var now = DateTime.UtcNow; var member = new Member("Name", State.Wa, now.AddYears(-memberAge)); var demographic = new Demographic(null, null, maximumAge); var applies = demographic.Contains(member, now); Assert.That(applies, Is.EqualTo(memberAge <= maximumAge)); }
/// <summary> /// Validates a message. /// </summary> /// <param name="options">The message to be validated.</param> /// <returns>Returns a list of result details containing validation results.</returns> public static IEnumerable <IResultDetail> ValidateMessage(Demographic options) { var details = new List <IResultDetail>(); if (string.IsNullOrEmpty(options.Metadata.AssigningAuthority) || string.IsNullOrWhiteSpace(options.Metadata.AssigningAuthority)) { details.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, nameof(options.Metadata.AssigningAuthority) + " cannot be null or empty.")); } if (options.DateOfBirthOptions?.Start != null && options.DateOfBirthOptions?.Exact != null) { details.Add(new ConflictingValueResultDetail(ResultDetailType.Error, nameof(options.DateOfBirthOptions) + " DateOfBirthOptions.End must be populated if DateOfBirthOptions.Start is populated.")); } if (options.DateOfBirthOptions?.End != null && options.DateOfBirthOptions?.Exact != null) { details.Add(new ConflictingValueResultDetail(ResultDetailType.Error, nameof(options.DateOfBirthOptions) + " DateOfBirthOptions.Start must be populated if DateOfBirthOptions.Start is populated.")); } if ((options.DateOfBirthOptions?.Start != null && options.DateOfBirthOptions?.End != null) && options.DateOfBirthOptions?.Exact != null) { details.Add(new ConflictingValueResultDetail(ResultDetailType.Error, nameof(options.DateOfBirthOptions) + " cannot have all fields populated.")); } if (options.Metadata.UseHL7v2 || options.Metadata.UseHL7v3) { if (string.IsNullOrEmpty(options.Metadata.ReceivingApplication) || string.IsNullOrWhiteSpace(options.Metadata.ReceivingApplication)) { details.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, nameof(options.Metadata.ReceivingApplication) + " cannot be null or empty.")); } if (string.IsNullOrEmpty(options.Metadata.ReceivingFacility) || string.IsNullOrWhiteSpace(options.Metadata.ReceivingFacility)) { details.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, nameof(options.Metadata.ReceivingFacility) + " cannot be null or empty.")); } if (string.IsNullOrEmpty(options.Metadata.SendingApplication) || string.IsNullOrWhiteSpace(options.Metadata.SendingApplication)) { details.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, nameof(options.Metadata.SendingApplication) + " cannot be null or empty.")); } if (string.IsNullOrEmpty(options.Metadata.SendingFacility) || string.IsNullOrWhiteSpace(options.Metadata.SendingFacility)) { details.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, nameof(options.Metadata.SendingFacility) + " cannot be null or empty.")); } } else { details.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, "Must specify FHIR, HL7v2, or HL7v3")); } return(details); }
private static Demographic <Country> GetCountryDemographic() { FacebookDataComponent fdc = new FacebookDataComponent(); FacebookFanInfo ffi = new FacebookFanInfo(new FacebookDataSource()); string accountId = XMLUtility.GetTextFromAccountNode(ffi.Xml, "id"); string accessToken = XMLUtility.GetTextFromAccountNode(ffi.Xml, "accesstoken"); Graph _graph = new Graph(); Demographic <Country> country = _graph.GetFanDemographics <Demographic <Country> >(accountId, accessToken, "page_fans_country"); return(country); }
public override void MoveNext() { if (Validate()) { Demographic = ClientDemographicDTO.CreateFromView(this); var json = JsonConvert.SerializeObject(Demographic); _settings.AddOrUpdateValue(GetType().Name, json); var clientinfo = Demographic.ToString(); var indexId = null != IndexClientDTO?IndexClientDTO.Id.ToString() : string.Empty; ShowViewModel <ClientContactViewModel>(new { clientinfo = clientinfo, indexId = indexId }); } }
// GET: Demographics/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Demographic demographic = db.Demographics.Find(id); if (demographic == null) { return(HttpNotFound()); } return(View(demographic)); }
/// <summary> /// Builds a list of name for a patient. /// </summary> /// <param name="patient">The patient for which to build the names.</param> /// <returns>Returns a list of name for a patient.</returns> private static LIST <PN> BuildNames(Demographic patient) { var personNames = new LIST <PN>(); foreach (var item in patient.Names) { personNames.Add(new PN(EntityNameUse.Legal, new[] { new ENXP(item.FirstName, EntityNamePartType.Given), new ENXP(item.LastName, EntityNamePartType.Family) })); } return(personNames); }
/// <summary> /// Validates the Demographic prior to save /// </summary> /// <param name="demographic"></param> private void ValidateForSave(Demographic demographic) { if (string.IsNullOrEmpty(demographic.ExternalRef)) { throw new System.Exception("ExternalRef is not set"); } if (string.IsNullOrEmpty(demographic.Name)) { throw new System.Exception("Name is not set"); } if (string.IsNullOrEmpty(demographic.ShortName)) { throw new System.Exception("Short Name is not set"); } }
// GET: Demographics/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Demographic demographic = db.Demographics.Find(id); if (demographic == null) { return(HttpNotFound()); } ViewBag.Id = new SelectList(db.AspNetUsers, "Id", "UserName", demographic.Id); return(View(demographic)); }
public void Facebook_GetFanDemographics() { FacebookDataComponent fdc = new FacebookDataComponent(); FacebookFanInfo ffi = new FacebookFanInfo(new FacebookTestDataSource()); string accountId = XMLUtility.GetTextFromAccountNode(ffi.Xml, "id"); string accessToken = XMLUtility.GetTextFromAccountNode(ffi.Xml, "accesstoken"); Demographic <Country> country = _graph.GetFanDemographics <Demographic <Country> >(accountId, accessToken, "page_fans_country"); Assert.IsNotNull(country.Data); Assert.AreNotEqual(0, country.Data.Count); Assert.IsNotNull(country.Data[0].Days); Assert.AreNotEqual(0, country.Data[0].Days.Count); Assert.IsNotNull(country.Data[0].Days[0].Country); Assert.AreNotEqual(0, country.Data[0].Days[0].Country.US); fdc.CountryDemographic = country; FanInfo.DroneDataSource.Process(fdc); Demographic <Locale> locale = _graph.GetFanDemographics <Demographic <Locale> >(accountId, accessToken, "page_fans_locale"); Assert.IsNotNull(locale.Data); Assert.AreNotEqual(0, locale.Data.Count); Assert.IsNotNull(locale.Data[0].Days); Assert.AreNotEqual(0, locale.Data[0].Days.Count); Assert.IsNotNull(locale.Data[0].Days[0].Locale); Assert.AreNotEqual(0, locale.Data[0].Days[0].Locale.en_US); fdc = new FacebookDataComponent(); fdc.LocaleDemographic = locale; FanInfo.DroneDataSource.Process(fdc); Demographic <Gender> gender = _graph.GetFanDemographics <Demographic <Gender> >(accountId, accessToken, "page_fans_gender_age"); Assert.IsNotNull(gender.Data); Assert.AreNotEqual(0, gender.Data.Count); Assert.IsNotNull(gender.Data[0].Days); Assert.AreNotEqual(0, gender.Data[0].Days.Count); Assert.IsNotNull(gender.Data[0].Days[0].Gender); Assert.AreNotEqual(0, gender.Data[0].Days[0].Gender.M_25to34); fdc = new FacebookDataComponent(); fdc.GenderDemographic = gender; FanInfo.DroneDataSource.Process(fdc); }