示例#1
0
        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);
        }
示例#2
0
        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());
        }
示例#3
0
        /// <summary>
        /// The field values in the word doc need to be update in the property settings object of the word doc. The questions
        /// have 'keys' which we are using with MappingsEnum to know how update with the value from the IntakeForms. Then we
        /// explicitly ask the user to verify the fields are to be updated when opening the word doc.
        /// </summary>
        /// <param name="intakeForms"></param>
        /// <param name="doc"></param>
        private void UpdateValuesInWordDocsCustomProperties(
            WordprocessingDocument doc,
            IntakeFormModel intakeForm,
            PatientModel patient,
            PhysicianModel physician,
            ICollection <SignatureModel> signatures)
        {
            // Get all question's with a key, then gather the value as all answers comma delimited
            var intakeFromKeys = intakeForm.Questions
                                 .Where(r => !string.IsNullOrEmpty(r.Key))
                                 .Select(y => new KeyValuePair <string, string>(y.Key.ToUpper(), y.Answers.Select(z => z.Text)
                                                                                .Aggregate((c, n) => $"{c},{n}"))).ToList();

            intakeFromKeys.AddRange(GetPatientKeys(patient));
            intakeFromKeys.AddRange(GetAllCodes(intakeForm));
            intakeFromKeys.AddRange(GetPhysicanKeys(physician));
            intakeFromKeys.AddRange(GetSignature(signatures.First())); // just use the first signature for now since IP/Creation should be identicalish
            intakeFromKeys.AddRange(GetDrNotes(intakeForm.PhysicianNotes ?? ""));

            //This will update all of the custom properties that are used in the word doc.
            //Again, the fields are update in the document settings, but the downloading user
            //will need to approve the update for any fields.

            //https://docs.microsoft.com/en-us/office/open-xml/how-to-set-a-custom-property-in-a-word-processing-document
            Properties properties = doc.CustomFilePropertiesPart.Properties;

            foreach (MappingEnums propertyEnum in Enum.GetValues(typeof(MappingEnums)))
            {
                var item = (CustomDocumentProperty)properties
                           .FirstOrDefault(x => ((CustomDocumentProperty)x).Name.Value.Equals(propertyEnum.ToString()));
                if (item != null)
                {
                    //If a key doesn't exist, you could see an empty value stuffed into the word doc
                    var val = intakeFromKeys.FirstOrDefault(x => x.Key == propertyEnum.ToString().ToUpper()).Value ?? "N/A";
                    item.VTLPWSTR = new VTLPWSTR(val);
                }
            }

            properties.Save();

            //The docx is using Custom Properties and above we are updating the custom property values,
            //however there is no way (that I have found) to programatically updated all of the fields
            //that are using the custom properties without requiring the downloader to
            DocumentSettingsPart settingsPart = doc.MainDocumentPart.GetPartsOfType <DocumentSettingsPart>().First();
            var updateFields = new UpdateFieldsOnOpen
            {
                Val = new OnOffValue(true)
            };

            settingsPart.Settings.PrependChild(updateFields);
            settingsPart.Settings.Save();
            doc.Save();
        }
示例#4
0
        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());
        }
示例#5
0
        /// <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();
        }
示例#6
0
        public ActionResult <IntakeFormModel> Post([FromBody] IntakeFormModel intakeForm)
        {
            try
            {
                IntakeFormModel newIntakeForm = _intakeBusiness.Create(intakeForm);

                return(newIntakeForm);
            }
            catch (Exception ex)
            {
                _logging.Log(LogSeverity.Error, ex.ToString());
                throw;
            }
        }
示例#7
0
        public ActionResult <IntakeFormModel> Put(int id, [FromBody] IntakeFormModel intakeForm)
        {
            try
            {
                intakeForm.IntakeFormId = id;

                return(_intakeBusiness.Update(intakeForm));
            }
            catch (Exception ex)
            {
                _logging.Log(LogSeverity.Error, ex.ToString());
                throw;
            }
        }
示例#8
0
        private List <KeyValuePair <string, string> > GetAllCodes(IntakeFormModel intake)
        {
            var kvps = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(MappingEnums.GeneralIntakeNotes.ToString().ToUpper(), ""),      //Below the Pain Chart Image
                new KeyValuePair <string, string>(MappingEnums.HCPCSCode.ToString().ToUpper(), GetOrthoPrescribedAfter255(intake.HCPCSCode)),
                new KeyValuePair <string, string>(MappingEnums.HCPCSProduct.ToString().ToUpper(), intake.Product ?? "N/A"),
                new KeyValuePair <string, string>(MappingEnums.HCPCSDescription.ToString().ToUpper(), GetOrthoPrescribed(intake.HCPCSCode)),
                new KeyValuePair <string, string>(MappingEnums.HCPCSDuration.ToString().ToUpper(), intake.Duration),
                new KeyValuePair <string, string>(MappingEnums.ICDCode.ToString().ToUpper(), GetDiagnosis(intake.ICD10Codes)),
                //  new KeyValuePair<string, string>(MappingEnums.ICDDescription.ToString().ToUpper(), intake.ICD10?.Description  ?? "N/A")
            };

            return(kvps);
        }
示例#9
0
        /// <summary>
        /// Take all of the intake forms and replace the properties on the word doc, then append all of the
        /// intake forms
        /// </summary>
        /// <param name="intakeForms"></param>
        /// <returns></returns>
        public byte[] GenerateIntakeDocuments(
            IntakeFormModel intakeForm,
            PatientModel patient,
            PhysicianModel physician,
            ICollection <SignatureModel> signatures)
        {
            MemoryStream examNoteMemoryStream = LoadMemoryStream();

            using (var doc = WordprocessingDocument.Open(examNoteMemoryStream, true))
            {
                Body docBody = doc.MainDocumentPart.Document.Body;

                // create and add the character style with the style id, style name, and
                // aliases specified.
                var answerFormatStyleId = CreateIntakeFormAnswersCharStyle(doc);

                SetSignatures(doc, signatures);

                // Create title and add the subsequent question answers for the questionaire
                AppendTitleForIntakeForm(doc, docBody, intakeForm);

                var questionCount = 1;
                foreach (QuestionModel question in intakeForm.Questions)
                {
                    questionCount = AppendQuestionAnswerPair(docBody, answerFormatStyleId, questionCount, question);
                }

                docBody.AppendChild(new Paragraph());

                // Manual mapping bits
                UpdateValuesInWordDocsCustomProperties(doc, intakeForm, patient, physician, signatures);
            }

            var result = examNoteMemoryStream.ToArray();

            examNoteMemoryStream.Flush();
            examNoteMemoryStream.Close();

            return(result);
        }
示例#10
0
        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);
        }
示例#11
0
        private void AppendTitleForIntakeForm(WordprocessingDocument doc, Body docBody, IntakeFormModel intakeForm)
        {
            docBody.AppendChild(new Paragraph());

            Paragraph titleParagraph = CreateIntakeFormTitle(intakeForm.IntakeFormType);

            if (titleParagraph != null)
            {
                Formatting.AddNewStyle(doc, "PRTitle1", "PRTitle", titleParagraph);
                ParagraphProperties paragraphProperties = titleParagraph.PrependChild(new ParagraphProperties());
                docBody.AppendChild(titleParagraph);
            }
            docBody.AppendChild(new Paragraph());
        }