/// <summary> /// Increments the patient counter. /// </summary> /// <param name="patient">The patient.</param> public void IncrementPatientCounter(LightPatientDto patient) { var entity = this.Session.Get <Patient>(patient.Id); entity.Counter++; this.Session.Update(entity); }
public IList <LightPictureDto> GetLightPictures(LightPatientDto patient) { var pictures = GetEntityPictures(patient, null); var result = Mapper.Map <IList <Picture>, IList <LightPictureDto> >(pictures); return(result); }
/// <summary> /// Removes the specified illness period list from the specified patient's /// illness history. /// </summary> /// <param name="illnessPeriods">The illness periods.</param> /// <param name="forPatient">The patient.</param> public void Remove(IList <IllnessPeriodDto> illnessPeriods, LightPatientDto forPatient) { foreach (var illnessPeriod in illnessPeriods) { this.Remove(illnessPeriod, forPatient); } }
/// <summary> /// Adds the specified doctor to the specified patient. /// </summary> /// <param name="patient">The patient.</param> /// <param name="doctor">The doctor.</param> /// <exception cref="EntityNotFoundException">If there's no link between the doctor and the patient</exception> public void AddDoctorTo(LightPatientDto patient, LightDoctorDto doctor) { var patientEntity = this.Session.Get <Patient>(patient.Id); var doctorEntity = this.Session.Get <Doctor>(doctor.Id); new Updator(this.Session).AddDoctorTo(patientEntity, doctorEntity); }
/// <summary> /// Adds the new child to the specified patient. /// Under the hood, the child will receive the specifed /// patient as a father or a mother depending on the gender /// of the patient. /// </summary> /// <param name="patient">The patient.</param> /// <param name="child">The child.</param> public void AddNewChild(LightPatientDto patient, LightPatientDto child) { if (patient.Id == child.Id) { throw new BusinessLogicException("You try to add a patient as his/her child or parent", Messages.Ex_CirularLinkFamily); } var ePatient = this.Session.Load <Patient>(patient.Id); var eChild = this.Session.Load <Patient>(child.Id); switch (ePatient.Gender) { case Gender.Male: eChild.Father = ePatient; break; case Gender.Female: eChild.Mother = ePatient; break; default: Assert.FailOnEnumeration(eChild.Gender); break; } this.Session.Update(eChild); }
/// <summary> /// Creates the specified meeting. /// </summary> /// <param name="appointment">The meeting.</param> /// <param name="patient">The patient.</param> public void Create(AppointmentDto appointment, LightPatientDto patient) { var patientEntity = this.Session.Get <Patient>(patient.Id); var meetingEntity = Mapper.Map <AppointmentDto, Appointment>(appointment); patientEntity.Appointments.Add(meetingEntity); this.Session.SaveOrUpdate(patientEntity); }
private void RemoveRelationAsync(LightPatientDto selectedPatient) { try { this.component.RemoveFamilyMember(this.SelectedMember, selectedPatient); } catch (Exception ex) { this.Handle.Error(ex); } }
/// <summary> /// Creates the specified illness period for the specified patient. /// </summary> /// <param name="period">The period.</param> /// <param name="patient">The patient.</param> public void Create(IllnessPeriodDto period, LightPatientDto patient) { var entity = this.Session.Get <Patient>(patient.Id); var illnessPeriod = Mapper.Map <IllnessPeriodDto, IllnessPeriod>(period); entity.IllnessHistory.Add(illnessPeriod); this.Session.SaveOrUpdate(entity); }
/// <summary> /// With this method, I manage exception of the component and let <see cref="AssertionException"/> /// be managed as fatal error /// </summary> private void AddParent(LightPatientDto selectedPatient, LightPatientDto selectedMember) { try { this.Component.AddNewParent(selectedPatient, selectedMember); } catch (Exception ex) { this.Handle.Error(ex); } }
/// <summary> /// Gets all the appointments between the specified start and end threshold for the specified patient. /// </summary> /// <param name="patient">The patient.</param> /// <param name="startThreshold">The start threshold.</param> /// <param name="endThreshold">The end threshold.</param> /// <returns></returns> public IList <AppointmentDto> GetAppointments(LightPatientDto patient, DateTime startThreshold, DateTime endThreshold) { var result = this.GetAppointments(patient); return((from r in result where r.StartTime >= startThreshold && r.EndTime <= endThreshold.AddDays(1) select r).ToList()); }
private IEnumerable <LightDoctorDto> SearchAsync(LightPatientDto selectedPatient) { Assert.IsNotNull(selectedPatient, "selectedPatient"); PluginContext.Host.SetWaitCursor(); var result = this.component.GetNotLinkedDoctorsFor(selectedPatient, this.Criteria, PluginContext.Configuration.SearchType); PluginContext.Host.SetArrowCursor(); return(result); }
/// <summary> /// Gets all bmi history for the specified patient. /// </summary> /// <param name="patient">The patient.</param> /// <returns> /// A list of BMI /// </returns> public IList <BmiDto> GetAllBmiHistory(LightPatientDto patient) { var entity = this.Session.Get <Patient>(patient.Id); var result = (from b in entity.BmiHistory select b).ToList(); return(Mapper.Map <IList <Bmi>, IList <BmiDto> >(result)); }
/// <summary> /// Gets the prescriptions between the specified dates for the specified patient. /// </summary> /// <param name="patient">The patient.</param> /// <param name="start">The start.</param> /// <param name="end">The end.</param> /// <returns>A list of prescriptions</returns> public IList <PrescriptionDocumentDto> GetPrescriptionsByDates(LightPatientDto patient, DateTime start, DateTime end) { var entity = this.Session.Get <Patient>(patient.Id); var prescriptions = (from p in entity.PrescriptionDocuments where p.CreationDate >= start && p.CreationDate <= end select p).ToList(); return(Mapper.Map <IList <PrescriptionDocument>, IList <PrescriptionDocumentDto> >(prescriptions)); }
public void Remove(AppointmentDto meeting, LightPatientDto patient, GoogleConfiguration config) { var entity = this.Session.Get <Appointment>(meeting.Id); if (config.IsActive) { new GoogleService(config).RemoveAppointment(entity); } this.Remove(meeting, patient); }
/// <summary> /// Determines whether the specified patient has the specified doctor. /// </summary> /// <param name="patient">The patient.</param> /// <param name="doctor">The doctor.</param> /// <returns> /// <c>true</c> if the specified patient has the doctor; otherwise, <c>false</c>. /// </returns> public bool HasDoctor(LightPatientDto patient, LightDoctorDto doctor) { var entity = (from p in this.Session.Query <Patient>() where p.Id == patient.Id select p).Single(); return((from d in entity.Doctors where d.Id == doctor.Id select d).Count() > 0); }
/// <summary> /// Creates the specified prescription document for the specified patient. /// </summary> /// <param name="document">The document.</param> /// <param name="patient">The patient.</param> public void Create(PrescriptionDocumentDto document, LightPatientDto patient) { var entity = this.Session.Get <Patient>(patient.Id); var documentEntity = Mapper.Map <PrescriptionDocumentDto, PrescriptionDocument>(document); ReloadTagsFor(documentEntity); entity.PrescriptionDocuments.Add(documentEntity); this.Session.SaveOrUpdate(entity); }
/// <summary> /// Removes the specified BMI entry from the specified patient. /// </summary> /// <param name="forPatient">The patient.</param> /// <param name="dto">The dto to remove.</param> public void Remove(BmiDto bmi, LightPatientDto forPatient) { var ebmi = this.Session.Get <Bmi>(bmi.Id); this.Session.Delete(ebmi); var patient = this.Session.Get <Patient>(forPatient.Id); this.Session.Update(patient); }
/// <summary> /// Adds the specified tag to the specified patient. /// </summary> /// <param name="patient">The light patient dto.</param> /// <param name="tag">The search tag dto.</param> public void AddTagTo(LightPatientDto patient, SearchTagDto tag) { var entity = (from p in this.Session.Query <Patient>() where p.Id == patient.Id select p).Single(); var eTag = Mapper.Map <SearchTagDto, SearchTag>(tag); entity.SearchTags.Add(eTag); this.Session.Save(entity); }
/// <summary> /// Updates the thumbnail of the specified patient. /// </summary> /// <param name="patientDto">The patient dto.</param> /// <param name="thumbnail">The byte array representing the thumbnail of the patient.</param> public void UpdateThumbnail(LightPatientDto patientDto, byte[] thumbnail) { var entity = (from p in this.Session.Query <Patient>() where p.Id == patientDto.Id select p).Single(); entity.Thumbnail = thumbnail; this.Session.Update(entity); }
/// <summary> /// Gets the bmi history. /// </summary> /// <param name="patient">The patient.</param> /// <param name="start">The start.</param> /// <param name="end">The end.</param> /// <returns></returns> public IList <BmiDto> GetBmiHistory(LightPatientDto patient, DateTime start, DateTime end) { var entity = this.Session.Get <Patient>(patient.Id); var result = (from b in entity.BmiHistory where b.Date >= start && b.Date <= end select b).ToList(); return(Mapper.Map <IList <Bmi>, IList <BmiDto> >(result)); }
/// <summary> /// Optimisation of mapping when mapping is slow /// </summary> private static void MapEntityToDto_Optimsised() { Mapper.CreateMap <Picture, PictureDto>().ConvertUsing(src => { var dto = new PictureDto() { Id = src.Id, Creation = src.Creation, IsImported = src.IsImported, LastUpdate = src.LastUpdate, Notes = src.Notes, Tag = Mapper.Map <Tag, TagDto>(src.Tag), ThumbnailBitmap = src.ThumbnailBitmap, Bitmap = src.Bitmap, }; Clean(dto); return(dto); }); Mapper.CreateMap <Picture, LightPictureDto>().ConvertUsing(src => { var dto = new LightPictureDto() { Id = src.Id, IsImported = src.IsImported, Tag = Mapper.Map <Tag, TagDto>(src.Tag), ThumbnailBitmap = src.ThumbnailBitmap, }; Clean(dto); return(dto); }); Mapper.CreateMap <Patient, LightPatientDto>().ConvertUsing(src => { var dto = new LightPatientDto() { Birthdate = src.BirthDate, FirstName = src.FirstName, Gender = src.Gender, Height = (int)src.Height, Id = src.Id, IsImported = src.IsImported, LastName = src.LastName, IsDeactivated = src.IsDeactivated, Profession = Mapper.Map <ProfessionDto>(src.Profession), InscriptionDate = src.InscriptionDate, LastUpdate = src.LastUpdate, Address = Mapper.Map <Address, AddressDto>(src.Address), Reason = src.Reason, }; Clean(dto); return(dto); }); }
/// <summary> /// Gets the bmi history of the specified patient. /// </summary> /// <param name="patient">The patient.</param> /// <returns></returns> public PatientBmiDto GetPatientWithBmiHistory(LightPatientDto patient) { //var patientDto = Mapper.Map<LightPatientDto, PatientBmiDto>(patient); var historyDto = Mapper.Map <IList <Bmi>, IList <BmiDto> >(this.Session.Get <Patient>(patient.Id).BmiHistory); historyDto.OrderBy(e => e.Date); var patientDto = new PatientBmiDto(historyDto); Mapper.Map <LightPatientDto, PatientBmiDto>(patient, patientDto); return(patientDto); }
/// <summary> /// Gets the illness history for the specified patient. /// </summary> /// <param name="patient">The patient.</param> /// <returns> /// The history of illness periods /// </returns> public IllnessHistoryDto GetIllnessHistory(LightPatientDto patient) { var illnessHistory = new IllnessHistoryDto() { Patient = patient }; var entity = this.Session.Get <Patient>(patient.Id); var periods = Mapper.Map <IList <IllnessPeriod>, IList <IllnessPeriodDto> >(entity.IllnessHistory); illnessHistory.Periods.Refill(periods); return(illnessHistory); }
/// <summary> /// Gets the count of the specified patient. That's the number of time he/she was selected /// </summary> /// <param name="patient">The patient.</param> /// <returns> /// The number of times the patient was selected /// </returns> public long GetCountOf(LightPatientDto patient) { var entity = (from p in this.Session.Query <Patient>() where p.Id == patient.Id select p).FirstOrDefault(); if (entity == null) { throw new EntityNotFoundException(typeof(Patient)); } return(entity.Counter); }
/// <summary> /// Gets the doctors (with full data) linked to the specified patient. /// </summary> /// <param name="patient">The patient.</param> /// <returns>A list of doctors</returns> public IEnumerable <DoctorDto> GetFullDoctorOf(LightPatientDto patient) { var entity = this.Session.Get <Patient>(patient.Id); if (entity.Doctors != null) { return(Mapper.Map <IList <Doctor>, IList <DoctorDto> >(entity.Doctors)); } else { return(new List <DoctorDto>()); } }
/// <summary> /// Removes the link that existed between the specified patient and the specified doctor. /// </summary> /// <param name="doctor">The doctor to remove of the specified patient.</param> /// <param name="forPatient">The doctor will be unbound for this patient.</param> /// <exception cref="EntityNotFoundException">If there's no link between the doctor and the patient</exception> public void Remove(LightDoctorDto doctor, LightPatientDto forPatient) { var patientEntity = this.Session.Get <Patient>(forPatient.Id); var doctorEntity = this.Session.Get <Doctor>(doctor.Id); var doctorToDel = this.GetDoctorToDel(doctor, patientEntity); var patientToDel = this.GetPatientToDel(forPatient, doctorEntity); patientEntity.Doctors.Remove(doctorToDel); doctorEntity.Patients.Remove(patientToDel); this.Session.Update(patientEntity); this.Session.Update(doctorEntity); }
/// <summary> /// Gets all the medical records of the specified patient. The records are packed into a /// medical record cabinet which contains medical records folders. Each folder contains a list /// of medical records. /// </summary> /// <param name="patient">The patient.</param> /// <returns></returns> public MedicalRecordCabinetDto GetMedicalRecordCabinet(LightPatientDto patient) { Assert.IsNotNull(patient, "patient"); var selectedPatient = (from p in this.Session.Query <Patient>() where p.Id == patient.Id select p).FirstOrDefault(); if (selectedPatient == null) { throw new EntityNotFoundException(typeof(Patient)); } return(Mapper.Map <Patient, MedicalRecordCabinetDto>(selectedPatient)); }
public void IncrementCounter(LightPatientDto patient) { var entity = (from p in this.Session.Query <Patient>() where p.Id == patient.Id select p).FirstOrDefault(); if (entity == null) { throw new EntityNotFoundException(typeof(Patient)); } entity.Counter++; this.Session.Update(entity); }
/// <summary> /// Binds the specified tags to the specified patient. /// </summary> /// <param name="patient">The patient.</param> /// <param name="tags">The tags.</param> public void BindTagsTo(LightPatientDto patient, IEnumerable <SearchTagDto> tags) { var ids = tags.Select(e => e.Id).ToList(); var ePatient = this.Session.Get <Patient>(patient.Id); var eTags = (from t in this.Session.Query <SearchTag>() where ids.Contains(t.Id) select t).ToList(); foreach (var t in eTags) { ePatient.SearchTags.Add(t); } this.Session.Update(ePatient); }
/// <summary> /// Gets all the search tags that are not binded to the specified patient /// </summary> /// <param name="patient">The patient.</param> /// <returns>The tags that are not assigned to the patient</returns> public IEnumerable <SearchTagDto> GetNotAssignedTagsOf(LightPatientDto patient) { var ids = this.Session .Get <Patient>(patient.Id) .SearchTags .Select(e => e.Id) .ToList(); var eTags = (from t in this.Session.Query <SearchTag>() where !ids.Contains(t.Id) select t).ToList(); return(Mapper.Map <IEnumerable <SearchTag>, IEnumerable <SearchTagDto> >(eTags)); }