Skip to content

Commit

Permalink
feat: view for obs and gyn view (#180)
Browse files Browse the repository at this point in the history
* feat: added elements for the ob and gyn view

* feat: added name to other diagnosis

* fix: fixed an error in css

* feat: added elements to the view

* feat: finished the view

* feat: added GET and PUT integration to view, pending linting warnings to fix

* fix: added linting and formatting

* feat: added stories for ObGyn view, pending error state to be implemented since view doesn't have it

* fix: added empty state handling in view and story

* fix: linting and format

* feat: added tests for obgyn view

* fix: formatting

* feat: adding edit icon and some changes

* fix: fixed error on add other diagnosis button and formatting

* fix: fixed operations sections dropdown bug

* fix: formatting

* fix: fixed tests to match frontend updates

* fix: fixing pr

---------

Co-authored-by: Xavier López (Nathan) <[email protected]>
Co-authored-by: XavierLopez25 <[email protected]>
  • Loading branch information
3 people authored Sep 1, 2024
1 parent 32d70b0 commit b57f7e7
Show file tree
Hide file tree
Showing 9 changed files with 2,353 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async function createPatientWithGynecologicalHistory() {
otherCondition: [
{
medication: {
illness: "illness A",
medication: "Med D",
dosage: "500mg",
frequency: "Once a day",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function generateValidUpdate(patientId) {
otherCondition: [
{
medication: {
illness: "illness A",
medication: "Med D",
dosage: "500mg",
frequency: "Once a day",
Expand Down Expand Up @@ -150,6 +151,7 @@ describe("Update Gynecological Medical History integration tests", () => {
otherCondition: [
{
medication: {
illness: "illness A",
medication: "Med D",
dosage: "500mg",
frequency: "Once a day",
Expand Down
2 changes: 1 addition & 1 deletion sanitas_frontend/src/components/DashboardSidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default function DashboardSidebar({
fontWeight: "normal",
paddingBottom: "1rem",
paddingTop: "1rem",
borderBottom: `0.1rem solid ${colors.darkerGrey}`,
borderBottom: `0.04rem solid ${colors.darkerGrey}`,
}}
>
Antecedentes
Expand Down
2 changes: 1 addition & 1 deletion sanitas_frontend/src/components/DropdownMenu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function DropdownMenu({
indicator: {
position: "absolute",
top: "50%",
right: "5%",
right: "6%",
transform: `translateY(-50%) rotate(${isOpen ? "180deg" : "0deg"})`,
transition: "transform 0.3s",
pointerEvents: "none",
Expand Down
69 changes: 69 additions & 0 deletions sanitas_frontend/src/dataLayer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,75 @@ export const updatePsichiatricHistory = async (
}
};

export const getGynecologicalHistory = async (patientId) => {
const sessionResponse = IS_PRODUCTION
? await getSession()
: await mockGetSession(true);
if (sessionResponse.error) {
return { error: sessionResponse.error };
}

if (!sessionResponse.result.isValid()) {
return { error: "Invalid session!" };
}

const token = sessionResponse?.result?.idToken?.jwtToken ?? "no-token";
const url = `${PROTECTED_URL}/patient/gyneco-history/${patientId}`;

try {
const response = await axios.get(url, {
headers: { Authorization: token },
});
if (response.status === 200) {
return { result: response.data };
}
} catch (error) {
if (error.response) {
return { error: error.response.data };
}
return { error: error.message };
}
};

export const updateGynecologicalHistory = async (
patientId,
gynecologicalHistoryDetails,
) => {
const sessionResponse = IS_PRODUCTION
? await getSession()
: await mockGetSession(true);
if (sessionResponse.error) {
return { error: sessionResponse.error };
}

if (!sessionResponse.result.isValid()) {
return { error: "Invalid session!" };
}

const token = sessionResponse?.result?.idToken?.jwtToken ?? "no-token";
const url = `${PROTECTED_URL}/patient/gyneco-history`;

const payload = {
patientId: patientId,
medicalHistory: gynecologicalHistoryDetails,
};

try {
const response = await axios.put(url, payload, {
headers: { Authorization: token },
});
if (response.status === 200) {
return { result: response.data };
}
return { error: `Unexpected status code: ${response.status}` };
} catch (error) {
if (error.response) {
return { error: error.response.data };
}
return { error: error.message };
}
};

/**
* @callback LinkAccountToPatientCallback
* @param {string} cui
Expand Down
30 changes: 29 additions & 1 deletion sanitas_frontend/src/router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
getStudentPatientInformation,
getSurgicalHistory,
getTraumatologicalHistory,
getAllergicHistory,
getGynecologicalHistory,
searchPatient,
submitPatientData,
updateCollaboratorInformation,
Expand All @@ -32,8 +34,8 @@ import {
updateSurgicalHistory,
updateStudentSurgicalHistory,
updateTraumatologicalHistory,
getAllergicHistory,
updateAllergicHistory,
updateGynecologicalHistory,
getPsichiatricHistory,
updatePsichiatricHistory,
getRole,
Expand All @@ -53,6 +55,7 @@ import SearchPatientView from "./views/SearchPatientView";
import UpdateInfoView from "./views/UpdateGeneralInformationView";
import { TraumatologicHistory } from "./views/History/Traumatological";
import { AllergicHistory } from "./views/History/Allergic";
import { ObGynHistory } from "./views/History/ObGyn";
import { PsichiatricHistory } from "./views/History/Psichiatric";
import StudentWelcomeView from "./views/StudentWelcomeView";
import { LinkPatientView } from "./views/LinkPatientView";
Expand Down Expand Up @@ -80,6 +83,7 @@ export const UPDATE_PATIENT_NAV_PATHS = {
PERSONAL_HISTORY: "personal",
NONPATHOLOGICAL_HISTORY: "non-pathological",
ALLERGIC_HISTORY: "allergic",
OBGYN_HISTORY: "obgyn",
PSICHIATRIC_HISTORY: "psichiatric",
// TODO: Add other Navigation routes...
};
Expand Down Expand Up @@ -132,6 +136,11 @@ export const DEFAULT_DASHBOARD_SIDEBAR_PROPS = {
`${NAV_PATHS.UPDATE_PATIENT}/${UPDATE_PATIENT_NAV_PATHS.ALLERGIC_HISTORY}`,
);
},
navigateToObstetrics: (navigate) => {
navigate(
`${NAV_PATHS.UPDATE_PATIENT}/${UPDATE_PATIENT_NAV_PATHS.OBGYN_HISTORY}`,
);
},
navigateToPsiquiatric: (navigate) => {
navigate(
`${NAV_PATHS.UPDATE_PATIENT}/${UPDATE_PATIENT_NAV_PATHS.PSICHIATRIC_HISTORY}`,
Expand Down Expand Up @@ -275,6 +284,21 @@ const psichiatricHistoryView = (
</RequireAuth>
);

const obgynHistoryView = (
<RequireAuth
getSession={IS_PRODUCTION ? getSession : mockGetSession}
path={NAV_PATHS.LOGIN_USER}
>
<ObGynHistory
getBirthdayPatientInfo={getGeneralPatientInformation}
getObGynHistory={getGynecologicalHistory}
updateObGynHistory={updateGynecologicalHistory}
sidebarConfig={DEFAULT_DASHBOARD_SIDEBAR_PROPS}
useStore={useStore}
/>
</RequireAuth>
);

export const ROUTES = [
{
path: NAV_PATHS.SEARCH_PATIENT,
Expand Down Expand Up @@ -374,6 +398,10 @@ export const ROUTES = [
path: UPDATE_PATIENT_NAV_PATHS.ALLERGIC_HISTORY,
element: allergicHistoryView,
},
{
path: UPDATE_PATIENT_NAV_PATHS.OBGYN_HISTORY,
element: obgynHistoryView,
},
{
path: UPDATE_PATIENT_NAV_PATHS.PSICHIATRIC_HISTORY,
element: psichiatricHistoryView,
Expand Down
Loading

0 comments on commit b57f7e7

Please sign in to comment.