private void Save() { try { if (this.HasEmptyPrescriptions()) { var dr = ViewService.MessageBox.Question(Messages.Msg_EmptyNotesForPrescriptions); if (!dr) { return; } } var document = new PrescriptionDocumentDto() { CreationDate = this.CreationDate }; document.Prescriptions.AddRange(this.Prescriptions); this.component.Create(document, PluginContext.Host.SelectedPatient); this.ResetPage(); } catch (Exception ex) { this.Handle.Error(ex); } }
/// <summary> /// Removes the specified item but doesn't touch the drugs liked to it. /// </summary> /// <param name="item">The item.</param> public void Remove(PrescriptionDocumentDto item) { foreach (var prescription in item.Prescriptions) { this.Remove <Prescription>(prescription); } this.Remove <PrescriptionDocument>(item); }
public void IsInvalid_NoDocument() { var item = new PrescriptionDocumentDto() { Title = Guid.NewGuid().ToString(), }; Assert.IsFalse(item.IsValid()); }
/// <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); }
public void IsValid() { var item = new PrescriptionDocumentDto() { Title = Guid.NewGuid().ToString(), }; item.Prescriptions.Add(new PrescriptionDto()); Assert.IsTrue(item.IsValid()); }
public void IsInvalid_EmptyName() { var item = new PrescriptionDocumentDto() { Title = string.Empty, }; item.Prescriptions.Add(new PrescriptionDto()); Assert.IsFalse(item.IsValid()); }
public void CreatePrescription_WithTwiceSameDrug_NoError() { var user = new PatientSessionComponent(this.Session).GetPatientsByNameLight("*", SearchOn.FirstAndLastName)[0]; var drugs = this.ComponentUnderTest.GetDrugsByName("*"); var document = new PrescriptionDocumentDto(); var prescription = new PrescriptionDto(); document.Prescriptions.Add(new PrescriptionDto() { Drug = drugs[0] }); document.Prescriptions.Add(new PrescriptionDto() { Drug = drugs[0] }); this.WrapInTransaction(() => this.ComponentUnderTest.Create(document, user)); }
/// <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) { new Creator(this.Session).Create(document, patient); }
/// <summary> /// Removes the specified item but doesn't touch the drugs liked to it. /// </summary> /// <param name="item">The item.</param> public void Remove(PrescriptionDocumentDto item) { new Remover(this.Session).Remove(item); }