예제 #1
0
 /// <summary>
 /// Constructs a view-model for an anamnesis, given the DB object representing it.
 /// </summary>
 /// <param name="anamnese">The DB object representing the anamnesis.</param>
 /// <returns>The view-model that contains data about the anamnesis.</returns>
 public static AnamneseViewModel GetViewModel(Anamnese anamnese, Func<DateTime, DateTime> toLocal)
 {
     return new AnamneseViewModel
     {
         Id = anamnese.Id,
         PatientId = anamnese.PatientId,
         Allergies = anamnese.Allergies,
         ChiefComplaint = anamnese.ChiefComplaint,
         Conclusion = anamnese.Conclusion,
         FamilyDeseases = anamnese.FamilyDiseases,
         HistoryOfThePresentIllness = anamnese.HistoryOfThePresentIllness,
         PastMedicalHistory = anamnese.PastMedicalHistory,
         RegularAndAcuteMedications = anamnese.RegularAndAcuteMedications,
         ReviewOfSystems = anamnese.ReviewOfSystems,
         SexualHistory = anamnese.SexualHistory,
         SocialHistory = anamnese.SocialDiseases,
         MedicalRecordDate = toLocal(anamnese.MedicalRecordDate),
     };
 }
        public void Delete_WhenTheresAnAnamnese()
        {
            PatientsController controller;
            int patientId;
            Patient patient;

            try
            {
                var doctor = Firestarter.Create_CrmMg_Psiquiatria_DrHouse_Andre(this.db);
                var mr = new MockRepository(true);
                controller = mr.CreateController<PatientsController>();
                Firestarter.CreateFakePatients(doctor, this.db, 1);

                // we now have 1 patient
                patient = this.db.Patients.FirstOrDefault();
                Assert.IsNotNull(patient);

                patientId = patient.Id;

                // now, let's add an anamnese
                var anamnese = new Anamnese()
                {
                    PatientId = patientId,
                    CreatedOn = DateTime.UtcNow,
                    Conclusion = "This is my anamnese",
                    PracticeId = doctor.PracticeId,
                };

                patient.Anamneses.Add(anamnese);
                this.db.SaveChanges();
            }
            catch
            {
                Assert.Inconclusive("Test initialization has failed.");
                return;
            }

            controller.Delete(patientId);

            // this patient must have been deleted
            patient = this.db.Patients.FirstOrDefault(p => p.Id == patientId);
            Assert.IsNull(patient);
        }
 /// <summary>
 /// Create a new Anamnese object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="patientId">Initial value of the PatientId property.</param>
 /// <param name="createdOn">Initial value of the CreatedOn property.</param>
 /// <param name="practiceId">Initial value of the PracticeId property.</param>
 /// <param name="chiefComplaint">Initial value of the ChiefComplaint property.</param>
 /// <param name="medicalRecordDate">Initial value of the MedicalRecordDate property.</param>
 public static Anamnese CreateAnamnese(global::System.Int32 id, global::System.Int32 patientId, global::System.DateTime createdOn, global::System.Int32 practiceId, global::System.String chiefComplaint, global::System.DateTime medicalRecordDate)
 {
     Anamnese anamnese = new Anamnese();
     anamnese.Id = id;
     anamnese.PatientId = patientId;
     anamnese.CreatedOn = createdOn;
     anamnese.PracticeId = practiceId;
     anamnese.ChiefComplaint = chiefComplaint;
     anamnese.MedicalRecordDate = medicalRecordDate;
     return anamnese;
 }
예제 #4
0
        public ActionResult Edit(AnamneseViewModel[] anamneses)
        {
            var formModel = anamneses.Single();

            Debug.Assert(formModel.PatientId != null, "formModel.PatientId != null");
            if (this.ModelState.IsValid)
            {
                Anamnese anamnese = null;
                if (formModel.Id == null)
                {

                    anamnese = new Anamnese
                    {
                        CreatedOn = this.GetUtcNow(),
                        PatientId = formModel.PatientId.Value,
                        PracticeId = this.DbUser.PracticeId,
                    };
                    this.db.Anamnese.AddObject(anamnese);
                }
                else
                    anamnese = this.db.Anamnese.First(a => a.Id == formModel.Id);

                anamnese.Patient.IsBackedUp = false;
                anamnese.Allergies = formModel.Allergies;
                anamnese.ChiefComplaint = formModel.ChiefComplaint;
                anamnese.Conclusion = formModel.Conclusion;
                anamnese.FamilyDiseases = formModel.FamilyDeseases;
                anamnese.HistoryOfThePresentIllness = formModel.HistoryOfThePresentIllness;
                anamnese.PastMedicalHistory = formModel.PastMedicalHistory;
                anamnese.RegularAndAcuteMedications = formModel.RegularAndAcuteMedications;
                anamnese.ReviewOfSystems = formModel.ReviewOfSystems;
                anamnese.SexualHistory = formModel.SexualHistory;
                anamnese.SocialDiseases = formModel.SocialHistory;
                anamnese.MedicalRecordDate = this.ConvertToUtcDateTime(formModel.MedicalRecordDate.Value);

                this.db.SaveChanges();

                // todo: this shoud be a redirect... so that if user press F5 in browser, the object will no be saved again.
                return this.View("Details", GetViewModel(anamnese, this.GetToLocalDateTimeConverter()));
            }

            return this.View("Edit", formModel);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Anamnese EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAnamnese(Anamnese anamnese)
 {
     base.AddObject("Anamnese", anamnese);
 }