diff --git a/app/actions/profileAction.js b/app/actions/profileAction.js
index 90df4ab..9b5871f 100644
--- a/app/actions/profileAction.js
+++ b/app/actions/profileAction.js
@@ -2,232 +2,232 @@
import { ApiRegistry } from "../apis.registry";
import config from "../config/config";
import {
- GET_PROFILE_ADDRESS_ERROR,
- GET_PROFILE_ADDRESS_LOADING,
- GET_PROFILE_ADDRESS_SUCCESS,
- GET_PROFILE_BASIC_ERROR,
- GET_PROFILE_BASIC_LOADING,
- GET_PROFILE_BASIC_SUCCESS,
- GET_PROFILE_EDUCATION_ERROR,
- GET_PROFILE_EDUCATION_LOADING,
- GET_PROFILE_EDUCATION_SUCCESS,
- GET_PROFILE_EXPERIENCE_ERROR,
- GET_PROFILE_EXPERIENCE_LOADING,
- GET_PROFILE_EXPERIENCE_SUCCESS,
- GET_PROFILE_REGISTRATION_ERROR,
- GET_PROFILE_REGISTRATION_LOADING,
- GET_PROFILE_REGISTRATION_SUCCESS
+ GET_PROFILE_ADDRESS_ERROR,
+ GET_PROFILE_ADDRESS_LOADING,
+ GET_PROFILE_ADDRESS_SUCCESS,
+ GET_PROFILE_BASIC_ERROR,
+ GET_PROFILE_BASIC_LOADING,
+ GET_PROFILE_BASIC_SUCCESS,
+ GET_PROFILE_EDUCATION_ERROR,
+ GET_PROFILE_EDUCATION_LOADING,
+ GET_PROFILE_EDUCATION_SUCCESS,
+ GET_PROFILE_EXPERIENCE_ERROR,
+ GET_PROFILE_EXPERIENCE_LOADING,
+ GET_PROFILE_EXPERIENCE_SUCCESS,
+ GET_PROFILE_REGISTRATION_ERROR,
+ GET_PROFILE_REGISTRATION_LOADING,
+ GET_PROFILE_REGISTRATION_SUCCESS
} from "../types/profileTypes";
// -- import { AUTHENTICATION_ERROR } from "../types/commonTypes";
let backendUrl = config.backendUrl;
export const getProfileBasic = (token) => {
- return (dispatch) => {
- dispatch({ type: GET_PROFILE_BASIC_LOADING });
- let newUrl = ApiRegistry.GET_PROFILE_BASIC_API;
-
- fetch(backendUrl + newUrl, {
- headers: {
- Accept : "application/json",
- Authorization : `Bearer ${token}`,
- "Content-Type": "application/json",
- },
- })
- .then((res) =>
- res.json().then((data) => {
- if (res.status === 200) {
- dispatch({
- message: data.message,
- payload: data,
- type : GET_PROFILE_BASIC_SUCCESS,
- });
- } else if (res.status === 403 || res.status === 401) {
- // -- dispatch({ type: "AUTHENTICATION_ERROR" });
- } else {
- dispatch({
- message: data.message,
- type : GET_PROFILE_BASIC_ERROR,
- });
- }
- })
- )
- .catch((err) => {
- // eslint-disable-next-line no-console
- console.error(err);
-
- dispatch({
- message: "Internal Error",
- type : GET_PROFILE_BASIC_ERROR,
- });
+ return (dispatch) => {
+ dispatch({ type: GET_PROFILE_BASIC_LOADING });
+ let newUrl = ApiRegistry.GET_PROFILE_BASIC_API;
+
+ fetch(backendUrl + newUrl, {
+ headers: {
+ Accept : "application/json",
+ Authorization : `Bearer ${token}`,
+ "Content-Type": "application/json",
+ },
+ })
+ .then((res) =>
+ res.json().then((data) => {
+ if (res.status === 200) {
+ dispatch({
+ message: data.message,
+ payload: data,
+ type : GET_PROFILE_BASIC_SUCCESS,
+ });
+ } else if (res.status === 403 || res.status === 401) {
+ // -- dispatch({ type: "AUTHENTICATION_ERROR" });
+ } else {
+ dispatch({
+ message: data.message,
+ type : GET_PROFILE_BASIC_ERROR,
});
- };
+ }
+ })
+ )
+ .catch((err) => {
+ // eslint-disable-next-line no-console
+ console.error(err);
+
+ dispatch({
+ message: "Internal Error",
+ type : GET_PROFILE_BASIC_ERROR,
+ });
+ });
+ };
};
export const getProfileRegistration = (token) => {
- return (dispatch) => {
- dispatch({ type: GET_PROFILE_REGISTRATION_LOADING });
- let newUrl = ApiRegistry.GET_PROFILE_REGISTRATION_API;
-
- fetch(backendUrl + newUrl, {
- headers: {
- Accept : "application/json",
- Authorization : `Bearer ${token}`,
- "Content-Type": "application/json",
- },
- })
- .then((res) =>
- res.json().then((data) => {
- if (res.status === 200) {
- dispatch({
- message: data.message,
- payload: data,
- type : GET_PROFILE_REGISTRATION_SUCCESS,
- });
- } else if (res.status === 403 || res.status === 401) {
- // -- dispatch({ type: "AUTHENTICATION_ERROR" });
- } else {
- dispatch({
- message: data.message,
- type : GET_PROFILE_REGISTRATION_ERROR,
- });
- }
- })
- )
- .catch((err) => {
- // eslint-disable-next-line no-console
- console.error(err);
-
- dispatch({
- message: "Internal Error",
- type : GET_PROFILE_REGISTRATION_ERROR,
- });
+ return (dispatch) => {
+ dispatch({ type: GET_PROFILE_REGISTRATION_LOADING });
+ let newUrl = ApiRegistry.GET_PROFILE_REGISTRATION_API;
+
+ fetch(backendUrl + newUrl, {
+ headers: {
+ Accept : "application/json",
+ Authorization : `Bearer ${token}`,
+ "Content-Type": "application/json",
+ },
+ })
+ .then((res) =>
+ res.json().then((data) => {
+ if (res.status === 200) {
+ dispatch({
+ message: data.message,
+ payload: data,
+ type : GET_PROFILE_REGISTRATION_SUCCESS,
});
- };
+ } else if (res.status === 403 || res.status === 401) {
+ // -- dispatch({ type: "AUTHENTICATION_ERROR" });
+ } else {
+ dispatch({
+ message: data.message,
+ type : GET_PROFILE_REGISTRATION_ERROR,
+ });
+ }
+ })
+ )
+ .catch((err) => {
+ // eslint-disable-next-line no-console
+ console.error(err);
+
+ dispatch({
+ message: "Internal Error",
+ type : GET_PROFILE_REGISTRATION_ERROR,
+ });
+ });
+ };
};
export const getProfileAddress = (token) => {
- return (dispatch) => {
- dispatch({ type: GET_PROFILE_ADDRESS_LOADING });
- let newUrl = ApiRegistry.GET_PROFILE_CLINIC_API;
-
- fetch(backendUrl + newUrl, {
- headers: {
- Accept : "application/json",
- Authorization : `Bearer ${token}`,
- "Content-Type": "application/json",
- },
- })
- .then((res) =>
- res.json().then((data) => {
- if (res.status === 200) {
- dispatch({
- message: data.message,
- payload: data,
- type : GET_PROFILE_ADDRESS_SUCCESS,
- });
- } else if (res.status === 403 || res.status === 401) {
- // -- dispatch({ type: "AUTHENTICATION_ERROR" });
- } else {
- dispatch({
- message: data.message,
- type : GET_PROFILE_ADDRESS_ERROR,
- });
- }
- })
- )
- .catch((err) => {
- // eslint-disable-next-line no-console
- console.error(err);
-
- dispatch({
- message: "Internal Error",
- type : GET_PROFILE_ADDRESS_ERROR,
- });
+ return (dispatch) => {
+ dispatch({ type: GET_PROFILE_ADDRESS_LOADING });
+ let newUrl = ApiRegistry.GET_PROFILE_CLINIC_API;
+
+ fetch(backendUrl + newUrl, {
+ headers: {
+ Accept : "application/json",
+ Authorization : `Bearer ${token}`,
+ "Content-Type": "application/json",
+ },
+ })
+ .then((res) =>
+ res.json().then((data) => {
+ if (res.status === 200) {
+ dispatch({
+ message: data.message,
+ payload: data,
+ type : GET_PROFILE_ADDRESS_SUCCESS,
+ });
+ } else if (res.status === 403 || res.status === 401) {
+ // -- dispatch({ type: "AUTHENTICATION_ERROR" });
+ } else {
+ dispatch({
+ message: data.message,
+ type : GET_PROFILE_ADDRESS_ERROR,
});
- };
+ }
+ })
+ )
+ .catch((err) => {
+ // eslint-disable-next-line no-console
+ console.error(err);
+
+ dispatch({
+ message: "Internal Error",
+ type : GET_PROFILE_ADDRESS_ERROR,
+ });
+ });
+ };
};
export const getProfileEducation = (token) => {
- return (dispatch) => {
- dispatch({ type: GET_PROFILE_EDUCATION_LOADING });
- let newUrl = ApiRegistry.GET_PROFILE_EDUCATION_API;
-
- fetch(backendUrl + newUrl, {
- headers: {
- Accept : "application/json",
- Authorization : `Bearer ${token}`,
- "Content-Type": "application/json",
- },
- })
- .then((res) =>
- res.json().then((data) => {
- if (res.status === 200) {
- dispatch({
- message: data.message,
- payload: data,
- type : GET_PROFILE_EDUCATION_SUCCESS,
- });
- } else if (res.status === 403 || res.status === 401) {
- // -- dispatch({ type: "AUTHENTICATION_ERROR" });
- } else {
- dispatch({
- message: data.message,
- type : GET_PROFILE_EDUCATION_ERROR,
- });
- }
- })
- )
- .catch((err) => {
- // eslint-disable-next-line no-console
- console.error(err);
-
- dispatch({
- message: "Internal Error",
- type : GET_PROFILE_EDUCATION_ERROR,
- });
+ return (dispatch) => {
+ dispatch({ type: GET_PROFILE_EDUCATION_LOADING });
+ let newUrl = ApiRegistry.GET_PROFILE_EDUCATION_API;
+
+ fetch(backendUrl + newUrl, {
+ headers: {
+ Accept : "application/json",
+ Authorization : `Bearer ${token}`,
+ "Content-Type": "application/json",
+ },
+ })
+ .then((res) =>
+ res.json().then((data) => {
+ if (res.status === 200) {
+ dispatch({
+ message: data.message,
+ payload: data,
+ type : GET_PROFILE_EDUCATION_SUCCESS,
});
- };
+ } else if (res.status === 403 || res.status === 401) {
+ // -- dispatch({ type: "AUTHENTICATION_ERROR" });
+ } else {
+ dispatch({
+ message: data.message,
+ type : GET_PROFILE_EDUCATION_ERROR,
+ });
+ }
+ })
+ )
+ .catch((err) => {
+ // eslint-disable-next-line no-console
+ console.error(err);
+
+ dispatch({
+ message: "Internal Error",
+ type : GET_PROFILE_EDUCATION_ERROR,
+ });
+ });
+ };
};
export const getProfileExperience = (token) => {
- return (dispatch) => {
- dispatch({ type: GET_PROFILE_EXPERIENCE_LOADING });
- let newUrl = ApiRegistry.GET_PROFILE_EXPERIENCE_API;
-
- fetch(backendUrl + newUrl, {
- headers: {
- Accept : "application/json",
- Authorization : `Bearer ${token}`,
- "Content-Type": "application/json",
- },
- })
- .then((res) =>
- res.json().then((data) => {
- if (res.status === 200) {
- dispatch({
- message: data.message,
- payload: data,
- type : GET_PROFILE_EXPERIENCE_SUCCESS,
- });
- } else if (res.status === 403 || res.status === 401) {
- // -- dispatch({ type: "AUTHENTICATION_ERROR" });
- } else {
- dispatch({
- message: data.message,
- type : GET_PROFILE_EXPERIENCE_ERROR,
- });
- }
- })
- )
- .catch((err) => {
- // eslint-disable-next-line no-console
- console.error(err);
-
- dispatch({
- message: "Internal Error",
- type : GET_PROFILE_EXPERIENCE_ERROR,
- });
+ return (dispatch) => {
+ dispatch({ type: GET_PROFILE_EXPERIENCE_LOADING });
+ let newUrl = ApiRegistry.GET_PROFILE_EXPERIENCE_API;
+
+ fetch(backendUrl + newUrl, {
+ headers: {
+ Accept : "application/json",
+ Authorization : `Bearer ${token}`,
+ "Content-Type": "application/json",
+ },
+ })
+ .then((res) =>
+ res.json().then((data) => {
+ if (res.status === 200) {
+ dispatch({
+ message: data.message,
+ payload: data,
+ type : GET_PROFILE_EXPERIENCE_SUCCESS,
+ });
+ } else if (res.status === 403 || res.status === 401) {
+ // -- dispatch({ type: "AUTHENTICATION_ERROR" });
+ } else {
+ dispatch({
+ message: data.message,
+ type : GET_PROFILE_EXPERIENCE_ERROR,
});
- };
+ }
+ })
+ )
+ .catch((err) => {
+ // eslint-disable-next-line no-console
+ console.error(err);
+
+ dispatch({
+ message: "Internal Error",
+ type : GET_PROFILE_EXPERIENCE_ERROR,
+ });
+ });
+ };
};
diff --git a/app/actions/test.action.js b/app/actions/test.action.js
index 9270e94..72da6cd 100644
--- a/app/actions/test.action.js
+++ b/app/actions/test.action.js
@@ -1,19 +1,19 @@
import { RESET_TEST, TEST_FAILURE, TEST_SUCCESS } from "../types/test.types";
export const testSuccess = () => {
- return (dispatch) => {
- dispatch({ type: TEST_SUCCESS });
- };
+ return (dispatch) => {
+ dispatch({ type: TEST_SUCCESS });
+ };
};
export const testFailure = () => {
- return (dispatch) => {
- dispatch({ type: TEST_FAILURE });
- };
+ return (dispatch) => {
+ dispatch({ type: TEST_FAILURE });
+ };
};
export const resetTest = () => {
- return (dispatch) => {
- dispatch({ type: RESET_TEST });
- };
+ return (dispatch) => {
+ dispatch({ type: RESET_TEST });
+ };
};
diff --git a/app/apis.registry.js b/app/apis.registry.js
index d35a3bb..a9562bc 100644
--- a/app/apis.registry.js
+++ b/app/apis.registry.js
@@ -1,11 +1,11 @@
export const ApiRegistry = {
- GET_PROFILE_BASIC_API : "/business/individual/ProfileBasic",
- GET_PROFILE_CLINIC_API : "/business/all/ProfileClinic",
- GET_PROFILE_EDUCATION_API : "/business/all/ProfileEducation",
- GET_PROFILE_EXPERIENCE_API : "/business/all/ProfileExperience",
- GET_PROFILE_REGISTRATION_API: "/rx/registrationInfo",
- PROFILE_COMPLETENESS_API:
+ GET_PROFILE_BASIC_API : "/business/individual/ProfileBasic",
+ GET_PROFILE_CLINIC_API : "/business/all/ProfileClinic",
+ GET_PROFILE_EDUCATION_API : "/business/all/ProfileEducation",
+ GET_PROFILE_EXPERIENCE_API : "/business/all/ProfileExperience",
+ GET_PROFILE_REGISTRATION_API: "/rx/registrationInfo",
+ PROFILE_COMPLETENESS_API:
"/business/individual/ProfileCompleteness",
- PROFILE_COMPLETENESS_CHECKLIST_API:
+ PROFILE_COMPLETENESS_CHECKLIST_API:
"/business/individual/MasterData",
};
diff --git a/app/components.registry.js b/app/components.registry.js
index 8e78463..ba4719c 100644
--- a/app/components.registry.js
+++ b/app/components.registry.js
@@ -13,17 +13,17 @@ import RegistrationCard from "./components/registration/RegistrationCard";
import UserProfile from "./components/UserProfile";
export const ComponentsRegistry = {
- BasicInfoCard : { comp: BasicInfoCard },
- ProfileBasicSkeleton : { comp: ProfileBasicSkeleton },
- ProfileClinicSkeleton : { comp: ProfileClinicSkeleton },
- ProfileContactSkeleton : { comp: ProfileContactSkeleton },
- ProfileEducationSkeleton : { comp: ProfileEducationSkeleton },
- ProfileExperienceSkeleton : { comp: ProfileExperienceSkeleton },
- ProfileRegistrationSkeleton: { comp: ProfileRegistrationSkeleton },
- UserProfile : { comp: UserProfile },
- clinicCard : { comp: ClinicCard },
- contactInfoCard : { comp: ContactInfoCard },
- educationCard : { comp: EducationCard },
- experienceCard : { comp: ExperienceCard },
- registrationCard : { comp: RegistrationCard }
+ BasicInfoCard : { comp: BasicInfoCard },
+ ProfileBasicSkeleton : { comp: ProfileBasicSkeleton },
+ ProfileClinicSkeleton : { comp: ProfileClinicSkeleton },
+ ProfileContactSkeleton : { comp: ProfileContactSkeleton },
+ ProfileEducationSkeleton : { comp: ProfileEducationSkeleton },
+ ProfileExperienceSkeleton : { comp: ProfileExperienceSkeleton },
+ ProfileRegistrationSkeleton: { comp: ProfileRegistrationSkeleton },
+ UserProfile : { comp: UserProfile },
+ clinicCard : { comp: ClinicCard },
+ contactInfoCard : { comp: ContactInfoCard },
+ educationCard : { comp: EducationCard },
+ experienceCard : { comp: ExperienceCard },
+ registrationCard : { comp: RegistrationCard }
};
diff --git a/app/components/ModuleComponent.js b/app/components/ModuleComponent.js
index 0734331..f339331 100644
--- a/app/components/ModuleComponent.js
+++ b/app/components/ModuleComponent.js
@@ -3,9 +3,9 @@ import { CoreBox, CoreClasses, CoreTypographyBody1 } from "@wrappid/core";
import ModuleClasses from "../styles/ModuleClasses";
export default function ModuleComponent() {
- return (
-
- ModuleComponent
-
- );
+ return (
+
+ ModuleComponent
+
+ );
}
diff --git a/app/components/ProfileCompletenessCard.js b/app/components/ProfileCompletenessCard.js
index 966ba3e..f02664d 100644
--- a/app/components/ProfileCompletenessCard.js
+++ b/app/components/ProfileCompletenessCard.js
@@ -1,273 +1,273 @@
import React from "react";
import {
- HTTP,
- apiRequestAction,
- coreUseNavigate,
- CoreClasses,
- CoreChip,
- CoreDivider,
- CoreIcon,
- CoreTypographyBody2,
- CoreCircularProgress,
- CoreContainedButton,
- CoreIconButton,
- CoreBox,
- CoreCard,
- CoreCardContent,
- CoreCardHeader,
- WEB_PLATFORM,
- detectPlatform,
- CoreAvatar
+ HTTP,
+ apiRequestAction,
+ coreUseNavigate,
+ CoreClasses,
+ CoreChip,
+ CoreDivider,
+ CoreIcon,
+ CoreTypographyBody2,
+ CoreCircularProgress,
+ CoreContainedButton,
+ CoreIconButton,
+ CoreBox,
+ CoreCard,
+ CoreCardContent,
+ CoreCardHeader,
+ WEB_PLATFORM,
+ detectPlatform,
+ CoreAvatar
} from "@wrappid/core";
import { useDispatch, useSelector } from "react-redux";
import { ApiRegistry } from "../apis.registry";
import { RoutesRegistry } from "../routes.registry";
import {
- PROFILE_COMPLETENESS_CHECKLIST_ERROR,
- PROFILE_COMPLETENESS_CHECKLIST_SUCCESS,
- PROFILE_COMPLETENESS_ERROR,
- PROFILE_COMPLETENESS_RELOAD,
- PROFILE_COMPLETENESS_REPORT_UPDATE,
- PROFILE_COMPLETENESS_SUCCESS
+ PROFILE_COMPLETENESS_CHECKLIST_ERROR,
+ PROFILE_COMPLETENESS_CHECKLIST_SUCCESS,
+ PROFILE_COMPLETENESS_ERROR,
+ PROFILE_COMPLETENESS_RELOAD,
+ PROFILE_COMPLETENESS_REPORT_UPDATE,
+ PROFILE_COMPLETENESS_SUCCESS
} from "../types/profileTypes";
// -- import { getLabel } from "../../utils/stringUtils";
export const PROFILE_COMPLETENESS = "pc_";
export default function ProfileCompletenessCard() {
- const dispatch = useDispatch();
- const navigate = coreUseNavigate();
- const auth = useSelector((state) => state.auth);
- const { uid = undefined, role } = auth;
- const { completeness } = useSelector((state) => state.profile);
- const {
- reload = true,
- success = false,
- error = false,
- checklist,
- data,
- report = {
- missingData : {},
- providedData: {},
- quotient : 0
- }
- } = completeness || {};
+ const dispatch = useDispatch();
+ const navigate = coreUseNavigate();
+ const auth = useSelector((state) => state.auth);
+ const { uid = undefined, role } = auth;
+ const { completeness } = useSelector((state) => state.profile);
+ const {
+ reload = true,
+ success = false,
+ error = false,
+ checklist,
+ data,
+ report = {
+ missingData : {},
+ providedData: {},
+ quotient : 0
+ }
+ } = completeness || {};
- const [cardOpen, setCardOpen] = React.useState(true);
+ const [cardOpen, setCardOpen] = React.useState(true);
- // platform detection
- // eslint-disable-next-line no-unused-vars
- const [platform, setPlatform] = React.useState(WEB_PLATFORM);
+ // platform detection
+ // eslint-disable-next-line no-unused-vars
+ const [platform, setPlatform] = React.useState(WEB_PLATFORM);
- React.useEffect(() => {
- setPlatform(detectPlatform());
- }, []);
+ React.useEffect(() => {
+ setPlatform(detectPlatform());
+ }, []);
- React.useEffect(() => {
- if (!checklist || Object.keys(checklist)?.length === 0) {
- dispatch(
- apiRequestAction(
- HTTP.GET,
- ApiRegistry.PROFILE_COMPLETENESS_CHECKLIST_API,
- true,
- {
- _defaultFilter: encodeURIComponent(
- JSON.stringify({ name: PROFILE_COMPLETENESS + role?.role })
- )
- },
- PROFILE_COMPLETENESS_CHECKLIST_SUCCESS,
- PROFILE_COMPLETENESS_CHECKLIST_ERROR
- )
- );
- }
- }, [role]);
+ React.useEffect(() => {
+ if (!checklist || Object.keys(checklist)?.length === 0) {
+ dispatch(
+ apiRequestAction(
+ HTTP.GET,
+ ApiRegistry.PROFILE_COMPLETENESS_CHECKLIST_API,
+ true,
+ {
+ _defaultFilter: encodeURIComponent(
+ JSON.stringify({ name: PROFILE_COMPLETENESS + role?.role })
+ )
+ },
+ PROFILE_COMPLETENESS_CHECKLIST_SUCCESS,
+ PROFILE_COMPLETENESS_CHECKLIST_ERROR
+ )
+ );
+ }
+ }, [role]);
- const getProfileData = () => {
- if (
- success &&
+ const getProfileData = () => {
+ if (
+ success &&
checklist &&
Object.keys(checklist)?.length > 0 &&
uid &&
uid > 0
- ) {
- dispatch(
- apiRequestAction(
- HTTP.GET,
- ApiRegistry.PROFILE_COMPLETENESS_API,
- true,
- { _defaultFilter: encodeURIComponent(JSON.stringify({ id: uid })) },
- PROFILE_COMPLETENESS_SUCCESS,
- PROFILE_COMPLETENESS_ERROR
- )
- );
- }
- };
+ ) {
+ dispatch(
+ apiRequestAction(
+ HTTP.GET,
+ ApiRegistry.PROFILE_COMPLETENESS_API,
+ true,
+ { _defaultFilter: encodeURIComponent(JSON.stringify({ id: uid })) },
+ PROFILE_COMPLETENESS_SUCCESS,
+ PROFILE_COMPLETENESS_ERROR
+ )
+ );
+ }
+ };
- React.useEffect(() => {
- if (success && checklist) {
- dispatch({ type: PROFILE_COMPLETENESS_RELOAD });
- }
- }, []);
+ React.useEffect(() => {
+ if (success && checklist) {
+ dispatch({ type: PROFILE_COMPLETENESS_RELOAD });
+ }
+ }, []);
- React.useEffect(() => {
- getProfileData();
- }, [checklist, reload]);
+ React.useEffect(() => {
+ getProfileData();
+ }, [checklist, reload]);
- React.useEffect(() => {
- if (
- success &&
+ React.useEffect(() => {
+ if (
+ success &&
checklist &&
Object.keys(checklist)?.length > 0 &&
data &&
Object.keys(data)?.length > 0
- ) {
- let completenessQuotient = 0;
+ ) {
+ let completenessQuotient = 0;
- let missingData = {};
+ let missingData = {};
- let providedData = {};
+ let providedData = {};
- if (success) {
- // api call success
- if (checklist && Object.keys(checklist)?.length > 0) {
- if (Object.keys(data)?.length > 0) {
- Object.keys(checklist)?.forEach((checklistKey) => {
- let exist = Object.keys(data)?.filter((key) => {
- return key?.endsWith(checklistKey) && data[key];
- })[0];
+ if (success) {
+ // api call success
+ if (checklist && Object.keys(checklist)?.length > 0) {
+ if (Object.keys(data)?.length > 0) {
+ Object.keys(checklist)?.forEach((checklistKey) => {
+ let exist = Object.keys(data)?.filter((key) => {
+ return key?.endsWith(checklistKey) && data[key];
+ })[0];
- if (exist) {
- completenessQuotient += checklist[checklistKey];
- providedData[checklistKey] = checklist[checklistKey];
- } else {
- missingData[checklistKey] = checklist[checklistKey];
- }
- });
- }
- }
- if (report?.quotient !== completenessQuotient) {
- // update profile completeness report
- dispatch({
- payload: {
- missingData : { ...missingData },
- providedData: { ...providedData },
- quotient : completenessQuotient
- },
- type: PROFILE_COMPLETENESS_REPORT_UPDATE
- });
- }
+ if (exist) {
+ completenessQuotient += checklist[checklistKey];
+ providedData[checklistKey] = checklist[checklistKey];
+ } else {
+ missingData[checklistKey] = checklist[checklistKey];
+ }
+ });
+ }
+ }
+ if (report?.quotient !== completenessQuotient) {
+ // update profile completeness report
+ dispatch({
+ payload: {
+ missingData : { ...missingData },
+ providedData: { ...providedData },
+ quotient : completenessQuotient
+ },
+ type: PROFILE_COMPLETENESS_REPORT_UPDATE
+ });
+ }
- if (completenessQuotient === 100) {
- setCardOpen(false);
- }
- } else if (error) {
- // api call failure
- }
+ if (completenessQuotient === 100) {
+ setCardOpen(false);
}
- }, [completeness]);
+ } else if (error) {
+ // api call failure
+ }
+ }
+ }, [completeness]);
- return (
- <>
- {cardOpen && !(completeness?.report?.quotient === 100) && (
-
-
- }
- title="Setup your Rxefy account"
- subheader="You still have information missing on your profile"
- action={
- {
- setCardOpen(false);
- }}
- >
- clear
-
- }
- />
+ return (
+ <>
+ {cardOpen && !(completeness?.report?.quotient === 100) && (
+
+
+ }
+ title="Setup your Rxefy account"
+ subheader="You still have information missing on your profile"
+ action={
+ {
+ setCardOpen(false);
+ }}
+ >
+ clear
+
+ }
+ />
-
+
-
-
+
+
Missing Information:
-
+
- {Object.keys(report?.missingData)?.map((data, index) => {
- return (
-
-
- }
- label={data}
- size="small"
- />
-
- );
- })}
+ {Object.keys(report?.missingData)?.map((data, index) => {
+ return (
+
+
+ }
+ label={data}
+ size="small"
+ />
+
+ );
+ })}
-
+
-
+
Provided Information:
-
+
- {Object.keys(report?.providedData)?.map((data, index) => {
- return (
-
-
- }
- label={data}
- size="small"
- />
-
- );
- })}
+ {Object.keys(report?.providedData)?.map((data, index) => {
+ return (
+
+
+ }
+ label={data}
+ size="small"
+ />
+
+ );
+ })}
-
- {
- navigate(`/${RoutesRegistry.PROFILE}`);
- }}
- />
-
-
-
- )}
- >
- );
+
+ {
+ navigate(`/${RoutesRegistry.PROFILE}`);
+ }}
+ />
+
+
+
+ )}
+ >
+ );
}
diff --git a/app/components/basicInfo/BasicInfoCard.js b/app/components/basicInfo/BasicInfoCard.js
index 3e622af..3eb98aa 100644
--- a/app/components/basicInfo/BasicInfoCard.js
+++ b/app/components/basicInfo/BasicInfoCard.js
@@ -1,95 +1,95 @@
import {
- CoreAvatar,
- CoreH6,
- CoreTypographyBody1,
- CoreTypographyCaption,
- CoreBox,
- CoreGrid,
- CoreClasses,
- getFullName,
- CoreIconText,
- __IconTypes,
- CoreStack
+ CoreAvatar,
+ CoreH6,
+ CoreTypographyBody1,
+ CoreTypographyCaption,
+ CoreBox,
+ CoreGrid,
+ CoreClasses,
+ getFullName,
+ CoreIconText,
+ __IconTypes,
+ CoreStack
} from "@wrappid/core";
import { useSelector } from "react-redux";
import { getAge /**, getFullName */ } from "../utils/helper";
export default function BasicInfoCard(props) {
- const {
- firstName, middleName, lastName, gender, dob, bio, photo
- } = props;
-
- const getGender = (gender, iconFlag = false) => {
- let genderTmp = "unknown";
-
- if (typeof gender === "string") {
- genderTmp = gender.toLowerCase();
- } else if (typeof gender === "object") {
- genderTmp = (gender?.id || gender?.label || "unknown").toLowerCase();
- } else {
- genderTmp = "unknown";
- }
-
- if (!iconFlag) {
- return genderTmp && genderTmp.trim() !== ""
- ? genderTmp
- .replace(/\w\S*/g, function (txt) {
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
- })
- : "N/A";
- }
-
- switch (genderTmp) {
- case "male":
- return "male";
-
- case "female":
- return "female";
-
- default:
- return "question_mark";
- }
- };
-
- const degrees = useSelector((state) => state?.profile?.registration?.degrees);
-
- return (
-
-
-
-
-
-
- {getFullName({ firstName, lastName, middleName })}
-
- {/* Display degrees */}
- {degrees}
-
-
+ const {
+ firstName, middleName, lastName, gender, dob, bio, photo
+ } = props;
+
+ const getGender = (gender, iconFlag = false) => {
+ let genderTmp = "unknown";
+
+ if (typeof gender === "string") {
+ genderTmp = gender.toLowerCase();
+ } else if (typeof gender === "object") {
+ genderTmp = (gender?.id || gender?.label || "unknown").toLowerCase();
+ } else {
+ genderTmp = "unknown";
+ }
+
+ if (!iconFlag) {
+ return genderTmp && genderTmp.trim() !== ""
+ ? genderTmp
+ .replace(/\w\S*/g, function (txt) {
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
+ })
+ : "N/A";
+ }
+
+ switch (genderTmp) {
+ case "male":
+ return "male";
+
+ case "female":
+ return "female";
+
+ default:
+ return "question_mark";
+ }
+ };
+
+ const degrees = useSelector((state) => state?.profile?.registration?.degrees);
+
+ return (
+
+
+
+
+
+
+ {getFullName({ firstName, lastName, middleName })}
+
+ {/* Display degrees */}
+ {degrees}
+
+
-
+
- {" | "}
+ {" | "}
-
+
-
-
+
+
-
- {bio}
-
-
- );
+
+ {bio}
+
+
+ );
}
diff --git a/app/components/basicInfo/ProfileBasicSkeleton.js b/app/components/basicInfo/ProfileBasicSkeleton.js
index fe1a9b0..bbf27cd 100644
--- a/app/components/basicInfo/ProfileBasicSkeleton.js
+++ b/app/components/basicInfo/ProfileBasicSkeleton.js
@@ -1,24 +1,24 @@
import { CoreSkeleton, CoreBox, CoreGrid, CoreClasses } from "@wrappid/core";
export default function ProfileBasicSkeleton() {
- return (
-
-
-
-
+ return (
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
- );
+
+
+
+
+ );
}
diff --git a/app/components/clinic/ClinicCard.js b/app/components/clinic/ClinicCard.js
index 18a0372..a5f95c3 100644
--- a/app/components/clinic/ClinicCard.js
+++ b/app/components/clinic/ClinicCard.js
@@ -1,72 +1,72 @@
import {
- CoreAvatar,
- CoreClasses,
- CoreIconText,
- __IconTypes,
- CoreGrid,
- CoreBox,
- CoreH6
+ CoreAvatar,
+ CoreClasses,
+ CoreIconText,
+ __IconTypes,
+ CoreGrid,
+ CoreBox,
+ CoreH6
} from "@wrappid/core";
export default function ClinicCard(props) {
- const {
- clinicLogo,
- fullName,
- phone,
- addLine1,
- addLine2,
- country,
- state,
- district,
- city,
- pin,
- landmark,
- } = props;
+ const {
+ clinicLogo,
+ fullName,
+ phone,
+ addLine1,
+ addLine2,
+ country,
+ state,
+ district,
+ city,
+ pin,
+ landmark,
+ } = props;
- const addressComponents = [];
+ const addressComponents = [];
- if (addLine1) addressComponents.push(addLine1);
- if (addLine2) addressComponents.push(addLine2);
- if (city) addressComponents.push(city);
- if (district) addressComponents.push(district);
- if (state) addressComponents.push(state);
- if (pin) addressComponents.push(`Pin-${pin}`);
- if (country) addressComponents.push(country);
- if (landmark) addressComponents.push(`Landmark: ${landmark}`);
+ if (addLine1) addressComponents.push(addLine1);
+ if (addLine2) addressComponents.push(addLine2);
+ if (city) addressComponents.push(city);
+ if (district) addressComponents.push(district);
+ if (state) addressComponents.push(state);
+ if (pin) addressComponents.push(`Pin-${pin}`);
+ if (country) addressComponents.push(country);
+ if (landmark) addressComponents.push(`Landmark: ${landmark}`);
- const formattedAddress = addressComponents.join(", ");
+ const formattedAddress = addressComponents.join(", ");
- const googleMapsUrl = `https://www.google.com/maps/place/${encodeURIComponent(
- formattedAddress
- )}`;
+ const googleMapsUrl = `https://www.google.com/maps/place/${encodeURIComponent(
+ formattedAddress
+ )}`;
- return (
-
-
+ return (
+
+
-
- {fullName}
+
+ {fullName}
-
+
-
-
-
- );
+
+
+
+ );
}
diff --git a/app/components/clinic/ProfileClinicSkeleton.js b/app/components/clinic/ProfileClinicSkeleton.js
index d5febac..ac4f2e7 100644
--- a/app/components/clinic/ProfileClinicSkeleton.js
+++ b/app/components/clinic/ProfileClinicSkeleton.js
@@ -1,24 +1,24 @@
import { CoreSkeleton, CoreBox, CoreGrid, CoreClasses } from "@wrappid/core";
export default function ProfileClinicSkeleton() {
- return (
-
-
-
-
+ return (
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
- );
+
+
+
+
+ );
}
diff --git a/app/components/contactInfo/ContactInfoCard.js b/app/components/contactInfo/ContactInfoCard.js
index f880695..51e5f1b 100644
--- a/app/components/contactInfo/ContactInfoCard.js
+++ b/app/components/contactInfo/ContactInfoCard.js
@@ -1,71 +1,71 @@
import {
- CoreIcon,
- CoreLabel,
- CoreTypographyBody1,
- CoreIconButton,
- CoreBox,
- CoreGrid,
- CoreCardHeader,
- CoreClasses,
- coreUseNavigate,
- CorePhoneLink,
- CoreEmailLink
+ CoreIcon,
+ CoreLabel,
+ CoreTypographyBody1,
+ CoreIconButton,
+ CoreBox,
+ CoreGrid,
+ CoreCardHeader,
+ CoreClasses,
+ coreUseNavigate,
+ CorePhoneLink,
+ CoreEmailLink
} from "@wrappid/core";
import { useSelector } from "react-redux";
export default function ContactInfoCard(props) {
- const navigate = coreUseNavigate();
- const contactInfo = useSelector((state) => state.profile.contact);
- const { phoneVerified, emailVerified } = contactInfo;
- // eslint-disable-next-line no-unused-vars
- const { phone, email, profileLink, website } = props;
+ const navigate = coreUseNavigate();
+ const contactInfo = useSelector((state) => state.profile.contact);
+ const { phoneVerified, emailVerified } = contactInfo;
+ // eslint-disable-next-line no-unused-vars
+ const { phone, email, profileLink, website } = props;
- return (
- <>
-
+ return (
+ <>
+
Contact Info
-
- }
- action={
- {
- navigate("/settings#account");
- }}
- >
- edit_note
-
- }
- />
+
+ }
+ action={
+ {
+ navigate("/settings#account");
+ }}
+ >
+ edit_note
+
+ }
+ />
-
-
- Primary Phone
+
+
+ Primary Phone
-
-
+
+
-
- Primary Email
+
+ Primary Email
-
-
+
+
- {/**
+ {/**
* @todo Removing as of now for quick release
*/}
- {/* --
@@ -102,7 +102,7 @@ export default function ContactInfoCard(props) {
*/}
-
- >
- );
+
+ >
+ );
}
diff --git a/app/components/contactInfo/ProfileContactSkeleton.js b/app/components/contactInfo/ProfileContactSkeleton.js
index 01a0f84..040e8e6 100644
--- a/app/components/contactInfo/ProfileContactSkeleton.js
+++ b/app/components/contactInfo/ProfileContactSkeleton.js
@@ -1,15 +1,15 @@
import { CoreSkeleton, CoreBox, CoreGrid } from "@wrappid/core";
export default function ProfileContactSkeleton() {
- return (
-
-
-
-
+ return (
+
+
+
+
-
-
-
-
- );
+
+
+
+
+ );
}
diff --git a/app/components/education/EducationCard.js b/app/components/education/EducationCard.js
index 04b601c..24c70e4 100644
--- a/app/components/education/EducationCard.js
+++ b/app/components/education/EducationCard.js
@@ -1,30 +1,30 @@
import {
- CoreTypographyBody1, CoreTypographyBody2, CoreTypographySubtitle2, CoreCardHeader, viewFormattedDate, CoreClasses, CoreStack
+ CoreTypographyBody1, CoreTypographyBody2, CoreTypographySubtitle2, CoreCardHeader, viewFormattedDate, CoreClasses, CoreStack
} from "@wrappid/core";
export default function EducationCard(props) {
- const {
- degree, school, location, board, startDate, endDate
- } = props;
+ const {
+ degree, school, location, board, startDate, endDate
+ } = props;
- return (
-
- {degree}
-
- }
- subheader={
-
- {school}
+ return (
+
+ {degree}
+
+ }
+ subheader={
+
+ {school}
- {board + ", " + location}
+ {board + ", " + location}
-
- {viewFormattedDate(startDate) + " - " + viewFormattedDate(endDate, "endDate")}
-
-
- }
- />
- );
+
+ {viewFormattedDate(startDate) + " - " + viewFormattedDate(endDate, "endDate")}
+
+
+ }
+ />
+ );
}
diff --git a/app/components/education/ProfileEducationSkeleton.js b/app/components/education/ProfileEducationSkeleton.js
index 24c9ade..8753cd1 100644
--- a/app/components/education/ProfileEducationSkeleton.js
+++ b/app/components/education/ProfileEducationSkeleton.js
@@ -1,5 +1,5 @@
import { CoreSkeleton } from "@wrappid/core";
export default function ProfileEducationSkeleton() {
- return ;
+ return ;
}
diff --git a/app/components/experience/ExperienceCard.js b/app/components/experience/ExperienceCard.js
index cbb4f36..4dd1da1 100644
--- a/app/components/experience/ExperienceCard.js
+++ b/app/components/experience/ExperienceCard.js
@@ -1,35 +1,35 @@
import {
- CoreTypographyBody1,
- CoreCardHeader,
- viewFormattedDate,
- CoreTypographyBody2,
- CoreTypographySubtitle2,
- CoreClasses,
- CoreStack
+ CoreTypographyBody1,
+ CoreCardHeader,
+ viewFormattedDate,
+ CoreTypographyBody2,
+ CoreTypographySubtitle2,
+ CoreClasses,
+ CoreStack
} from "@wrappid/core";
export default function ExperienceCard(props) {
- const { designation, organization, location, startDate, endDate } = props;
+ const { designation, organization, location, startDate, endDate } = props;
- return (
-
- {designation}
- >
- }
- subheader={
-
- {organization}
+ return (
+
+ {designation}
+ >
+ }
+ subheader={
+
+ {organization}
- {location}
+ {location}
-
+
- {viewFormattedDate(startDate) + " - " + viewFormattedDate(endDate, "endDate")}
-
-
- }
- />
- );
+ {viewFormattedDate(startDate) + " - " + viewFormattedDate(endDate, "endDate")}
+
+
+ }
+ />
+ );
}
diff --git a/app/components/experience/ProfileExperienceSkeleton.js b/app/components/experience/ProfileExperienceSkeleton.js
index 7d6321d..8109d5c 100644
--- a/app/components/experience/ProfileExperienceSkeleton.js
+++ b/app/components/experience/ProfileExperienceSkeleton.js
@@ -1,9 +1,9 @@
import { CoreSkeleton } from "@wrappid/core";
export default function ProfileExperienceSkeleton() {
- return (
- <>
-
- >
- );
+ return (
+ <>
+
+ >
+ );
}
diff --git a/app/components/registration/ProfileRegistrationSkeleton.js b/app/components/registration/ProfileRegistrationSkeleton.js
index 2500c26..2efda46 100644
--- a/app/components/registration/ProfileRegistrationSkeleton.js
+++ b/app/components/registration/ProfileRegistrationSkeleton.js
@@ -1,17 +1,17 @@
import { CoreSkeleton } from "@wrappid/core";
export default function ProfileRegistrationSkeleton() {
- return (
- <>
-
+ return (
+ <>
+
-
+
-
+
-
+
-
- >
- );
+
+ >
+ );
}
diff --git a/app/components/registration/RegistrationCard.js b/app/components/registration/RegistrationCard.js
index 1a422c6..2dbccbc 100644
--- a/app/components/registration/RegistrationCard.js
+++ b/app/components/registration/RegistrationCard.js
@@ -1,56 +1,56 @@
import {
- CoreLabel,
- CoreTypographyBody2,
- CoreGrid,
- CoreLink
+ CoreLabel,
+ CoreTypographyBody2,
+ CoreGrid,
+ CoreLink
} from "@wrappid/core";
import { useSelector } from "react-redux";
export default function RegistrationCard(props) {
- const {
- regNo = "",
- regDate = "",
- degrees = "",
- departmentId,
- registrationDocument = "",
- } = props;
+ const {
+ regNo = "",
+ regDate = "",
+ degrees = "",
+ departmentId,
+ registrationDocument = "",
+ } = props;
- const departments = useSelector(state => state?.common?.departments);
+ const departments = useSelector(state => state?.common?.departments);
- // eslint-disable-next-line no-console
- console.log("PROFILE REGISTRAION CARD", props);
+ // eslint-disable-next-line no-console
+ console.log("PROFILE REGISTRAION CARD", props);
- return (
-
- Specialization
+ return (
+
+ Specialization
-
- {departments?.find(dept => dept?.id === departmentId)?.name || "Not Given"}
-
+
+ {departments?.find(dept => dept?.id === departmentId)?.name || "Not Given"}
+
- Degrees
+ Degrees
-
- {degrees || "Not given"}
-
+
+ {degrees || "Not given"}
+
- Registration Number
+ Registration Number
- {regNo || "Not given"}
+ {regNo || "Not given"}
- Registration Date
+ Registration Date
-
- {regDate ? regDate : "Not given"}
-
+
+ {regDate ? regDate : "Not given"}
+
- Registration Document
+ Registration Document
- {registrationDocument ? (
- Download
- ) : (
- {"Not given"}
- )}
-
- );
+ {registrationDocument ? (
+ Download
+ ) : (
+ {"Not given"}
+ )}
+
+ );
}
diff --git a/app/components/utils/helper.js b/app/components/utils/helper.js
index a029c1e..726788c 100644
--- a/app/components/utils/helper.js
+++ b/app/components/utils/helper.js
@@ -1,88 +1,88 @@
export function getAge(birthDate) {
- let dob = new Date(birthDate);
+ let dob = new Date(birthDate);
- //extract the year, month, and date from date input
- let dobYear = dob.getYear();
+ //extract the year, month, and date from date input
+ let dobYear = dob.getYear();
- let dobMonth = dob.getMonth();
+ let dobMonth = dob.getMonth();
- let dobDate = dob.getDate();
+ let dobDate = dob.getDate();
- //get the current date from the system
- let now = new Date();
+ //get the current date from the system
+ let now = new Date();
- //extract the year, month, and date from current date
- let currentYear = now.getYear();
+ //extract the year, month, and date from current date
+ let currentYear = now.getYear();
- let currentMonth = now.getMonth();
+ let currentMonth = now.getMonth();
- let currentDate = now.getDate();
+ let currentDate = now.getDate();
- //declare a variable to collect the age in year, month, and days
- let age = {};
+ //declare a variable to collect the age in year, month, and days
+ let age = {};
- let dateAge = 0;
+ let dateAge = 0;
- let monthAge = 0;
+ let monthAge = 0;
- //get years
- let yearAge = currentYear - dobYear;
+ //get years
+ let yearAge = currentYear - dobYear;
- //get months
- if (currentMonth >= dobMonth) {
+ //get months
+ if (currentMonth >= dobMonth) {
//get months when current month is greater
- monthAge = currentMonth - dobMonth;
- } else {
- yearAge--;
- monthAge = 12 + currentMonth - dobMonth;
- }
-
- //get days
- if (currentDate >= dobDate) {
+ monthAge = currentMonth - dobMonth;
+ } else {
+ yearAge--;
+ monthAge = 12 + currentMonth - dobMonth;
+ }
+
+ //get days
+ if (currentDate >= dobDate) {
//get days when the current date is greater
- dateAge = currentDate - dobDate;
- } else {
- monthAge--;
- dateAge = 31 + currentDate - dobDate;
-
- if (monthAge < 0) {
- monthAge = 11;
- yearAge--;
- }
+ dateAge = currentDate - dobDate;
+ } else {
+ monthAge--;
+ dateAge = 31 + currentDate - dobDate;
+
+ if (monthAge < 0) {
+ monthAge = 11;
+ yearAge--;
}
- //group the age in a single variable
- age = {
- days : dateAge,
- months: monthAge,
- years : yearAge,
- };
-
- let ageString = "";
-
+ }
+ //group the age in a single variable
+ age = {
+ days : dateAge,
+ months: monthAge,
+ years : yearAge,
+ };
+
+ let ageString = "";
+
+ if (age.years > 0) {
+ ageString = age.years + " year";
if (age.years > 0) {
- ageString = age.years + " year";
- if (age.years > 0) {
- ageString += "s";
- }
+ ageString += "s";
}
- if (age.months > 0) {
- if (ageString) ageString += ", ";
- ageString += age.months + " month";
- if (age.months > 1) {
- ageString += "s";
- }
+ }
+ if (age.months > 0) {
+ if (ageString) ageString += ", ";
+ ageString += age.months + " month";
+ if (age.months > 1) {
+ ageString += "s";
}
-
- //show days only if year is 0 (zero)
- if (age.years > 0 === false) {
- if (age.days > 0) {
- if (ageString) ageString += ", ";
- ageString += age.days + " day";
- if (age.days > 1) {
- ageString += "s";
- }
- }
+ }
+
+ //show days only if year is 0 (zero)
+ if (age.years > 0 === false) {
+ if (age.days > 0) {
+ if (ageString) ageString += ", ";
+ ageString += age.days + " day";
+ if (age.days > 1) {
+ ageString += "s";
+ }
}
- //return the calculated age
- return ageString && ageString.length > 0 ? ageString : "N/A";
+ }
+ //return the calculated age
+ return ageString && ageString.length > 0 ? ageString : "N/A";
}
diff --git a/app/formIds.registry.js b/app/formIds.registry.js
index 1a3fce9..d4c3a6c 100644
--- a/app/formIds.registry.js
+++ b/app/formIds.registry.js
@@ -1,8 +1,8 @@
export const FORM_IDS = {
- __PROFILE_BASIC : "profileBasic",
- __PROFILE_CLINIC : "profileClinic",
- __PROFILE_CONTACT : "profileContact",
- __PROFILE_EDUCATION : "profileEducation",
- __PROFILE_EXPERIENCE : "profileExperience",
- __PROFILE_REGISTRATION: "profileRegistration",
+ __PROFILE_BASIC : "profileBasic",
+ __PROFILE_CLINIC : "profileClinic",
+ __PROFILE_CONTACT : "profileContact",
+ __PROFILE_EDUCATION : "profileEducation",
+ __PROFILE_EXPERIENCE : "profileExperience",
+ __PROFILE_REGISTRATION: "profileRegistration",
};
\ No newline at end of file
diff --git a/app/formValidationMap.registry.js b/app/formValidationMap.registry.js
index 55d6773..c16dfac 100644
--- a/app/formValidationMap.registry.js
+++ b/app/formValidationMap.registry.js
@@ -3,162 +3,162 @@ import moment from "moment";
import * as yup from "yup";
export const ValidationsRegistry = {
- profileBaic: {
- bio: yup
- .string()
- .trim()
- // .required(getFormikRequiredMessage("bio"))
- .matches(
- /^[a-zA-Z0-9\s.'"@$&-/\\?]+$/,
- "All special charecters are not allowed"
- ),
- dob: yup
- .date()
- .required(getFormikRequiredMessage("dateOfBirth"))
- .min(moment().subtract(115, "years"), "MIN_AGE")
- .max(moment().endOf("day").subtract(18, "years"), "Min age should be 18"),
- firstName: yup
- .string()
- .trim()
- .required(getFormikRequiredMessage("firstName"))
- .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
- gender : yup.string().required("Gender is required"),
- lastName: yup
- .string()
- .trim()
- .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
- middleName: yup
- .string()
- .trim()
- .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
- },
- profileEducation: {
- board: yup
- .string()
- .trim()
- .required("Board name is required")
- .matches(
- /^[a-zA-Z0-9\s-.,/()[\]]+$/,
- "All special charecters are not allowed except - . , / ( ) [ ]"
- ),
- degree: yup
- .string()
- .trim()
- .required("Degree is required")
- .matches(
- /^[a-zA-Z0-9\s-.,/()[\]]+$/,
- "All special charecters are not allowed except - . , / ( ) [ ]"
- ),
- endDate: yup
- .date()
- .max(new Date(), "Must be today or earlier than today")
- .when("isCurrent", {
- is : true,
- otherwise: yup
- .date()
- .required("End date required")
- .test(
- "start-end-check",
- "End date should be after start date",
- (val, props) => {
- // -- console.log("kkikikiki", props.parent.startDate, val, moment(props.parent.startDate).diff(moment(val), 'days'));
- // -- console.log("HERER", val);
- if (
- props.parent.startDate &&
+ profileBaic: {
+ bio: yup
+ .string()
+ .trim()
+ // .required(getFormikRequiredMessage("bio"))
+ .matches(
+ /^[a-zA-Z0-9\s.'"@$&-/\\?]+$/,
+ "All special charecters are not allowed"
+ ),
+ dob: yup
+ .date()
+ .required(getFormikRequiredMessage("dateOfBirth"))
+ .min(moment().subtract(115, "years"), "MIN_AGE")
+ .max(moment().endOf("day").subtract(18, "years"), "Min age should be 18"),
+ firstName: yup
+ .string()
+ .trim()
+ .required(getFormikRequiredMessage("firstName"))
+ .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
+ gender : yup.string().required("Gender is required"),
+ lastName: yup
+ .string()
+ .trim()
+ .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
+ middleName: yup
+ .string()
+ .trim()
+ .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
+ },
+ profileEducation: {
+ board: yup
+ .string()
+ .trim()
+ .required("Board name is required")
+ .matches(
+ /^[a-zA-Z0-9\s-.,/()[\]]+$/,
+ "All special charecters are not allowed except - . , / ( ) [ ]"
+ ),
+ degree: yup
+ .string()
+ .trim()
+ .required("Degree is required")
+ .matches(
+ /^[a-zA-Z0-9\s-.,/()[\]]+$/,
+ "All special charecters are not allowed except - . , / ( ) [ ]"
+ ),
+ endDate: yup
+ .date()
+ .max(new Date(), "Must be today or earlier than today")
+ .when("isCurrent", {
+ is : true,
+ otherwise: yup
+ .date()
+ .required("End date required")
+ .test(
+ "start-end-check",
+ "End date should be after start date",
+ (val, props) => {
+ // -- console.log("kkikikiki", props.parent.startDate, val, moment(props.parent.startDate).diff(moment(val), 'days'));
+ // -- console.log("HERER", val);
+ if (
+ props.parent.startDate &&
val &&
moment(val).diff(moment(props.parent.startDate), "days") > 0
- ) {
- return true;
- } else return false;
- }
- ),
- then: yup.date(),
- }),
- isCurrent: yup.boolean().notRequired(),
- school : yup
- .string()
- .trim()
- .required("School name is required")
- .matches(
- /^[a-zA-Z0-9\s-.,/()[\]]+$/,
- "All special charecters are not allowed except - . , / ( ) [ ]"
- ),
- startDate: yup
- .date()
- .max(new Date(), "Must be today or earlier than today")
- .required("Start date is required"),
- },
- profileExperience: {
- designation: yup
- .string()
- .trim()
- .required("Designation is required")
- .matches(
- /^[a-zA-Z0-9\s-.,/()[\]]+$/,
- "All special charecters are not allowed except - . , / ( ) [ ]"
- ),
- endDate: yup
- .date()
- .max(new Date(), "Must be today or earlier than today")
- .when("isCurrent", {
- is : true,
- otherwise: yup
- .date()
- .required("End date required")
- .test(
- "start-end-check",
- "End date should be after start date",
- (val, props) => {
- // -- console.log("kkikikiki", props.parent.startDate, val, moment(props.parent.startDate).diff(moment(val), 'days'));
- // -- console.log("HERER", val);
- if (
- props.parent.startDate &&
+ ) {
+ return true;
+ } else return false;
+ }
+ ),
+ then: yup.date(),
+ }),
+ isCurrent: yup.boolean().notRequired(),
+ school : yup
+ .string()
+ .trim()
+ .required("School name is required")
+ .matches(
+ /^[a-zA-Z0-9\s-.,/()[\]]+$/,
+ "All special charecters are not allowed except - . , / ( ) [ ]"
+ ),
+ startDate: yup
+ .date()
+ .max(new Date(), "Must be today or earlier than today")
+ .required("Start date is required"),
+ },
+ profileExperience: {
+ designation: yup
+ .string()
+ .trim()
+ .required("Designation is required")
+ .matches(
+ /^[a-zA-Z0-9\s-.,/()[\]]+$/,
+ "All special charecters are not allowed except - . , / ( ) [ ]"
+ ),
+ endDate: yup
+ .date()
+ .max(new Date(), "Must be today or earlier than today")
+ .when("isCurrent", {
+ is : true,
+ otherwise: yup
+ .date()
+ .required("End date required")
+ .test(
+ "start-end-check",
+ "End date should be after start date",
+ (val, props) => {
+ // -- console.log("kkikikiki", props.parent.startDate, val, moment(props.parent.startDate).diff(moment(val), 'days'));
+ // -- console.log("HERER", val);
+ if (
+ props.parent.startDate &&
val &&
moment(val).diff(moment(props.parent.startDate), "days") > 0
- ) {
- return true;
- } else return false;
- }
- ),
- then: yup.date(),
- }),
- isCurrent: yup.boolean().notRequired(),
- location : yup
- .string()
- .trim()
- .required("Location is required")
- .matches(
- /^[a-zA-Z0-9\s-.,/()[\]]+$/,
- "All special charecters are not allowed except - . , / ( ) [ ]"
- )
- .required(),
- organization: yup
- .string()
- .trim()
- .required("Organization name is required")
- .matches(
- /^[a-zA-Z0-9\s-.,/()[\]]+$/,
- "All special charecters are not allowed except - . , / ( ) [ ]"
- ),
- startDate: yup
- .date()
- .max(new Date(), "Must be today or earlier than today")
- .required("Start date is required"),
- },
- profileRegistration: {
- departmentId: yup.string().required("Department is required"),
- regDate : yup
- .date()
- .max(new Date(), "Registration date must be today or earlier than today")
- .required("Registration date is required"),
- regNo: yup
- .string()
- .trim()
- .required("Registration No. is required")
- .matches(
- /^[a-zA-Z0-9\s-/]+$/,
- "Special charecters are not allowed except - and /"
- ),
- registrationDocument: yup.object().nullable(),
- }
+ ) {
+ return true;
+ } else return false;
+ }
+ ),
+ then: yup.date(),
+ }),
+ isCurrent: yup.boolean().notRequired(),
+ location : yup
+ .string()
+ .trim()
+ .required("Location is required")
+ .matches(
+ /^[a-zA-Z0-9\s-.,/()[\]]+$/,
+ "All special charecters are not allowed except - . , / ( ) [ ]"
+ )
+ .required(),
+ organization: yup
+ .string()
+ .trim()
+ .required("Organization name is required")
+ .matches(
+ /^[a-zA-Z0-9\s-.,/()[\]]+$/,
+ "All special charecters are not allowed except - . , / ( ) [ ]"
+ ),
+ startDate: yup
+ .date()
+ .max(new Date(), "Must be today or earlier than today")
+ .required("Start date is required"),
+ },
+ profileRegistration: {
+ departmentId: yup.string().required("Department is required"),
+ regDate : yup
+ .date()
+ .max(new Date(), "Registration date must be today or earlier than today")
+ .required("Registration date is required"),
+ regNo: yup
+ .string()
+ .trim()
+ .required("Registration No. is required")
+ .matches(
+ /^[a-zA-Z0-9\s-/]+$/,
+ "Special charecters are not allowed except - and /"
+ ),
+ registrationDocument: yup.object().nullable(),
+ }
};
\ No newline at end of file
diff --git a/app/functions.registry.js b/app/functions.registry.js
index a0d9476..315ace3 100644
--- a/app/functions.registry.js
+++ b/app/functions.registry.js
@@ -1,48 +1,48 @@
import { profileRegistrationSpecilization } from "./functions/asyncselect.functions";
import { getCity, getDistrict, getState } from "./functions/form.dependency.function";
import {
- SanBasicEditUrlChange, SanClinicAddUrlChange, SanClinicDeleteUrlChange, SanClinicEditUrlChange, SanClinicReadUrlChange, SanEducationAddUrlChange, SanEducationEditUrlChange, SanEducationReadUrlChange, SanExperienceAddUrlChange, SanExperienceEditUrlChange, SanExperienceReadUrlChange, SanProfileBasicRead, SanProfileClinicRead, SanProfileEducationRead, SanProfileExperienceRead, SanProfileRegistrationRead, SanRegistrationReadUrlChange
+ SanBasicEditUrlChange, SanClinicAddUrlChange, SanClinicDeleteUrlChange, SanClinicEditUrlChange, SanClinicReadUrlChange, SanEducationAddUrlChange, SanEducationEditUrlChange, SanEducationReadUrlChange, SanExperienceAddUrlChange, SanExperienceEditUrlChange, SanExperienceReadUrlChange, SanProfileBasicRead, SanProfileClinicRead, SanProfileEducationRead, SanProfileExperienceRead, SanProfileRegistrationRead, SanRegistrationReadUrlChange
} from "./functions/sanity.functions";
// asyncSelect and formSubmitSanitization
export const FunctionsRegistry = {
- SanBasicEditUrlChange: SanBasicEditUrlChange,
- SanClinicAddUrlChange: SanClinicAddUrlChange,
+ SanBasicEditUrlChange: SanBasicEditUrlChange,
+ SanClinicAddUrlChange: SanClinicAddUrlChange,
- SanClinicDeleteUrlChange: SanClinicDeleteUrlChange,
+ SanClinicDeleteUrlChange: SanClinicDeleteUrlChange,
- SanClinicEditUrlChange: SanClinicEditUrlChange,
+ SanClinicEditUrlChange: SanClinicEditUrlChange,
- SanClinicReadUrlChange: SanClinicReadUrlChange,
+ SanClinicReadUrlChange: SanClinicReadUrlChange,
- SanEducationAddUrlChange: SanEducationAddUrlChange,
+ SanEducationAddUrlChange: SanEducationAddUrlChange,
- SanEducationEditUrlChange: SanEducationEditUrlChange,
+ SanEducationEditUrlChange: SanEducationEditUrlChange,
- SanEducationReadUrlChange: SanEducationReadUrlChange,
+ SanEducationReadUrlChange: SanEducationReadUrlChange,
- //PROFILE EXP SANITIZATION FUNCTIONS
- SanExperienceAddUrlChange : SanExperienceAddUrlChange,
- SanExperienceEditUrlChange: SanExperienceEditUrlChange,
- SanExperienceReadUrlChange: SanExperienceReadUrlChange,
- SanProfileBasicRead : SanProfileBasicRead,
- SanProfileClinicRead : SanProfileClinicRead,
+ //PROFILE EXP SANITIZATION FUNCTIONS
+ SanExperienceAddUrlChange : SanExperienceAddUrlChange,
+ SanExperienceEditUrlChange: SanExperienceEditUrlChange,
+ SanExperienceReadUrlChange: SanExperienceReadUrlChange,
+ SanProfileBasicRead : SanProfileBasicRead,
+ SanProfileClinicRead : SanProfileClinicRead,
- SanProfileEducationRead: SanProfileEducationRead,
+ SanProfileEducationRead: SanProfileEducationRead,
- SanProfileExperienceRead: SanProfileExperienceRead,
+ SanProfileExperienceRead: SanProfileExperienceRead,
- SanProfileRegistrationRead: SanProfileRegistrationRead,
+ SanProfileRegistrationRead: SanProfileRegistrationRead,
- SanRegistrationReadUrlChange: SanRegistrationReadUrlChange,
+ SanRegistrationReadUrlChange: SanRegistrationReadUrlChange,
- getCity: getCity,
+ getCity: getCity,
- getDepartmentsValue: profileRegistrationSpecilization.getOptionValue,
+ getDepartmentsValue: profileRegistrationSpecilization.getOptionValue,
- getDistrict: getDistrict,
+ getDistrict: getDistrict,
- getState: getState
+ getState: getState
};
diff --git a/app/functions/asyncselect.functions.js b/app/functions/asyncselect.functions.js
index bc1c45d..c9e0963 100644
--- a/app/functions/asyncselect.functions.js
+++ b/app/functions/asyncselect.functions.js
@@ -1,5 +1,5 @@
export const profileRegistrationSpecilization = {
- getOptionValue: (data) => {
- return { id: data?.id || "", label: data?.name || "" };
- },
+ getOptionValue: (data) => {
+ return { id: data?.id || "", label: data?.name || "" };
+ },
};
\ No newline at end of file
diff --git a/app/functions/form.dependency.function.js b/app/functions/form.dependency.function.js
index 1de17ca..de789f0 100644
--- a/app/functions/form.dependency.function.js
+++ b/app/functions/form.dependency.function.js
@@ -1,24 +1,24 @@
export function getState(formik, others) {
- const parent = formik?.values ? formik?.values?.country : -1;
+ const parent = formik?.values ? formik?.values?.country : -1;
- return others.type === "mount"
- ? { dependentQuery: { name: parent } }
- : { calculatedValue: "", dependentQuery: { name: parent } };
+ return others.type === "mount"
+ ? { dependentQuery: { name: parent } }
+ : { calculatedValue: "", dependentQuery: { name: parent } };
}
export function getDistrict(formik, others) {
- const parent = formik?.values ? formik?.values?.state : -1;
+ const parent = formik?.values ? formik?.values?.state : -1;
- return others.type === "mount"
- ? { dependentQuery: { name: parent } }
- : { calculatedValue: "", dependentQuery: { name: parent } };
+ return others.type === "mount"
+ ? { dependentQuery: { name: parent } }
+ : { calculatedValue: "", dependentQuery: { name: parent } };
}
export function getCity(formik, others) {
- const parent = formik?.values ? formik?.values?.district : -1;
+ const parent = formik?.values ? formik?.values?.district : -1;
- return others.type === "mount"
- ? { dependentQuery: { name: parent } }
- : { calculatedValue: "", dependentQuery: { name: parent } };
+ return others.type === "mount"
+ ? { dependentQuery: { name: parent } }
+ : { calculatedValue: "", dependentQuery: { name: parent } };
}
\ No newline at end of file
diff --git a/app/functions/sanity.functions.js b/app/functions/sanity.functions.js
index a34b16b..4a27081 100644
--- a/app/functions/sanity.functions.js
+++ b/app/functions/sanity.functions.js
@@ -1,174 +1,174 @@
/* eslint-disable id-length */
/* eslint-disable no-unused-vars */
export const SanBasicEditUrlChange = (formData, apiMeta, state, others) => {
- // -- console.log("SANITING", apiMeta, others);
- return {
- endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
- values : formData,
- };
+ // -- console.log("SANITING", apiMeta, others);
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
+ values : formData,
+ };
};
export const SanEducationAddUrlChange = (formData, apiMeta, state, others) => {
- // -- console.log("SANITING", apiMeta.endpoint, others);
- return {
- endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
- values : formData,
- };
+ // -- console.log("SANITING", apiMeta.endpoint, others);
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
+ values : formData,
+ };
};
export const SanEducationEditUrlChange = (formData, apiMeta, state, others) => {
- // -- console.log("SANITING", apiMeta, others);
- return {
- endpoint: apiMeta.endpoint.replace(":id", others.editing),
- values : formData,
- };
+ // -- console.log("SANITING", apiMeta, others);
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", others.editing),
+ values : formData,
+ };
};
export const SanEducationReadUrlChange = (formData, apiMeta, state, others) => {
- // -- console.log("SANITING", apiMeta, others);
- return {
- endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
- values : formData,
- };
+ // -- console.log("SANITING", apiMeta, others);
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
+ values : formData,
+ };
};
export const SanExperienceAddUrlChange = (formData, apiMeta, state, others) => {
- // -- console.log("SANITING", apiMeta.endpoint, others);
- return {
- endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
- values : formData,
- };
+ // -- console.log("SANITING", apiMeta.endpoint, others);
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
+ values : formData,
+ };
};
export const SanExperienceEditUrlChange = (formData, apiMeta, state, others) => {
- // -- console.log("SANITING", apiMeta, others);
- return {
- endpoint: apiMeta.endpoint.replace(":id", others.editing),
- values : formData,
- };
+ // -- console.log("SANITING", apiMeta, others);
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", others.editing),
+ values : formData,
+ };
};
export const SanExperienceReadUrlChange = (formData, apiMeta, state, others) => {
- // -- console.log("SANITING", apiMeta, others);
- return {
- endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
- values : formData,
- };
+ // -- console.log("SANITING", apiMeta, others);
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
+ values : formData,
+ };
};
export const SanProfileBasicRead = (data) => {
- // -- console.log("SANITING", apiMeta, others);
- return {
- bio : data?.data.extraInfo ? data?.data.extraInfo.bio : "",
- dob : data?.data.dob ? data?.data.dob : "",
- firstName : data?.data.firstName ? data.data.firstName : "",
- gender : data?.data?.gender,
- lastName : data?.data.lastName ? data.data.lastName : "",
- middleName: data?.data.middleName ? data.data.middleName : "",
- photo : data?.data.photoUrl ? data?.data.photoUrl : "",
- };
+ // -- console.log("SANITING", apiMeta, others);
+ return {
+ bio : data?.data.extraInfo ? data?.data.extraInfo.bio : "",
+ dob : data?.data.dob ? data?.data.dob : "",
+ firstName : data?.data.firstName ? data.data.firstName : "",
+ gender : data?.data?.gender,
+ lastName : data?.data.lastName ? data.data.lastName : "",
+ middleName: data?.data.middleName ? data.data.middleName : "",
+ photo : data?.data.photoUrl ? data?.data.photoUrl : "",
+ };
};
export const SanProfileExperienceRead = (data) => {
- // -- console.log("SANITING", apiMeta, others);
- return data?.rows?.map((m) => {
- return {
- designation : m?.designation,
- endDate : m?.endDate,
- id : m?.id,
- isCurrent : m?.endDate ? false : true,
- location : m?.location,
- organization: m?.organization,
- startDate : m?.startDate,
- };
- });
+ // -- console.log("SANITING", apiMeta, others);
+ return data?.rows?.map((m) => {
+ return {
+ designation : m?.designation,
+ endDate : m?.endDate,
+ id : m?.id,
+ isCurrent : m?.endDate ? false : true,
+ location : m?.location,
+ organization: m?.organization,
+ startDate : m?.startDate,
+ };
+ });
};
export const SanProfileEducationRead = (data) => {
- // -- console.log("SANITING", apiMeta, others);
- return data?.rows?.map((m) => {
- return {
- board : m?.board,
- degree : m?.degree,
- endDate : m?.endDate,
- field : m?.field,
- id : m?.id,
- isCurrent: m?.endDate ? false : true,
- location : m?.location,
- school : m?.school,
- startDate: m?.startDate,
- };
- });
+ // -- console.log("SANITING", apiMeta, others);
+ return data?.rows?.map((m) => {
+ return {
+ board : m?.board,
+ degree : m?.degree,
+ endDate : m?.endDate,
+ field : m?.field,
+ id : m?.id,
+ isCurrent: m?.endDate ? false : true,
+ location : m?.location,
+ school : m?.school,
+ startDate: m?.startDate,
+ };
+ });
};
export const SanProfileRegistrationRead = (data, otherData) => {
- return {
- degrees : data?.degrees ? data.degrees : "",
- departmentId : data?.departmentId,
- regDate : data?.regDate ? data.regDate : "",
- regNo : data?.regNo ? data.regNo : "",
- registrationDocument: data?.registrationDocument,
- };
+ return {
+ degrees : data?.degrees ? data.degrees : "",
+ departmentId : data?.departmentId,
+ regDate : data?.regDate ? data.regDate : "",
+ regNo : data?.regNo ? data.regNo : "",
+ registrationDocument: data?.registrationDocument,
+ };
};
export const SanRegistrationReadUrlChange = (formData, apiMeta, state, others) => {
- return {
- endpoint: apiMeta.endpoint,
- values : formData,
- };
+ return {
+ endpoint: apiMeta.endpoint,
+ values : formData,
+ };
};
export function SanClinicAddUrlChange(formData, apiMeta, state, others) {
- formData["addressTypeId"] = state?.common?.addressTypes?.find(
- (a) => a.type.toLowerCase() === "clinic"
- )?.id;
- return {
- endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
- values : formData,
- };
+ formData["addressTypeId"] = state?.common?.addressTypes?.find(
+ (a) => a.type.toLowerCase() === "clinic"
+ )?.id;
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
+ values : formData,
+ };
}
export function SanClinicEditUrlChange(formData, apiMeta, state, others) {
- for (let key in formData) {
- if (formData[key] === null) {
- delete formData[key];
- }
+ for (let key in formData) {
+ if (formData[key] === null) {
+ delete formData[key];
}
- return {
- endpoint: apiMeta.endpoint.replace(":id", others.editing),
- values : formData,
- };
+ }
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", others.editing),
+ values : formData,
+ };
}
export function SanClinicDeleteUrlChange(formData, apiMeta, state, others) {
- return {
- endpoint: apiMeta.endpoint.replace(":id", others.deleting),
- values : formData,
- };
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", others.deleting),
+ values : formData,
+ };
}
export function SanClinicReadUrlChange(formData, apiMeta, state, others) {
- return {
- endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
- values : formData,
- };
+ return {
+ endpoint: apiMeta.endpoint.replace(":id", state?.profile?.basic?.id),
+ values : formData,
+ };
}
export function SanProfileClinicRead(data) {
- return data?.rows?.map((m) => {
- return {
- addLine1 : m?.addLine1,
- addLine2 : m?.addLine2,
- city : m?.city,
- clinicLogo: m?.Clinic?.photoUrl,
- country : m?.country,
- district : m?.district,
- fullName : m?.fullName,
- id : m?.id,
- landmark : m?.landmark,
- phone : m?.phone,
- pin : m?.pin,
- state : m?.state,
- };
- });
+ return data?.rows?.map((m) => {
+ return {
+ addLine1 : m?.addLine1,
+ addLine2 : m?.addLine2,
+ city : m?.city,
+ clinicLogo: m?.Clinic?.photoUrl,
+ country : m?.country,
+ district : m?.district,
+ fullName : m?.fullName,
+ id : m?.id,
+ landmark : m?.landmark,
+ phone : m?.phone,
+ pin : m?.pin,
+ state : m?.state,
+ };
+ });
}
diff --git a/app/reducers/profileReducer.js b/app/reducers/profileReducer.js
index 32bb755..db3bc8f 100644
--- a/app/reducers/profileReducer.js
+++ b/app/reducers/profileReducer.js
@@ -1,309 +1,309 @@
import {
- PROFILE_COMPLETENESS_CHECKLIST_ERROR,
- PROFILE_COMPLETENESS_CHECKLIST_SUCCESS,
- PROFILE_COMPLETENESS_ERROR,
- PROFILE_COMPLETENESS_RELOAD,
- PROFILE_COMPLETENESS_REPORT_UPDATE,
- PROFILE_COMPLETENESS_SUCCESS,
- GET_PROFILE_ADDRESS_ERROR,
- GET_PROFILE_ADDRESS_LOADING,
- GET_PROFILE_ADDRESS_SUCCESS,
- GET_PROFILE_BASIC_ERROR,
- GET_PROFILE_BASIC_LOADING,
- GET_PROFILE_BASIC_SUCCESS,
- GET_PROFILE_CONTACT_ERROR,
- GET_PROFILE_CONTACT_LOADING,
- GET_PROFILE_CONTACT_SUCCESS,
- GET_PROFILE_EDUCATION_ERROR,
- GET_PROFILE_EDUCATION_LOADING,
- GET_PROFILE_EDUCATION_SUCCESS,
- GET_PROFILE_EXPERIENCE_ERROR,
- GET_PROFILE_EXPERIENCE_LOADING,
- GET_PROFILE_EXPERIENCE_SUCCESS,
- GET_PROFILE_REGISTRATION_ERROR,
- GET_PROFILE_REGISTRATION_LOADING,
- GET_PROFILE_REGISTRATION_SUCCESS,
- LOGOUT_SUCCESS
+ PROFILE_COMPLETENESS_CHECKLIST_ERROR,
+ PROFILE_COMPLETENESS_CHECKLIST_SUCCESS,
+ PROFILE_COMPLETENESS_ERROR,
+ PROFILE_COMPLETENESS_RELOAD,
+ PROFILE_COMPLETENESS_REPORT_UPDATE,
+ PROFILE_COMPLETENESS_SUCCESS,
+ GET_PROFILE_ADDRESS_ERROR,
+ GET_PROFILE_ADDRESS_LOADING,
+ GET_PROFILE_ADDRESS_SUCCESS,
+ GET_PROFILE_BASIC_ERROR,
+ GET_PROFILE_BASIC_LOADING,
+ GET_PROFILE_BASIC_SUCCESS,
+ GET_PROFILE_CONTACT_ERROR,
+ GET_PROFILE_CONTACT_LOADING,
+ GET_PROFILE_CONTACT_SUCCESS,
+ GET_PROFILE_EDUCATION_ERROR,
+ GET_PROFILE_EDUCATION_LOADING,
+ GET_PROFILE_EDUCATION_SUCCESS,
+ GET_PROFILE_EXPERIENCE_ERROR,
+ GET_PROFILE_EXPERIENCE_LOADING,
+ GET_PROFILE_EXPERIENCE_SUCCESS,
+ GET_PROFILE_REGISTRATION_ERROR,
+ GET_PROFILE_REGISTRATION_LOADING,
+ GET_PROFILE_REGISTRATION_SUCCESS,
+ LOGOUT_SUCCESS
} from "../types/profileTypes";
const initState = {
- addresses: null,
-
- addressesError : false,
- addressesLoading: false,
- addressesSuccess: false,
- basic : null,
-
- basicError : false,
- basicLoading: false,
- basicSuccess: false,
- completeness: {
- checklist: {},
- data : {},
- error : false,
- reload : false,
- report : {
- missingData : {},
- providedData: {},
- quotient : 0,
- },
- success: false,
+ addresses: null,
+
+ addressesError : false,
+ addressesLoading: false,
+ addressesSuccess: false,
+ basic : null,
+
+ basicError : false,
+ basicLoading: false,
+ basicSuccess: false,
+ completeness: {
+ checklist: {},
+ data : {},
+ error : false,
+ reload : false,
+ report : {
+ missingData : {},
+ providedData: {},
+ quotient : 0,
},
-
- contact : false,
- contactError : false,
- contactLoading: false,
- contactSuccess: false,
-
- educations : null,
- educationsError : false,
- educationsLoading: false,
- educationsSuccess: false,
-
- experiences : null,
- experiencesError : false,
- experiencesLoading: false,
- experiencesSuccess: false,
-
- registration : null,
- registrationError : false,
- registrationLoading: false,
- registrationSuccess: false,
+ success: false,
+ },
+
+ contact : false,
+ contactError : false,
+ contactLoading: false,
+ contactSuccess: false,
+
+ educations : null,
+ educationsError : false,
+ educationsLoading: false,
+ educationsSuccess: false,
+
+ experiences : null,
+ experiencesError : false,
+ experiencesLoading: false,
+ experiencesSuccess: false,
+
+ registration : null,
+ registrationError : false,
+ registrationLoading: false,
+ registrationSuccess: false,
};
const profileReducer = (state = initState, action) => {
- switch (action.type) {
- case GET_PROFILE_BASIC_LOADING:
- return {
- ...state,
- basic : null,
- basicError : false,
- basicLoading: true,
- basicSuccess: false,
- };
-
- case GET_PROFILE_BASIC_SUCCESS:
- return {
- ...state,
- basic : action.payload?.data?.data,
- basicError : false,
- basicLoading: false,
- basicSuccess: true,
- };
-
- case GET_PROFILE_BASIC_ERROR:
- return {
- ...state,
- basic : null,
- basicError : true,
- basicLoading: false,
- basicSuccess: false,
- };
-
- case GET_PROFILE_REGISTRATION_LOADING:
- return {
- ...state,
- registration : null,
- registrationError : false,
- registrationLoading: true,
- registrationSuccess: false,
- };
-
- case GET_PROFILE_REGISTRATION_SUCCESS:
- return {
- ...state,
- registration : action.payload.data,
- registrationError : false,
- registrationLoading: false,
- registrationSuccess: true,
- };
-
- case GET_PROFILE_REGISTRATION_ERROR:
- return {
- ...state,
- registration : null,
- registrationError : true,
- registrationLoading: false,
- registrationSuccess: false,
- };
-
- case GET_PROFILE_ADDRESS_LOADING:
- return {
- ...state,
- addresses : null,
- addressesError : false,
- addressesLoading: true,
- addressesSuccess: false,
- };
-
- case GET_PROFILE_ADDRESS_SUCCESS:
- return {
- ...state,
- addresses : action.payload.data,
- addressesError : false,
- addressesLoading: false,
- addressesSuccess: true,
- };
-
- case GET_PROFILE_ADDRESS_ERROR:
- return {
- ...state,
- addresses : null,
- addressesError : true,
- addressesLoading: false,
- addressesSuccess: false,
- };
-
- case GET_PROFILE_EDUCATION_LOADING:
- return {
- ...state,
- educations : null,
- educationsError : false,
- educationsLoading: true,
- educationsSuccess: false,
- };
-
- case GET_PROFILE_EDUCATION_SUCCESS:
- return {
- ...state,
- educations : action.payload.data,
- educationsError : false,
- educationsLoading: false,
- educationsSuccess: true,
- };
-
- case GET_PROFILE_EDUCATION_ERROR:
- return {
- ...state,
- educations : null,
- educationsError : true,
- educationsLoading: false,
- educationsSuccess: false,
- };
-
- case GET_PROFILE_EXPERIENCE_LOADING:
- return {
- ...state,
- experiences : null,
- experiencesError : false,
- experiencesLoading: true,
- experiencesSuccess: false,
- };
-
- case GET_PROFILE_EXPERIENCE_SUCCESS:
- return {
- ...state,
- experiences : action.payload.data,
- experiencesError : false,
- experiencesLoading: false,
- experiencesSuccess: true,
- };
-
- case GET_PROFILE_EXPERIENCE_ERROR:
- return {
- ...state,
- experiences : null,
- experiencesError : true,
- experiencesLoading: false,
- experiencesSuccess: false,
- };
-
- case GET_PROFILE_CONTACT_LOADING:
- return {
- ...state,
- contact : null,
- contactError : false,
- contactLoading: true,
- contactSuccess: false,
- };
-
- case GET_PROFILE_CONTACT_SUCCESS:
- return {
- ...state,
- contact : action.payload.data,
- contactError : false,
- contactLoading: false,
- contactSuccess: true,
- };
-
- case GET_PROFILE_CONTACT_ERROR:
- return {
- ...state,
- contact : null,
- contactError : true,
- contactLoading: false,
- contactSuccess: false,
- };
-
- case PROFILE_COMPLETENESS_RELOAD:
- return {
- ...state,
- completeness: {
- ...state.completeness,
- reload: true,
- },
- };
-
- case PROFILE_COMPLETENESS_SUCCESS:
- return {
- ...state,
- completeness: {
- ...state.completeness,
- data : action?.payload?.data?.data,
- error : false,
- reload : false,
- success: true,
- },
- };
-
- case PROFILE_COMPLETENESS_ERROR:
- return {
- ...state,
- completeness: {
- ...state.completeness,
- data : action?.payload,
- error : true,
- success: false,
- },
- };
-
- case PROFILE_COMPLETENESS_CHECKLIST_SUCCESS:
- return {
- ...state,
- completeness: {
- ...state.completeness,
- checklist: action?.payload?.data?.data?.extraInfo,
- error : false,
- success : true,
- },
- };
-
- case PROFILE_COMPLETENESS_CHECKLIST_ERROR:
- return {
- ...state,
- completeness: {
- ...state.completeness,
- checklist: action?.payload,
- error : true,
- success : false,
- },
- };
-
- case PROFILE_COMPLETENESS_REPORT_UPDATE:
- return {
- ...state,
- completeness: {
- ...state.completeness,
- report: action?.payload,
- },
- };
-
- case LOGOUT_SUCCESS:
- return initState;
-
- default:
- return state;
- }
+ switch (action.type) {
+ case GET_PROFILE_BASIC_LOADING:
+ return {
+ ...state,
+ basic : null,
+ basicError : false,
+ basicLoading: true,
+ basicSuccess: false,
+ };
+
+ case GET_PROFILE_BASIC_SUCCESS:
+ return {
+ ...state,
+ basic : action.payload?.data?.data,
+ basicError : false,
+ basicLoading: false,
+ basicSuccess: true,
+ };
+
+ case GET_PROFILE_BASIC_ERROR:
+ return {
+ ...state,
+ basic : null,
+ basicError : true,
+ basicLoading: false,
+ basicSuccess: false,
+ };
+
+ case GET_PROFILE_REGISTRATION_LOADING:
+ return {
+ ...state,
+ registration : null,
+ registrationError : false,
+ registrationLoading: true,
+ registrationSuccess: false,
+ };
+
+ case GET_PROFILE_REGISTRATION_SUCCESS:
+ return {
+ ...state,
+ registration : action.payload.data,
+ registrationError : false,
+ registrationLoading: false,
+ registrationSuccess: true,
+ };
+
+ case GET_PROFILE_REGISTRATION_ERROR:
+ return {
+ ...state,
+ registration : null,
+ registrationError : true,
+ registrationLoading: false,
+ registrationSuccess: false,
+ };
+
+ case GET_PROFILE_ADDRESS_LOADING:
+ return {
+ ...state,
+ addresses : null,
+ addressesError : false,
+ addressesLoading: true,
+ addressesSuccess: false,
+ };
+
+ case GET_PROFILE_ADDRESS_SUCCESS:
+ return {
+ ...state,
+ addresses : action.payload.data,
+ addressesError : false,
+ addressesLoading: false,
+ addressesSuccess: true,
+ };
+
+ case GET_PROFILE_ADDRESS_ERROR:
+ return {
+ ...state,
+ addresses : null,
+ addressesError : true,
+ addressesLoading: false,
+ addressesSuccess: false,
+ };
+
+ case GET_PROFILE_EDUCATION_LOADING:
+ return {
+ ...state,
+ educations : null,
+ educationsError : false,
+ educationsLoading: true,
+ educationsSuccess: false,
+ };
+
+ case GET_PROFILE_EDUCATION_SUCCESS:
+ return {
+ ...state,
+ educations : action.payload.data,
+ educationsError : false,
+ educationsLoading: false,
+ educationsSuccess: true,
+ };
+
+ case GET_PROFILE_EDUCATION_ERROR:
+ return {
+ ...state,
+ educations : null,
+ educationsError : true,
+ educationsLoading: false,
+ educationsSuccess: false,
+ };
+
+ case GET_PROFILE_EXPERIENCE_LOADING:
+ return {
+ ...state,
+ experiences : null,
+ experiencesError : false,
+ experiencesLoading: true,
+ experiencesSuccess: false,
+ };
+
+ case GET_PROFILE_EXPERIENCE_SUCCESS:
+ return {
+ ...state,
+ experiences : action.payload.data,
+ experiencesError : false,
+ experiencesLoading: false,
+ experiencesSuccess: true,
+ };
+
+ case GET_PROFILE_EXPERIENCE_ERROR:
+ return {
+ ...state,
+ experiences : null,
+ experiencesError : true,
+ experiencesLoading: false,
+ experiencesSuccess: false,
+ };
+
+ case GET_PROFILE_CONTACT_LOADING:
+ return {
+ ...state,
+ contact : null,
+ contactError : false,
+ contactLoading: true,
+ contactSuccess: false,
+ };
+
+ case GET_PROFILE_CONTACT_SUCCESS:
+ return {
+ ...state,
+ contact : action.payload.data,
+ contactError : false,
+ contactLoading: false,
+ contactSuccess: true,
+ };
+
+ case GET_PROFILE_CONTACT_ERROR:
+ return {
+ ...state,
+ contact : null,
+ contactError : true,
+ contactLoading: false,
+ contactSuccess: false,
+ };
+
+ case PROFILE_COMPLETENESS_RELOAD:
+ return {
+ ...state,
+ completeness: {
+ ...state.completeness,
+ reload: true,
+ },
+ };
+
+ case PROFILE_COMPLETENESS_SUCCESS:
+ return {
+ ...state,
+ completeness: {
+ ...state.completeness,
+ data : action?.payload?.data?.data,
+ error : false,
+ reload : false,
+ success: true,
+ },
+ };
+
+ case PROFILE_COMPLETENESS_ERROR:
+ return {
+ ...state,
+ completeness: {
+ ...state.completeness,
+ data : action?.payload,
+ error : true,
+ success: false,
+ },
+ };
+
+ case PROFILE_COMPLETENESS_CHECKLIST_SUCCESS:
+ return {
+ ...state,
+ completeness: {
+ ...state.completeness,
+ checklist: action?.payload?.data?.data?.extraInfo,
+ error : false,
+ success : true,
+ },
+ };
+
+ case PROFILE_COMPLETENESS_CHECKLIST_ERROR:
+ return {
+ ...state,
+ completeness: {
+ ...state.completeness,
+ checklist: action?.payload,
+ error : true,
+ success : false,
+ },
+ };
+
+ case PROFILE_COMPLETENESS_REPORT_UPDATE:
+ return {
+ ...state,
+ completeness: {
+ ...state.completeness,
+ report: action?.payload,
+ },
+ };
+
+ case LOGOUT_SUCCESS:
+ return initState;
+
+ default:
+ return state;
+ }
};
export default profileReducer;
diff --git a/app/reducers/test.reducer.js b/app/reducers/test.reducer.js
index d5f233e..cf0dac2 100644
--- a/app/reducers/test.reducer.js
+++ b/app/reducers/test.reducer.js
@@ -1,28 +1,28 @@
import { TEST_FAILURE, TEST_SUCCESS } from "../types/test.types";
const initialState = {
- error : false,
- message: "This is a test module.",
- success: false,
+ error : false,
+ message: "This is a test module.",
+ success: false,
};
const testReducer = (state = initialState, action) => {
- switch (action.type) {
- case TEST_SUCCESS:
- return {
- ...state,
- success: true,
- };
+ switch (action.type) {
+ case TEST_SUCCESS:
+ return {
+ ...state,
+ success: true,
+ };
- case TEST_FAILURE:
- return {
- ...state,
- success: true,
- };
+ case TEST_FAILURE:
+ return {
+ ...state,
+ success: true,
+ };
- default:
- return state;
- }
+ default:
+ return state;
+ }
};
export default testReducer;
diff --git a/app/validations/test.validation.js b/app/validations/test.validation.js
index 27ae30c..ac46bc0 100644
--- a/app/validations/test.validation.js
+++ b/app/validations/test.validation.js
@@ -1,6 +1,6 @@
/* eslint-disable no-undef */
export const checkEmailorPhone = {
- message: yup
- .string()
- .required("Please enter a valid message."),
+ message: yup
+ .string()
+ .required("Please enter a valid message."),
};
\ No newline at end of file
diff --git a/service/controllers.registry.js b/service/controllers.registry.js
index 41557aa..a90f021 100644
--- a/service/controllers.registry.js
+++ b/service/controllers.registry.js
@@ -2,34 +2,35 @@ const { CoreMiddlewaresRegistry } = require("@wrappid/service-core");
const profileController = require("./controllers/profile.controller");
const {
- getContactInfo,
- getAddressTypeSchema,
- departmentGET,
- getPersonContacts,
- getRegistrationInfo,
- putBasicDetails,
- putRegistrationDetails,
- postAddEducation,
- postUpdateEducation,
- putDeleteEducation,
- postAddExperience,
- putUpdateExperience,
- putDeleteExperience
+ getContactInfo,
+ getAddressTypeSchema,
+ departmentGET,
+ getPersonContacts,
+ getRegistrationInfo,
+ putBasicDetails,
+ putRegistrationDetails,
+ postAddEducation,
+ postUpdateEducation,
+ putDeleteEducation,
+ postAddExperience,
+ putUpdateExperience,
+ putDeleteExperience
} = require("./validations/profile.validation");
+
const controllersRegistry = {
- getAddressType : [CoreMiddlewaresRegistry.validation(getAddressTypeSchema), profileController.getAddressType],
- getContactInfo : [CoreMiddlewaresRegistry.validation(getContactInfo), profileController.getContactInfo],
- getDepartment : [CoreMiddlewaresRegistry.validation(departmentGET), profileController.getDepartment],
- getRegistrationInfo : [CoreMiddlewaresRegistry.validation(getRegistrationInfo), profileController.getRegistrationInfo],
- getpersonContacts : [CoreMiddlewaresRegistry.validation(getPersonContacts), profileController.getPersonContacts],
- postAddEducation : [CoreMiddlewaresRegistry.validation(postAddEducation), profileController.postAddEducation],
- postAddExperience : [CoreMiddlewaresRegistry.validation(postAddExperience), profileController.postAddExperience],
- putBasicDetails : [CoreMiddlewaresRegistry.validation(putBasicDetails), CoreMiddlewaresRegistry.fileHandler({ filename: "photo" }), profileController.putBasicDetails],
- putDeleteEducation : [CoreMiddlewaresRegistry.validation(putDeleteEducation), profileController.putDeleteEducation],
- putDeleteExperience : [CoreMiddlewaresRegistry.validation(putDeleteExperience), profileController.putDeleteExperience],
- putRegistrationDetails: [CoreMiddlewaresRegistry.validation(putRegistrationDetails), CoreMiddlewaresRegistry.fileHandler({ filename: "registrationDocument" }), profileController.putRegistrationDetails],
- putUpdateEducation : [CoreMiddlewaresRegistry.validation(postUpdateEducation), profileController.putUpdateEducation],
- putUpdateExperience : [CoreMiddlewaresRegistry.validation(putUpdateExperience), profileController.putUpdateExperience]
+ getAddressType : [CoreMiddlewaresRegistry.validation(getAddressTypeSchema), profileController.getAddressType],
+ getContactInfo : [CoreMiddlewaresRegistry.validation(getContactInfo), profileController.getContactInfo],
+ getDepartment : [CoreMiddlewaresRegistry.validation(departmentGET), profileController.getDepartment],
+ getRegistrationInfo : [CoreMiddlewaresRegistry.validation(getRegistrationInfo), profileController.getRegistrationInfo],
+ getpersonContacts : [CoreMiddlewaresRegistry.validation(getPersonContacts), profileController.getPersonContacts],
+ postAddEducation : [CoreMiddlewaresRegistry.validation(postAddEducation), profileController.postAddEducation],
+ postAddExperience : [CoreMiddlewaresRegistry.validation(postAddExperience), profileController.postAddExperience],
+ putBasicDetails : [CoreMiddlewaresRegistry.validation(putBasicDetails), CoreMiddlewaresRegistry.fileHandler({ filename: "photo" }), profileController.putBasicDetails],
+ putDeleteEducation : [CoreMiddlewaresRegistry.validation(putDeleteEducation), profileController.putDeleteEducation],
+ putDeleteExperience : [CoreMiddlewaresRegistry.validation(putDeleteExperience), profileController.putDeleteExperience],
+ putRegistrationDetails: [CoreMiddlewaresRegistry.validation(putRegistrationDetails), CoreMiddlewaresRegistry.fileHandler({ filename: "registrationDocument" }), profileController.putRegistrationDetails],
+ putUpdateEducation : [CoreMiddlewaresRegistry.validation(postUpdateEducation), profileController.putUpdateEducation],
+ putUpdateExperience : [CoreMiddlewaresRegistry.validation(putUpdateExperience), profileController.putUpdateExperience]
};
exports.controllersRegistry = controllersRegistry;
diff --git a/service/controllers/address.controller.js b/service/controllers/address.controller.js
index 6524a9c..b91697b 100644
--- a/service/controllers/address.controller.js
+++ b/service/controllers/address.controller.js
@@ -11,12 +11,12 @@ const { createAddress, updateAddress, deleteAddress } = require("../functions/ad
* @param {*} res
*/
module.exports.createAddress = async (req, res) => {
- try {
- await createAddress(req, res, databaseActions);
- } catch (err) {
- console.log(err);
- res.status(500).json({ message: "Error to create person address" });
- }
+ try {
+ await createAddress(req, res, databaseActions);
+ } catch (err) {
+ console.log(err);
+ res.status(500).json({ message: "Error to create person address" });
+ }
};
/**
@@ -25,12 +25,12 @@ module.exports.createAddress = async (req, res) => {
* @param {*} res
*/
module.exports.updateAddress = async (req, res) => {
- try {
- await updateAddress(req, res, databaseActions);
- } catch (err) {
- console.log(err);
- res.status(500).json({ message: "Error to update person address" });
- }
+ try {
+ await updateAddress(req, res, databaseActions);
+ } catch (err) {
+ console.log(err);
+ res.status(500).json({ message: "Error to update person address" });
+ }
};
/**
@@ -39,12 +39,12 @@ module.exports.updateAddress = async (req, res) => {
* @param {*} res
*/
module.exports.deleteAddress = async (req, res) => {
- try {
- let data = await deleteAddress(req, databaseActions);
+ try {
+ let data = await deleteAddress(req, databaseActions);
- res.status(data.status).json({ data: data?.data, message: data?.message });
- } catch (err) {
- console.log(err);
- res.status(500).json({ message: "Error to delete person address" });
- }
+ res.status(data.status).json({ data: data?.data, message: data?.message });
+ } catch (err) {
+ console.log(err);
+ res.status(500).json({ message: "Error to delete person address" });
+ }
};
diff --git a/service/controllers/basic.controller.js b/service/controllers/basic.controller.js
index f0f990c..ab1a142 100644
--- a/service/controllers/basic.controller.js
+++ b/service/controllers/basic.controller.js
@@ -4,10 +4,10 @@ const { databaseActions, messageProcessor } = require("@wrappid/service-core");
const { updateBasicDetails } = require("../functions/basic.functions");
module.exports.updateBasicDetails = async (req, res) => {
- try {
- await updateBasicDetails(req, res, databaseActions);
- } catch (err) {
- console.log(err);
- res.status(500).json({ message: messageProcessor(err) });
- }
+ try {
+ await updateBasicDetails(req, res, databaseActions);
+ } catch (err) {
+ console.log(err);
+ res.status(500).json({ message: messageProcessor(err) });
+ }
};
diff --git a/service/controllers/profile.controller.js b/service/controllers/profile.controller.js
index 19c2f02..b6e918d 100644
--- a/service/controllers/profile.controller.js
+++ b/service/controllers/profile.controller.js
@@ -6,25 +6,25 @@
const profileFunction = require("../functions/profile.function");
module.exports.getContactInfo = async (req, res) => {
- try{
- let { status, ...restData } = await profileFunction.getContactInfoFunc(req, res);
-
- res.status(status).json(restData);
- }catch(error){
- console.error("Error:: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let { status, ...restData } = await profileFunction.getContactInfoFunc(req, res);
+
+ res.status(status).json(restData);
+ }catch(error){
+ console.error("Error:: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.getAddressType = async (req, res) => {
- try{
- let { status, ...restData } = await profileFunction.getAddressTypeFunc(req, res);
-
- res.status(status).json(restData);
- }catch(error){
- console.error("Error:: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let { status, ...restData } = await profileFunction.getAddressTypeFunc(req, res);
+
+ res.status(status).json(restData);
+ }catch(error){
+ console.error("Error:: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
/**
@@ -34,25 +34,25 @@ module.exports.getAddressType = async (req, res) => {
*/
module.exports.getDepartment = async (req, res) => {
- try{
- let { status, ...restData } = await profileFunction.getDepartmentFunc(req, res);
-
- res.status(status).json(restData);
- }catch(error){
- console.error("Error:: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let { status, ...restData } = await profileFunction.getDepartmentFunc(req, res);
+
+ res.status(status).json(restData);
+ }catch(error){
+ console.error("Error:: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.getPersonContacts = async (req, res) => {
- try{
- let { status, ...restData } = await profileFunction.getPersonContactsFunc(req, res);
-
- res.status(status).json(restData);
- }catch(error){
- console.error("Error:: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let { status, ...restData } = await profileFunction.getPersonContactsFunc(req, res);
+
+ res.status(status).json(restData);
+ }catch(error){
+ console.error("Error:: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
/**
@@ -63,233 +63,233 @@ module.exports.getPersonContacts = async (req, res) => {
*/
module.exports.postContact = async (req, res) => {
- try {
- let personId = req.user.personId;
- let exists = await db.PersonContacts.findOne({
- where: {
- data : req.body.data.toString(),
- personId: personId,
- },
- });
-
- if (exists) {
- console.log("Contact already exists", exists.id);
- res.status(500).json({ message: "Contact already exists" });
- } else {
- let createdContact = await db.PersonContacts.create({
- ...req.body,
- _status : entityStatus.ACTIVE,
- personId: personId,
- type : isNaN(req.body.data)
- ? constant.contact.EMAIL
- : constant.contact.PHONE,
- });
-
- console.log(
- "Person contact created, id:",
- createdContact.id,
- ", Person Id: ",
- personId
- );
- res.status(200).json({ message: "Contact info created successfully" });
- }
- } catch (err) {
- console.error(err);
- res.status(500).json({
- error : err,
- message: "Contact info create error",
- });
+ try {
+ let personId = req.user.personId;
+ let exists = await db.PersonContacts.findOne({
+ where: {
+ data : req.body.data.toString(),
+ personId: personId,
+ },
+ });
+
+ if (exists) {
+ console.log("Contact already exists", exists.id);
+ res.status(500).json({ message: "Contact already exists" });
+ } else {
+ let createdContact = await db.PersonContacts.create({
+ ...req.body,
+ _status : entityStatus.ACTIVE,
+ personId: personId,
+ type : isNaN(req.body.data)
+ ? constant.contact.EMAIL
+ : constant.contact.PHONE,
+ });
+
+ console.log(
+ "Person contact created, id:",
+ createdContact.id,
+ ", Person Id: ",
+ personId
+ );
+ res.status(200).json({ message: "Contact info created successfully" });
}
+ } catch (err) {
+ console.error(err);
+ res.status(500).json({
+ error : err,
+ message: "Contact info create error",
+ });
+ }
};
module.exports.updateContact = async (req, res) => {
- try {
- let contact = await db.PersonContacts.findByPk(req.params.id);
+ try {
+ let contact = await db.PersonContacts.findByPk(req.params.id);
- if (contact.primaryFlag) {
- console.log("Can not delete primary mail");
- res.status(500).json({
- message:
+ if (contact.primaryFlag) {
+ console.log("Can not delete primary mail");
+ res.status(500).json({
+ message:
"Can not delete primary contact. Change primary then try again",
- });
- }
- // -- eslint-disable-next-line no-unused-lets
- let [nrows, rows] = await db.PersonContacts.update(
- {
- _status : entityStatus.DELETED,
- deletedAt: moment(),
- deletedBy: req.user.userId,
- isActive : false,
- },
- { where: { id: req.params.id } }
- );
-
- console.log("Person contact deleted, id:", req.params.id);
- res.status(200).json({ message: "Contact info deleted successfully" });
- } catch (err) {
- console.error(err);
- res.status(500).json({ message: "Contact info delete error" });
+ });
}
+ // -- eslint-disable-next-line no-unused-lets
+ let [nrows, rows] = await db.PersonContacts.update(
+ {
+ _status : entityStatus.DELETED,
+ deletedAt: moment(),
+ deletedBy: req.user.userId,
+ isActive : false,
+ },
+ { where: { id: req.params.id } }
+ );
+
+ console.log("Person contact deleted, id:", req.params.id);
+ res.status(200).json({ message: "Contact info deleted successfully" });
+ } catch (err) {
+ console.error(err);
+ res.status(500).json({ message: "Contact info delete error" });
+ }
};
module.exports.getPersonContact = async (req, res) => {
- try {
+ try {
// get user specific
- let personID = req.user.personId;
-
- console.log("Person ID = " + personID);
-
- let baseQuery = {};
-
- if (req.query.input) {
- baseQuery["data"] = req.query.input;
- }
- if (req.query.type) {
- baseQuery["type"] = req.query.type;
- }
- if (req.query.verified) {
- baseQuery["verified"] = req.query.verified === "true" ? true : false;
- }
-
- let pageQuery = {};
-
- pageQuery["page"] = req.query.page;
- pageQuery["maxRowInPage"] = req.query.maxRowInPage;
- pageQuery["orderBy"] = req.query.orderBy;
- pageQuery["order"] = req.query.order;
-
- paginate(
- db.PersonContacts,
- [],
- { isActive: true, personId: personID, ...baseQuery },
- pageQuery
- )
- .then((_data) => {
- _data["columns"] = Object.keys(_data?.rows[0]?.dataValues || {});
- res.status(200).json({
- data : _data,
- message: "Contacts data fetched successfully",
- });
- })
- .catch((err) => {
- console.log(err);
- res
- .status(500)
- .json({ error: err, message: "Error to fetch Contacts data" });
- });
- } catch (err) {
+ let personID = req.user.personId;
+
+ console.log("Person ID = " + personID);
+
+ let baseQuery = {};
+
+ if (req.query.input) {
+ baseQuery["data"] = req.query.input;
+ }
+ if (req.query.type) {
+ baseQuery["type"] = req.query.type;
+ }
+ if (req.query.verified) {
+ baseQuery["verified"] = req.query.verified === "true" ? true : false;
+ }
+
+ let pageQuery = {};
+
+ pageQuery["page"] = req.query.page;
+ pageQuery["maxRowInPage"] = req.query.maxRowInPage;
+ pageQuery["orderBy"] = req.query.orderBy;
+ pageQuery["order"] = req.query.order;
+
+ paginate(
+ db.PersonContacts,
+ [],
+ { isActive: true, personId: personID, ...baseQuery },
+ pageQuery
+ )
+ .then((_data) => {
+ _data["columns"] = Object.keys(_data?.rows[0]?.dataValues || {});
+ res.status(200).json({
+ data : _data,
+ message: "Contacts data fetched successfully",
+ });
+ })
+ .catch((err) => {
console.log(err);
res
- .status(500)
- .json({ error: err, message: "Error to fetch Contacts data" });
- }
+ .status(500)
+ .json({ error: err, message: "Error to fetch Contacts data" });
+ });
+ } catch (err) {
+ console.log(err);
+ res
+ .status(500)
+ .json({ error: err, message: "Error to fetch Contacts data" });
+ }
};
module.exports.getRegistrationInfo = async (req, res) => {
- try {
- let result = await profileFunction.getRegistrationInfoFunc(req, res);
- let { status, message, data } = result;
-
- res.status(status).json({ data, message: message });
- } catch (error) {
- console.error("Registration info fetched Error:: ", error);
- res.status(500).json({ message: error.message });
- }
+ try {
+ let result = await profileFunction.getRegistrationInfoFunc(req, res);
+ let { status, message, data } = result;
+
+ res.status(status).json({ data, message: message });
+ } catch (error) {
+ console.error("Registration info fetched Error:: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.putBasicDetails = async (req, res) => {
- try {
- let result = await profileFunction.putBasicDetailsFunc(req, res);
- let { status, message, data } = result;
+ try {
+ let result = await profileFunction.putBasicDetailsFunc(req, res);
+ let { status, message, data } = result;
- res.status(status).json({ data, message: message });
+ res.status(status).json({ data, message: message });
- } catch (error) {
- console.error("Error :: ", error);
- res.status(500).json({ message: error.message });
- }
+ } catch (error) {
+ console.error("Error :: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.putRegistrationDetails = async (req, res) => {
- try {
- let result = await profileFunction.putRegistrationDetailsFunc(req, res);
- let { status, message } = result;
-
- res.status(status).json({ message: message });
- } catch (error) {
- console.error("Error :: ", error);
- res.status(500).json({ message: error.message });
- }
+ try {
+ let result = await profileFunction.putRegistrationDetailsFunc(req, res);
+ let { status, message } = result;
+
+ res.status(status).json({ message: message });
+ } catch (error) {
+ console.error("Error :: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.postAddEducation = async (req, res) => {
- try{
- let result = await profileFunction.postAddEducationFunc(req, res);
- let { status, message, data } = result;
-
- res.status(status).json({ data, message: message });
- }catch(error){
- console.error("Error :: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let result = await profileFunction.postAddEducationFunc(req, res);
+ let { status, message, data } = result;
+
+ res.status(status).json({ data, message: message });
+ }catch(error){
+ console.error("Error :: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.putUpdateEducation = async (req, res) => {
- try{
- let result = await profileFunction.putUpdateEducationFunc(req, res);
- let { status, message, data } = result;
-
- res.status(status).json({ data, message: message });
- }catch(error){
- console.error("Error :: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let result = await profileFunction.putUpdateEducationFunc(req, res);
+ let { status, message, data } = result;
+
+ res.status(status).json({ data, message: message });
+ }catch(error){
+ console.error("Error :: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.putDeleteEducation = async (req, res) => {
- try{
- let result = await profileFunction.putDeleteEducationFunc(req, res);
- let { status, message, data } = result;
-
- res.status(status).json({ data, message: message });
- }catch(error){
- console.error("Error :: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let result = await profileFunction.putDeleteEducationFunc(req, res);
+ let { status, message, data } = result;
+
+ res.status(status).json({ data, message: message });
+ }catch(error){
+ console.error("Error :: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.postAddExperience = async (req, res) => {
- try{
- let result = await profileFunction.postAddExperienceFunc(req, res);
- let { status, message, data } = result;
-
- res.status(status).json({ data, message: message });
- }catch(error){
- console.error("Error :: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let result = await profileFunction.postAddExperienceFunc(req, res);
+ let { status, message, data } = result;
+
+ res.status(status).json({ data, message: message });
+ }catch(error){
+ console.error("Error :: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.putUpdateExperience = async (req, res) => {
- try{
- let result = await profileFunction.putUpdateExperienceFunc(req, res);
- let { status, message, data } = result;
-
- res.status(status).json({ data, message: message });
- }catch(error){
- console.error("Error :: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let result = await profileFunction.putUpdateExperienceFunc(req, res);
+ let { status, message, data } = result;
+
+ res.status(status).json({ data, message: message });
+ }catch(error){
+ console.error("Error :: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
module.exports.putDeleteExperience = async (req, res) => {
- try{
- let result = await profileFunction.putDeleteExperienceFunc(req, res);
- let { status, message, data } = result;
-
- res.status(status).json({ data, message: message });
- }catch(error){
- console.error("Error :: ", error);
- res.status(500).json({ message: error.message });
- }
+ try{
+ let result = await profileFunction.putDeleteExperienceFunc(req, res);
+ let { status, message, data } = result;
+
+ res.status(status).json({ data, message: message });
+ }catch(error){
+ console.error("Error :: ", error);
+ res.status(500).json({ message: error.message });
+ }
};
\ No newline at end of file
diff --git a/service/functions/address.functions.js b/service/functions/address.functions.js
index 3fb3348..4d1e61d 100644
--- a/service/functions/address.functions.js
+++ b/service/functions/address.functions.js
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
const {
- databaseProvider, deleteS3FIle, messageProcessor, getUrl, upload, entityStatus
+ databaseProvider, deleteS3FIle, messageProcessor, getUrl, upload, entityStatus
} = require("@wrappid/service-core");
const { DEFAULT_DB } = require("../constants/profile.constants");
@@ -13,82 +13,82 @@ const { DEFAULT_DB } = require("../constants/profile.constants");
* @returns
*/
const createAddress = async (req, res, databaseActions) => {
- try {
- let del_urls = [];
- let personId = req.params.id;
-
- await upload.fields([{ maxCount: 1, name: "clinicLogo" }])(
- req,
- res,
- async function (err) {
- try {
- if (err) {
- console.log("FIle Upload error", err);
- throw err;
- } else {
- let data = req.body;
- let file_url = null;
-
- if (req.files["clinicLogo"] && req.files["clinicLogo"][0]) {
- file_url = await getUrl(
- req.files["clinicLogo"][0].filename
- ? req.files["clinicLogo"][0].filename
- : req.files["clinicLogo"][0].key
- ? req.files["clinicLogo"][0].key
- : req.files["clinicLogo"][0].originalname
- );
- data[""];
- }
-
- let result = await databaseProvider.application.sequelize.transaction(async (transaction) => {
- let address = await databaseActions.findByPk(DEFAULT_DB, "AddressTypes",
- data.addressTypeId
- );
- let addDetail = await databaseActions.create(DEFAULT_DB, "PersonAddresses",
- {
- ...data,
- _status : entityStatus.ACTIVE,
- createdBy: req.user.userId,
- personId : personId,
- updatedBy: req.user.userId,
- },
- { transaction }
- );
-
- let clinicDetail = {};
-
- if (address?.type?.toLowerCase() === "clinic") {
- clinicDetail = await databaseActions.create(DEFAULT_DB, "Clinics",
- {
- _status : entityStatus.ACTIVE,
- createdBy : req.user.userId,
- name : data.fullName,
- personAddressId: addDetail.id,
- photoUrl : file_url,
- updatedBy : req.user.userId,
- },
- { transaction }
- );
-
- }
-
- return { addressId: addDetail?.id, clinicId: clinicDetail?.id };
- });
-
- console.log("Address created", result);
- res.status(200).json({ message: messageProcessor(200005) });
- }
- } catch (err) {
- console.log(err);
- await deleteS3FIle(del_urls);
- res.status(500).json({ message: messageProcessor(err) });
- }
+ try {
+ let del_urls = [];
+ let personId = req.params.id;
+
+ await upload.fields([{ maxCount: 1, name: "clinicLogo" }])(
+ req,
+ res,
+ async function (err) {
+ try {
+ if (err) {
+ console.log("FIle Upload error", err);
+ throw err;
+ } else {
+ let data = req.body;
+ let file_url = null;
+
+ if (req.files["clinicLogo"] && req.files["clinicLogo"][0]) {
+ file_url = await getUrl(
+ req.files["clinicLogo"][0].filename
+ ? req.files["clinicLogo"][0].filename
+ : req.files["clinicLogo"][0].key
+ ? req.files["clinicLogo"][0].key
+ : req.files["clinicLogo"][0].originalname
+ );
+ data[""];
}
- );
- } catch (err) {
- console.log(err);
- return { message: messageProcessor(err), status: 500 };
- }
+
+ let result = await databaseProvider.application.sequelize.transaction(async (transaction) => {
+ let address = await databaseActions.findByPk(DEFAULT_DB, "AddressTypes",
+ data.addressTypeId
+ );
+ let addDetail = await databaseActions.create(DEFAULT_DB, "PersonAddresses",
+ {
+ ...data,
+ _status : entityStatus.ACTIVE,
+ createdBy: req.user.userId,
+ personId : personId,
+ updatedBy: req.user.userId,
+ },
+ { transaction }
+ );
+
+ let clinicDetail = {};
+
+ if (address?.type?.toLowerCase() === "clinic") {
+ clinicDetail = await databaseActions.create(DEFAULT_DB, "Clinics",
+ {
+ _status : entityStatus.ACTIVE,
+ createdBy : req.user.userId,
+ name : data.fullName,
+ personAddressId: addDetail.id,
+ photoUrl : file_url,
+ updatedBy : req.user.userId,
+ },
+ { transaction }
+ );
+
+ }
+
+ return { addressId: addDetail?.id, clinicId: clinicDetail?.id };
+ });
+
+ console.log("Address created", result);
+ res.status(200).json({ message: messageProcessor(200005) });
+ }
+ } catch (err) {
+ console.log(err);
+ await deleteS3FIle(del_urls);
+ res.status(500).json({ message: messageProcessor(err) });
+ }
+ }
+ );
+ } catch (err) {
+ console.log(err);
+ return { message: messageProcessor(err), status: 500 };
+ }
};
/**
@@ -98,87 +98,87 @@ const createAddress = async (req, res, databaseActions) => {
* @param {*} databaseActions
*/
async function updateAddress(req, res, databaseActions) {
- try {
- let del_urls = [];
- let addressId = req.params.id;
- let file_url = null;
+ try {
+ let del_urls = [];
+ let addressId = req.params.id;
+ let file_url = null;
- await upload.fields([{ maxCount: 1, name: "clinicLogo" }])(
- req,
- res,
- async function (err) {
- try {
- if (err) {
- console.log("FIle Upload error", err);
- throw err;
- } else {
- let data = req.body;
-
- if (req.files["clinicLogo"] && req.files["clinicLogo"][0]) {
- file_url = await getUrl(
- req.files["clinicLogo"][0].filename
- ? req.files["clinicLogo"][0].filename
- : req.files["clinicLogo"][0].key
- ? req.files["clinicLogo"][0].key
- : req.files["clinicLogo"][0].originalname
- );
- data[""];
- }
- await databaseProvider.application.sequelize.transaction(async (transaction) => {
- let address = await databaseActions.findByPk(DEFAULT_DB, "PersonAddresses",
- req.params.id,
- { include: [{ model: databaseProvider.application.models.AddressTypes }] }
- );
- let updateInfo = await databaseActions.update(DEFAULT_DB, "PersonAddresses",
- {
- ...data,
- updatedBy: req.user.userId,
- },
- {
- transaction,
- where: { id: addressId },
- }
- );
-
- if (updateInfo[0] === 0) {
- throw 290007;
- }
-
- if (address?.AddressType?.type?.toLowerCase() === "clinic") {
- console.log("Clinic Url", file_url);
- let updateOb = {
- name : data.fullName,
- updatedBy: req.user.userId,
- };
-
- if (file_url) {
- updateOb["photoUrl"] = file_url;
- }
- updateInfo = await databaseActions.update(DEFAULT_DB, "Clinics", updateOb, {
- transaction,
- where: { personAddressId: addressId },
- });
-
- if (updateInfo === 0) {
- throw 290008;
- }
- }
- });
-
- console.log("Registration detail created");
- res.status(200).json({ message: messageProcessor(200006) });
- }
- } catch (err) {
- console.log(err);
- await deleteS3FIle(del_urls);
- res.status(500).json({ message: messageProcessor(err) });
- }
+ await upload.fields([{ maxCount: 1, name: "clinicLogo" }])(
+ req,
+ res,
+ async function (err) {
+ try {
+ if (err) {
+ console.log("FIle Upload error", err);
+ throw err;
+ } else {
+ let data = req.body;
+
+ if (req.files["clinicLogo"] && req.files["clinicLogo"][0]) {
+ file_url = await getUrl(
+ req.files["clinicLogo"][0].filename
+ ? req.files["clinicLogo"][0].filename
+ : req.files["clinicLogo"][0].key
+ ? req.files["clinicLogo"][0].key
+ : req.files["clinicLogo"][0].originalname
+ );
+ data[""];
}
- );
- } catch (err) {
- console.log(err);
- res.status(500).json({ message: messageProcessor(err) });
- }
+ await databaseProvider.application.sequelize.transaction(async (transaction) => {
+ let address = await databaseActions.findByPk(DEFAULT_DB, "PersonAddresses",
+ req.params.id,
+ { include: [{ model: databaseProvider.application.models.AddressTypes }] }
+ );
+ let updateInfo = await databaseActions.update(DEFAULT_DB, "PersonAddresses",
+ {
+ ...data,
+ updatedBy: req.user.userId,
+ },
+ {
+ transaction,
+ where: { id: addressId },
+ }
+ );
+
+ if (updateInfo[0] === 0) {
+ throw 290007;
+ }
+
+ if (address?.AddressType?.type?.toLowerCase() === "clinic") {
+ console.log("Clinic Url", file_url);
+ let updateOb = {
+ name : data.fullName,
+ updatedBy: req.user.userId,
+ };
+
+ if (file_url) {
+ updateOb["photoUrl"] = file_url;
+ }
+ updateInfo = await databaseActions.update(DEFAULT_DB, "Clinics", updateOb, {
+ transaction,
+ where: { personAddressId: addressId },
+ });
+
+ if (updateInfo === 0) {
+ throw 290008;
+ }
+ }
+ });
+
+ console.log("Registration detail created");
+ res.status(200).json({ message: messageProcessor(200006) });
+ }
+ } catch (err) {
+ console.log(err);
+ await deleteS3FIle(del_urls);
+ res.status(500).json({ message: messageProcessor(err) });
+ }
+ }
+ );
+ } catch (err) {
+ console.log(err);
+ res.status(500).json({ message: messageProcessor(err) });
+ }
}
/**
@@ -188,58 +188,58 @@ async function updateAddress(req, res, databaseActions) {
* @returns
*/
async function deleteAddress(req, databaseActions){
- try {
- await databaseProvider.application.sequelize.transaction(async (transaction) => {
- let addressId = req.params.id;
- let address = await databaseActions.findByPk(DEFAULT_DB, "PersonAddresses", addressId, { include: [{ model: databaseProvider.application.models.AddressTypes }] });
-
- let updateInfo = await databaseActions.update(DEFAULT_DB, "PersonAddresses",
- {
- _status : entityStatus.DELETED,
- isActive : false,
- updatedBy: req.user.userId,
- },
- {
- transaction,
- where: { id: addressId },
- }
- );
-
- if (updateInfo[0] === 0) {
- console.error("Error here address");
- throw 290009;
- }
-
- if (address?.AddressType?.type?.toLowerCase() === "clinic") {
- updateInfo = await databaseActions.update(DEFAULT_DB, "Clinics",
- {
- isActive : false,
- updatedBy: req.user.userId,
- },
- {
- transaction,
- where: { personAddressId: addressId },
- }
- );
+ try {
+ await databaseProvider.application.sequelize.transaction(async (transaction) => {
+ let addressId = req.params.id;
+ let address = await databaseActions.findByPk(DEFAULT_DB, "PersonAddresses", addressId, { include: [{ model: databaseProvider.application.models.AddressTypes }] });
+
+ let updateInfo = await databaseActions.update(DEFAULT_DB, "PersonAddresses",
+ {
+ _status : entityStatus.DELETED,
+ isActive : false,
+ updatedBy: req.user.userId,
+ },
+ {
+ transaction,
+ where: { id: addressId },
+ }
+ );
+
+ if (updateInfo[0] === 0) {
+ console.error("Error here address");
+ throw 290009;
+ }
+
+ if (address?.AddressType?.type?.toLowerCase() === "clinic") {
+ updateInfo = await databaseActions.update(DEFAULT_DB, "Clinics",
+ {
+ isActive : false,
+ updatedBy: req.user.userId,
+ },
+ {
+ transaction,
+ where: { personAddressId: addressId },
+ }
+ );
- if (updateInfo[0] === 0) {
- console.error("Error here clinic");
- throw 290009;
- }
- }
- });
+ if (updateInfo[0] === 0) {
+ console.error("Error here clinic");
+ throw 290009;
+ }
+ }
+ });
- console.log("Address deleted: ", req.params.id);
- return { message: messageProcessor(200007), status: 200 };
- } catch (error) {
- console.log("Address Delete error", error);
- return { message: messageProcessor(error), status: 500 };
- }
+ console.log("Address deleted: ", req.params.id);
+ return { message: messageProcessor(200007), status: 200 };
+ } catch (error) {
+ console.log("Address Delete error", error);
+ return { message: messageProcessor(error), status: 500 };
+ }
}
module.exports = {
- createAddress,
- deleteAddress,
- updateAddress
+ createAddress,
+ deleteAddress,
+ updateAddress
};
diff --git a/service/functions/basic.functions.js b/service/functions/basic.functions.js
index f269690..1ad1e39 100644
--- a/service/functions/basic.functions.js
+++ b/service/functions/basic.functions.js
@@ -9,59 +9,59 @@ const { DEFAULT_DB } = require("../constants/profile.constants");
* @returns
*/
const updateBasicDetails = async (req, res, databaseActions) => {
- try {
- let del_urls = [];
- let file_url = null;
- let personId = req.params.id;
+ try {
+ let del_urls = [];
+ let file_url = null;
+ let personId = req.params.id;
- await upload.fields([{ maxCount: 1, name: "photo" }])(
- req,
- res,
- async function (err) {
- try {
- if (err) {
- console.log("FIle Upload error", err);
- throw err;
- } else {
- let data = req.body;
+ await upload.fields([{ maxCount: 1, name: "photo" }])(
+ req,
+ res,
+ async function (err) {
+ try {
+ if (err) {
+ console.log("FIle Upload error", err);
+ throw err;
+ } else {
+ let data = req.body;
- if (data.extraInfo) data.extraInfo = JSON.parse(data.extraInfo);
- if (data.bio) data["extraInfo"] = { bio: data.bio };
- if (req.files["photo"] && req.files["photo"][0]) {
- file_url = await getUrl(
- req.files["photo"][0].filename
- ? req.files["photo"][0].filename
- : req.files["photo"][0].key
- ? req.files["photo"][0].key
- : req.files["photo"][0].originalname
- );
- del_urls.push(file_url);
- data.photoUrl = file_url;
- }
- console.log("UPDATEING DATA", data);
+ if (data.extraInfo) data.extraInfo = JSON.parse(data.extraInfo);
+ if (data.bio) data["extraInfo"] = { bio: data.bio };
+ if (req.files["photo"] && req.files["photo"][0]) {
+ file_url = await getUrl(
+ req.files["photo"][0].filename
+ ? req.files["photo"][0].filename
+ : req.files["photo"][0].key
+ ? req.files["photo"][0].key
+ : req.files["photo"][0].originalname
+ );
+ del_urls.push(file_url);
+ data.photoUrl = file_url;
+ }
+ console.log("UPDATEING DATA", data);
- await databaseActions.update(DEFAULT_DB, "Persons",
- {
- ...data,
- updatedBy: req.user.userId,
- },
- { where: { id: personId } }
- );
+ await databaseActions.update(DEFAULT_DB, "Persons",
+ {
+ ...data,
+ updatedBy: req.user.userId,
+ },
+ { where: { id: personId } }
+ );
- console.log("Basic detail updated");
- res.status(200).json({ message: messageProcessor(200004) });
- }
- } catch (err) {
- console.log(err);
- await deleteS3FIle(del_urls);
- res.status(500).json({ message: messageProcessor(err) });
- }
- }
- );
- } catch (err) {
- console.log(err);
- res.status(500).json({ message: messageProcessor(err) });
- }
+ console.log("Basic detail updated");
+ res.status(200).json({ message: messageProcessor(200004) });
+ }
+ } catch (err) {
+ console.log(err);
+ await deleteS3FIle(del_urls);
+ res.status(500).json({ message: messageProcessor(err) });
+ }
+ }
+ );
+ } catch (err) {
+ console.log(err);
+ res.status(500).json({ message: messageProcessor(err) });
+ }
};
module.exports = { updateBasicDetails };
diff --git a/service/functions/doctor.functions.js b/service/functions/doctor.functions.js
index ad3e4cf..c7eea9d 100644
--- a/service/functions/doctor.functions.js
+++ b/service/functions/doctor.functions.js
@@ -9,128 +9,128 @@ const { DEFAULT_DB } = require("../constants/profile.constants");
* @returns
*/
const updateDoctorDetails = async (req, res, databaseActions) => {
- try {
- let del_urls = [];
- let file_url = null;
- let personId = req.params.id;
-
- await upload.fields([{ maxCount: 1, name: "registrationDocument" }])(req, res, async function (err) {
- try {
- if (err) {
- console.log("FIle Upload error", err);
- throw err;
- } else {
- if (
- req.files["registrationDocument"] &&
+ try {
+ let del_urls = [];
+ let file_url = null;
+ let personId = req.params.id;
+
+ await upload.fields([{ maxCount: 1, name: "registrationDocument" }])(req, res, async function (err) {
+ try {
+ if (err) {
+ console.log("FIle Upload error", err);
+ throw err;
+ } else {
+ if (
+ req.files["registrationDocument"] &&
req.files["registrationDocument"][0]
- ) {
- file_url = await getUrl(
- req.files["registrationDocument"][0].filename
- ? req.files["registrationDocument"][0].filename
- : req.files["registrationDocument"][0].key
- ? req.files["registrationDocument"][0].key
- : req.files["registrationDocument"][0].originalname
- );
- }
- console.log("File URL", file_url);
-
- let exists = await databaseActions.findOne(DEFAULT_DB, "DoctorDetails", { where: { doctorId: req.params.id } });
-
- del_urls.push(file_url);
-
- let data = req.body;
+ ) {
+ file_url = await getUrl(
+ req.files["registrationDocument"][0].filename
+ ? req.files["registrationDocument"][0].filename
+ : req.files["registrationDocument"][0].key
+ ? req.files["registrationDocument"][0].key
+ : req.files["registrationDocument"][0].originalname
+ );
+ }
+ console.log("File URL", file_url);
+
+ let exists = await databaseActions.findOne(DEFAULT_DB, "DoctorDetails", { where: { doctorId: req.params.id } });
+
+ del_urls.push(file_url);
+
+ let data = req.body;
- await databaseProvider.action.sequelize.transaction(async (transaction) => {
- data.personDocs = [];
-
- if (!exists) {
- console.log("Docotr details not found");
- await databaseActions.create(DEFAULT_DB, "DoctorDetails",
- {
- ...data,
- doctorId : personId,
- updatedBy: req.user.userId,
- },
- { transaction }
- );
- } else {
- console.log("Docotr details found: ", exists.id);
- }
-
- if (file_url) {
- let updateInfo = await databaseActions.update(DEFAULT_DB, "PersonDocs",
- {
- docUrl : file_url,
- updatedBy: req.user.userId,
- },
- {
- transaction,
- where: { personId: personId },
- }
- );
-
- if (updateInfo === 0) {
- let nPersonDocs = await databaseActions.create(DEFAULT_DB, "PersonDocs",
- {
- docUrl : file_url,
- personId,
- type : "Registration Document",
- updatedBy: req.user.userId,
- },
- { transaction }
- );
-
- console.log(
- "Registration file entry made:",
- nPersonDocs.id
- );
- } else {
- console.log("Registration file URL updated");
- }
- } else {
- console.log("No registration file given");
- }
-
- if (data.departmentId) {
- await databaseActions.update(DEFAULT_DB, "Persons",
- {
- departmentId: data.departmentId,
- updatedBy : req.user.userId,
- },
- {
- transaction,
- where: { id: personId },
- }
- );
-
- console.log("Department updated");
- }
-
- await databaseActions.update(DEFAULT_DB, "DoctorDetails",
- {
- ...data,
- updatedBy: req.user.userId,
- },
- {
- transaction,
- where: { doctorId: personId },
- }
- );
- });
-
- console.log("Registration detail updated");
- res.status(200).json({ message: messageProcessor(200003) });
+ await databaseProvider.action.sequelize.transaction(async (transaction) => {
+ data.personDocs = [];
+
+ if (!exists) {
+ console.log("Docotr details not found");
+ await databaseActions.create(DEFAULT_DB, "DoctorDetails",
+ {
+ ...data,
+ doctorId : personId,
+ updatedBy: req.user.userId,
+ },
+ { transaction }
+ );
+ } else {
+ console.log("Docotr details found: ", exists.id);
+ }
+
+ if (file_url) {
+ let updateInfo = await databaseActions.update(DEFAULT_DB, "PersonDocs",
+ {
+ docUrl : file_url,
+ updatedBy: req.user.userId,
+ },
+ {
+ transaction,
+ where: { personId: personId },
+ }
+ );
+
+ if (updateInfo === 0) {
+ let nPersonDocs = await databaseActions.create(DEFAULT_DB, "PersonDocs",
+ {
+ docUrl : file_url,
+ personId,
+ type : "Registration Document",
+ updatedBy: req.user.userId,
+ },
+ { transaction }
+ );
+
+ console.log(
+ "Registration file entry made:",
+ nPersonDocs.id
+ );
+ } else {
+ console.log("Registration file URL updated");
+ }
+ } else {
+ console.log("No registration file given");
+ }
+
+ if (data.departmentId) {
+ await databaseActions.update(DEFAULT_DB, "Persons",
+ {
+ departmentId: data.departmentId,
+ updatedBy : req.user.userId,
+ },
+ {
+ transaction,
+ where: { id: personId },
}
- } catch (err) {
- console.log(err);
- await deleteS3FIle(del_urls);
- res.status(500).json({ message: messageProcessor(err) });
+ );
+
+ console.log("Department updated");
}
- });
- } catch (err) {
+
+ await databaseActions.update(DEFAULT_DB, "DoctorDetails",
+ {
+ ...data,
+ updatedBy: req.user.userId,
+ },
+ {
+ transaction,
+ where: { doctorId: personId },
+ }
+ );
+ });
+
+ console.log("Registration detail updated");
+ res.status(200).json({ message: messageProcessor(200003) });
+ }
+ } catch (err) {
console.log(err);
+ await deleteS3FIle(del_urls);
res.status(500).json({ message: messageProcessor(err) });
- }
+ }
+ });
+ } catch (err) {
+ console.log(err);
+ res.status(500).json({ message: messageProcessor(err) });
+ }
};
/**
@@ -139,81 +139,81 @@ const updateDoctorDetails = async (req, res, databaseActions) => {
* @returns
*/
const createDoctorDetails = async (req, res, databaseActions) => {
- try {
- let del_urls = [];
- let personId = req.params.id;
+ try {
+ let del_urls = [];
+ let personId = req.params.id;
- await upload.fields([{ maxCount: 1, name: "registrationDocument" }])(req, res, async function (err) {
- try {
- if (err) {
- console.log("FIle Upload error", err);
- throw err;
- } else {
- if (
- req.files["registrationDocument"] &&
+ await upload.fields([{ maxCount: 1, name: "registrationDocument" }])(req, res, async function (err) {
+ try {
+ if (err) {
+ console.log("FIle Upload error", err);
+ throw err;
+ } else {
+ if (
+ req.files["registrationDocument"] &&
req.files["registrationDocument"][0]
- ) {
- let file_url = null;
-
- file_url = await getUrl(
- req.files["registrationDocument"][0].filename
- ? req.files["registrationDocument"][0].filename
- : req.files["registrationDocument"][0].key
- ? req.files["registrationDocument"][0].key
- : req.files["registrationDocument"][0].originalname
- );
-
- let doctorDetails = await databaseActions.findOne(DEFAULT_DB, "DoctorDetails", { where: { personId: req.params.id } });
-
- // eslint-disable-next-line no-undef
- del_urls.push(url);
- if (doctorDetails) {
- throw 290004;
- }
- let data = req.body;
-
- // eslint-disable-next-line no-undef
- await db.sequelize.transaction(async (transaction) => {
- data.personDocs = [];
- // eslint-disable-next-line no-undef
- await db.PersonDocs.create(
- {
- createdBy: req.user.userId,
- personId : personId,
- type : "Registration Document",
- updatedBy: req.user.userId,
- url : file_url,
- },
- { transaction: transaction }
- );
- // eslint-disable-next-line no-undef
- await db.DoctorDetails.create(
- {
- ...req.body,
- createdBy: req.user.userId,
- doctorId : personId,
- updatedBy: req.user.userId,
- },
- { transaction: transaction }
- );
- });
+ ) {
+ let file_url = null;
+
+ file_url = await getUrl(
+ req.files["registrationDocument"][0].filename
+ ? req.files["registrationDocument"][0].filename
+ : req.files["registrationDocument"][0].key
+ ? req.files["registrationDocument"][0].key
+ : req.files["registrationDocument"][0].originalname
+ );
- console.log("Registration detail created");
- res.status(200).json({ message: messageProcessor(200002) });
- } else {
- throw 290003;
- }
- }
- } catch (err) {
- console.log(err);
- await deleteS3FIle(del_urls);
- res.status(500).json({ message: messageProcessor(err) });
+ let doctorDetails = await databaseActions.findOne(DEFAULT_DB, "DoctorDetails", { where: { personId: req.params.id } });
+
+ // eslint-disable-next-line no-undef
+ del_urls.push(url);
+ if (doctorDetails) {
+ throw 290004;
}
- });
- } catch (err) {
+ let data = req.body;
+
+ // eslint-disable-next-line no-undef
+ await db.sequelize.transaction(async (transaction) => {
+ data.personDocs = [];
+ // eslint-disable-next-line no-undef
+ await db.PersonDocs.create(
+ {
+ createdBy: req.user.userId,
+ personId : personId,
+ type : "Registration Document",
+ updatedBy: req.user.userId,
+ url : file_url,
+ },
+ { transaction: transaction }
+ );
+ // eslint-disable-next-line no-undef
+ await db.DoctorDetails.create(
+ {
+ ...req.body,
+ createdBy: req.user.userId,
+ doctorId : personId,
+ updatedBy: req.user.userId,
+ },
+ { transaction: transaction }
+ );
+ });
+
+ console.log("Registration detail created");
+ res.status(200).json({ message: messageProcessor(200002) });
+ } else {
+ throw 290003;
+ }
+ }
+ } catch (err) {
console.log(err);
+ await deleteS3FIle(del_urls);
res.status(500).json({ message: messageProcessor(err) });
- }
+ }
+ });
+ } catch (err) {
+ console.log(err);
+ res.status(500).json({ message: messageProcessor(err) });
+ }
};
module.exports = { createDoctorDetails, updateDoctorDetails };
diff --git a/service/functions/profile.function.js b/service/functions/profile.function.js
index 2f92436..5cd4d06 100644
--- a/service/functions/profile.function.js
+++ b/service/functions/profile.function.js
@@ -2,538 +2,538 @@
/* eslint-disable no-unused-vars*/
const {
- databaseActions,
- databaseProvider,
- coreConstant,
+ databaseActions,
+ databaseProvider,
+ coreConstant,
} = require("@wrappid/service-core");
const getContactInfoFunc = async (req, res) => {
- //eslint-disable-next-line no-useless-catch
- try {
- let userID = req.user.userId;
-
- console.log("User ID = " + userID);
-
- let userDetails = await databaseActions.findOne("application", "Users", {
- include: [
- {
- as : "Person",
- model: databaseProvider.application.models.Persons,
- },
- ],
- where: { id: userID },
- });
- let data = {
- email : userDetails.email,
- emailVerified: userDetails?.Person?.emailVerified,
- phone : userDetails?.phone,
- phoneVerified: userDetails?.Person?.phoneVerified,
- profileId : userDetails?.Person?.profileId,
- website : userDetails?.Person?.website,
- };
-
- console.log("Contact info fetched successfully");
- return { data, message: "Contact info fetched successfully", status: 200 };
- } catch (err) {
- throw err;
- }
+ //eslint-disable-next-line no-useless-catch
+ try {
+ let userID = req.user.userId;
+
+ console.log("User ID = " + userID);
+
+ let userDetails = await databaseActions.findOne("application", "Users", {
+ include: [
+ {
+ as : "Person",
+ model: databaseProvider.application.models.Persons,
+ },
+ ],
+ where: { id: userID },
+ });
+ let data = {
+ email : userDetails.email,
+ emailVerified: userDetails?.Person?.emailVerified,
+ phone : userDetails?.phone,
+ phoneVerified: userDetails?.Person?.phoneVerified,
+ profileId : userDetails?.Person?.profileId,
+ website : userDetails?.Person?.website,
+ };
+
+ console.log("Contact info fetched successfully");
+ return { data, message: "Contact info fetched successfully", status: 200 };
+ } catch (err) {
+ throw err;
+ }
};
const getAddressTypeFunc = async (req, res) => {
- try {
- let data = await databaseActions.findAll("application", "AddressTypes", { attributes: ["id", "type"] });
-
- if (data.length > 1) {
- console.log("Address types fetched successfully");
- return {
- data,
- message: "Address types fetched successfully",
- status : 200,
- };
- }
- } catch (err) {
- console.log(err);
- throw err;
+ try {
+ let data = await databaseActions.findAll("application", "AddressTypes", { attributes: ["id", "type"] });
+
+ if (data.length > 1) {
+ console.log("Address types fetched successfully");
+ return {
+ data,
+ message: "Address types fetched successfully",
+ status : 200,
+ };
}
+ } catch (err) {
+ console.log(err);
+ throw err;
+ }
};
const getDepartmentFunc = async (req, res) => {
- try {
- let data = await databaseActions.findAll("application", "Departments", { where: { ...req.query } });
-
- if (data.length > 1) {
- console.log("Departments fetched successfully");
- return {
- data,
- message: "Departments fetched successfully",
- status : 200,
- };
- }
- } catch (err) {
- console.log(err);
- throw err;
+ try {
+ let data = await databaseActions.findAll("application", "Departments", { where: { ...req.query } });
+
+ if (data.length > 1) {
+ console.log("Departments fetched successfully");
+ return {
+ data,
+ message: "Departments fetched successfully",
+ status : 200,
+ };
}
+ } catch (err) {
+ console.log(err);
+ throw err;
+ }
};
const getPersonContactsFunc = async (req, res) => {
- try {
- let person = await databaseActions.findOne("application", "Persons", { where: { userId: req.user.userId } });
- let personId = person.id;
- let contactType = req.params.contactType;
- let personContacts = await databaseActions.findAll(
- "application",
- "PersonContacts",
- {
- where: {
- personId: personId,
- type : contactType,
- verified: true,
- },
- }
- );
-
- if (personContacts && personContacts.length > 0) {
- // send 200
- console.log("Contact info fetched successfully");
- return {
- data : { rows: personContacts },
- message: "Contact info fetched successfully",
- status : 204,
- };
- } else {
- // send 204
- return {
- message: `No ${contactType}(s) found.`,
- status : 204,
- };
- }
- } catch (err) {
- console.log(err);
- throw err;
+ try {
+ let person = await databaseActions.findOne("application", "Persons", { where: { userId: req.user.userId } });
+ let personId = person.id;
+ let contactType = req.params.contactType;
+ let personContacts = await databaseActions.findAll(
+ "application",
+ "PersonContacts",
+ {
+ where: {
+ personId: personId,
+ type : contactType,
+ verified: true,
+ },
+ }
+ );
+
+ if (personContacts && personContacts.length > 0) {
+ // send 200
+ console.log("Contact info fetched successfully");
+ return {
+ data : { rows: personContacts },
+ message: "Contact info fetched successfully",
+ status : 204,
+ };
+ } else {
+ // send 204
+ return {
+ message: `No ${contactType}(s) found.`,
+ status : 204,
+ };
}
+ } catch (err) {
+ console.log(err);
+ throw err;
+ }
};
const putBasicDetailsFunc = async (req, res) => {
- try {
- let file_url = null;
- let personId = req.params.id;
+ try {
+ let file_url = null;
+ let personId = req.params.id;
- let data = req.body;
+ let data = req.body;
- if (data.extraInfo) data.extraInfo = JSON.parse(data.extraInfo);
- if (data.bio) data["extraInfo"] = { bio: data.bio };
- if (req?.files && req.files["photo"] && req.files["photo"][0]) {
- file_url = req.files.photo[0].location;
- data.photoUrl = file_url;
- }
- console.log(data.photoUrl);
- console.log("UPDATEING DATA", data);
- let result = await databaseProvider.application.sequelize.transaction(
- async (transaction) => {
- let docDetail = await databaseActions.update(
- "application",
- "Persons",
- {
- ...data,
- updatedBy: req.user.userId,
- },
- {
- transaction: transaction,
- where : { id: personId },
- }
- );
- }
+ if (data.extraInfo) data.extraInfo = JSON.parse(data.extraInfo);
+ if (data.bio) data["extraInfo"] = { bio: data.bio };
+ if (req?.files && req.files["photo"] && req.files["photo"][0]) {
+ file_url = req.files.photo[0].location;
+ data.photoUrl = file_url;
+ }
+ console.log(data.photoUrl);
+ console.log("UPDATEING DATA", data);
+ let result = await databaseProvider.application.sequelize.transaction(
+ async (transaction) => {
+ let docDetail = await databaseActions.update(
+ "application",
+ "Persons",
+ {
+ ...data,
+ updatedBy: req.user.userId,
+ },
+ {
+ transaction: transaction,
+ where : { id: personId },
+ }
);
+ }
+ );
- console.log("Basic detail updated");
+ console.log("Basic detail updated");
- return { message: "Basic details updated", status: 200 };
- } catch (err) {
- console.log(err);
- return { message: err, status: 500 };
- }
+ return { message: "Basic details updated", status: 200 };
+ } catch (err) {
+ console.log(err);
+ return { message: err, status: 500 };
+ }
};
const getRegistrationInfoFunc = async (req, res) => {
- try {
- let userID = req.user.userId;
+ try {
+ let userID = req.user.userId;
- console.log("User ID = " + userID);
+ console.log("User ID = " + userID);
- /**
+ /**
* TODO: put another model data to patient if required
*/
- let doctorDetails = await databaseActions.findOne(
- "application",
- "DoctorDetails",
- {
- include: [
- {
- as : "Persons",
- model: databaseProvider.application.models.Persons,
- where: { userId: userID },
- },
- ],
- }
- );
-
- let personDocs = doctorDetails
- ? await databaseActions.findOne("application", "PersonDocs", {
- where: {
- personId: doctorDetails?.dataValues?.Persons?.id,
- type : "Registration Document",
- },
- })
- : null;
-
- let temp = { ...doctorDetails?.dataValues };
-
- delete temp.Persons;
- temp["departmentId"] = doctorDetails?.dataValues?.Persons?.departmentId;
- temp["registrationDocument"] = personDocs?.docUrl;
-
- if (doctorDetails) {
- return {
- data : temp,
- message: "Registration info fetched successfully",
- status : 200,
- };
- } else {
- return { message: "Person registration info not found", status: 204 };
- }
- } catch (err) {
- console.error(err);
- return {
- error : err,
- message: "Error while fetch person registration info data",
- };
+ let doctorDetails = await databaseActions.findOne(
+ "application",
+ "DoctorDetails",
+ {
+ include: [
+ {
+ as : "Persons",
+ model: databaseProvider.application.models.Persons,
+ where: { userId: userID },
+ },
+ ],
+ }
+ );
+
+ let personDocs = doctorDetails
+ ? await databaseActions.findOne("application", "PersonDocs", {
+ where: {
+ personId: doctorDetails?.dataValues?.Persons?.id,
+ type : "Registration Document",
+ },
+ })
+ : null;
+
+ let temp = { ...doctorDetails?.dataValues };
+
+ delete temp.Persons;
+ temp["departmentId"] = doctorDetails?.dataValues?.Persons?.departmentId;
+ temp["registrationDocument"] = personDocs?.docUrl;
+
+ if (doctorDetails) {
+ return {
+ data : temp,
+ message: "Registration info fetched successfully",
+ status : 200,
+ };
+ } else {
+ return { message: "Person registration info not found", status: 204 };
}
+ } catch (err) {
+ console.error(err);
+ return {
+ error : err,
+ message: "Error while fetch person registration info data",
+ };
+ }
};
const putRegistrationDetailsFunc = async (req, res) => {
- try {
- let del_urls = [];
- let file_url = null;
- let personId = req.params.id;
+ try {
+ let del_urls = [];
+ let file_url = null;
+ let personId = req.params.id;
- if (
- req.file["registrationDocument"] &&
+ if (
+ req.file["registrationDocument"] &&
req.file["registrationDocument"][0]
- ) {
- //eslint-disable-next-line no-undef
- file_url = await getUrl(
- req.file["registrationDocument"][0].filename
- ? req.file["registrationDocument"][0].filename
- : req.file["registrationDocument"][0].key
- ? req.file["registrationDocument"][0].key
- : req.file["registrationDocument"][0].originalname
+ ) {
+ //eslint-disable-next-line no-undef
+ file_url = await getUrl(
+ req.file["registrationDocument"][0].filename
+ ? req.file["registrationDocument"][0].filename
+ : req.file["registrationDocument"][0].key
+ ? req.file["registrationDocument"][0].key
+ : req.file["registrationDocument"][0].originalname
+ );
+ }
+ console.log("File URL", file_url);
+
+ let docData = await databaseActions.findOne("application", "DoctorDetails", { where: { doctorId: req.params.id } });
+
+ del_urls.push(file_url);
+
+ let data = req.body;
+ let result = await databaseProvider.application.sequelize.transaction(
+ async (transaction) => {
+ data.personDocs = [];
+
+ if (!docData) {
+ console.log("Docotr details not found");
+ let docDetail = await databaseActions.create(
+ "application",
+ "DoctorDetails",
+ {
+ ...data,
+ doctorId : personId,
+ updatedBy: req.user.userId,
+ },
+ { transaction: transaction }
+ );
+ } else {
+ console.log("Docotr details found: ", docData.id);
+ }
+
+ if (file_url) {
+ let [nrows, rows] = await databaseActions.update(
+ "application",
+ "PersonDocs",
+ {
+ docUrl : file_url,
+ updatedBy: req.user.userId,
+ },
+ { where: { personId: personId } },
+ { transaction: transaction }
+ );
+
+ if (nrows == 0) {
+ let nPersonDocs = await databaseActions.create(
+ "application",
+ "PersonDocs",
+ {
+ docUrl : file_url,
+ personId,
+ type : "Registration Document",
+ updatedBy: req.user.userId,
+ },
+ { transaction: transaction }
);
+
+ console.log("Registration file entry made:", nPersonDocs.id);
+ } else {
+ console.log("Registration file URL updated");
+ }
+ } else {
+ console.log("No registration file given");
}
- console.log("File URL", file_url);
-
- let docData = await databaseActions.findOne("application", "DoctorDetails", { where: { doctorId: req.params.id } });
-
- del_urls.push(file_url);
-
- let data = req.body;
- let result = await databaseProvider.application.sequelize.transaction(
- async (transaction) => {
- data.personDocs = [];
-
- if (!docData) {
- console.log("Docotr details not found");
- let docDetail = await databaseActions.create(
- "application",
- "DoctorDetails",
- {
- ...data,
- doctorId : personId,
- updatedBy: req.user.userId,
- },
- { transaction: transaction }
- );
- } else {
- console.log("Docotr details found: ", docData.id);
- }
-
- if (file_url) {
- let [nrows, rows] = await databaseActions.update(
- "application",
- "PersonDocs",
- {
- docUrl : file_url,
- updatedBy: req.user.userId,
- },
- { where: { personId: personId } },
- { transaction: transaction }
- );
-
- if (nrows == 0) {
- let nPersonDocs = await databaseActions.create(
- "application",
- "PersonDocs",
- {
- docUrl : file_url,
- personId,
- type : "Registration Document",
- updatedBy: req.user.userId,
- },
- { transaction: transaction }
- );
-
- console.log("Registration file entry made:", nPersonDocs.id);
- } else {
- console.log("Registration file URL updated");
- }
- } else {
- console.log("No registration file given");
- }
-
- if (data.departmentId) {
- let docDetail = await databaseActions.update(
- "application",
- "Persons",
- {
- departmentId: data.departmentId,
- updatedBy : req.user.userId,
- },
- { where: { id: personId } },
- { transaction: transaction }
- );
-
- console.log("Department updated");
- }
-
- let docDetail = await databaseActions.update(
- "application",
- "DoctorDetails",
- {
- ...data,
- updatedBy: req.user.userId,
- },
- { where: { doctorId: personId } },
- { transaction: transaction }
- );
- }
- );
- console.log("Registration detail updated");
- return { message: "Registration details updated", status: 200 };
- } catch (err) {
- console.log(err);
- return { message: err, status: 500 };
- }
+ if (data.departmentId) {
+ let docDetail = await databaseActions.update(
+ "application",
+ "Persons",
+ {
+ departmentId: data.departmentId,
+ updatedBy : req.user.userId,
+ },
+ { where: { id: personId } },
+ { transaction: transaction }
+ );
+
+ console.log("Department updated");
+ }
+
+ let docDetail = await databaseActions.update(
+ "application",
+ "DoctorDetails",
+ {
+ ...data,
+ updatedBy: req.user.userId,
+ },
+ { where: { doctorId: personId } },
+ { transaction: transaction }
+ );
+ }
+ );
+
+ console.log("Registration detail updated");
+ return { message: "Registration details updated", status: 200 };
+ } catch (err) {
+ console.log(err);
+ return { message: err, status: 500 };
+ }
};
const postAddEducationFunc = async (req, res) => {
- try {
- let data = req.body;
- let personId = req.params.id;
- let result = await databaseProvider.application.sequelize.transaction(
- async (transaction) => {
- if (data.isCurrent) {
- data.endDate = null;
- }
- let addDetail = await databaseActions.create(
- "application",
- "PersonEducations",
- {
- ...data,
- _status : coreConstant.entityStatus.ACTIVE,
- createdBy: req.user.userId,
- personId : personId,
- updatedBy: req.user.userId,
- },
- { transaction: transaction }
- );
-
- return addDetail.id;
- }
+ try {
+ let data = req.body;
+ let personId = req.params.id;
+ let result = await databaseProvider.application.sequelize.transaction(
+ async (transaction) => {
+ if (data.isCurrent) {
+ data.endDate = null;
+ }
+ let addDetail = await databaseActions.create(
+ "application",
+ "PersonEducations",
+ {
+ ...data,
+ _status : coreConstant.entityStatus.ACTIVE,
+ createdBy: req.user.userId,
+ personId : personId,
+ updatedBy: req.user.userId,
+ },
+ { transaction: transaction }
);
- console.log("Education created", result);
- return { message: "Education create success", status: 200 };
- } catch (err) {
- console.log(err);
- return { message: err, status: 500 };
- }
+ return addDetail.id;
+ }
+ );
+
+ console.log("Education created", result);
+ return { message: "Education create success", status: 200 };
+ } catch (err) {
+ console.log(err);
+ return { message: err, status: 500 };
+ }
};
const putUpdateEducationFunc = async (req, res) => {
- try {
- let data = req.body;
+ try {
+ let data = req.body;
- if (data.isCurrent) {
- data.endDate = null;
- }
- let result = await databaseProvider.application.sequelize.transaction(
- async (transaction) => {
- let [nrows, rows] = await databaseActions.update(
- "application",
- "PersonEducations",
- {
- ...data,
- updatedBy: req.user.userId,
- },
- { where: { id: req.params.id } },
- { transaction: transaction }
- );
-
- if (nrows == 0) {
- throw "Education update success";
- }
- }
+ if (data.isCurrent) {
+ data.endDate = null;
+ }
+ let result = await databaseProvider.application.sequelize.transaction(
+ async (transaction) => {
+ let [nrows, rows] = await databaseActions.update(
+ "application",
+ "PersonEducations",
+ {
+ ...data,
+ updatedBy: req.user.userId,
+ },
+ { where: { id: req.params.id } },
+ { transaction: transaction }
);
- console.log("Education detail updated");
- return { message: "Education update success", status: 200 };
- } catch (err) {
- console.log(err);
- return { message: err, status: 500 };
- }
+ if (nrows == 0) {
+ throw "Education update success";
+ }
+ }
+ );
+
+ console.log("Education detail updated");
+ return { message: "Education update success", status: 200 };
+ } catch (err) {
+ console.log(err);
+ return { message: err, status: 500 };
+ }
};
const putDeleteEducationFunc = async (req, res) => {
- try {
- let educationId = req.params.id;
- let result = await databaseProvider.application.sequelize.transaction(
- async (transaction) => {
- let [nrows, rows] = await databaseActions.update(
- "application",
- "PersonEducations",
- {
- _status : coreConstant.entityStatus.DELETED,
- isActive : false,
- updatedBy: req.user.userId,
- },
- { where: { id: educationId } },
- { transaction: transaction }
- );
-
- if (nrows == 0) {
- throw "Experience update success";
- }
- }
+ try {
+ let educationId = req.params.id;
+ let result = await databaseProvider.application.sequelize.transaction(
+ async (transaction) => {
+ let [nrows, rows] = await databaseActions.update(
+ "application",
+ "PersonEducations",
+ {
+ _status : coreConstant.entityStatus.DELETED,
+ isActive : false,
+ updatedBy: req.user.userId,
+ },
+ { where: { id: educationId } },
+ { transaction: transaction }
);
- console.log("education deleted: ", req.params.id);
- return { message: "Education delete success", status: 200 };
- } catch (error) {
- console.log("education Delete error", error);
- return { message: error, status: 500 };
- }
+ if (nrows == 0) {
+ throw "Experience update success";
+ }
+ }
+ );
+
+ console.log("education deleted: ", req.params.id);
+ return { message: "Education delete success", status: 200 };
+ } catch (error) {
+ console.log("education Delete error", error);
+ return { message: error, status: 500 };
+ }
};
const postAddExperienceFunc = async (req, res) => {
- try {
- let data = req.body;
- let personId = req.params.id;
- let result = await databaseProvider.application.sequelize.transaction(
- async (transaction) => {
- if (data.isCurrent) {
- data.endDate = null;
- }
- let addDetail = await databaseActions.create(
- "application",
- "PersonExperiences",
- {
- ...data,
- _status : coreConstant.entityStatus.ACTIVE,
- createdBy: req.user.userId,
- personId : personId,
- updatedBy: req.user.userId,
- },
- { transaction: transaction }
- );
-
- return addDetail.id;
- }
+ try {
+ let data = req.body;
+ let personId = req.params.id;
+ let result = await databaseProvider.application.sequelize.transaction(
+ async (transaction) => {
+ if (data.isCurrent) {
+ data.endDate = null;
+ }
+ let addDetail = await databaseActions.create(
+ "application",
+ "PersonExperiences",
+ {
+ ...data,
+ _status : coreConstant.entityStatus.ACTIVE,
+ createdBy: req.user.userId,
+ personId : personId,
+ updatedBy: req.user.userId,
+ },
+ { transaction: transaction }
);
- console.log("Experience created", result);
- return { message: "Experience create success", status: 200 };
- } catch (err) {
- console.log(err);
- return { message: err, status: 500 };
- }
+ return addDetail.id;
+ }
+ );
+
+ console.log("Experience created", result);
+ return { message: "Experience create success", status: 200 };
+ } catch (err) {
+ console.log(err);
+ return { message: err, status: 500 };
+ }
};
const putUpdateExperienceFunc = async (req, res) => {
- try {
- let data = req.body;
+ try {
+ let data = req.body;
- if (data.isCurrent) {
- data.endDate = null;
- }
- let result = await databaseProvider.application.sequelize.transaction(
- async (transaction) => {
- let [nrows] = await databaseActions.update(
- "application",
- "PersonExperiences",
- {
- ...data,
- updatedBy: req.user.userId,
- },
- { where: { id: req.params.id } },
- { transaction: transaction }
- );
-
- if (nrows == 0) {
- throw "Experience update error";
- }
- }
+ if (data.isCurrent) {
+ data.endDate = null;
+ }
+ let result = await databaseProvider.application.sequelize.transaction(
+ async (transaction) => {
+ let [nrows] = await databaseActions.update(
+ "application",
+ "PersonExperiences",
+ {
+ ...data,
+ updatedBy: req.user.userId,
+ },
+ { where: { id: req.params.id } },
+ { transaction: transaction }
);
- console.log("Experiences detail updated");
- return { message: "Experience update success", status: 200 };
- } catch (err) {
- console.log(err);
- return { message: err, status: 500 };
- }
+ if (nrows == 0) {
+ throw "Experience update error";
+ }
+ }
+ );
+
+ console.log("Experiences detail updated");
+ return { message: "Experience update success", status: 200 };
+ } catch (err) {
+ console.log(err);
+ return { message: err, status: 500 };
+ }
};
const putDeleteExperienceFunc = async (req, res) => {
- try {
- let result = await databaseProvider.application.sequelize.transaction(
- async (transaction) => {
- let experienceId = req.params.id;
- let [nrows, rows] = await databaseActions.update(
- "application",
- "PersonExperiences",
- {
- _status : coreConstant.entityStatus.DELETED,
- isActive : false,
- updatedBy: req.user.userId,
- },
- { where: { id: experienceId } },
- { transaction: transaction }
- );
-
- if (nrows == 0) {
- throw "Experience delete error";
- }
- }
+ try {
+ let result = await databaseProvider.application.sequelize.transaction(
+ async (transaction) => {
+ let experienceId = req.params.id;
+ let [nrows, rows] = await databaseActions.update(
+ "application",
+ "PersonExperiences",
+ {
+ _status : coreConstant.entityStatus.DELETED,
+ isActive : false,
+ updatedBy: req.user.userId,
+ },
+ { where: { id: experienceId } },
+ { transaction: transaction }
);
- console.log("Experiences deleted: ", req.params.id);
- return { message: "Experience delete success", status: 200 };
- } catch (error) {
- console.log("education Delete error", error);
- return { message: error, status: 500 };
- }
+ if (nrows == 0) {
+ throw "Experience delete error";
+ }
+ }
+ );
+
+ console.log("Experiences deleted: ", req.params.id);
+ return { message: "Experience delete success", status: 200 };
+ } catch (error) {
+ console.log("education Delete error", error);
+ return { message: error, status: 500 };
+ }
};
module.exports = {
- getAddressTypeFunc,
- getContactInfoFunc,
- getDepartmentFunc,
- getRegistrationInfoFunc,
- postAddEducationFunc,
- postAddExperienceFunc,
- putBasicDetailsFunc,
- putDeleteEducationFunc,
- putDeleteExperienceFunc,
- putRegistrationDetailsFunc,
- putUpdateEducationFunc,
- putUpdateExperienceFunc,
+ getAddressTypeFunc,
+ getContactInfoFunc,
+ getDepartmentFunc,
+ getRegistrationInfoFunc,
+ postAddEducationFunc,
+ postAddExperienceFunc,
+ putBasicDetailsFunc,
+ putDeleteEducationFunc,
+ putDeleteExperienceFunc,
+ putRegistrationDetailsFunc,
+ putUpdateEducationFunc,
+ putUpdateExperienceFunc,
};
diff --git a/service/models.registry.js b/service/models.registry.js
index c980bcc..99f52f4 100644
--- a/service/models.registry.js
+++ b/service/models.registry.js
@@ -7,43 +7,44 @@ const PersonExperiences = require("./models/PersonExperiences.model");
const PersonRelations = require("./models/PersonRelations.model");
const Persons = require("./models/Persons.model");
const Relations = require("./models/Relations.model");
+
const modelsRegistry = {
- AddressTypes: {
- database: "application",
- model : AddressTypes
- },
- PersonAddresses: {
- database: "application",
- model : PersonAddresses
- },
- PersonContacts: {
- database: "application",
- model : PersonContacts
- },
- PersonDocs: {
- database: "application",
- model : PersonDocs
- },
- PersonEducations: {
- database: "application",
- model : PersonEducations
- },
- PersonExperiences: {
- database: "application",
- model : PersonExperiences
- },
- PersonRelations: {
- database: "application",
- model : PersonRelations
- },
- Persons: {
- database: "application",
- model : Persons
- },
- Relations: {
- database: "application",
- model : Relations
- }
+ AddressTypes: {
+ database: "application",
+ model : AddressTypes
+ },
+ PersonAddresses: {
+ database: "application",
+ model : PersonAddresses
+ },
+ PersonContacts: {
+ database: "application",
+ model : PersonContacts
+ },
+ PersonDocs: {
+ database: "application",
+ model : PersonDocs
+ },
+ PersonEducations: {
+ database: "application",
+ model : PersonEducations
+ },
+ PersonExperiences: {
+ database: "application",
+ model : PersonExperiences
+ },
+ PersonRelations: {
+ database: "application",
+ model : PersonRelations
+ },
+ Persons: {
+ database: "application",
+ model : Persons
+ },
+ Relations: {
+ database: "application",
+ model : Relations
+ }
};
exports.modelsRegistry = modelsRegistry;
diff --git a/service/models/AddressTypes.model.js b/service/models/AddressTypes.model.js
index 860650c..411a652 100644
--- a/service/models/AddressTypes.model.js
+++ b/service/models/AddressTypes.model.js
@@ -1,46 +1,46 @@
module.exports = (sequelize, DataTypes) => {
- const addressTypes = sequelize.define("AddressTypes", {
- _status : { type: DataTypes.STRING },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- type: {
- defaultValue: "",
- type : DataTypes.STRING
- }
- });
+ const addressTypes = sequelize.define("AddressTypes", {
+ _status : { type: DataTypes.STRING },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ type: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ }
+ });
- addressTypes.associate = (models) => {
- addressTypes.hasMany(models.PersonAddresses, {
- foreignKey: "addressTypeId",
- sourceKey : "id"
- });
- addressTypes.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- addressTypes.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- addressTypes.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ addressTypes.associate = (models) => {
+ addressTypes.hasMany(models.PersonAddresses, {
+ foreignKey: "addressTypeId",
+ sourceKey : "id"
+ });
+ addressTypes.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ addressTypes.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ addressTypes.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return addressTypes;
+ return addressTypes;
};
diff --git a/service/models/PersonAddresses.model.js b/service/models/PersonAddresses.model.js
index afc205d..e91d8d7 100644
--- a/service/models/PersonAddresses.model.js
+++ b/service/models/PersonAddresses.model.js
@@ -1,99 +1,99 @@
module.exports = (sequelize, DataTypes) => {
- const personAddresses = sequelize.define("PersonAddresses", {
- _status : { type: DataTypes.STRING },
- addLine1: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- addLine2: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- city: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- country: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- district: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- fullName: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- isDefault: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- landmark: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- phone: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- pin: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- state: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- status: {
- defaultValue: "",
- type : DataTypes.STRING
- }
- });
+ const personAddresses = sequelize.define("PersonAddresses", {
+ _status : { type: DataTypes.STRING },
+ addLine1: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ addLine2: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ city: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ country: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ district: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ fullName: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ isDefault: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ landmark: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ phone: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ pin: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ state: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ status: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ }
+ });
- personAddresses.associate = (models) => {
- personAddresses.belongsTo(models.Persons, {
- as : "Person",
- foreignKey: "personId",
- sourceKey : "id"
- });
- personAddresses.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- personAddresses.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- personAddresses.belongsTo(models.AddressTypes, {
- foreignKey: "addressTypeId",
- sourceKey : "id"
- });
- personAddresses.hasOne(models.Clinics, {
- foreignKey: "personAddressId",
- sourceKey : "id"
- });
- personAddresses.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ personAddresses.associate = (models) => {
+ personAddresses.belongsTo(models.Persons, {
+ as : "Person",
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ personAddresses.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ personAddresses.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ personAddresses.belongsTo(models.AddressTypes, {
+ foreignKey: "addressTypeId",
+ sourceKey : "id"
+ });
+ personAddresses.hasOne(models.Clinics, {
+ foreignKey: "personAddressId",
+ sourceKey : "id"
+ });
+ personAddresses.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return personAddresses;
+ return personAddresses;
};
diff --git a/service/models/PersonContacts.model.js b/service/models/PersonContacts.model.js
index 15abe94..7279d35 100644
--- a/service/models/PersonContacts.model.js
+++ b/service/models/PersonContacts.model.js
@@ -1,62 +1,62 @@
module.exports = (sequelize, DataTypes) => {
- const personContacts = sequelize.define("PersonContacts", {
- _status: { type: DataTypes.STRING },
- data : {
- defaultValue: "",
- type : DataTypes.STRING
- },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- notificationFlag: {
- defaultValue: false,
- type : DataTypes.BOOLEAN
- },
- primaryFlag: {
- defaultValue: false,
- type : DataTypes.BOOLEAN
- },
- type: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- verified: {
- defaultValue: false,
- type : DataTypes.BOOLEAN
- }
- });
+ const personContacts = sequelize.define("PersonContacts", {
+ _status: { type: DataTypes.STRING },
+ data : {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ notificationFlag: {
+ defaultValue: false,
+ type : DataTypes.BOOLEAN
+ },
+ primaryFlag: {
+ defaultValue: false,
+ type : DataTypes.BOOLEAN
+ },
+ type: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ verified: {
+ defaultValue: false,
+ type : DataTypes.BOOLEAN
+ }
+ });
- personContacts.associate = (models) => {
- personContacts.belongsTo(models.Persons, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- personContacts.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- personContacts.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- personContacts.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ personContacts.associate = (models) => {
+ personContacts.belongsTo(models.Persons, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ personContacts.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ personContacts.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ personContacts.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return personContacts;
+ return personContacts;
};
diff --git a/service/models/PersonDocs.model.js b/service/models/PersonDocs.model.js
index 6995f59..c56eba9 100644
--- a/service/models/PersonDocs.model.js
+++ b/service/models/PersonDocs.model.js
@@ -1,54 +1,54 @@
module.exports = (sequelize, DataTypes) => {
- const personDocs = sequelize.define("PersonDocs", {
- _status : { type: DataTypes.STRING },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- description: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- docUrl: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- type: {
- defaultValue: "",
- type : DataTypes.STRING
- }
- });
+ const personDocs = sequelize.define("PersonDocs", {
+ _status : { type: DataTypes.STRING },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ description: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ docUrl: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ type: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ }
+ });
- personDocs.associate = (models) => {
- personDocs.belongsTo(models.Persons, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- personDocs.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- personDocs.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- personDocs.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ personDocs.associate = (models) => {
+ personDocs.belongsTo(models.Persons, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ personDocs.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ personDocs.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ personDocs.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return personDocs;
+ return personDocs;
};
diff --git a/service/models/PersonEducations.model.js b/service/models/PersonEducations.model.js
index 8ff1d0a..8fff783 100644
--- a/service/models/PersonEducations.model.js
+++ b/service/models/PersonEducations.model.js
@@ -1,90 +1,90 @@
module.exports = (sequelize, DataTypes) => {
- const personEducations = sequelize.define("PersonEducations", {
- _status: { type: DataTypes.STRING },
- board : {
- defaultValue: "",
- type : DataTypes.STRING
- },
- degree: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- endDate: {
- defaultValue: new Date(),
- type : "TIMESTAMP"
- },
- endMonth: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- endYear: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- field: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- location: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- school: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- startDate: {
- defaultValue: new Date(),
- type : "TIMESTAMP"
- },
- startMonth: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- startYear: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- type: {
- defaultValue: "",
- type : DataTypes.STRING
- }
- });
+ const personEducations = sequelize.define("PersonEducations", {
+ _status: { type: DataTypes.STRING },
+ board : {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ degree: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ endDate: {
+ defaultValue: new Date(),
+ type : "TIMESTAMP"
+ },
+ endMonth: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ endYear: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ field: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ location: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ school: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ startDate: {
+ defaultValue: new Date(),
+ type : "TIMESTAMP"
+ },
+ startMonth: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ startYear: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ type: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ }
+ });
- personEducations.associate = (models) => {
- personEducations.belongsTo(models.Persons, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- personEducations.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- personEducations.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- personEducations.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ personEducations.associate = (models) => {
+ personEducations.belongsTo(models.Persons, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ personEducations.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ personEducations.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ personEducations.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return personEducations;
+ return personEducations;
};
diff --git a/service/models/PersonExperiences.model.js b/service/models/PersonExperiences.model.js
index 06a78c0..96c8209 100644
--- a/service/models/PersonExperiences.model.js
+++ b/service/models/PersonExperiences.model.js
@@ -1,90 +1,90 @@
module.exports = (sequelize, DataTypes) => {
- const personExperiences = sequelize.define("PersonExperiences", {
- _status : { type: DataTypes.STRING },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- description: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- designation: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- endDate: {
- defaultValue: new Date(),
- type : "TIMESTAMP"
- },
- endMonth: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- endYear: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- field: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- location: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- organization: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- startDate: {
- defaultValue: new Date(),
- type : "TIMESTAMP"
- },
- startMonth: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- startYear: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- type: {
- defaultValue: "",
- type : DataTypes.STRING
- }
- });
+ const personExperiences = sequelize.define("PersonExperiences", {
+ _status : { type: DataTypes.STRING },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ description: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ designation: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ endDate: {
+ defaultValue: new Date(),
+ type : "TIMESTAMP"
+ },
+ endMonth: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ endYear: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ field: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ location: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ organization: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ startDate: {
+ defaultValue: new Date(),
+ type : "TIMESTAMP"
+ },
+ startMonth: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ startYear: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ type: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ }
+ });
- personExperiences.associate = (models) => {
- personExperiences.belongsTo(models.Persons, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- personExperiences.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- personExperiences.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- personExperiences.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ personExperiences.associate = (models) => {
+ personExperiences.belongsTo(models.Persons, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ personExperiences.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ personExperiences.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ personExperiences.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return personExperiences;
+ return personExperiences;
};
diff --git a/service/models/PersonRelations.model.js b/service/models/PersonRelations.model.js
index f5f3d2c..fb8efbf 100644
--- a/service/models/PersonRelations.model.js
+++ b/service/models/PersonRelations.model.js
@@ -1,56 +1,56 @@
module.exports = (sequelize, DataTypes) => {
- const personRelations = sequelize.define("PersonRelations", {
- _status : { type: DataTypes.STRING },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- extraInfo: {
- defaultValue: null,
- type : DataTypes.JSONB
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- }
- });
+ const personRelations = sequelize.define("PersonRelations", {
+ _status : { type: DataTypes.STRING },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ extraInfo: {
+ defaultValue: null,
+ type : DataTypes.JSONB
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ }
+ });
- personRelations.associate = (models) => {
- personRelations.belongsTo(models.Persons, {
- as : "Person",
- foreignKey: "personId",
- sourceKey : "id"
- });
- personRelations.belongsTo(models.Persons, {
- as : "RelatedPerson",
- foreignKey: "relatedPersonId",
- sourceKey : "id"
- });
- personRelations.belongsTo(models.Relations, {
- foreignKey: "relationId",
- sourceKey : "id"
- });
- personRelations.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- personRelations.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- personRelations.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ personRelations.associate = (models) => {
+ personRelations.belongsTo(models.Persons, {
+ as : "Person",
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ personRelations.belongsTo(models.Persons, {
+ as : "RelatedPerson",
+ foreignKey: "relatedPersonId",
+ sourceKey : "id"
+ });
+ personRelations.belongsTo(models.Relations, {
+ foreignKey: "relationId",
+ sourceKey : "id"
+ });
+ personRelations.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ personRelations.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ personRelations.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return personRelations;
+ return personRelations;
};
diff --git a/service/models/Persons.model.js b/service/models/Persons.model.js
index 145866b..9ade415 100644
--- a/service/models/Persons.model.js
+++ b/service/models/Persons.model.js
@@ -1,159 +1,159 @@
module.exports = (sequelize, DataTypes) => {
- const person = sequelize.define("Persons", {
- _status : { type: DataTypes.STRING },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- dob: {
- defaultValue: new Date(),
- type : "TIMESTAMP"
- },
- emailVerified: {
- defaultValue: false,
- type : DataTypes.BOOLEAN
- },
- extraInfo: {
- defaultValue: null,
- type : DataTypes.JSONB
- },
- firstName: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- gender: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- height: {
- defaultValue: null,
- type : DataTypes.FLOAT
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- isVerified: {
- defaultValue: false,
- type : DataTypes.BOOLEAN
- },
- lastName: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- medicalId: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- middleName: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- phoneVerified: {
- defaultValue: false,
- type : DataTypes.BOOLEAN
- },
- photoUrl: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- profileId: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- rating: {
- defaultValue: null,
- type : DataTypes.FLOAT
- },
- userInvitationToken: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- website: {
- defaultValue: "",
- type : DataTypes.STRING
- },
- weight: {
- defaultValue: null,
- type : DataTypes.FLOAT
- }
- });
+ const person = sequelize.define("Persons", {
+ _status : { type: DataTypes.STRING },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ dob: {
+ defaultValue: new Date(),
+ type : "TIMESTAMP"
+ },
+ emailVerified: {
+ defaultValue: false,
+ type : DataTypes.BOOLEAN
+ },
+ extraInfo: {
+ defaultValue: null,
+ type : DataTypes.JSONB
+ },
+ firstName: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ gender: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ height: {
+ defaultValue: null,
+ type : DataTypes.FLOAT
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ isVerified: {
+ defaultValue: false,
+ type : DataTypes.BOOLEAN
+ },
+ lastName: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ medicalId: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ middleName: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ phoneVerified: {
+ defaultValue: false,
+ type : DataTypes.BOOLEAN
+ },
+ photoUrl: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ profileId: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ rating: {
+ defaultValue: null,
+ type : DataTypes.FLOAT
+ },
+ userInvitationToken: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ website: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ },
+ weight: {
+ defaultValue: null,
+ type : DataTypes.FLOAT
+ }
+ });
- person.associate = (models) => {
- person.belongsTo(models.Users, {
- as : "User",
- foreignKey: "userId",
- sourceKey : "id"
- });
- person.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- person.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- person.belongsTo(models.Departments, {
- foreignKey: "departmentId",
- sourceKey : "id"
- });
- person.hasMany(models.PersonRelations, {
- as : "Person",
- foreignKey: "personId",
- sourceKey : "id"
- });
- person.hasMany(models.PersonContacts, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- person.hasMany(models.PersonRelations, {
- as : "RelatedPersons",
- foreignKey: "relatedPersonId",
- sourceKey : "id"
- });
- person.hasOne(models.DoctorDetails, {
- foreignKey: "doctorId",
- sourceKey : "id"
- });
- person.hasMany(models.PersonAddresses, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- person.hasMany(models.PersonEducations, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- person.hasMany(models.PersonExperiences, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- person.hasMany(models.PersonDocs, {
- foreignKey: "personId",
- sourceKey : "id"
- });
- person.hasMany(models.Appointments, {
- as : "DoctorAppointments",
- foreignKey: "doctorId",
- sourceKey : "id"
- });
- person.hasMany(models.Appointments, {
- as : "PatientAppointments",
- foreignKey: "patientId",
- sourceKey : "id"
- });
- person.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ person.associate = (models) => {
+ person.belongsTo(models.Users, {
+ as : "User",
+ foreignKey: "userId",
+ sourceKey : "id"
+ });
+ person.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ person.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ person.belongsTo(models.Departments, {
+ foreignKey: "departmentId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.PersonRelations, {
+ as : "Person",
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.PersonContacts, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.PersonRelations, {
+ as : "RelatedPersons",
+ foreignKey: "relatedPersonId",
+ sourceKey : "id"
+ });
+ person.hasOne(models.DoctorDetails, {
+ foreignKey: "doctorId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.PersonAddresses, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.PersonEducations, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.PersonExperiences, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.PersonDocs, {
+ foreignKey: "personId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.Appointments, {
+ as : "DoctorAppointments",
+ foreignKey: "doctorId",
+ sourceKey : "id"
+ });
+ person.hasMany(models.Appointments, {
+ as : "PatientAppointments",
+ foreignKey: "patientId",
+ sourceKey : "id"
+ });
+ person.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return person;
+ return person;
};
diff --git a/service/models/Relations.model.js b/service/models/Relations.model.js
index 9d27725..f07b0e8 100644
--- a/service/models/Relations.model.js
+++ b/service/models/Relations.model.js
@@ -1,50 +1,50 @@
module.exports = (sequelize, DataTypes) => {
- const relations = sequelize.define("Relations", {
- _status : { type: DataTypes.STRING },
- deletedAt: {
- allowNull: true,
- type : "TIMESTAMP"
- },
- extraInfo: {
- defaultValue: null,
- type : DataTypes.JSONB
- },
- id: {
- autoIncrement: true,
- primaryKey : true,
- type : DataTypes.INTEGER
- },
- isActive: {
- defaultValue: true,
- type : DataTypes.BOOLEAN
- },
- name: {
- defaultValue: "",
- type : DataTypes.STRING
- }
- });
+ const relations = sequelize.define("Relations", {
+ _status : { type: DataTypes.STRING },
+ deletedAt: {
+ allowNull: true,
+ type : "TIMESTAMP"
+ },
+ extraInfo: {
+ defaultValue: null,
+ type : DataTypes.JSONB
+ },
+ id: {
+ autoIncrement: true,
+ primaryKey : true,
+ type : DataTypes.INTEGER
+ },
+ isActive: {
+ defaultValue: true,
+ type : DataTypes.BOOLEAN
+ },
+ name: {
+ defaultValue: "",
+ type : DataTypes.STRING
+ }
+ });
- relations.associate = (models) => {
- relations.belongsTo(models.Users, {
- as : "Owner",
- foreignKey: "createdBy",
- sourceKey : "id"
- });
- relations.belongsTo(models.Users, {
- as : "Updater",
- foreignKey: "updatedBy",
- sourceKey : "id"
- });
- relations.hasMany(models.PersonRelations, {
- foreignKey: "relationId",
- sourceKey : "id"
- });
- relations.belongsTo(models.Users, {
- as : "Destroyer",
- foreignKey: "deletedBy",
- sourceKey : "id"
- });
- };
+ relations.associate = (models) => {
+ relations.belongsTo(models.Users, {
+ as : "Owner",
+ foreignKey: "createdBy",
+ sourceKey : "id"
+ });
+ relations.belongsTo(models.Users, {
+ as : "Updater",
+ foreignKey: "updatedBy",
+ sourceKey : "id"
+ });
+ relations.hasMany(models.PersonRelations, {
+ foreignKey: "relationId",
+ sourceKey : "id"
+ });
+ relations.belongsTo(models.Users, {
+ as : "Destroyer",
+ foreignKey: "deletedBy",
+ sourceKey : "id"
+ });
+ };
- return relations;
+ return relations;
};
diff --git a/service/validations/profile.validation.js b/service/validations/profile.validation.js
index ae905d0..0ff093b 100644
--- a/service/validations/profile.validation.js
+++ b/service/validations/profile.validation.js
@@ -2,180 +2,180 @@ const moment = require("moment");
const yup = require("yup");
const getContactInfo = {
- body : yup.object({}).noUnknown().strict(),
- query: yup.object({}).noUnknown().strict(),
+ body : yup.object({}).noUnknown().strict(),
+ query: yup.object({}).noUnknown().strict(),
};
const getAddressTypeSchema = {
- body : yup.object({}).noUnknown().strict(),
- query: yup.object({}).noUnknown().strict(),
+ body : yup.object({}).noUnknown().strict(),
+ query: yup.object({}).noUnknown().strict(),
};
const getPersonContacts = {
- body : yup.object({}).noUnknown().strict(),
- query: yup.object({}).noUnknown().strict(),
+ body : yup.object({}).noUnknown().strict(),
+ query: yup.object({}).noUnknown().strict(),
};
const getRegistrationInfo = {
- body : yup.object({}).noUnknown().strict(),
- query: yup.object({}).noUnknown().strict(),
+ body : yup.object({}).noUnknown().strict(),
+ query: yup.object({}).noUnknown().strict(),
};
const departmentGET = {
- body : yup.object({}).noUnknown().strict(),
- params: yup.object({}).noUnknown().strict(),
- query : yup.object({ isActive: yup.boolean() }).noUnknown().strict(),
+ body : yup.object({}).noUnknown().strict(),
+ params: yup.object({}).noUnknown().strict(),
+ query : yup.object({ isActive: yup.boolean() }).noUnknown().strict(),
};
const putUpdateExperience = yup.object({
- body: yup
- .object({
- description : yup.string().max(150),
- designation : yup.string().max(50),
- endDate : yup.string().nullable(),
- endMonth : yup.string().max(150),
- endYear : yup.string().max(150),
- field : yup.string().max(150),
- id : yup.mixed(),
- isActive : yup.boolean(),
- location : yup.string().max(150),
- organization: yup.string().max(150),
- startDate : yup.string(),
- startMonth : yup.string().max(150),
- startYear : yup.string().max(150),
- type : yup.string().max(50),
- })
- .noUnknown()
- .strict(),
+ body: yup
+ .object({
+ description : yup.string().max(150),
+ designation : yup.string().max(50),
+ endDate : yup.string().nullable(),
+ endMonth : yup.string().max(150),
+ endYear : yup.string().max(150),
+ field : yup.string().max(150),
+ id : yup.mixed(),
+ isActive : yup.boolean(),
+ location : yup.string().max(150),
+ organization: yup.string().max(150),
+ startDate : yup.string(),
+ startMonth : yup.string().max(150),
+ startYear : yup.string().max(150),
+ type : yup.string().max(50),
+ })
+ .noUnknown()
+ .strict(),
});
const putBasicDetails = yup.object({
- bio: yup
- .string()
- .trim()
- .matches(
- /^[a-zA-Z0-9\s.'"@$&-/\\?]+$/,
- "All special charecters are not allowed"
- ),
- dob: yup
- .date()
- .required()
- .min(moment().subtract(115, "years"), "MIN_AGE")
- .max(moment().endOf("day").subtract(18, "years"), "Min age should be 18"),
- firstName: yup
- .string()
- .trim()
- .required()
- .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
- gender : yup.string().required("Gender is required"),
- lastName: yup
- .string()
- .trim()
- .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
- middleName: yup
- .string()
- .trim()
- .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
+ bio: yup
+ .string()
+ .trim()
+ .matches(
+ /^[a-zA-Z0-9\s.'"@$&-/\\?]+$/,
+ "All special charecters are not allowed"
+ ),
+ dob: yup
+ .date()
+ .required()
+ .min(moment().subtract(115, "years"), "MIN_AGE")
+ .max(moment().endOf("day").subtract(18, "years"), "Min age should be 18"),
+ firstName: yup
+ .string()
+ .trim()
+ .required()
+ .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
+ gender : yup.string().required("Gender is required"),
+ lastName: yup
+ .string()
+ .trim()
+ .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
+ middleName: yup
+ .string()
+ .trim()
+ .matches(/^[a-zA-Z\s]+$/, "Only alphabets are allowed for this field "),
});
const putRegistrationDetails = yup.object({
- body: yup
- .object({
- regDate: yup.string(),
- regNo : yup.string(),
- regYear: yup.string(),
- })
- .noUnknown()
- .strict(),
+ body: yup
+ .object({
+ regDate: yup.string(),
+ regNo : yup.string(),
+ regYear: yup.string(),
+ })
+ .noUnknown()
+ .strict(),
});
const postAddEducation = yup.object({
- body: yup
- .object({
- board : yup.string().max(150),
- degree : yup.string().max(50),
- endDate : yup.string().nullable(),
- endMonth : yup.string().max(150),
- endYear : yup.string().max(150),
- field : yup.string().max(150),
- location : yup.string().max(150),
- school : yup.string().max(150),
- startDate : yup.string(),
- startMonth: yup.string().max(150),
- startYear : yup.string().max(150),
- type : yup.string().max(50),
- })
- .noUnknown()
- .strict(),
+ body: yup
+ .object({
+ board : yup.string().max(150),
+ degree : yup.string().max(50),
+ endDate : yup.string().nullable(),
+ endMonth : yup.string().max(150),
+ endYear : yup.string().max(150),
+ field : yup.string().max(150),
+ location : yup.string().max(150),
+ school : yup.string().max(150),
+ startDate : yup.string(),
+ startMonth: yup.string().max(150),
+ startYear : yup.string().max(150),
+ type : yup.string().max(50),
+ })
+ .noUnknown()
+ .strict(),
});
const postUpdateEducation = yup.object({
- body: yup
- .object({
- board : yup.string().max(150),
- degree : yup.string().max(50),
- endDate : yup.string().nullable(),
- endMonth : yup.string().max(150),
- endYear : yup.string().max(150),
- field : yup.string().max(150),
- id : yup.mixed(),
- isActive : yup.boolean(),
- location : yup.string().max(150),
- school : yup.string().max(150),
- startDate : yup.string(),
- startMonth: yup.string().max(150),
- startYear : yup.string().max(150),
- type : yup.string().max(50),
- })
- .noUnknown()
- .strict(),
+ body: yup
+ .object({
+ board : yup.string().max(150),
+ degree : yup.string().max(50),
+ endDate : yup.string().nullable(),
+ endMonth : yup.string().max(150),
+ endYear : yup.string().max(150),
+ field : yup.string().max(150),
+ id : yup.mixed(),
+ isActive : yup.boolean(),
+ location : yup.string().max(150),
+ school : yup.string().max(150),
+ startDate : yup.string(),
+ startMonth: yup.string().max(150),
+ startYear : yup.string().max(150),
+ type : yup.string().max(50),
+ })
+ .noUnknown()
+ .strict(),
});
const putDeleteEducation = yup.object({
- body: yup
- .object({ isActive: yup.boolean() })
- .noUnknown()
- .strict(),
+ body: yup
+ .object({ isActive: yup.boolean() })
+ .noUnknown()
+ .strict(),
});
const postAddExperience = yup.object({
- body: yup
- .object({
- description : yup.string().max(150),
- designation : yup.string().max(50),
- endDate : yup.string().nullable(),
- endMonth : yup.string().max(150),
- endYear : yup.string().max(150),
- field : yup.string().max(150),
- location : yup.string().max(150),
- organization: yup.string().max(150),
- startDate : yup.string(),
- startMonth : yup.string().max(150),
- startYear : yup.string().max(150),
- type : yup.string().max(50),
- })
- .noUnknown()
- .strict(),
+ body: yup
+ .object({
+ description : yup.string().max(150),
+ designation : yup.string().max(50),
+ endDate : yup.string().nullable(),
+ endMonth : yup.string().max(150),
+ endYear : yup.string().max(150),
+ field : yup.string().max(150),
+ location : yup.string().max(150),
+ organization: yup.string().max(150),
+ startDate : yup.string(),
+ startMonth : yup.string().max(150),
+ startYear : yup.string().max(150),
+ type : yup.string().max(50),
+ })
+ .noUnknown()
+ .strict(),
});
const putDeleteExperience = yup.object({
- body: yup
- .object({ isActive: yup.boolean() })
- .noUnknown()
- .strict(),
+ body: yup
+ .object({ isActive: yup.boolean() })
+ .noUnknown()
+ .strict(),
});
module.exports = {
- departmentGET,
- getAddressTypeSchema,
- getContactInfo,
- getPersonContacts,
- getRegistrationInfo,
- postAddEducation,
- postAddExperience,
- postUpdateEducation,
- putBasicDetails,
- putDeleteEducation,
- putDeleteExperience,
- putRegistrationDetails,
- putUpdateExperience
+ departmentGET,
+ getAddressTypeSchema,
+ getContactInfo,
+ getPersonContacts,
+ getRegistrationInfo,
+ postAddEducation,
+ postAddExperience,
+ postUpdateEducation,
+ putBasicDetails,
+ putDeleteEducation,
+ putDeleteExperience,
+ putRegistrationDetails,
+ putUpdateExperience
};