public async Task <bool> Update(MedicalRecordDto model) { _medicalRecordRepository.Update(_mapper.Map <TMedicalRecord>(model)); var recordUpdated = await _medicalRecordRepository.SaveChangeAsync(); return(recordUpdated > 0); }
private void LoadRecords(object[] addedItems) { try { if (addedItems != null && addedItems.Length > 0) { this.MedicalRecordCabinet = this.component.GetMedicalRecordCabinet(addedItems[0] as LightPatientDto); PluginContext.Host.WriteStatus(StatusType.Info, Messages.Msg_MedicalRecordLoaded); if (this.MedicalRecordCabinet != null && this.MedicalRecordCabinet.Folders.Count > 0) { this.SelectedFolder = this.MedicalRecordCabinet.Folders[0]; } if (this.SelectedFolder != null && this.SelectedFolder.Records.Count > 0) { this.SelectedRecord = this.SelectedFolder.Records[0]; } } else { return; } } catch (Exception ex) { this.Handle.Error(ex); } }
private bool ValidateLettersOnly(MedicalRecordDto dto) { if (!BasicValidation.ValidateString(dto.Patient.Name, lettersOnlyRegex) || !BasicValidation.ValidateString(dto.Patient.ParentName, lettersOnlyRegex) || !BasicValidation.ValidateString(dto.Patient.Surname, lettersOnlyRegex)) { return(false); } return(true); }
public void IsValid() { var item = new MedicalRecordDto() { Name = Guid.NewGuid().ToString(), CreationDate = DateTime.Today, }; Assert.IsTrue(item.IsValid()); }
public void IsInvalid_NoName() { var item = new MedicalRecordDto() { Name = string.Empty, CreationDate = DateTime.Today, }; Assert.IsFalse(item.IsValid()); }
public void IsInvalid_NoDate() { var item = new MedicalRecordDto() { Name = Guid.NewGuid().ToString(), CreationDate = DateTime.MinValue, }; Assert.IsFalse(item.IsValid()); }
/// <summary> /// Revert the specified medical record into the specified state /// </summary> /// <param name="record">The record.</param> /// <param name="toState">The state.</param> public void Revert(MedicalRecordDto record, MedicalRecordStateDto toState) { Assert.IsNotNull(toState, "toState"); record.Rtf = toState.Rtf; record.Tag = toState.Tag; record.LastUpdate = DateTime.Now; new Updator(this.Session).Update(record); }
public bool ValidateMedicalRecord(MedicalRecordDto medicalRecordDto) { if (!ValidateUsername(medicalRecordDto.Patient.Username) || !ValidatePassword(medicalRecordDto.Patient.Password, medicalRecordDto.ConfirmedPassword) || !ValidateLettersOnly(medicalRecordDto) || !ValidateJmbg(medicalRecordDto.Patient.Jmbg) || !ValidateIdentityCard(medicalRecordDto.Patient.IdentityCard) || !ValidateHealthInsuranceCard(medicalRecordDto.Patient.HealthInsuranceCard) || !ValidateDateOfBirth(medicalRecordDto.Patient.DateOfBirth) || !ValidateContactNumber(medicalRecordDto.Patient.ContactNumber) || !ValidateEMail(medicalRecordDto.Patient.EMail) || !EmptyAddress(medicalRecordDto)) { return(false); } return(true); }
/// <summary> /// Refreshes the whole data of this instance. /// </summary> public void Refresh() { try { var family = this.component.GetFamily(PluginContext.Host.SelectedPatient); this.FamilyMembers.Refill(family.ToPatients()); this.SelectedFolder = null; this.SelectedRecord = null; } catch (Exception ex) { this.Handle.Error(ex); } }
private bool EmptyAddress(MedicalRecordDto medicalRecordDto) { if (!BasicValidation.CheckIfStringIsEmptyOrNull(medicalRecordDto.Patient.City.Name) || !BasicValidation.CheckIfStringIsEmptyOrNull(medicalRecordDto.Patient.City.PostCode.ToString()) || !BasicValidation.CheckIfStringIsEmptyOrNull(medicalRecordDto.Patient.City.Address) || !BasicValidation.CheckIfStringIsEmptyOrNull(medicalRecordDto.Patient.City.Country.Name)) { return(false); } return(true); }
[HttpPost] // POST /api/medicalRecord public IActionResult RegisterPatient(MedicalRecordDto dto) { MedicalRecordValidation medicalRecordValidation = new MedicalRecordValidation(); if (!medicalRecordValidation.ValidateMedicalRecord(dto)) { return(BadRequest("The data which were entered are incorrect!")); } App.Instance().MedicalRecordService.CreatePatientMedicalRecord(new MailAddress(dto.Patient.EMail), MedicalRecordMapper.MedicalRecordDtoToMedicalRecord(dto)); App.Instance().MedicalRecordService.WritePatientProfilePictureInFile(dto.Patient.Username, dto.ProfilePicture); return(Ok(200)); }
public async Task <bool> Put(MedicalRecordDto model) { var result = false; if (ModelState.IsValid) { var dateTimeUtcNow = DateTime.Now; model.UpdatedBy = _authenticationDto.UserId; model.UpdatedTime = dateTimeUtcNow; result = await _medicalRecordBusiness.Update(model); } return(result); }
public async Task <MedicalRecordDto> Add(MedicalRecordDto model) { model.Code = string.Empty; var entity = _medicalRecordRepository.Add(_mapper.Map <TMedicalRecord>(model)); await _medicalRecordRepository.SaveChangeAsync(); var maxId = await _medicalRecordRepository.Repo.MaxAsync(c => c.Id); entity.Code = $"BA-{(maxId + 1):D10}"; await _medicalRecordRepository.SaveChangeAsync(); model.Id = entity.Id; return(model); }
public static MedicalRecord MedicalRecordDtoToMedicalRecord(MedicalRecordDto dto) { MedicalRecord medicalRecord = new MedicalRecord(new Patient(), new Anamnesis(), new List <Allergies>(), new List <Medicament>()); medicalRecord.Id = dto.Id; medicalRecord.Patient = dto.Patient; medicalRecord.PatientId = medicalRecord.Patient.Id; medicalRecord.AnamnesisId = dto.AnamnesisId; medicalRecord.Anamnesis = new Anamnesis(); medicalRecord.Allergies = dto.Allergies; medicalRecord.Medicaments = new List <Medicament>(); medicalRecord.ActiveMedicalRecord = false; return(medicalRecord); }
public static MedicalRecordDto MedicalRecordToMedicalRecordDto(MedicalRecord medicalRecord) { MedicalRecordDto dto = new MedicalRecordDto(); dto.Id = medicalRecord.Id; dto.Patient = medicalRecord.Patient; dto.PatientId = medicalRecord.PatientId; dto.ActiveMedicalRecord = medicalRecord.ActiveMedicalRecord; dto.Anamnesis = medicalRecord.Anamnesis; dto.Allergies = medicalRecord.Allergies; dto.Medicaments = medicalRecord.Medicaments; dto.DateOfBirthday = medicalRecord.Patient.DateOfBirth.ToString("dd.MM.yyyy."); dto.ProfilePicture = medicalRecord.Patient.Username + ".png"; return(dto); }
/// <summary> /// Create the specified item into the database /// </summary> /// <param name="item">The item to add in the database</param> public void Create(MedicalRecordDto item) { Assert.IsNotNull(item, "item"); var found = (from p in this.Session.Query <MedicalRecord>() where p.Id == item.Id select p).ToList().Count() > 0; if (found) { throw new ExistingItemException(); } var entity = Mapper.Map <MedicalRecordDto, MedicalRecord>(item); this.Session.Save(entity); }
/// <summary> /// Updates the specified medical record. /// </summary> /// <param name="item">The insurance.</param> public void Update(MedicalRecordDto item) { Assert.IsNotNull(item, "item"); var entity = this.Session.Get <MedicalRecord>(item.Id); var tag = this.Session.Get <Tag>(entity.Tag.Id); //Reload the tag to avoid exception from nhibernate Mapper.Map <MedicalRecordDto, MedicalRecord>(item, entity); entity.Tag = tag; //Save the state new MedicalRecordMemento().SaveState(entity); this.Session.Update(entity); }
public async Task <int> Post(MedicalRecordDto model) { var result = 0; if (ModelState.IsValid) { var dateTimeUtcNow = DateTime.Now; model.CreatedBy = _authenticationDto.UserId; model.CreatedTime = dateTimeUtcNow; model.UpdatedBy = _authenticationDto.UserId; model.UpdatedTime = dateTimeUtcNow; model.IsActived = true; var modelInsert = await _medicalRecordBusiness.Add(model); result = modelInsert.Id; } return(result); }
/// <summary> /// Creates the specified record and link it to the specidied patient. /// </summary> /// <param name="record">The record.</param> /// <param name="forPatient">For patient.</param> public void Create(MedicalRecordDto record, LightPatientDto forPatient) { Assert.IsNotNull(record, "item"); var foundPatient = (from p in this.Session.Query <Patient>() where p.Id == forPatient.Id select p).FirstOrDefault(); if (foundPatient == null) { throw new EntityNotFoundException(typeof(Patient)); } var recEntity = Mapper.Map <MedicalRecordDto, MedicalRecord>(record); foundPatient.MedicalRecords.Add(recEntity); this.Session.SaveOrUpdate(foundPatient); }
/// <summary> /// Removes item with the specified id. /// </summary> /// <typeparam name="T">The type of the item to remove</typeparam> /// <param name="id">The id of the item to remove.</param> public void Remove(MedicalRecordDto item) { Assert.IsNotNull(item, "item"); this.Remove <MedicalRecord>(item); }
/// <summary> /// Gets the history of the specified medical record. /// </summary> /// <param name="record">The record.</param> /// <returns>The items contained in the history</returns> public IEnumerable <MedicalRecordStateDto> GetHistory(MedicalRecordDto record) { var history = this.Session.Get <MedicalRecord>(record.Id); return(Mapper.Map <IEnumerable <MedicalRecordState>, IEnumerable <MedicalRecordStateDto> >(history.PreviousStates)); }
public AddRecordViewModel() { PluginContext.Host.UserConnected += (sender, e) => this.component = PluginContext.ComponentFactory.GetInstance <IMedicalRecordComponent>(); this.recordToAdd = new MedicalRecordDto(); this.addRecordCommand = new RelayCommand(() => this.AddRecord(), () => this.CanAddRecord()); }
/// <summary> /// Creates the specified record and link it to the specidied patient. /// </summary> /// <param name="record">The record.</param> /// <param name="forPatient">For patient.</param> public void Create(MedicalRecordDto record, LightPatientDto forPatient) { new Creator(this.Session).Create(record, forPatient); }
public static TitledMedicalRecordDto CreateFrom(MedicalRecordDto record) { return(Mapper.Map <MedicalRecordDto, TitledMedicalRecordDto>(record)); }