/// <summary>The save patient insurance extension.</summary> /// <param name="patientInsurance">The patient insurance.</param> /// <param name="isNew">indicate whether it is new.</param> private static void SavePatientInsuranceExtension(PatientInsurance patientInsurance, bool isNew) { if (isNew) { patientInsurance.IsActive = true; } var ext = new PatientInsuranceAlsl { PatientId = patientInsurance.PatientId, PatientInsuranceId = patientInsurance.Id, IsActive = patientInsurance.IsActive, IsPrimaryInsurance = patientInsurance.IsPrimaryInsurance }; var alslInsurances = new List <PatientInsuranceAlsl> { ext }; PatientManager.SavePatientInsuranceAlsl(alslInsurances); }
/// <summary>The put.</summary> /// <param name="officeNumber">The office number.</param> /// <param name="patientInsurance">The patient insurance.</param> /// <param name="userId">The user id.</param> /// <returns>The <see cref="HttpResponseMessage"/>.</returns> public HttpResponseMessage Put(string officeNumber, [FromBody] PatientInsurance patientInsurance, int userId) { try { AccessControl.VerifyUserAccessToPatient(patientInsurance.PatientId); if (patientInsurance.PlanId == 0 || patientInsurance.InsuranceCarrier == null || string.IsNullOrEmpty(patientInsurance.InsuranceCarrier.Code)) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } var isNew = patientInsurance.Id == 0; var id = this.patientInsuranceManager.SavePatientInsurance(officeNumber, patientInsurance, userId); patientInsurance.Id = id; SavePatientInsuranceExtension(patientInsurance, isNew); patientInsurance.Carriers = this.patientInsuranceManager.GetPatientInsurancesForScheduler(patientInsurance.PatientId, true); return(Request.CreateResponse(HttpStatusCode.OK, patientInsurance)); } catch (Exception ex) { var error = string.Format("Put(userId = {0}, insuranceId = {1} {2} {3}", userId, patientInsurance.Id, ")\n", ex); return(HandleExceptions.LogExceptions(error, Logger, ex)); } }