Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

#129 Connect Symptoms Update and Doctor/Patient #148

Merged
merged 34 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
58fdbfb
#129 Fixed how user symptoms are initially stored in the database
MilitsaB Mar 22, 2022
1099a4c
#129 Code refactoring
MilitsaB Mar 22, 2022
41cf0be
#129 fixed bugs in medical staff view
fadi-albasha Mar 26, 2022
df63bae
Merge branch '#129-Connect-SymptomsUpdate-and-Doc/Patient' of https:/…
fadi-albasha Mar 26, 2022
7f358f6
#129 Fixed how user symptoms are initially stored in the database
MilitsaB Mar 22, 2022
f62794f
#129 Code refactoring
MilitsaB Mar 22, 2022
44a1adb
#129 fixed bugs in medical staff view
fadi-albasha Mar 26, 2022
192ed5c
#129 Added Patient UI for doctor
MilitsaB Mar 27, 2022
606afd5
#129 Fixed unsubscribe error
MilitsaB Mar 27, 2022
be53376
#129 Added Changes from Dev
MilitsaB Mar 27, 2022
d31c9a1
#129 Fixed tests
MilitsaB Mar 27, 2022
a13160a
#129 Added New Test
MilitsaB Mar 27, 2022
763eb47
#129 Fixed how user symptoms are initially stored in the database
MilitsaB Mar 22, 2022
22d326f
#129 Code refactoring
MilitsaB Mar 22, 2022
05cafad
#129 fixed bugs in medical staff view
fadi-albasha Mar 26, 2022
023b47d
#129 Added Patient UI for doctor
MilitsaB Mar 27, 2022
98fbdfc
#129 Fixed unsubscribe error
MilitsaB Mar 27, 2022
831f3bd
#129 Added Changes from Dev
MilitsaB Mar 27, 2022
b8fe81a
#129 Fixed tests
MilitsaB Mar 27, 2022
5fadba4
#129 Added New Test
MilitsaB Mar 27, 2022
ea4e1c7
Merge branch '#129-Connect-SymptomsUpdate-and-Doc/Patient' of https:/…
fadi-albasha Mar 28, 2022
edddea4
#129 Code Refactoring
MilitsaB Mar 28, 2022
27e358a
Fixing Merge Issues
AhmadHashems Mar 28, 2022
1262472
Run Cypress on pull_request
AhmadHashems Mar 28, 2022
ef0f8c7
#51 - Fix Formatting and Memory Leak
martinsenecal Mar 28, 2022
1457376
Merge branch '#129-Connect-SymptomsUpdate-and-Doc/Patient' of https:/…
AhmadHashems Mar 28, 2022
aae6b4d
#129 - Refactor Patient View
martinsenecal Mar 28, 2022
acbe44b
#129 - Fixed Tests and Fixed PatientInfo Refresh Data
martinsenecal Mar 28, 2022
a58d998
#129 Fixed latest symptoms bug
MilitsaB Mar 28, 2022
0a67ab5
#129 code refactoring and bug fixing
fadi-albasha Mar 28, 2022
99ecb6c
#129 - Removed Patient Chat
martinsenecal Mar 28, 2022
57a9712
#129 fix test for patient info
gkillick Mar 28, 2022
18d5814
Merge remote-tracking branch 'origin/#129-Connect-SymptomsUpdate-and-…
AhmadHashems Mar 28, 2022
27b7c49
Updating package-lock.json
AhmadHashems Mar 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Cypress Tests

on: [pull_request]
on: [push]

jobs:
cypress-run:
Expand Down Expand Up @@ -63,6 +63,7 @@ jobs:
npm install -g firebase-tools
npm ci
npm run build
npx browserslist@latest --update-db
working-directory: functions

- name: Update browsers
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/protect-together/medical.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Sprint 3 Medical Suite', () => {
cy.contains('Welcome Dr. Demo')
cy.get('button').contains('View Appointments')
cy.get('[type="text"]').click().type('Cypress')
cy.contains('Cypress System Tests')
// cy.contains('Cypress System Tests')
})

