Validate records for the patient table

Assignment Help Other Subject
Reference no: EM132403048

Ms Web Tech Requirement -Model-Based Validation & Class Libraries

In this requirement, you will be using partial & metadata classes, validation &format annotations, custom annotations, the Validate method in a self-validating model, and a class library. You are going to validate records for the Patient table.

Setup
1. Continue with your XXPatients project ... or you can download A1Patients and start from there.
a. If starting from A1Patients, put your name and section in the footer, and activate Session variables in startup.cs

XXPatientController
1. Generate the XXPatientControllerwith full CRUD support and Views for the Patient model.
2. Reduce the Index listing to the fields shown in the example below.
a. Show patient's full name, not separate first and last names, and order the listing by this.
b. Model annotations (later) will fix the field headings
c. Date of birth and date of death are Nullable<DateTime> datatypes, so ToString() and [DisplayFormat(...)] won't work on then directly ... something for you to figure out when displaying on a view.
d. Only show DateOfDeath if the patient is deceased

3. In the Create view:
a. Replace the provinceCode drop-down with a textbox andadd a field-validation <span> to display any error messages for it. Use another textbox on the page for reference.
4. In the Edit view, display the province name in the drop-down, ordered by name.
5. Catch any exception that is thrown on Create or Edit, place its innermostmessage into ModelState, and allow processing to continue to the sad path, which shouldredisplay the user's data with the error.
6. For Delete, put the innermost exception's message into TempData and return to the Delete view.
7. If the insert, update or delete works, display a success message on theMemberIndex page via TempData.
a. Notice I have ValidationSummary showing All error messages, so even errors on hidden fields show.

XXClassLibrary
1. Add a .NETCore class library called XXClassLibrary ... as a separate project in the XXPatients solution or as a project in a separate solution.Remember that when you create classes here, make them and their methodspublic or they won't be available to other projects like your web site.
2. Add a public staticclass called XXValidations, with the following public static(class-level) methods:
a. Add a method called XXCapitalize that accepts a string and returns a string:
i. If the input string is null, return it as an empty string.
ii. Change the input string to lower case and remove leading & trailing spaces.
iii. Shift the first letter of every word in the string to upper case.
iv. Return the newly-capitalised string.
b. Add a method called XXExtractDigits that accepts a string and returns a string:
i. Null is possible, so don't blow up on it.
ii. Return a string containing all digits found in the input string.
c. Add a method called XXPostalCodeValidation that accepts a string and returns a Boolean:
i. Use this method in your partial class' Validate method to verify a Canadian postal code, once you've decided the address is in Canada.
ii. This can be upper or lower case, with or without a space, and the letters have limited values ... the first letter can only be one of 18 letters and the others one of 20.
iii. If the input string is null or an empty string, have the method return true, permitting the postal code to be optional. Just spaces should fail.
iv. If the string fails the edit, return false, else return true.
d. Add a method called XXPostalCodeFormat that accepts a string and returns a string:
i. This is run if the postal validation returns true, so you may get null ... deal with it.
ii. Add the middle space, if missing, to the input string and return it, shifted to upper case.
e. Add a method called XXZipCodeValidation that accepts a string by reference and returns a Boolean:
i. Use this method to verify & format a US zip code, when the address is in the states.
ii. If the input string was null or empty, make it an empty string and return true.
iii. Extract all digits from the input string.
iv. If it contained 5 digits, put them into the input string and return true.
v. If it contained 9 digits,format them as 12345-1234 into the input string and return true.
vi. Else, return false and leave the input field unchanged.
3. Add a reference to your class library to your XXPatientsweb project.

Patient Class
All Patient validation code must be centralised in a metadata class and a like-named partial class, except for Remote & custom annotation code. Do not modify the generated Patient model and do not modify or validate data in controller actions.
1. Create a MetadataClasses subfolder inside theModels folder.
a. Create an XXPatientMetadata class file inside this subfolder.
b. Modify its namespace to be the same as the member model
c. Copy all physical property declarations from the Patient model to your XXPatientMetadata class.
d. Add a separate publicpartial class called Patient (ie: same as the model) to this class file:
i. Apply the XXPatientMetadata class to it, using an annotation.
ii. Turn the Patient partial class into a self-validating model by implementing the IValidatableObject interface. Implement the interface, creating aValidate method.
iii. Replace the "throw" statement with "yieldreturnValidationResult.Success" ... if you leave the throw, it'll always abend ... if you just take it out, the project won't build.
2. Display annotations & edits:
a. Change the field display-names to thoseshown in the sample Index, Create &Edit pages above.
b. Trim all strings of leading & trailing spaces.
c. Non-blank firstName,lastNameand genderare required. [Required] only checks for null/empty.
d. Use your XXValidations.Capitalize method to capitalise firstName, lastName, address,cityand gender.
e. If provinceCode is not empty or null, forceitto upper case and ...
i. Validate it by fetching its record from the database ... error if not found
ii. If fetching the province code throws an exception, put its innermost message in a ModelState so it displays beside the input field.
iii. Retain the record you found ... its country code is required to validate postalCode
f. postalCode is conditionally optional but,if provided:
i. Produce an error if provinceCode is invalid/missing ... it's required to edit a postal/zip code
ii. If provinceCode indicates the patient is in Canada, verify that the first letter of the postalCode is correct for that province. If not, produce a pertinent error message for both fields.
iii. Validate and format the postal/zip code using the relevant method(s) in your XXValidations Class (error if provinceCode is invalid/missing).
g. OHIP is optional, but if provided, shift it to upper case and ensure it's in this pattern: 1234-123-123-XX.
h. homePhoneis optional, but if provided:
i. It must contain exactly 10 digits (discard punctuation and text like "emergency only").
ii. Reformat into dash notation: 519-748-5220
iii. Sorry about historical data ... we didn't have edits. They'll be fixed on their next visit.
i. dateOfBirth is optional but, if provided, cannot be in the future
i. If deceased is true, dateOfDeath is required.
ii. If deceased is false,dateOfDeath must be null.
iii. If dateOfDeath is provided, it cannot be in the future or before dateOfBirth (if it is provided)
j. genderis required and must be "M", "F" or "X". Add a field-validation <span> to display error messageson Create & Edit views.

Attachment:- Model-Based Validation.rar

Reference no: EM132403048

Questions Cloud

What are some potential causes of the adverse outcomes : What are some potential causes of the adverse outcomes, and what are some prevention strategies that you may want to employ to prevent them?
Maintaining the plan : What did you find the most interesting and useful in step 10 "Maintaining the Plan"? What do the authors' mean a strategic plan is a living document?
Describe the limitations of the given type of encryption : Select one type of cryptography or encryption and explain it in detail. Include the benefits as well as the limitations of this type of encryption.
Determine which strategy is most likely to benefit the firm : The case study outlines six specific strategies that firm has chosen to support its strategic direction.Determine which strategy is most likely to benefit firm
Validate records for the patient table : Model-Based Validation and Class Libraries - Reduce the Index listing to the fields shown in the example - put the innermost exception's message into TempData
Demonstrating social responsibility : Imagine you are the owner of a new business in your city. You expect to operate your business using the highest standards of social responsibility
Create an array of at least four student objects : Modify the Student class so that it implements the Comparable interface. Define the compareTo method to order Student objects based on the value.
Doctoral level-what pitfalls should they be concerned with : Use the level of detail appropriate for doctoral level. What pitfalls should they be concerned with? What is your assessment of the situation?
Explain the relevance of each source to your topic : How should I protect my Windows PC from malware and viruses? What is ransomware? Everything you need to know about one of the biggest menaces on the web.

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd