Skip to content

Veteran Intake Form

AndrewBaik edited this page Aug 10, 2018 · 6 revisions

Veteran Intake Form Implementation

Summary

When a veteran starts the process of creating the form, VeteranIntakeForm.cs is created, and assigns to the veteran, and saves onto the database. As veteran continues with the process, in each steps of the process, IntakeFormViewModels.cs gets utilized to hold veterans input answers from CreateStep.cshtml views and reassigns to VeteranIntakeForm. When CreateStep8.cshtml gets displayed, summery page, all of the information from IntakeFormViewModel.cs gets reassigned to IntakeFormViewModelMaster.cs for validating purpose. During this process, veterans are required to go back to intake form process for any missing answers. Once form completed, veteran will be able to view, edit, delete, or create will document.

VeteranIntakeFormController.cs

General Process

When veteran enters the form dashboard page Veteran/Index, user will have options to create a new application, continue filling out the form, or view completed form. Only certain links will be displayed based on the progress with the form.

  1. Creating a Form Filling out the form process is divided into 8 different Views. Each Views display different list of questions that veterans are required to answer. At the end of process in the summary page (step 8), that is where the validation will conduct checks if all of the required questions have been answered. If not, user will not be able to complete the process.

  2. Continue filling out the Form When a veteran 'Save and Exit's while creating a form, the form will be saved in the state of where it was left off. Veteran will be able to go straight back to where he/she left off with the process. If veteran desires to start fresh, forms can be deleted.

  3. View Completed Form Once form is completed, veteran has options to view detail, edit, delete, and create will. Detail view list out the answers veteran filled out. Edit view allows veterans to go back and edit the answers to questions(Not been implemented yet). Create will displays the official Will documentation with form information.

GoToStep

This method acts as a router. During the 8 step process, each createstep methods are calling this methods to redirect one page to another.

        [HttpGet]
        public IActionResult GoToStep(byte step = 0)
        {
            if (step == 1) return RedirectToAction(nameof(CreateStep1));
            if (step == 2) return RedirectToAction(nameof(CreateStep2));
            if (step == 3) return RedirectToAction(nameof(CreateStep3));
            if (step == 4) return RedirectToAction(nameof(CreateStep4));
            if (step == 5) return RedirectToAction(nameof(CreateStep5));
            if (step == 6) return RedirectToAction(nameof(CreateStep6));
            if (step == 7) return RedirectToAction(nameof(CreateStep7));
            if (step == 8) return RedirectToAction(nameof(CreateStep8));
            return RedirectToAction(nameof(CreateStep0));
        }

CreateStep1 - CreateStep8

Each CreateStep methods utilizes its own ViewModels (also 1 through 8). New IntakeFormViewModel gets injected out to View pages to bind its properties, which are answers to questionnairs. Each required questions/properties within the ViewModels are not annotated as 'required' at this time, so that users are free to 'Save & Exit' at any stage of this process without filling out the required questions.

  • Throughout both Get and Post methods, CurrentStep property is being reassigned to keep track of last page user is on in case user quits out of page.
        [HttpGet]
        public async Task<IActionResult> CreateStep1()
        {
            IntakeFormViewModel1 ifvm = new IntakeFormViewModel1();
            VeteranIntakeForm veteranIntakeForm = _context.VeteranIntakeForms.FirstOrDefault(form =>
                    form.VeteranApplicationUserId == _userManager.GetUserId(User) &&
                    form.IsCompleted == null
                );
            if (veteranIntakeForm != null)
            {
                ifvm.FullLegalName = veteranIntakeForm.FullLegalName;
                ifvm.Address = veteranIntakeForm.Address;
                ifvm.PhoneNumber = veteranIntakeForm.PhoneNumber;

                veteranIntakeForm.CurrentStep = 1;
                _context.Update(veteranIntakeForm);
                await _context.SaveChangesAsync();

                return View(ifvm);
            }

            return View(ifvm);
        }
            return RedirectToAction(nameof(GoToStep), new { step = currentForm.CurrentStep });

Once Post method gets called, all of users answers attached to the ViewModel gets gets reassigned to an VeteranIntakeForm object and saves onto the database. This is the object that will hold all of the form answers and eventually will be used to create the official Documentation.

        [HttpPost]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> CreateStep1([Bind("FullLegalName,Address,PhoneNumber,Exit")] IntakeFormViewModel1 
                                                      intakeFormViewModel)
        {
            VeteranIntakeForm currentForm = _context.VeteranIntakeForms.FirstOrDefault(form =>
                form.VeteranApplicationUserId == _userManager.GetUserId(User) &&
                form.IsCompleted == null
            );
            currentForm.TimeStamp = DateTime.Now;

            currentForm.FullLegalName = intakeFormViewModel.FullLegalName;
            currentForm.Address = intakeFormViewModel.Address;
            currentForm.PhoneNumber = intakeFormViewModel.PhoneNumber;

            if (intakeFormViewModel.Exit != null)
            {
                _context.VeteranIntakeForms.Update(currentForm);
                await _context.SaveChangesAsync();
                return RedirectToAction("Index", "Veteran");
            }
            currentForm.CurrentStep = 2;
            _context.VeteranIntakeForms.Update(currentForm);
            await _context.SaveChangesAsync();

            return RedirectToAction(nameof(GoToStep), new { step = currentForm.CurrentStep });
        }

if (intakeFormViewModel.Exit != null) this condition will be met when veteran 'Save & Exit' in the middle of process.

IntakeFormViewModel.cs

This class gets saved onto the database with all of the answers to form questionnaires. When veterans fill-out the form in the view, those answers will be held and transferred to the POST method with the IntakeFormViewModel and gets reassigned to this IntakeFormViewModel. Then it will Update/SaveAsync to the database. Veteran property is a Foreign-Key to hold One-to-Many connections with Veteran class (Core version 2.0 implementation).

IntakeFormViewModel0.cs ~ IntakeFormViewModelMaster.cs

These viewmodel classes are used in the CreateStep.cshtml. IntakeFormViewModel0 ~ IntakeFormViewModel7 holds different list of questions that are used in the first 7 views of form process. Once veteran inputs answer in the view page, data in these viewmodels gets reassigned to VeteranIntakeForm in the POST methods and saves onto the database. At the end of the process, IntakeFormViewModelMaster is used in the CreateStep8, where VeteranIntakeform gets reassign to view Model Master and validate all the required properties. If any of required properties are missing, veterans are not allowed to move forward, veterans are required to go back to the process and answer those missing questions.

DocumentController.cs

Document controller is where AllDocsViewModel gets created to generate the Will document for Veteran. View model compiles its properties from completed VeteranIntakeForm.cs and displays onto pre-created official will documentation (Views/Document/Confirmation.cshtml).

Note: Some of required AllDocsViewModel properties are not being asked during the intake form process. That needs to be addressed to allow Will to dynamically created in the future