public void CreatePatientDocument_GivenValidArguments_EntityIsEditable() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var bytes = new byte[] { 0, 0, 0 }; var patientDocumentRepositoryMock = new Mock <IPatientDocumentRepository>(); var hashingUtility = new Mock <IHashingUtility>(); hashingUtility.Setup(m => m.ComputeHash(bytes)).Returns("XXXXXXXXXXX"); var patientDocumentFactory = new PatientDocumentFactory( patientDocumentRepositoryMock.Object, hashingUtility.Object); var patient = new Mock <Patient>(); var patientDocumentType = new Mock <PatientDocumentType>(); PatientDocument patientDocument = patientDocumentFactory.CreatePatientDocument( patient.Object, patientDocumentType.Object, bytes, "filename"); patientDocument.ReviseOtherDocumentTypeName("Other"); } }
// POST: /Kurs1/Delete/5 //[HttpPost, ActionName("Delete")] //[ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id, int id2) { PatientDocument patientdocument = db.PatientDocument.Find(id); db.PatientDocument.Remove(patientdocument); db.SaveChanges(); return(RedirectToAction("Index", new { id = id2 })); }
public void SetupTest() { Reporting.documentName = "TestSetup"; login = new Login("Login.csv"); login.SetupAndLogin(); patient = new PatientDocument("Patient", "PatientData1.csv"); patient.CreateSimplePatient(); visit = new PatientVisit("Patient", "PatientVisit1.csv"); visit.ScheduleSimpleVisit(); } // end SetUp()
public ActionResult Create(PatientDocument value) { int patientId = value.ID; Patient patient = db.Patient.Find(value.ID); patient.PatientDocument.Add(value); db.SaveChanges(); return(RedirectToAction("Index", new { id = patientId })); }
public IActionResult DeletePatientDocument(long id) { PatientDocument PatientDocument = doc_repo.Find(id); if (PatientDocument == null) { return(NotFound()); } doc_repo.Delete(PatientDocument); return(Ok()); }
private bool MapProperties(PatientDocumentDto dto, PatientDocument entity) { var patientDocumentType = _mappingHelper.MapLookupField <PatientDocumentType> (dto.PatientDocumentType); var clinicalDateRange = new DateRange(dto.ClinicalStartDate, dto.ClinicalEndDate); entity.RevisePatientDocumentType(patientDocumentType); entity.ReviseClinicalDateRange(clinicalDateRange); entity.ReviseDescription(dto.Description); entity.ReviseDocumentProviderName(dto.DocumentProviderName); entity.ReviseOtherDocumentTypeName(dto.OtherDocumentTypeName); return(true); }
/// <summary> /// Processes the single aggregate. /// </summary> /// <param name="dto">The dto to process.</param> /// <param name="entity">The entity.</param> /// <returns>A <see cref="System.Boolean"/></returns> protected override bool ProcessSingleAggregate(PatientDocumentDto dto, PatientDocument entity) { var result = MapProperties(dto, entity); //TODO: Why these rules are here? var ruleEngine = RuleEngine <PatientDocument> .CreateTypedRuleEngine(); var executionResults = ruleEngine.ExecuteRuleSet(entity, "SavePatientDocument"); result &= !executionResults.HasRuleViolation; dto.MapViolations(executionResults.RuleViolations); return(result); }
public ActionResult Edit(PatientDocumentEditVo patientdocument) { if (ModelState.IsValid) { PatientDocument patientdocumentEntity = db.PatientDocument.Find(patientdocument.ID); patientdocumentEntity.Details = patientdocument.Details; patientdocumentEntity.Date = patientdocument.Date; patientdocumentEntity.DocumentName = patientdocument.DocumentName; patientdocumentEntity.TypeDocument = patientdocument.TypeDocument; db.Entry(patientdocumentEntity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = patientdocument.PatientId })); } return(View(patientdocument)); }
public async Task <IActionResult> AddPatientDocuments([FromRoute] long patientid, List <IFormFile> models) { IList <string> filepaths = new List <string>(); IList <PatientDocument> docs = new List <PatientDocument>(); foreach (IFormFile f in models) { string storePath = patientid.ToString() + "_" + f.Name; string docFolder = Path.Combine("PatientDocuments", storePath); try { if (f == null || f.Length == 0) { return(Content("File not selected")); } string path = FileUploadHandler.GetFilePathForUpload(docFolder, f.FileName); using (FileStream stream = new FileStream(path, FileMode.Create)) { await f.CopyToAsync(stream); } } catch (Exception e) { return(Json(new { result = "Upload Failed", error = e.Message })); } string filePath = FileUploadHandler.FileReturnPath(docFolder, f.FileName); PatientDocument doc = new PatientDocument { PatientId = patientid, FilePath = filePath, DocumentName = f.FileName }; docs.Add(doc); filepaths.Add(filePath); } doc_repo.AddRange(docs); return(Json(new { FilePaths = filepaths, PatientID = patientid })); }
// GET: /Kurs1/Edit/5 public ActionResult Edit(int id = 0, int id2 = 0) { PatientDocument patientdocument = db.PatientDocument.Find(id); var patientdocumentEditVo = new PatientDocumentEditVo { ID = patientdocument.ID, PatientId = id2, Details = patientdocument.Details, Date = patientdocument.Date, DocumentName = patientdocument.DocumentName, TypeDocument = patientdocument.TypeDocument }; if (patientdocument == null) { return(HttpNotFound()); } return(View(patientdocumentEditVo)); }
/// <summary> /// Saves new documents to the database /// </summary> private void SaveNewDocument() { foreach (Telerik.WebControls.UploadedFile uplFile in uplNewDocument.UploadedFiles) { PatientDocument pDoc = new PatientDocument(); pDoc.DocumentLink = UploadLocation + uplFile.FileName; pDoc.DocumentType = ddlDocType.Text; pDoc.LocationType = (int)LocationType.Trinity; pDoc.ReferenceDate = rdpEncounterStartDate.SelectedDate.Value; pDoc.Active = true; pDoc.OriginationSource = OriginationSource; pDoc.DateAdded = DateTime.Now; pDoc.Visible = true; if (ddlDocType.SelectedValue == "AddType") { pDoc.DocumentType = txtDocumentType.Text; } using (TMM_DEPLOYEntities tmmEntities = new TMM_DEPLOYEntities()) { tmmEntities.Attach(CurrentPatientEncounter); pDoc.Patient = CurrentPatientEncounter; tmmEntities.AddToPatientDocument(pDoc); tmmEntities.SaveChanges(); tmmEntities.Detach(CurrentPatientEncounter); } _newdocumentID = pDoc.DocumentID; HandleUploadedFile(pDoc.DocumentID, uplFile); NotifyUsers(); } ClientScript.RegisterStartupScript(grdDocuments.GetType(), "UploadComplete", "<script>document.getElementById('divUploadFile').style.display = 'none'; document.getElementById('divUploadButton').style.display = 'block';</script>"); LoadDocumentList(); ClearUploadForm(); }
public void grdDocuments_ItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e) { if (e.Item.DataItem != null && e.Item.DataItem.GetType() == typeof(PatientDocument)) { Telerik.WebControls.GridItem item = e.Item; PatientDocument pDoc = (PatientDocument)e.Item.DataItem; LinkButton lnkHide = (LinkButton)item.FindControl("lnkHide"); LinkButton lnkShow = (LinkButton)item.FindControl("lnkShow"); if (lnkHide != null && lnkShow != null) { if (pDoc.Visible) { lnkHide.Visible = true; lnkShow.Visible = false; } else { lnkShow.Visible = true; lnkHide.Visible = false; } } } }
/// <summary> /// Processes the single aggregate. /// </summary> /// <param name="dto">The dto to process.</param> /// <param name="entity">The entity.</param> /// <returns>A <see cref="System.Boolean"/></returns> protected override bool ProcessSingleAggregate(MailAttachmentPatientDocumentDto dto, PatientDocument entity) { var patientDocumentType = _mappingHelper.MapLookupField <PatientDocumentType>(dto.PatientDocumentType); var clinicalDateRange = new DateRange(dto.ClinicalStartDate, dto.ClinicalEndDate); entity.RevisePatientDocumentType(patientDocumentType); entity.ReviseClinicalDateRange(clinicalDateRange); entity.ReviseDescription(dto.Description); entity.ReviseDocumentProviderName(dto.DocumentProviderName); entity.ReviseOtherDocumentTypeName(dto.OtherDocumentTypeName); return(true); }
public override Object SaveAsBlob(int objectId, int companyId, string objectType, string documentType, string uploadpath) { BO.Document docInfo = new BO.Document(); string errMessage = string.Empty; string errDesc = string.Empty; using (var dbContextTransaction = _context.Database.BeginTransaction()) { if (documentType.ToLower() == "profile") { var patientProfileDocumemnts = _context.MidasDocuments.Where(mid => mid.ObjectId == objectId && mid.DocumentType == documentType && (mid.IsDeleted.HasValue == false || (mid.IsDeleted.HasValue == true && mid.IsDeleted.Value == false))); patientProfileDocumemnts.ToList().ForEach(ppd => ppd.IsDeleted = true); _context.SaveChanges(); } MidasDocument midasdoc = _context.MidasDocuments.Add(new MidasDocument() { ObjectType = documentType.ToUpper().Equals(EN.Constants.ConsentType) ? string.Concat(EN.Constants.ConsentType, "_" + companyId) : objectType, ObjectId = objectId, DocumentType = documentType, DocumentName = Path.GetFileName(uploadpath),//streamContent.Headers.ContentDisposition.FileName.Replace("\"", string.Empty), DocumentPath = uploadpath, CreateDate = DateTime.UtcNow }); _context.Entry(midasdoc).State = System.Data.Entity.EntityState.Added; _context.SaveChanges(); PatientDocument patientDoc = _context.PatientDocuments.Add(new PatientDocument() { MidasDocumentId = midasdoc.Id, PatientId = objectId, DocumentType = documentType, DocumentName = Path.GetFileName(uploadpath),//streamContent.Headers.ContentDisposition.FileName.Replace("\"", string.Empty), CreateDate = DateTime.UtcNow }); _context.Entry(patientDoc).State = System.Data.Entity.EntityState.Added; _context.SaveChanges(); //Code to update User Info with ImageLink from midasdoc.DocumentPath if (patientDoc.DocumentType.ToLower() == "profile".ToLower()) { int PatientId = midasdoc.ObjectId; string ImageLink = midasdoc.DocumentPath; var patientUser = _context.Users.Where(p => p.id == PatientId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) .FirstOrDefault(); if (patientUser != null) { patientUser.ImageLink = ImageLink; _context.SaveChanges(); } } dbContextTransaction.Commit(); docInfo.Status = errMessage.Equals(string.Empty) ? "Success" : "Failed"; docInfo.Message = errDesc; docInfo.DocumentId = midasdoc.Id; docInfo.DocumentPath = errMessage.Equals(string.Empty) ? midasdoc.DocumentPath : midasdoc.DocumentName; docInfo.DocumentName = midasdoc.DocumentName; docInfo.DocumentType = errMessage.Equals(string.Empty) ? midasdoc.DocumentType : string.Empty; docInfo.id = objectId; } return((Object)docInfo); }