public static void AddEventRecord(DataSurfContext context, CovidTestEvents model) { CovidTestEvents result = context.CovidTestEvents.FirstOrDefault(result => result.SignupID == model.SignupID); if (result == null) { result = new CovidTestEvents(); result.SignupID = model.SignupID; result.startdate = model.startdate; result.enddate = model.enddate; result.Title = model.Title; result.TotalSlots = model.TotalSlots; result.FilledSlots = model.FilledSlots; context.CovidTestEvents.Add(result); } else { result.startdate = model.startdate; result.enddate = model.enddate; result.Title = model.Title; result.TotalSlots = model.TotalSlots; result.FilledSlots = model.FilledSlots; context.CovidTestEvents.Update(result); } context.SaveChangesAsync(); }
public static bool AddCovidRecord(DataSurfContext context, Models.CovidTestJson model) { Models.CovidTestSearch search = new Models.CovidTestSearch(); if (!string.IsNullOrEmpty(model.AppointmentID)) { search.CovidTestId = model.AppointmentID; } else { search.CovidTestId = model.CovidtestId; } search.patient_first_name = model.patient_first_name; search.patient_last_name = model.patient_last_name; search.patient_email = model.patient_email; Models.CovidTestDBModel save = null; save = GetCovidRecord(context, search); //Models.CovidTestDBModel save = new Models.CovidTestDBModel(); if (save == null) { save = new Models.CovidTestDBModel(); save.AppointmentID = 0; save.CovidtestId = 0; } save.appointmentLocationID = 0; save.sample_collection_date = DateTime.UtcNow; save.patient_first_name = model.patient_first_name; save.patient_last_name = model.patient_last_name; save.patient_phone_number = model.patient_phone_number; save.patient_sex = model.patient_sex; save.patient_state = model.patient_state; save.patient_city = model.patient_city; save.patient_street_address = model.patient_street_address; save.patient_zip_code = model.patient_zip_code; save.patient_bill_city = model.patient_bill_city; save.patient_bill_name = model.patient_bill_name; save.patient_bill_state = model.patient_bill_state; save.patient_bill_street = model.patient_bill_street; save.patient_bill_zip = model.patient_bill_zip; save.patient_date_of_birth = Convert.ToDateTime(model.patient_date_of_birth); save.patient_email = model.patient_email; save.sample_1_container_barcode = model.sample_1_container_barcode; save.identifier = model.sample_1_container_barcode; save.sample_1_collected_by = "Maricopa Technician"; save.sample_1_container_type = "TUBE"; save.identifier = model.sample_1_container_barcode; save.sample_1_state_position = "A01"; save.test_panel_code = "IDT-COVID-19"; save.sample_1_identifier = "CLINTEST01"; save.num_samples = 1; save.provider_npi = "1639369036"; save.institutional_bill_name = model.institutional_bill_name; save.primary_insurance_id_number = model.primary_insurance_id_number; save.primary_insurance_insurance_provider = model.primary_insurance_insurance_provider; save.primary_insurance_relationship_to_insured = model.primary_insurance_relationship_to_insured; save.bill_type = string.IsNullOrEmpty(save.primary_insurance_insurance_provider) ? "Institutional Bill" : "Insurance"; save.patient_bill_phone_number = model.patient_bill_phone_number; save.provider_account = model.provider_account; save.SSN = model.SSN; save.identification = model.identification; save.last_mod_dt = DateTime.Now; save.consent_date = model.patient_consent.ToLower() == "yes" ? DateTime.Now:DateTime.MinValue; if (save.CovidtestId == 0) { context.CovidTests.Add(save); } else { context.CovidTests.Update(save); } Models.CovidQuestionsModel questions = context.CovidQuestions.FirstOrDefault(result => result.CovidTestId == save.CovidtestId); if (questions == null) { questions = new Models.CovidQuestionsModel(); questions.CovidTestId = save.CovidtestId; questions.covid_in_household = model.covid_in_household == "Yes" ? true:false; questions.traveled_outside_us = model.traveled_outside_us == "Yes" ? true : false; questions.covid_positive = model.covid_positive == "Yes" ? true: false; questions.covid_recovered = model.covid_recovered == "Yes" ? true: false; questions.had_covid_contact = model.had_covid_contact == "Yes" ? true : false; questions.was_at_covid_risk_location = model.was_at_covid_risk_location == "Yes" ? true : false; context.CovidQuestions.Add(questions); } else { questions.CovidTestId = save.CovidtestId; questions.covid_in_household = model.covid_in_household == "Yes" ? true : false; questions.traveled_outside_us = model.traveled_outside_us == "Yes" ? true : false; questions.covid_positive = model.covid_positive == "Yes" ? true : false; questions.covid_recovered = model.covid_recovered == "Yes" ? true : false; questions.had_covid_contact = model.had_covid_contact == "Yes" ? true : false; questions.was_at_covid_risk_location = model.was_at_covid_risk_location == "Yes" ? true : false; context.CovidQuestions.Update(questions); } context.SaveChangesAsync(); return(true); }