public IHttpActionResult AddClinicalNote(ClinicalNote clinicalNote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (clinicalNote.CategoryID < 1)
            {
                clinicalNote.CategoryID = clinicalNote.Category.ID;
            }
            clinicalNote.Participant = null;
            clinicalNote.Doctor      = null;
            clinicalNote.Category    = null;
            clinicalNote.VisitDate   = clinicalNote.VisitDate.Date;
            clinicalNote.Created     = DateTime.Now.Date;
            clinicalNote.checkSummary();

            db.ClinicalNotes.Add(clinicalNote);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = clinicalNote.ID }, clinicalNote));
        }
        public IHttpActionResult UpdateClinicalNote(ClinicalNote clinicalNote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (clinicalNote.ID == 0)
            {
                return(BadRequest());
            }

            try
            {
                clinicalNote.Participant = null;
                clinicalNote.Doctor      = null;
                clinicalNote.Category    = null;
                clinicalNote.VisitDate   = clinicalNote.VisitDate.Date;
                clinicalNote.checkSummary();

                db.Entry(clinicalNote).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception e)
            {
                if (!ClinicalNoteExists(clinicalNote.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }