Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added Validation for Insurance input fields in patient registration issue (#8672) #8681

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from

Conversation

syedfardeenjeelani
Copy link
Contributor

@syedfardeenjeelani syedfardeenjeelani commented Oct 1, 2024

Proposed Changes

All.fields.are.mandatory.1.mp4

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Prep screenshot or demo video for changelog entry, and attach it to the issue.

@syedfardeenjeelani syedfardeenjeelani requested a review from a team as a code owner October 1, 2024 05:53
Copy link

netlify bot commented Oct 1, 2024

Deploy Preview for care-ohc failed.

Name Link
🔨 Latest commit d7da9f8
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67135586dc4c840008785e62

@rithviknishad
Copy link
Member

@syedfardeenjeelani is this ready for review?

@syedfardeenjeelani
Copy link
Contributor Author

@syedfardeenjeelani is this ready for review?

we are getting the error from the validator.ts which is something like this
if (
!value.policy_id.trim() ||
!value.subscriber_id.trim() ||
(enable_hcx && (!value.insurer_id?.trim() || !value.insurer_name?.trim()))
)
return "All fields are mandatory";

so should i use field_required from the i18n locale here instead of "All fields are mandatory"

@rithviknishad
Copy link
Member

yes

@syedfardeenjeelani
Copy link
Contributor Author

yes

Thanks I'll do the changes and push

@syedfardeenjeelani
Copy link
Contributor Author

@rithviknishad if we do it like this
if (
!value.policy_id.trim() ||
!value.subscriber_id.trim() ||
(enable_hcx && (!value.insurer_id?.trim() || !value.insurer_name?.trim()))
)
return t("field_required");
};

then it will also show it right here
issue
so instead should a make a key which says "all_fields_mandatory": "All fields are mandatory"

or should we handle both cases seprately

@rithviknishad
Copy link
Member

rithviknishad commented Oct 1, 2024

Let's keep the error texts same as before itself instead of showing the error on ALL fields, just that ensure ALL fields required validation happens as mentioned in the issue.

@syedfardeenjeelani
Copy link
Contributor Author

@rithviknishad I've made some changes based on your feedback, but I'm not sure if I got it right. Could you take a look at my PR when you get a chance and let me know if i am headed in the right direction or not ?

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only validation logic in this file needs to be modified: https://github.com/ohcnetwork/care_fe/blob/develop/src/Components/HCX/validators.ts

label={t("policy__insurer_name")}
error={error}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error={error}

@@ -133,6 +138,7 @@ const InsuranceDetailEditCard = ({
<TextFormField
required
name="policy_id"
error={error}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error={error}

@@ -125,6 +129,7 @@ const InsuranceDetailEditCard = ({
<TextFormField
required
name="subscriber_id"
error={error}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error={error}

}: {
policy: HCXPolicyModel;
handleUpdate: (event: FieldChangeEvent<unknown>) => void;
handleUpdates: (diffs: object) => void;
handleRemove: () => void;
gridView?: boolean;
error: FieldError;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error: FieldError;

@@ -91,12 +93,14 @@ const InsuranceDetailEditCard = ({
handleUpdates,
handleRemove,
gridView,
error,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error,

@@ -73,6 +74,7 @@ export default function InsuranceDetailsBuilder(props: Props) {
>
<InsuranceDetailEditCard
policy={policy}
error={props.error}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error={props.error}

@@ -15,6 +15,7 @@ import request from "../../Utils/request/request";
import routes from "../../Redux/api";
import { useTranslation } from "react-i18next";
import careConfig from "@careConfig";
import { FieldError } from "../Form/FieldValidators";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { FieldError } from "../Form/FieldValidators";

Comment on lines 145 to 149
console.log(error.response.data.detaillocal_ip_address);
// Notification.BadRequest({
// errs: error.response.data,
// });
// return error.response;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed?

@syedfardeenjeelani
Copy link
Contributor Author

Only validation logic in this file needs to be modified: https://github.com/ohcnetwork/care_fe/blob/develop/src/Components/HCX/validators.ts

hey @rithviknishad should it be something like this
if (!value.policy_id.trim()) {
return "some err message";
} else if (!value.subscriber_id.trim()) {
return "some err message";
}
if (enable_hcx) {
if (!value.insurer_id?.trim()) {
return "some err message";
} else if (!value.insurer_name?.trim()) {
return "some err message";
}
}

also do we only have to change this particular file and nothing else

@rithviknishad
Copy link
Member

also do we only have to change this particular file and nothing else

yes

@nihal467
Copy link
Member

nihal467 commented Oct 4, 2024

@rithviknishad can you verify is it ready for testing

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

texts to be in i18n locale files

https://github.com/ohcnetwork/care_fe#translations

@syedfardeenjeelani
Copy link
Contributor Author

texts to be in i18n locale files

https://github.com/ohcnetwork/care_fe#translations

@rithviknishad hello should i put them in common.json

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Oct 7, 2024
Copy link

github-actions bot commented Oct 7, 2024

👋 Hi, @syedfardeenjeelani,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@rithviknishad
Copy link
Member

Put in en.json

@syedfardeenjeelani
Copy link
Contributor Author

Put in en.json

okay

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Oct 16, 2024
Copy link

👋 Hi, @syedfardeenjeelani,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot added Deploy-Failed Deplyment is not showing preview and removed merge conflict pull requests with merge conflict labels Oct 16, 2024
@nihal467
Copy link
Member

nihal467 commented Oct 16, 2024

image
image

  • Even though the validation is added, it's not blocking the user from submitting a patient registration form when the insurance fields are kept blank

@nihal467 nihal467 added test failed and removed needs testing Deploy-Failed Deplyment is not showing preview labels Oct 16, 2024
@AdityaJ2305
Copy link
Contributor

Hey @syedfardeenjeelani , Please check by adding this line errors["insurance_details"] = insuranceDetailsError; in validateForm func in PatientRegister.tsx

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Oct 16, 2024
Copy link

👋 Hi, @syedfardeenjeelani,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@rithviknishad
Copy link
Member

@syedfardeenjeelani could you resolve the merge conflicts?

@rithviknishad
Copy link
Member

ensure the en.json file has keys sorted. pre-commit should do it for you if setup properly.

@github-actions github-actions bot added Deploy-Failed Deplyment is not showing preview and removed merge conflict pull requests with merge conflict labels Oct 17, 2024
@syedfardeenjeelani
Copy link
Contributor Author

@nihal467 please test this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the entire file having a change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-commit was not sorting keys for me so i used https://codeshack.io/json-sorter/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use npm run sort-locales instead; also why is pre-commit not sorting?

Copy link
Contributor Author

@syedfardeenjeelani syedfardeenjeelani Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will look into it @rithviknishad also can you please tell me if i should hard reset to commit f5a265172e499e4f4016be1453751680b7eb416b (fixed validation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes required Deploy-Failed Deplyment is not showing preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Validation for Insurance input fields in patient registration form
4 participants