public static IntakeFormModel ToModel(this IntakeForm entity) { var model = new IntakeFormModel { IntakeFormId = entity.IntakeFormId, PatientId = entity.PatientId, PhysicianId = entity.PhysicianId, DocumentId = entity.DocumentId, ICD10Codes = entity.ICD10Codes?.Select(x => x.ToModel()).ToList(), HCPCSCode = entity.HCPCSCode, Product = entity.Product, PhysicianNotes = entity.PhysicianNotes, Duration = entity.Duration, IntakeFormType = entity.IntakeFormType, Status = entity.Status, PhysicianPaid = entity.PhysicianPaid, VendorBilled = entity.VendorBilled, VendorPaid = entity.VendorPaid, DeniedReason = entity.DeniedReason, Questions = entity.Questions?.Select(q => q.ToModel()).ToList(), CreatedOn = entity.CreatedOn, ModifiedOn = entity.ModifiedOn }; return(model); }
public void Create_Document_From_Scratch() { // Create agent with Vendor, UserProfile, and Agent var agent = CreateAgent(); // Create Patient with Address, Medicare, and Private Insurance var patient = CreateAndPersistPatient(agent); IntakeForm intakeForm = CreateIntakeFormLocal(patient.PatientId); IntakeForm intakeForm2 = CreateIntakeFormLocal(patient.PatientId); // Create Document Byte Array var intakeModel = intakeForm.ToModel(); var intakeModel2 = intakeForm2.ToModel(); var exporter = new DocumentGenerator(); //todo if we are going to populate the questionare we need all intake forms to be passed to the DocumentGenerator //var intakeForms = new List<IntakeFormModel> { intakeModel, intakeModel2 }; var signatures = new List <SignatureModel> { CreateSignature().ToModel(), CreateSignature(false).ToModel() }; var documentContent = exporter.GenerateIntakeDocuments(intakeModel, patient.ToModel(), intakeForm.Physician.ToModel(), signatures); // Create Document var document = new Document { IntakeFormId = intakeForm.IntakeFormId, Content = documentContent }; var doc = dbContext.Document.Add(document); var id = dbContext.SaveChanges(); Console.WriteLine($"Run project and open your browser to https://localhost:44327/document/{doc.Entity.DocumentId}/download to see the word doc generated from this test"); }
public IntakeFormModel Create(IntakeFormModel intakeFormModel) { var intakeForm = new IntakeForm(); intakeForm.MapFromModel(intakeFormModel); intakeForm.Status = IntakeFormStatus.New; _context.IntakeForm.Add(intakeForm); _context.SaveChanges(); return(intakeForm.ToModel()); }
public IntakeFormModel Update(IntakeFormModel intakeFormModel) { IntakeForm intakeForm = _context.IntakeForm .Include(i => i.Signatures) .Include("Questions.Answers") .First(u => u.IntakeFormId == intakeFormModel.IntakeFormId); intakeForm.MapFromModel(intakeFormModel); _context.SaveChanges(); return(intakeForm.ToModel()); }
/// <summary> /// Takes an EF Core Entity and maps the model to it /// </summary> /// <param name="model"></param> /// <param name="entity"></param> /// <returns></returns> public static void MapFromModel(this IntakeForm entity, IntakeFormModel model) { if (entity == null) { entity = new IntakeForm(); } //IntakeFormId = model.IntakeFormId don't map primary key from the model entity.PatientId = model.PatientId; entity.PhysicianId = model.PhysicianId; entity.DocumentId = model.DocumentId; entity.Status = model.Status; entity.IntakeFormType = model.IntakeFormType; entity.Product = model.Product; entity.PhysicianNotes = model.PhysicianNotes; entity.Duration = model.Duration; entity.PhysicianPaid = model.PhysicianPaid; entity.VendorBilled = model.VendorBilled; entity.VendorPaid = model.VendorPaid; entity.DeniedReason = model.DeniedReason; entity.HCPCSCode = model.HCPCSCode; entity.CreatedOn = model.CreatedOn; entity.ModifiedOn = model.ModifiedOn; if (entity.Questions == null) { entity.Questions = new List <Question>(); } entity.Questions = model.Questions?.Select(questionsModel => { var question = new Question(); question.MapFromModel(questionsModel, entity.IntakeFormId); return(question); }).ToList(); if (entity.ICD10Codes == null) { entity.ICD10Codes = new List <ICD10Code>(); } entity.ICD10Codes = model.ICD10Codes?.Select(iCD10CodeModel => { var icd10Code = new ICD10Code(); icd10Code.MapFromModel(iCD10CodeModel); return(icd10Code); }).ToList(); }
protected IntakeForm CreateIntakeFormLocal(int patientId) { // Create IntakeForm with ICD, HCPCSCode, Phsycian, and Signature IntakeForm intakeForm = CreateIntakeForm(patientId); Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry <IntakeForm> savedIntakeForm = dbContext.IntakeForm.Add(intakeForm); dbContext.SaveChanges(); var intakeFormId = savedIntakeForm.Entity.IntakeFormId; // Add Questions intakeForm.Questions = CreateQuestions(intakeFormId); dbContext.IntakeForm.Update(intakeForm); dbContext.SaveChanges(); return(intakeForm); }
public int Create(int intakeFormId, SignatureModel signatureModel) { IntakeForm intakeForm = _context.IntakeForm .Include(i => i.Signatures) .First(u => u.IntakeFormId == intakeFormId); var sig = new Signature(); sig.MapFromModel(signatureModel); if (intakeForm.Signatures == null) { intakeForm.Signatures = new List <Signature>(); } intakeForm.Signatures.Add(sig); _context.SaveChanges(); return(sig.SignatureId); }
public int Create(DocumentModel documentModel) { IntakeForm intakeForm = _context.IntakeForm .Include("Questions.Answers") .Include(i => i.ICD10Codes) .Include(i => i.Physician.Address) .Include(i => i.Signatures) .First(i => i.IntakeFormId == documentModel.IntakeFormId); Patient patient = _context.Patient .Include(p => p.Address) .Include(p => p.PrivateInsurance) .Include(p => p.Medicare) .First(p => p.PatientId == intakeForm.PatientId); IntakeFormModel intakeFormModel = intakeForm.ToModel(); PatientModel patientModel = patient.ToModel(); PhysicianModel physicianModel = intakeForm.Physician.ToModel(); ICollection <SignatureModel> signatureModels = intakeForm.Signatures.Select(s => s.ToModel()).ToList(); var documentContent = _exporter.GenerateIntakeDocuments( intakeFormModel, patientModel, physicianModel, signatureModels); var document = new Document { IntakeFormId = documentModel.IntakeFormId, Content = documentContent }; intakeForm.Document = document; _context.SaveChanges(); return(document.DocumentId); }