forked from PapithaDharmalingam/Healthcare-DAPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da44ccf
commit 86ead93
Showing
6 changed files
with
46,168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
const drug_detailsABI = [ | ||
{ | ||
"constant": true, | ||
"inputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "medicalAssets", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "id", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "sup_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "drug_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "date_of_pur", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "expiry_date", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "quantity", | ||
"type": "string" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": true, | ||
"inputs": [], | ||
"name": "nextId", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"internalType": "string", | ||
"name": "name", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "drug_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "date_of_pur", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "expiry_date", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "quantity", | ||
"type": "string" | ||
} | ||
], | ||
"name": "create", | ||
"outputs": [], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": true, | ||
"inputs": [], | ||
"name": "readAll", | ||
"outputs": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "id", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "sup_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "drug_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "date_of_pur", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "expiry_date", | ||
"type": "string" | ||
}, | ||
{ | ||
"internalType": "string", | ||
"name": "quantity", | ||
"type": "string" | ||
} | ||
], | ||
"internalType": "struct Drug_details.MedicalAsset[]", | ||
"name": "", | ||
"type": "tuple[]" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
]; | ||
//address of smart contact | ||
const drug_detailsAddress = '0x92fBF274F53C0fB3BaAB254541f5581e475f648b'; | ||
const web3 = new Web3('http://localhost:9545'); | ||
const drug_details = new web3.eth.Contract(drug_detailsABI, drug_detailsAddress,{gas: '1000000'}); | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
//elements to be manipulated | ||
const $setData = document.getElementById('set_data'); | ||
const $data = document.getElementById('data'); | ||
let accounts = []; | ||
//getting the accounts | ||
web3.eth.getAccounts() | ||
.then(_accounts => { | ||
accounts = _accounts; | ||
}); | ||
|
||
|
||
const getData = () => { | ||
drug_details.methods | ||
.readAll() | ||
.call() | ||
.then(result => { | ||
console.log(result); | ||
$data.innerHTML = result[3]; | ||
}) | ||
}; | ||
getData(); | ||
|
||
$setData.addEventListener('submit', e => { | ||
//prevent reloadd | ||
e.preventDefault(); | ||
const sup = e.target.elements[0].value; | ||
const drug = e.target.elements[1].value; | ||
const quant = e.target.elements[2].value; | ||
const date_of_pur = e.target.elements[3].value; | ||
const date_of_exp = e.target.elements[4].value; | ||
console.log(sup+drug+quant+date_of_pur+date_of_exp); | ||
|
||
drug_details.methods | ||
.create(sup,drug,date_of_pur,date_of_exp,quant) | ||
.send({from: accounts[0]}) | ||
.then(getData); | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
<!-- Font Awesome --> | ||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"> | ||
<!-- Google Fonts --> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"> | ||
<!-- Bootstrap core CSS --> | ||
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"> | ||
<!-- Material Design Bootstrap --> | ||
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.14.1/css/mdb.min.css" rel="stylesheet"> | ||
</head> | ||
<body > | ||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | ||
<a class="navbar-brand" href="#">Health Care Dapp</a> | ||
|
||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
|
||
<div class="collapse navbar-collapse" id="navbarNavDropdown"> | ||
|
||
<div class="collapse navbar-collapse" id="navbarSupportedContent-4"> | ||
<ul class="navbar-nav ml-auto"> | ||
<li class="nav-item active"> | ||
<a class="nav-link" href="#"> | ||
<i class="fas fa-info-circle"></i>About Us | ||
<span class="sr-only">(current)</span> | ||
</a> | ||
</li> | ||
|
||
<li class="nav-item dropdown"> | ||
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink-4" data-toggle="dropdown" | ||
aria-haspopup="true" aria-expanded="false"> | ||
<i class="fas fa-user"></i> Profile </a> | ||
<div class="dropdown-menu dropdown-menu-right dropdown-info" aria-labelledby="navbarDropdownMenuLink-4"> | ||
<a class="dropdown-item" href="#">My account</a> | ||
<a class="dropdown-item" href="#">Log out</a> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
<br> | ||
<div class="container"> | ||
<div class="row"> | ||
|
||
<div class="col-sm-6"> | ||
<br><br><br> | ||
<div class="card border-info "> | ||
<ul class="nav nav-pills px-3 pt-3 mb-3" id="pills-tab" role="tablist"> | ||
<li class="nav-item"> | ||
<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true">New Request</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="false">Accepted Requests</a> | ||
</li> | ||
|
||
</ul> | ||
<div class="card-body border-info"> | ||
|
||
<div class="tab-content" id="pills-tabContent"> | ||
<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab"> | ||
<label class="mr-sm-2" for="inlineFormCustomSelect">Send Request to Access Data of the Patient : </label> | ||
<select class="form-control form-control-sm"> | ||
<option>Patient Names</option> | ||
</select> | ||
<br> | ||
<div class="d-flex justify-content-center"> | ||
<button type="submit" class="btn btn-primary my-1 ">Submit</button> | ||
</div> | ||
</div> | ||
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab"> | ||
<div class="list-group"> | ||
<a href="#" class="list-group-item list-group-item-action active"> | ||
Patient 3 | ||
</a> | ||
<a href="#" class="list-group-item list-group-item-action">Patient 1</a> | ||
<a href="#" class="list-group-item list-group-item-action">Patient 2</a> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-sm-6"> | ||
<div class="card border-info "> | ||
<div class="card-header bg-info border-info h4 text-center"><b>Add medical Record to the Selected Patient</b></div> | ||
<div class="card-body"> | ||
|
||
<p class="card-text"> | ||
|
||
<!-- Default form register --> | ||
<form id="patientRecord" action=""> | ||
|
||
|
||
|
||
<!-- Suppliers name --> | ||
<input type="text" id="patient_name" class="form-control mb-4" placeholder="Patient Name"> | ||
|
||
<div class="form-row mb-4"> | ||
<div class="col"> | ||
<!-- First name --> | ||
<input type="date" id="consultation_date" class="form-control" placeholder="Consultation Date"> | ||
</div> | ||
|
||
</div> | ||
<div class="form-row mb-4"> | ||
<input type="text" id="diagnosis_name" class="form-control" placeholder="Treatment/Consulted For Reason"> | ||
|
||
</div> | ||
|
||
|
||
|
||
|
||
<small class="form-text text-muted mb-4 text-center"> | ||
<p>After clicking | ||
<em>Submit</em> you cannot change details later | ||
|
||
</small> | ||
|
||
|
||
<!-- Sign up button --> | ||
<button class="btn btn-info my-4 btn-block" type="submit">Add to Patient Record</button> | ||
|
||
<!-- Social register --> | ||
|
||
|
||
<hr> | ||
|
||
<!-- Terms of service --> | ||
|
||
</form> | ||
<!-- Default form register --> | ||
|
||
</p> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<!-- JQuery --> | ||
<script src="web3.js"></script> | ||
<script src="bundle.js"></script> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | ||
<!-- Bootstrap tooltips --> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.4/umd/popper.min.js"></script> | ||
<!-- Bootstrap core JavaScript --> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.min.js"></script> | ||
<!-- MDB core JavaScript --> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.14.1/js/mdb.min.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.