public IHttpActionResult GetClinicalNote(int id)
        {
            ClinicalNote clinicalNote = db.ClinicalNotes.Find(id);

            if (clinicalNote == null)
            {
                return(NotFound());
            }

            return(Ok(clinicalNote));
        }
        public IHttpActionResult DeleteClinicalNote([FromBody] int id)
        {
            ClinicalNote clinicalNote = db.ClinicalNotes.Find(id);

            if (clinicalNote == null)
            {
                return(NotFound());
            }

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

            return(Ok(clinicalNote));
        }
        private void FillDB()
        {
            try
            {
                if (db.ClinicalNotes.Count() > 0)
                {
                    return;
                }

                if (db.ClinicalNoteCategories.Count() <= 0)
                {
                    ClinicalNoteCategory cnc = new ClinicalNoteCategory();
                    cnc.Name          = "Cat1";
                    cnc.ComponentName = "Test";
                    cnc.FriendlyName  = "First Clinical Note";
                    db.ClinicalNoteCategories.Add(cnc);
                    db.SaveChanges();
                }

                ClinicalNote cn = new ClinicalNote();
                cn.CategoryID    = 1;
                cn.ParticipantID = 1;
                cn.DoctorID      = 1;
                cn.Created       = DateTime.Now.Date;
                cn.VisitDate     = DateTime.Now.Date;
                cn.Summary       = "This is a brief of the first note";
                cn.Data          = "{\"Brief\":\"This is a brief of the first note.\", \"Comments\":\"This is suppused to be a longer text, only used as a place-holder for the first test note.\"}";

                db.ClinicalNotes.Add(cn);

                cn               = new ClinicalNote();
                cn.CategoryID    = 1;
                cn.ParticipantID = 2;
                cn.DoctorID      = 2;
                cn.Created       = DateTime.Now.Date;
                cn.VisitDate     = DateTime.Now.Date;
                cn.Summary       = "This is a brief of the second note";
                cn.Data          = "{\"Brief\":\"This is a brief of the second note.\", \"Comments\":\"This is suppused to be a longer text, only used as a place-holder for the second test note.\"}";

                db.ClinicalNotes.Add(cn);

                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw;
            }
        }
Пример #4
0
        public void Can_AddClinicalNote()
        {
            //Arrange
            var builder = new DbContextOptionsBuilder <DataContext>();

            builder.UseInMemoryDatabase("AddClinicalNote");
            SeedInMemoryStore(builder.Options);

            //Act
            using (var dataContext = new DataContext(builder.Options))
            {
                var dataService  = new DataService(new Uow(dataContext));
                var clinicalNote = new ClinicalNote();
                dataService.AddClinicalNote(clinicalNote);

                // Assert
                Assert.IsNotNull(dataContext.ClinicalNotes.First(x => x.Id == 4));
            }
        }
        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));
        }
Пример #6
0
        public async Task Handle(EncounterCreated message)
        {
            var obj = this.ParseMessage(message);

            var nhsNumber = obj.Subject.Identifier.Value;
            var patient   = await this.Patients.GetOne(nhsNumber);

            if (patient == null)
            {
                return;
            }

            var clinicalNote = new ClinicalNote
            {
                ClinicalNotesType = "Encounter",
                Notes             = $"Encounter created from INR",
                PatientId         = nhsNumber,
                DateCreated       = obj.Meta?.LastUpdated?.DateTime ?? DateTime.UtcNow,
                Source            = "INR",
                SourceId          = obj.Identifier[0].Value
            };

            await this.ClinicalNotes.AddOrUpdate(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));
        }
Пример #8
0
 public Task AddOrUpdate(ClinicalNote item)
 {
     return(this.Collection.AddOrUpdate(item));
 }