Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
301 changes: 145 additions & 156 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
margin-left: 50px;
margin-right: 40px;
display: flex;
background-image: url('/Users/varisharashid/blockchain/src/assets/icons/bg.jpeg');
background-image: url('/Users/mananjethwani/personal/Private-Blockchain-EHR-DAPP/PHR_Blockchain/src/assets/icons/bg.jpeg');
}

.choose-box{
Expand Down Expand Up @@ -378,4 +378,15 @@ label {

.mx-t3{
margin-top: -3rem;
}

.login-box{
height: 28rem;
box-shadow: 0px 0px 5px 1px #999;
margin-left: 200px;
width: 70%;
display: flex;
padding-top: 45px;
flex-direction: column;
align-items: center;
}
10 changes: 7 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ import OrgRegister from './components/BasicDetails'
import HealthProffRegister from './components/HealthProffRegister'
import Hospitals from './components/HospitalsData'
import Decision from './components/Decision';
import Login from './components/Forms/LoginForm';

function App() {

const user = localStorage.getItem('user');

const [auth, setAuth] = React.useState(true);
let [auth, setAuth] = React.useState(true);

React.useEffect(() => {
if (user === null) {
setAuth = false;
setAuth(false);
}
})

Expand All @@ -52,7 +53,7 @@ function App() {
<Route path="/medical" element={<MedicalRecordsForm />} />
</Routes>
<Routes>
<Route path="/profile" element={<UserProfile />} />
<Route path="/profile/:id" element={<UserProfile />} />
</Routes>
<Routes>
<Route path="/medicalProfile" element={<MedicalProfile />} />
Expand Down Expand Up @@ -81,6 +82,9 @@ function App() {
<Routes>
<Route path="/records" element={<DoctorRecords />} />
</Routes>
<Routes>
<Route path="/login" element={<Login />} />
</Routes>
</BrowserRouter>
</div>
);
Expand Down
43 changes: 33 additions & 10 deletions src/components/BasicDetails.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { useState, useEffect } from 'react'
import { useNavigate } from 'react-router-dom';
import axios from "axios";

export default function BasicDetails() {

Expand All @@ -13,36 +14,48 @@ export default function BasicDetails() {
const [state, setState] = useState('Jharkhand')
const [password, setPassword] = useState('varru1029')
const [phone, setPhone] = useState('9931230984')
const [profession, setProfession] = useState('');


useEffect(() => {
if (localStorage.getItem('user') === null) {
setAuth = false;
setAuth(false);
}

}, [])

const navigate = useNavigate();

function handleSubmit(event) {
async function handleSubmit(event) {
event.preventDefault();

console.log(event)
let basicData = {
name: name,
patientName: name,
email: email,
address: address,
location: address,
dob: dob,
gender: gender,
state: state,
password: password,
phone: phone,

}

localStorage.setItem('basicDetails', JSON.stringify(basicData))
let details = JSON.parse(localStorage.getItem('basicDetails'))
navigate('/medical')
if (localStorage.getItem("profile") === "patient") {
localStorage.setItem('basicDetails', JSON.stringify(basicData))
navigate('/medical')
} else {
let { data } = await axios.post("http://localhost:3001/HPR", {
hpr_details: {
...basicData,
profession,
adhar_number: localStorage.getItem('aadhar')
}
});
localStorage.setItem('HPR_details', JSON.stringify(data));
localStorage.setItem('user', JSON.stringify(data));
navigate("/hospitals")
}
}

return (
Expand Down Expand Up @@ -312,18 +325,28 @@ export default function BasicDetails() {
<option data-countryCode="ZW" value="263">Zimbabwe (+263)</option>
</select>
</div>
<div className="col-sm-4 form-group">
<div className="col-sm-3 mr-10 form-group">
<label htmlFor="tel">Phone</label>
<input type="tel" name="phone" className="form-control" id="tel" placeholder="Enter your phone number." required onChange={event => {
setPhone(event.target.value)
}}/>
</div>
<div className="col-sm-6 form-group">
<div className="col-sm-6 ml-20 form-group">
<label htmlFor="password" >Password</label>
<input type="Password" name="password" className="form-control" id="pass" placeholder="Enter your password." required onChange={event => {
setPassword(event.target.value)
}}/>
</div>
{ localStorage.getItem("profile") === "patient" ? <></> :
<>
<div className="col-sm-6 form-group">
<label htmlFor="profession" >profession</label>
<input type="text" name="profession" className="form-control" id="prof" placeholder="Enter your profession" required onChange={event => {
setProfession(event.target.value)
}}/>
</div>
</>
}
<div className="col-sm-12">
<a href='/medical'><button className="btn btn-primary float-center pr-6 pl-6" onClick={handleSubmit}>Next</button></a>
</div>
Expand Down
41 changes: 37 additions & 4 deletions src/components/Common/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,41 @@ import AccountCircle from '@mui/icons-material/AccountCircle';
import MenuItem from '@mui/material/MenuItem';
import Menu from '@mui/material/Menu';
import { Link } from '@mui/material';
import Button from '@mui/material/Button';
import { useNavigate } from 'react-router-dom';

export default function MenuAppBar() {
const [auth, setAuth] = React.useState(true);
const [anchorEl, setAnchorEl] = React.useState(null);
const [userProfile, setUserProfile] = React.useState({});
const [profile, setProfile] = React.useState()
const navigate = useNavigate();


React.useEffect(() => {
if (localStorage.getItem('user') === null) {
setAuth = false;
setAuth(false);
}

if (localStorage.getItem('user') !== null) {
let user = JSON.parse(localStorage.getItem('user'));
let prof = localStorage.getItem('profile');
console.log(user);
console.log(prof);
setUserProfile(user);
setProfile(prof);
}
}, [])

const handleMenu = (event) => {
setAnchorEl(event.currentTarget);
};

const handleClose = () => {
const handleClose = (event) => {
setAnchorEl(null);
localStorage.clear();
event.preventDefault();
navigate("/");
};

return (
Expand All @@ -43,9 +59,26 @@ export default function MenuAppBar() {
{/* <Typography variant="h6" component="div" sx={{ marginLeft: '852px', textAlign: 'right' }}>
About us
</Typography> */}
<Typography variant="h6" component="div" sx={{ flexGrow: 1, marginRight: '30px', textAlign: 'right' }}>
{
!auth &&
<Button href="/login" variant="h6" sx={{ text: "white", marginRight: '30px', textAlign: 'right' }}>
Login
</Typography>
</Button>
}

{
auth && profile === "Patient" &&
<Button variant="h6" href="/findDoctor" sx={{ marginLeft: '830px', textAlign: 'right' }}>
Find Doctor
</Button>
}

{
auth && profile !== "Patient" && userProfile.is_admin &&
<Button variant="h6" href="/decision" sx={{ marginLeft: '852px', textAlign: 'right' }}>
Requests
</Button>
}


{auth && (
Expand Down
37 changes: 24 additions & 13 deletions src/components/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,38 @@ import * as React from 'react';
import { Button, Typography } from "@mui/material";
import Navbar from './Common/Navbar';
import { Link } from 'react-router-dom';
import {useEffect, useState} from 'react';
import FindPatient from './Patient';
import Hospitals from './HospitalsData';
import UserProfile from './UserProfile';

export default function Dashboard() {

let [profile, setProfile] = useState();
let [userDetails, setUserDetails] = useState();

useEffect(() => {
let prof = localStorage.getItem("profile");
let user = JSON.parse(localStorage.getItem("user"));
console.log(user);
setUserDetails(user);
setProfile(prof);
}, []);

return (
<div>
<Navbar />
<div className='box mt-10'>
<Typography variant="h4" gutterBottom>
Dashboard
</Typography>

<Typography variant="h4" gutterBottom>
<a href="/findDoctor">Find Doctor anywhere in the world</a>
</Typography>
<Typography variant="h4" gutterBottom>
<a href="/profile">Medical History</a>
</Typography>

{
profile === "Patient" ?
<>
<UserProfile />
</> :
<>
{userDetails && userDetails.HFR_id === "" ? <Hospitals /> : <FindPatient />}
</>
}
</div>

</div>

);
}
30 changes: 25 additions & 5 deletions src/components/Decision.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@


import * as React from 'react';
import Navbar from './Common/Navbar';
import { Typography } from '@mui/material';
import {useEffect, useState} from "react";
import axios from "axios";

export default function Decision() {

let [data, setData] = useState([]);

useEffect(() => {
let user = JSON.parse(localStorage.getItem("user"));
console.log(user);
console.log(`http://localhost:3001/link-request?HFR_id=${user.HFR_id}`);
axios.get(`http://localhost:3001/link-request?HFR_id=${user.HFR_id}`).then(({data}) => {
setData(data);
})
}, []);

async function handleApprove(item) {
console.log(item);
let {data} = await axios.post("http://localhost:3001/approve-link-request", {
request_details: {
id: item.id
}
});
setData(data);
}

const data = [
const dat = [
{
"name": "Vikram",
"adhar_number": "1234121313341",
Expand Down Expand Up @@ -45,14 +65,14 @@ export default function Decision() {
{data.map((item,ind) => (
<div className='decision-box' key={ind}>

<Typography variant='h6' sx={{ fontWeight: 500}} >Name: {item.name}</Typography>
<Typography variant='h6' sx={{ fontWeight: 500}} >Name: {item.patientName}</Typography>
{/* <br/> */}

<Typography variant='h6' sx={{ fontWeight: 500}} >Profession: {item.profession}</Typography>

<Typography variant='h6' sx={{ fontWeight: 500 }}>Phone: {item.phone}</Typography>

<button className="btn btn-primary float-center">Approve</button>
<button onClick={() => handleApprove(item)} className="btn btn-primary float-center">Approve</button>

<button className="btn btn-danger float-center ml-4">Reject</button>
</div>
Expand Down
Loading