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

Fixes Add Validation for Insurance Input Fields in Patient Registration Form #8672 #8836

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Components/HCX/validators.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { t } from "i18next";
import { FieldValidator } from "../Form/FieldValidators";
import { HCXPolicyModel } from "./models";

const HCXPolicyValidator: FieldValidator<HCXPolicyModel> = (
value,
enable_hcx,
) => {
if (
!value.policy_id.trim() ||
!value.subscriber_id.trim() ||
(enable_hcx && (!value.insurer_id?.trim() || !value.insurer_name?.trim()))
)
return "All fields are mandatory";
if (!value.subscriber_id.trim()) {
return t("member_id_required");
} else if (!value.policy_id.trim()) {
return t("policy_id_required");
}
if (enable_hcx) {
if (!value.insurer_id?.trim() || !value.insurer_name?.trim()) {
return t("insurer_name_required");
}
}
};

export default HCXPolicyValidator;
2 changes: 2 additions & 0 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ export const PatientRegister = (props: PatientRegisterProps) => {
.find((error) => !!error);
setInsuranceDetailsError(insuranceDetailsError);

errors["insurance_details"] = insuranceDetailsError;

Object.keys(form).forEach((field) => {
let phoneNumber, emergency_phone_number;
switch (field) {
Expand Down
3 changes: 3 additions & 0 deletions src/Locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@
"indicator": "Indicator",
"inidcator_event": "Indicator Event",
"instruction_on_titration": "Instruction on titration",
"insurer_name_required": "Insurer Name is required",
"international_mobile": "International Mobile",
"invalid_asset_id_msg": "Oops! The asset ID you entered does not appear to be valid.",
"invalid_email": "Please Enter a Valid Email Address",
Expand Down Expand Up @@ -808,6 +809,7 @@
"medicine_administration_history": "Medicine Administration History",
"medicines_administered": "Medicine(s) administered",
"medicines_administered_error": "Error administering medicine(s)",
"member_id_required": "Member Id is required",
"middleware_hostname": "Middleware Hostname",
"middleware_hostname_example": "e.g. example.ohc.network",
"middleware_hostname_sourced_from": "Middleware hostname sourced from {{ source }}",
Expand Down Expand Up @@ -967,6 +969,7 @@
"policy__policy_id__example": "POL001",
"policy__subscriber_id": "Member ID",
"policy__subscriber_id__example": "SUB001",
"policy_id_required": "Policy Id or Policy Name is required",
"position": "Position",
"post_your_comment": "Post Your Comment",
"powered_by": "Powered By",
Expand Down
Loading