From 1c3a2d27f0c3fe4f96448ac32a59853c052c9c89 Mon Sep 17 00:00:00 2001 From: sainingo Date: Wed, 10 May 2023 13:38:49 +0300 Subject: [PATCH 1/2] Modify patient object --- src/App.tsx | 38 +- src/components/PatientInformation.tsx | 25 +- src/components/SideNavBar/SideNavBar.tsx | 12 +- .../authentication/AuthenticationResource.ts | 2 +- .../patientSearch/DisplayPatientResult.tsx | 14 +- .../patientSearch/PatientSearch.resource.ts | 2 +- src/context/AppContext.ts | 56 +- vite.config.ts | 4 +- yarn.lock | 10859 ++++++++++------ 9 files changed, 6630 insertions(+), 4382 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 6dcc099..cadcf2f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,21 +1,49 @@ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; -import { AppContext, AppContextType } from './context/AppContext'; -import { useEffect, useState } from 'react'; +import { AppContext, AppContextType, PatientObjSubset } from './context/AppContext'; +import { useState } from 'react'; import PatientSearch from './components/patientSearch/Patient'; import Orders from './components/Orders/Orders.component'; import Login from './components/authentication/Login'; import ProtectedRoutes from './components/authentication/ProtectedRoutes'; import PatientInformation from './components/PatientInformation'; import Home from './components/layout/Home'; -import { CheckSession, DeleteSession } from './components/ManageSession'; import Moh731SyncQueueComponent from './components/RdeSync/Moh731Sync.component'; import AddPatientIdentifier from './components/RdeSync/AddPatients.component'; const App = () => { - const [currentPatient] = useState([]); + const [currentPatient, setCurrentPatient] = useState({ + preferredName: { + uuid: '', + display: '', + links: [], + }, + preferredAddress: { + uuid: '', + display: '', + links: [], + }, + gender: '', + age: 0, + birthdate: '', + }); const contextValue: AppContextType = { - currentPatient, + currentPatient: { + preferredName: currentPatient.preferredName || { + uuid: '', + display: '', + links: [], + }, + preferredAddress: currentPatient.preferredAddress || { + uuid: '', + display: '', + links: [], + }, + gender: currentPatient.gender || '', + age: currentPatient.age || 0, + birthdate: currentPatient.birthdate || '', + }, + setCurrentPatient, }; // useEffect(() => { // const verifySession = setInterval(async () => { diff --git a/src/components/PatientInformation.tsx b/src/components/PatientInformation.tsx index 1c9947e..03aafd7 100644 --- a/src/components/PatientInformation.tsx +++ b/src/components/PatientInformation.tsx @@ -5,51 +5,44 @@ import SideNavBar from './SideNavBar/SideNavBar'; const PatientInformation = () => { const { currentPatient } = useContext(AppContext); - return ( <>
- {currentPatient.length <= 1 ? ( - currentPatient.map((info: any = {}, index) => ( - <> -
+ <> +
-

{info[0].person.preferredName.display[0]}

+

{currentPatient?.preferredName?.display?.[0]}

-

{info[0].person.preferredName.display}

+

{currentPatient?.preferredName?.display}

-
+
Address -

{info[0].person.preferredAddress.display}

+

{currentPatient?.preferredAddress?.display}

Gender -

{info[0]?.person.gender}

+

{currentPatient?.gender}

Age -

{info[0]?.person.age}

+

{currentPatient?.age}

Date of Birth -

{new Date(info[0]?.person.birthdate).toLocaleString().split(' ')[0].slice(0, -1)}

+

{currentPatient?.birthdate}

- )) - ) : ( -

Go to search patient..

- )}
); diff --git a/src/components/SideNavBar/SideNavBar.tsx b/src/components/SideNavBar/SideNavBar.tsx index 97223c8..13e6b90 100644 --- a/src/components/SideNavBar/SideNavBar.tsx +++ b/src/components/SideNavBar/SideNavBar.tsx @@ -3,30 +3,26 @@ import { AiOutlineInfoCircle } from 'react-icons/ai'; import { BsPencilSquare } from 'react-icons/bs'; import { FaWalking, FaRegCalendarAlt } from 'react-icons/fa'; import { BiBandAid } from 'react-icons/bi'; -import { NavLink } from 'react-router-dom'; -import { AppContext } from '../../context/AppContext'; +import { NavLink, useParams } from 'react-router-dom'; const SideNavBar = () => { let activeStyle = { color: '#2FBAF1', cursor: 'pointer', }; - const { currentPatient } = useContext(AppContext); + const {id} = useParams() - const patientId = currentPatient.map((info: any = {}) => { - return info[0].uuid; - }); return (