after(() => {
Expand Down
4 changes: 3 additions & 1 deletion functions/src/callable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const dispatchDoctor = functions.https.onCall( (_data)=> {
// assign patients
querySnap.docs.forEach((doc)=>{
batch.update(doc.ref, "assignedDoctor", _data.medicalID);
batch.update(doc.ref, "doctorName", `${_data.firstName} ${_data.lastName}`);
});
batch.commit().then(()=>{
// adjust doctor slots
Expand Down Expand Up @@ -54,8 +55,9 @@ export const requestDoctor = functions.https.onCall(async (_data, context)=>{

// assign user to doctor
if (availableDoctorRef) {
const availableDoc = availableDoctorRef.data();
return userSnap.ref
.update({assignedDoctor: availableDoctorRef.data().UID}).then(()=>{
.update({assignedDoctor: availableDoc.UID, doctorName: `${availableDoc.firstName} ${_data.lastName}`}).then(()=>{
// decrement available Slots
const newfilledSlots = availableDoctorRef.data().filledSlots +1;
const newAvailableSlots = availableDoctorRef.data().patientSlots - newfilledSlots;
Expand Down
13,761 changes: 12,865 additions & 896 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ChangePassword from '../pages/auth/change';
import ForgotPassword from '../pages/auth/forgot';
import SymptomsForm from '../pages/symptomsForm/SymptomsForm';
import SymptomsUpdate from '../pages/symptomsForm/SymptomsUpdate';
import PatientChat from './chat/PatientChat';
martinsenecal marked this conversation as resolved.
Show resolved Hide resolved
import { LayoutContext } from '../context/LayoutContext';
import { UserProvider } from '../context/UserContext';

Expand All @@ -41,6 +42,7 @@ function App() {
<Route path="/styleguide" element={<StyleGuide />} />
<Route path="/symptomsForm" element={<AuthRequired component={<SymptomsForm />} />} />
<Route path="/symptomsUpdate" element={<AuthRequired component={<SymptomsUpdate />} />} />
<Route path="/connect" element={<AuthRequired component={<PatientChat />} />} />
<Route path="/change" element={<AuthRequired component={<ChangePassword />} />} />
</Routes>
</UserProvider>
Expand Down
158 changes: 158 additions & 0 deletions src/components/chat/PatientChat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/* eslint-disable @typescript-eslint/no-shadow */
import React, { useEffect, useState } from 'react';
import DashboardOutlinedIcon from '@mui/icons-material/DashboardOutlined';
import CoronavirusIcon from '@mui/icons-material/Coronavirus';
import ContentPasteIcon from '@mui/icons-material/ContentPaste';
import BiotechIcon from '@mui/icons-material/Biotech';
// eslint-disable-next-line import/no-unresolved
import '../../static/style/CovidData.css';
import {
Button,
Box,
CssBaseline,
Divider,
List,
ListItem,
ListItemIcon,
ListItemText,
Modal,
useMediaQuery,
useTheme,
} from '@mui/material';
import { useNavigate } from 'react-router-dom';
import { doc, DocumentData, onSnapshot } from 'firebase/firestore';
import Header from '../layout/Header';
import MainContent from '../layout/MainContent';
import SideBar from '../layout/SideBar';
import { UserContext } from '../../context/UserContext';
import { firestore } from '../../config/firebase_config';
import UpdateTestResult from '../dashboard/patienttestresult';
import TestResults from '../dashboard/TestResults';
import theme from '../../static/style/theme';

const style = {
position: 'absolute' as const,
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: 600,
[theme.breakpoints.down('sm')]: {
width: '100%',
padding: 0,
},
boxShadow: 0,
margin: 0,
p: 4,
};

function PatientChat() {
const navigate = useNavigate();
const theme = useTheme();
const { state, update } = React.useContext(UserContext);
const [user, setUser] = useState<DocumentData>();
const [modalOpen, setModalOpen] = useState(false);
const handleOpenQuiz = () => setModalOpen(true);
const handleClose = () => setModalOpen(false);
const [testOpen, setTestOpen] = useState(false);
const [testROpen, setTestROpen] = useState(false);
const handleTestOpen = () => setTestOpen(true);
const handleTestClose = () => setTestOpen(false);
const handleTestROpen = () => setTestROpen(true);
const handleTestRClose = () => setTestROpen(false);

useEffect(() => {
const unsubscribe = onSnapshot(doc(firestore, 'users', `${state.id}`), (docu) => {
const data = docu.data();
if (data) {
setUser(data);
}
});
return () => {
unsubscribe();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<Box sx={{ display: 'flex', width: '100%' }}>
<CssBaseline />
<Header title={`Chat with Dr. ${user?.doctorName}`}>
<Button variant="contained" color="primary" onClick={() => { navigate('/symptomsUpdate'); }}>
Update Your Symptoms
</Button>
</Header>
<SideBar>
<List>
<ListItem button key="Dashboard">
<ListItemIcon>
<DashboardOutlinedIcon />
</ListItemIcon>
<ListItemText
primary="Dashboard"
onClick={() => { navigate('/dashboard'); }}
/>
</ListItem>
<ListItem button key="Dashboard2">
<ListItemIcon>
<CoronavirusIcon />
</ListItemIcon>
<ListItemText data-testid="covidtest2" primary="Add Covid-19 Test" onClick={handleTestOpen} />
</ListItem>
<ListItem button key="Test">
<ListItemIcon>
<BiotechIcon />
</ListItemIcon>
<ListItemText data-testid="TestResults" primary="Test Results" onClick={handleTestROpen} />
</ListItem>
<ListItem button key="Results" data-testid="SymptomsUpdate2">
<ListItemIcon>
<ContentPasteIcon />
</ListItemIcon>
{user?.assignedDoctor && (
<ListItemText
primary="Symptoms Update"
onClick={() => { navigate('/symptomsUpdate'); }}
/>
)}
</ListItem>

</List>
<Divider />
</SideBar>
<MainContent>
Chat
</MainContent>
<Modal
open={testOpen}
onClose={handleTestClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<UpdateTestResult handleTestClose={handleTestClose} />
</Box>
</Modal>
<Modal
open={testROpen}
onClose={handleTestRClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<TestResults handleTestRClose={handleTestRClose} />
</Box>
</Modal>
<Modal
open={modalOpen}
onClose={handleClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style}>
quiz
</Box>
</Modal>
</Box>
);
}
export default PatientChat;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export const EditUser = ({ handleClose, selectedUser }: Props) => {
userRef.update({ patientSlots: newPatientSlots, availableSlots: newAvailableSlots }).then(() => {
// check if patients need to be assigned to doctor
const dispatchDoctor = Firebase.functions().httpsCallable('dispatchDoctor');
dispatchDoctor({ medicalID: user.UID, availableSlots: newAvailableSlots, filledSlots: user.filledSlots });
dispatchDoctor({ medicalID: user.UID,
availableSlots: newAvailableSlots,
filledSlots: user.filledSlots,
firstName: user.firstName,
lastName: user.lastName });
});
}

Expand Down
Loading