コード例 #1
0
 public static DiagnosisViewModel GetViewModel(Diagnosis diagnosis, Func<DateTime, DateTime> toLocal)
 {
     return new DiagnosisViewModel
     {
         Id = diagnosis.Id,
         PatientId = diagnosis.PatientId,
         Text = diagnosis.Observations,
         Cid10Code = diagnosis.Cid10Code,
         Cid10Name = diagnosis.Cid10Name,
         MedicalRecordDate = toLocal(diagnosis.MedicalRecordDate),
     };
 }
コード例 #2
0
        public void Delete_WhenTheresADiagnosis()
        {
            PatientsController controller;
            Patient patient;

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

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

                var diagnosis = new Diagnosis()
                {
                    CreatedOn = referenceTime,
                    PatientId = patient.Id,
                    Cid10Code = "QAA",
                    Cid10Name = "Doença X", // x-men!
                    PracticeId = docAndre.PracticeId,
                };

                this.db.Diagnoses.AddObject(diagnosis);
                this.db.SaveChanges();
            }
            catch
            {
                Assert.Inconclusive("Test initialization has failed.");
                return;
            }

            controller.Delete(patient.Id);

            // this patient must have been deleted
            patient = this.db.Patients.FirstOrDefault(p => p.Id == patient.Id);
            Assert.IsNull(patient);
        }
コード例 #3
0
 /// <summary>
 /// Create a new Diagnosis 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="medicalRecordDate">Initial value of the MedicalRecordDate property.</param>
 public static Diagnosis CreateDiagnosis(global::System.Int32 id, global::System.Int32 patientId, global::System.DateTime createdOn, global::System.Int32 practiceId, global::System.DateTime medicalRecordDate)
 {
     Diagnosis diagnosis = new Diagnosis();
     diagnosis.Id = id;
     diagnosis.PatientId = patientId;
     diagnosis.CreatedOn = createdOn;
     diagnosis.PracticeId = practiceId;
     diagnosis.MedicalRecordDate = medicalRecordDate;
     return diagnosis;
 }
コード例 #4
0
        public ActionResult Edit(DiagnosisViewModel[] diagnoses)
        {
            var formModel = diagnoses.Single();

            if (string.IsNullOrEmpty(formModel.Text) && string.IsNullOrEmpty(formModel.Cid10Name))
                this.ModelState.AddModelError("", "É necessário preencher um diagnóstico CID-10 ou as notas");

            if (this.ModelState.IsValid)
            {
                Diagnosis dbObject;
                if (formModel.Id == null)
                {
                    Debug.Assert(formModel.PatientId != null, "formModel.PatientId != null");
                    dbObject = new Diagnosis()
                    {
                        CreatedOn = this.GetUtcNow(),
                        PatientId = formModel.PatientId.Value,
                        PracticeId = this.DbUser.PracticeId,
                    };
                    this.db.Diagnoses.AddObject(dbObject);
                }
                else
                    dbObject = this.db.Diagnoses.First(a => a.Id == formModel.Id);

                dbObject.Patient.IsBackedUp = false;
                dbObject.Observations = formModel.Text;
                dbObject.Cid10Code = formModel.Cid10Code;
                dbObject.Cid10Name = formModel.Cid10Name;
                dbObject.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(dbObject, this.GetToLocalDateTimeConverter()));
            }

            return this.View("Edit", formModel);
        }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Diagnoses EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDiagnoses(Diagnosis diagnosis)
 {
     base.AddObject("Diagnoses", diagnosis);
 }