public ActionResult Create(Guid parentID, FormCollection collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: We need to also check to see if a consultation ID was passed in, i.e. if we're reusing a consultation.
                    // TODO: timestamp = date + time
                    Consultation consultation;
                    if (collection["ConsultationID"] != "null")
                    {
                        consultation = db.Consultations.Find(
                            new System.Guid(collection["ConsultationID"]));
                    }
                    else
                    {
                        consultation = new Consultation()
                        {
                            Location = collection["Consultation.Location"],
                            Timestamp = DateTime.Parse(collection["Consultation.Timestamp"])
                        };
                        db.Consultations.Add(consultation);
                    }

                    var procedure = new Procedure()
                    {
                        Repositioning = collection["Repositioning"],
                        FractureID = parentID,
                        ConsultationID = consultation.ID
                    };
                    db.Procedures.Add(procedure);
                    db.SaveChanges();

                    db.Entry(procedure).Reference(p => p.Fracture).Load();
                    return RedirectToAction("Details", "Patients", new { id = procedure.Fracture.Incident.PersonalNumber });
                }
            }
            catch
            { }

            // TODO: This should actually report some useful error to the user (or developer...maybe breakpoint?)
            return View();
        }
Beispiel #2
0
        static void addPatients(DbContext db)
        {
            var patient = new Patient () {
                FirstName = "Bubba", LastName = "Ho-Tep", Age = 1234, PersonalNumber = "1111111231234"
            };
            db.Patients.Add (patient);
            db.SaveChanges ();

            var incident = new Incident()
            {
                InjuryDate = "2010-03-04",
                InjuryHour = 9,
                PersonalNumber = patient.PersonalNumber
            };
            db.Incidents.Add(incident);

            var frac1 = new Fracture()
            {
                AOCode = "33C2",
                IncidentID = incident.ID
            };
            db.Fractures.Add(frac1);

            var frac2 = new Fracture()
            {
                AOCode = "22B1",
                IncidentID = incident.ID
            };
            db.Fractures.Add(frac2);

            var consultation = new Consultation();
            db.Consultations.Add(consultation);

            var procedure = new Procedure() {
                // ConsultationID = consultation.ID,
                FractureID = frac1.ID
            };
            db.Procedures.Add(procedure);

            procedure = new Procedure()
            {
                // ConsultationID = consultation.ID,
                FractureID = frac2.ID
            };
            db.Procedures.Add(procedure);

            //patient = new Patient () {
            //    FirstName = "Joe", LastName = "Schmoe", Age = 35
            //};
            //db.Patients.Add (patient);
            //db.SaveChanges ();

            //injury = new Injury () {
            //    AOCode = "31B2",
            //    InjuryDate = new DateTime (2002, 8, 5),
            //    InjuryHour = 23,
            //    PatientID=patient.ID
            //};
            //db.Injuries.Add (injury);
        }