[
  {
    "path": ".gitignore",
    "content": "# Don't track content of these folders\nnode_modules/\nbuild/\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019 Rishabh Thaney\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Medical Insurance claiming DApp (for ConsenSys)\nProblem statement:\n1) Patient logs in, uploads medical/lab test bills and submits it for insurance. Notifications are sent to hospital and lab admin.\n2) Hospital admin logs in, verifies and approves the bills. This approval is stored on the smart contract\n3) Lab admin approves the lab test bills. This approval is also stored on the smart contract\n4) Once both of them approve, notification are sent to insurance admin.\n5) Insurance admin can check for approvals of hospital and lab after which he will calculate the claim amount and do the claim.\n\n `HealthCare.sol` contract maintains the logic for this DApp.  \n  The web pages found in the `Web-client` folder are used to communicate with the deployed smart contract and also allow logging in for each specific user\n\n## Steps to deploy and interact with the contract:\n1. Copy and paste the contract code on https://remix.ethereum.org/\n2. Run an instance of ganache-cli on your local machine and connect your metamask wallet to it. Also, add the first 3 accounts from ganache to your metamask by importing their private keys and assign the following names to it:  \n    account 1: Hospital admin  \n    account 2: Lab admin  \n    account 3: Patient  \n3. Pass the Lab Admin's address as an argument in the constructor while deploying the contract\n4. Select `Injected Web3` in the `Environment` field and make sure your Metamask wallet is unlocked. This will connect Remix to the first account(Hospital admin) in your Metamask wallet.\n5. Deploy the contract\n6. Select Account 3(Patient) and created a new medical record by calling the `newRecord` function with the respective fields.\n7. You can check if the record was created and it's details by calling the `_records` mapping with index 1.\n8. To sign the record, switch back to account 1(Hospital admin) in Metamask, enter the record's `_ID` in the `signRecord` function and click on transact.\n9. Repeat the same steps using account 2(Lab Admin) from metamask.\n10. Now the record is approved and you can verify the same by calling the `_records` mapping again where you can see that the `signatureCount` has incremented. \n\nNote that you can not sign the record using the patient's account from metamask and neither can the same account sign a record twice.\n\nUpdate:  \nWith Remix's new interface, you need to change the account address from the `ACCOUNT` drop down on the `Deploy and Run` tab (required in step 8):  \n\n<img width=\"369\" alt=\"Screenshot 2021-05-02 at 2 10 52 PM\" src=\"https://user-images.githubusercontent.com/20457952/117578650-f00c6480-b10c-11eb-906e-c5ff79252585.png\">\n\n## Known issues:  \n- The table on the React front end doesn't display the records created by the user (Issue #1).  \n\nThe main focus of this project at the time of making was the smart contract logic, I just made the front end in a jiffy as I had some extra time left after implementing the contracts.  \n\nContributions to fix the open issues are welcome, you'll receive some DOGE as well 😏\n\n## Steps to contribute  \n1. Fork this repo.\n2. Commit your changes.\n3. Send a PR to this project's `master` branch and add me as a reviewer\n\n\n"
  },
  {
    "path": "Web-client/package.json",
    "content": "{\n  \"name\": \"web\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^16.6.1\",\n    \"react-dom\": \"^16.6.1\",\n    \"react-router-dom\": \"^4.3.1\",\n    \"react-scripts\": \"5.0.1\",\n    \"web3\": \"^4.0.2\"\n  },\n  \"scripts\": {\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n    \"test\": \"react-scripts test\",\n    \"eject\": \"react-scripts eject\"\n  },\n  \"eslintConfig\": {\n    \"extends\": \"react-app\"\n  },\n  \"browserslist\": [\n    \">0.2%\",\n    \"not dead\",\n    \"not ie <= 11\",\n    \"not op_mini all\"\n  ]\n}\n"
  },
  {
    "path": "Web-client/public/index.html",
    "content": "<!DOCTYPE html>\r\n<html lang=\"en\">\r\n  <head>\r\n    <meta charset=\"utf-8\">\r\n    <link rel=\"shortcut icon\" href=\"%PUBLIC_URL%/favicon.ico\">\r\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\r\n    <link rel=\"manifest\" href=\"%PUBLIC_URL%/manifest.json\">\r\n    <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" integrity=\"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u\" crossorigin=\"anonymous\">\r\n\r\n    <title>React App</title>\r\n  </head>\r\n  <body>\r\n    <div id=\"boot\"></div>\r\n    <div id=\"root\"></div>\r\n  </body>\r\n</html>\r\n"
  },
  {
    "path": "Web-client/public/manifest.json",
    "content": "{\n  \"short_name\": \"React App\",\n  \"name\": \"Create React App Sample\",\n  \"icons\": [\n    {\n      \"src\": \"favicon.ico\",\n      \"sizes\": \"64x64 32x32 24x24 16x16\",\n      \"type\": \"image/x-icon\"\n    }\n  ],\n  \"start_url\": \".\",\n  \"display\": \"standalone\",\n  \"theme_color\": \"#000000\",\n  \"background_color\": \"#ffffff\"\n}\n"
  },
  {
    "path": "Web-client/src/HealthCare.js",
    "content": "import web3 from './web3';\n\nconst address = \"0x29044ca950147a55ad4e6c8868f650713f932dd6\";\n\nconst abi = [\n\t{\n\t\t\"constant\": false,\n\t\t\"inputs\": [\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"_ID\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"_tName\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"_date\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"hName\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"price\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"name\": \"newRecord\",\n\t\t\"outputs\": [],\n\t\t\"payable\": false,\n\t\t\"stateMutability\": \"nonpayable\",\n\t\t\"type\": \"function\"\n\t},\n\t{\n\t\t\"inputs\": [],\n\t\t\"payable\": false,\n\t\t\"stateMutability\": \"nonpayable\",\n\t\t\"type\": \"constructor\"\n\t},\n\t{\n\t\t\"anonymous\": false,\n\t\t\"inputs\": [\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"ID\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"testName\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"date\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"hospitalName\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"price\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"name\": \"recordCreated\",\n\t\t\"type\": \"event\"\n\t},\n\t{\n\t\t\"anonymous\": false,\n\t\t\"inputs\": [\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"ID\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"testName\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"date\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"hospitalName\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"indexed\": false,\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"price\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"name\": \"recordSigned\",\n\t\t\"type\": \"event\"\n\t},\n\t{\n\t\t\"constant\": false,\n\t\t\"inputs\": [\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"_ID\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"name\": \"signRecord\",\n\t\t\"outputs\": [],\n\t\t\"payable\": false,\n\t\t\"stateMutability\": \"nonpayable\",\n\t\t\"type\": \"function\"\n\t},\n\t{\n\t\t\"constant\": true,\n\t\t\"inputs\": [\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"name\": \"_records\",\n\t\t\"outputs\": [\n\t\t\t{\n\t\t\t\t\"internalType\": \"address\",\n\t\t\t\t\"name\": \"pAddr\",\n\t\t\t\t\"type\": \"address\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"ID\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"testName\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"date\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"string\",\n\t\t\t\t\"name\": \"hospitalName\",\n\t\t\t\t\"type\": \"string\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"price\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"bool\",\n\t\t\t\t\"name\": \"isValue\",\n\t\t\t\t\"type\": \"bool\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"signatureCount\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"payable\": false,\n\t\t\"stateMutability\": \"view\",\n\t\t\"type\": \"function\"\n\t},\n\t{\n\t\t\"constant\": true,\n\t\t\"inputs\": [\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"name\": \"recordsArr\",\n\t\t\"outputs\": [\n\t\t\t{\n\t\t\t\t\"internalType\": \"uint256\",\n\t\t\t\t\"name\": \"\",\n\t\t\t\t\"type\": \"uint256\"\n\t\t\t}\n\t\t],\n\t\t\"payable\": false,\n\t\t\"stateMutability\": \"view\",\n\t\t\"type\": \"function\"\n\t}\n]\n\nexport default new web3.eth.Contract(abi, address);\n"
  },
  {
    "path": "Web-client/src/hadmin.js",
    "content": "import React from \"react\";\r\nimport ReactDOM from \"react-dom\";\r\nimport HealthCare from \"./HealthCare\";\r\nimport web3 from \"./web3\";\r\n\r\nexport default class Hadmin extends React.Component {\r\n  constructor(props) {\r\n    super(props);\r\n    this.handleClick = this.handleClick.bind(this);\r\n    this.state = {\r\n      recID: \"\",\r\n      message: \"\"\r\n    };\r\n  }\r\n\r\n  async handleClick(event) {\r\n    event.preventDefault();\r\n    const accounts = await web3.eth.getAccounts();\r\n    await HealthCare.methods\r\n      .signRecord(this.state.recID)\r\n      .send({ from: accounts[0], gas: 2100000 });\r\n    this.setState({ message: \"Record approved!\" });\r\n  }\r\n\r\n  render() {\r\n    return (\r\n      <div className=\"container container-fluid login-conatiner\">\r\n        <div className=\"col-md-4\">\r\n          <h3 className=\"text-center\">Hospital Admin</h3>\r\n          <div className=\"login-form\">\r\n            <h4 className=\"text-center\">Approve Medical Record</h4>\r\n            <div className=\"form-group\">\r\n              <input\r\n                type=\"number\"\r\n                value={this.state.recID}\r\n                onChange={event => this.setState({ recID: event.target.value })}\r\n                className=\"form-control\"\r\n                placeholder=\"ID\"\r\n              />\r\n              <br />\r\n            </div>\r\n            <div className=\"form-group\">\r\n              <button\r\n                className=\"btn btn-primary btn-block\"\r\n                onClick={this.handleClick}\r\n              >\r\n                Approve\r\n              </button>\r\n            </div>\r\n            {this.state.message && (\r\n              <p className=\"alert alert-danger fade in\">{this.state.message}</p>\r\n            )}\r\n          </div>\r\n        </div>\r\n        <div className=\"col-md-6 col-md-offset-2\">\r\n          <div className=\"c-list\">\r\n            <h2 className=\"text-center\">Records</h2>\r\n            <table class=\"table table-bordered table-striped\">\r\n              <thead>\r\n                <tr>\r\n                  <th>ID</th>\r\n                  <th>Name</th>\r\n                  <th>Date</th>\r\n                  <th>Hospital Name</th>\r\n                  <th>Price</th>\r\n                  <th>Sign Count</th>\r\n                </tr>\r\n              </thead>\r\n            </table>\r\n          </div>\r\n        </div>\r\n      </div>\r\n    );\r\n  }\r\n}\r\n"
  },
  {
    "path": "Web-client/src/index.css",
    "content": "/* h1{\r\n  color: white;\r\n  font-size: 40px;\r\n  text-align: center;\r\n  font-family: calibri;\r\n  text-shadow: 2px 2px black;\r\n}\r\nheader{\r\n  background-color: #26474e;\r\npadding: 2px;\r\ncolor: white;\r\nfont-size: 40px;\r\nmargin-top: -8px;\r\nwidth: 101%;\r\nmargin-left: -8px;\r\n}\r\n.login{\r\n  position:relative;\r\n  width: 30%;\r\n  top:15px;\r\n  padding: 30px;\r\n  height: 350px;\r\n  float: left;\r\n  box-sizing: border-box;\r\n  background-color: #fff;\r\n  box-shadow: -20px 0 15px rgba(0,0,0,0.2);\r\n  margin-left: 35%;\r\n}\r\nh2{\r\n  font-family: calibri;\r\n  margin-top: -10px;\r\n  text-align: center;\r\n  font-size: 40px;\r\n}\r\n#selection{\r\n  font-family: calibri;\r\n  cursor: pointer;\r\n  display: block;\r\n  border-radius: 25px;\r\n  margin-top: 20px;\r\n  padding: 5px;\r\n  width: 100%;\r\n  border: 2px solid grey;\r\n  margin-bottom: 30px;\r\n}\r\ninput{\r\n    font-family: calibri;\r\n  display: block;\r\n  border-radius: 25px;\r\n  margin-top: 20px;\r\n  padding: 5px;\r\n  width: 100%;\r\n  border: 2px solid grey;\r\n}\r\n\r\nbutton{\r\n    font-family: calibri;\r\n  border-radius:32px;\r\n  margin-top: 10px;\r\n  font-size: 20px;\r\n  margin-top:15px;\r\n  width: 100%;\r\n  color: white;\r\n  background:  #B71C1C;\r\n  border: 2px solid  #B71C1C;\r\n  transition: 0.5s;\r\n  cursor: pointer;\r\n}\r\n */\r\n.App {\r\n  text-align: center;\r\n  /*background: rgba(204, 204, 204, 0.5);*/\r\n}\r\n\r\n\r\n.App-header {\r\n  background-color: #15324B;\r\n  padding: 2px;\r\n  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;\r\n  color: white;\r\n  font-size: 20px;\r\n  margin: 0px;\r\n}\r\n\r\n.App-title {\r\n  font-size: 1.8em;\r\n}\r\n"
  },
  {
    "path": "Web-client/src/index.js",
    "content": "import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport { BrowserRouter as Router, Route, Link,Redirect } from \"react-router-dom\";\r\nimport Patient from './patient'\r\nimport Hadmin from './hadmin'\r\nimport Labadmin from './ladmin'\r\nimport Insurance from './insurance'\r\nimport './index.css'\r\n//import HealthCare from './HealthCare'\r\nconst FullApp = () => (\r\n  <Router>\r\n    <div>\r\n    <header className=\"App-header\">\r\n          <h1 className=\"App-title text-center\">HealthCare Insurance</h1>\r\n        </header>\r\n      <Route exact path=\"/\" component={App} />\r\n      <Route path=\"/patient\" component={Patient} />\r\n      <Route path=\"/hadmin\" component={Hadmin} />\r\n      <Route path=\"/labadmin\" component={Labadmin} />\r\n      <Route path=\"/insurance\" component={Insurance} />\r\n\r\n    </div>\r\n  </Router>\r\n);\r\nclass App extends React.Component {\r\n  constructor(props) {\r\n    super(props);\r\n    this.state = {\r\n      user:'',\r\n      password:'',\r\n      login:false\r\n    }\r\n  }\r\n  render() {\r\n    return (\r\n      <div className=\"container container-fluid login-conatiner\">\r\n      {this.state.login ? this.state.user === \"\" ? this.state.password === \"patient\"? <Redirect to=\"/patient\" /> :\r\nthis.state.password === \"hadmin\" ?<Redirect to=\"/hadmin\" /> :\r\nthis.state.password === \"labadmin\"? <Redirect to=\"/labadmin\" />:\r\nthis.state.password === \"insurance\"? <Redirect to=\"/insurance\" />:null:null:null}\r\n<div style={{\r\n                    maxWidth: '300px',\r\n                    margin: '0 auto' }}>\r\n                    <div className=\"login-form\">\r\n                        <form method=\"post\">\r\n                        <h2 className=\"text-center\">Log in</h2>\r\n\r\n  <div className=\"form-group\">\r\n\r\n          <select id=\"selection\"  className=\"form-control\">\r\n            <option selected>Select Mode..</option>\r\n            <option>Patient</option>\r\n            <option>Hospital Admin</option>\r\n            <option>Lab Admin</option>\r\n            <option>Insurance Company</option>\r\n          </select>\r\n</div>\r\n<div className=\"form-group\">\r\n\r\n          <input type=\"password\"  className=\"form-control\" placeholder=\"Password\" onChange={e => this.setState({password:e.target.value})}  ></input></div>\r\n          <div className=\"form-group\">\r\n\r\n          <button className=\"btn btn-primary btn-block\" onClick={()=> this.setState({login:true})} >Submit</button></div>\r\n          <div className=\"clearfix\">\r\n                            </div>\r\n                        </form>\r\n        </div>\r\n      </div>\r\n      </div>\r\n    );\r\n  }\r\n}\r\n\r\nReactDOM.render(<FullApp />, document.getElementById('root'));\r\n"
  },
  {
    "path": "Web-client/src/insurance.js",
    "content": "import React from 'react';\r\n//import './insurance.css';\r\n\r\n export default class Insurance extends React.Component{\r\n   render(){\r\n     return(\r\n\r\n\r\n      <div className=\"col-md-12\">\r\n      <h3  className=\"text-center\">Insurance Page</h3>\r\n      <div className=\"c-list\">\r\n      <h2 className=\"text-center\">Approved Records</h2>\r\n        <table class=\"table table-bordered table-striped\">\r\n        <thead>\r\n             <tr>\r\n                <th>ID</th>\r\n                <th>Name</th>\r\n                <th>Date</th>\r\n                <th>Hospital Name</th>\r\n                <th>Price</th>\r\n                <th>Sign Count</th>\r\n             </tr>\r\n             </thead>\r\n          </table>\r\n         </div>\r\n       </div>\r\n     );\r\n   }\r\n }\r\n\r\n"
  },
  {
    "path": "Web-client/src/ladmin.js",
    "content": "import React from \"react\";\r\nimport ReactDOM from \"react-dom\";\r\nimport HealthCare from \"./HealthCare\";\r\nimport web3 from \"./web3\";\r\n\r\nexport default class Labadmin extends React.Component {\r\n  constructor(props) {\r\n    super(props);\r\n    this.handleClick = this.handleClick.bind(this);\r\n    this.state = {\r\n      recID: \"\",\r\n      message: \"\"\r\n    };\r\n  }\r\n  async handleClick(event) {\r\n    event.preventDefault();\r\n    const accounts = await web3.eth.getAccounts();\r\n    await HealthCare.methods\r\n      .signRecord(this.state.recID)\r\n      .send({ from: accounts[0], gas: 2100000 });\r\n    this.setState({ message: \"Record approved!\" });\r\n  }\r\n\r\n  render() {\r\n    return (\r\n      <div className=\"container container-fluid login-conatiner\">\r\n        <div className=\"col-md-4\">\r\n          <h3 className=\"text-center\">Lab Admin</h3>\r\n          <div className=\"login-form\">\r\n            <h4>Approve Medical Record</h4>\r\n            <div className=\"form-group\">\r\n              <input\r\n                type=\"Number\"\r\n                value={this.state.recID}\r\n                onChange={event => this.setState({ recID: event.target.value })}\r\n                className=\"form-control\"\r\n                placeholder=\"Input\"\r\n              />\r\n            </div>\r\n            <div className=\"form-group\">\r\n              <button\r\n                className=\"btn btn-primary btn-block\"\r\n                onClick={this.handleClick}\r\n              >\r\n                Approve\r\n              </button>\r\n            </div>\r\n            {this.state.message && (\r\n              <p className=\"alert alert-danger fade in\">{this.state.message}</p>\r\n            )}\r\n          </div>\r\n        </div>\r\n        <div className=\"col-md-6 col-md-offset-2\">\r\n          <div className=\"c-list\">\r\n            <h2 className=\"text-center\">Records</h2>\r\n            <table class=\"table table-bordered table-striped\">\r\n              <thead>\r\n                <tr>\r\n                  <th>ID</th>\r\n                  <th>Name</th>\r\n                  <th>Date</th>\r\n                  <th>Hospital Name</th>\r\n                  <th>Price</th>\r\n                  <th>Sign Count</th>\r\n                </tr>\r\n              </thead>\r\n            </table>\r\n          </div>\r\n        </div>\r\n      </div>\r\n    );\r\n  }\r\n}\r\n"
  },
  {
    "path": "Web-client/src/patient.js",
    "content": "import React from \"react\";\r\nimport ReactDOM from \"react-dom\";\r\nimport HealthCare from \"./HealthCare\";\r\nimport web3 from \"./web3\";\r\n\r\nexport default class Patient extends React.Component {\r\n  constructor(props) {\r\n    super(props);\r\n    this.handleClick = this.handleClick.bind(this);\r\n    this.state = {\r\n      recID: \"\",\r\n      pname: \"\",\r\n      dDate: \"\",\r\n      hname: \"\",\r\n      price: \"\",\r\n      message: \"\"\r\n    };\r\n  }\r\n\r\n  async handleClick(event) {\r\n    event.preventDefault();\r\n    const accounts = await web3.eth.getAccounts();\r\n    await HealthCare.methods\r\n      .newRecord(\r\n        this.state.recID,\r\n        this.state.pname,\r\n        this.state.dDate,\r\n        this.state.hname,\r\n        this.state.price\r\n      )\r\n      .send({ from: accounts[0], gas: 2100000 });\r\n    this.setState({ message: \"Record created\" });\r\n  }\r\n\r\n  render() {\r\n    return (\r\n      <div className=\"container container-fluid login-conatiner\">\r\n        <div className=\"col-md-4\">\r\n          <div className=\"login-form\">\r\n            <form method=\"post\" autoComplete=\"off\">\r\n              <h2 className=\"text-center\">New Record</h2>\r\n              <div className=\"form-group\">\r\n                <input\r\n                  type=\"text\"\r\n                  value={this.state.recID}\r\n                  onChange={event =>\r\n                    this.setState({ recID: event.target.value })\r\n                  }\r\n                  className=\"form-control\"\r\n                  placeholder=\"ID\"\r\n                />\r\n              </div>\r\n              <div className=\"form-group\">\r\n                <input\r\n                  type=\"text\"\r\n                  value={this.state.pname}\r\n                  onChange={event =>\r\n                    this.setState({ pname: event.target.value })\r\n                  }\r\n                  className=\"form-control\"\r\n                  placeholder=\"Name\"\r\n                />\r\n              </div>\r\n              <div className=\"form-group\">\r\n                <input\r\n                  type=\"Date\"\r\n                  value={this.state.dDate}\r\n                  onChange={event =>\r\n                    this.setState({ dDate: event.target.value })\r\n                  }\r\n                  className=\"form-control\"\r\n                  placeholder=\"Date\"\r\n                />\r\n              </div>\r\n              <div className=\"form-group\">\r\n                <input\r\n                  type=\"text\"\r\n                  value={this.state.hname}\r\n                  onChange={event =>\r\n                    this.setState({ hname: event.target.value })\r\n                  }\r\n                  className=\"form-control\"\r\n                  placeholder=\"Hospital Name\"\r\n                />\r\n              </div>\r\n              <div className=\"form-group\">\r\n                <input\r\n                  type=\"text\"\r\n                  value={this.state.price}\r\n                  onChange={event =>\r\n                    this.setState({ price: event.target.value })\r\n                  }\r\n                  className=\"form-control\"\r\n                  placeholder=\"Price\"\r\n                />\r\n              </div>\r\n              <div className=\"form-group\">\r\n                <button\r\n                  className=\"btn btn-primary btn-block\"\r\n                  onClick={this.handleClick}\r\n                >\r\n                  Submit\r\n                </button>\r\n              </div>\r\n              {this.state.message && (\r\n                <p className=\"alert alert-danger fade in\">\r\n                  {this.state.message}\r\n                </p>\r\n              )}\r\n              <div className=\"clearfix\" />\r\n            </form>\r\n          </div>\r\n        </div>\r\n\r\n        <div className=\"col-md-6 col-md-offset-2\">\r\n          <div className=\"c-list\">\r\n            <h2 className=\"text-center\">Records</h2>\r\n            <table class=\"table table-bordered table-striped\">\r\n              <thead>\r\n                <tr>\r\n                  <th>ID</th>\r\n                  <th>Name</th>\r\n                  <th>Date</th>\r\n                  <th>Hospital Name</th>\r\n                  <th>Price</th>\r\n                  <th>Sign Count</th>\r\n                </tr>\r\n              </thead>\r\n            </table>\r\n          </div>\r\n        </div>\r\n      </div>\r\n    );\r\n  }\r\n}\r\n"
  },
  {
    "path": "Web-client/src/web3.js",
    "content": "\nimport Web3 from 'web3';\n\nconst web3 = new Web3(window.web3.currentProvider);\n\nexport default web3;\n"
  },
  {
    "path": "contracts/HealthCare.sol",
    "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract HealthCare {\n    address public hospitalAdmin;\n    address public labAdmin;\n\n    struct Record {\n        uint256 ID;\n        uint256 price;\n        uint256 signatureCount;\n        string testName;\n        string date;\n        string hospitalName;\n        bool isValue;\n        address pAddr;\n        mapping (address => uint256) signatures;\n    }\n\n    constructor(address _labAdmin) {\n        hospitalAdmin = msg.sender;\n        labAdmin = _labAdmin;\n    }\n\n    // Mapping to store records\n    mapping (uint256=> Record) public _records;\n    uint256[] public recordsArr;\n\n    event recordCreated(uint256 ID, string testName, string date, string hospitalName, uint256 price);\n    event recordSigned(uint256 ID, string testName, string date, string hospitalName, uint256 price);\n\n    modifier signOnly {\n        require (msg.sender == hospitalAdmin || msg.sender == labAdmin, \"You are not authorized to sign this.\");\n        _;\n    }\n\n    modifier checkAuthBeforeSign(uint256 _ID) {\n        require(_records[_ID].isValue, \"Recored does not exist\");\n        require(address(0) != _records[_ID].pAddr, \"Address is zero\");\n        require(msg.sender != _records[_ID].pAddr, \"You are not authorized to perform this action\");\n        require(_records[_ID].signatures[msg.sender] != 1, \"Same person cannot sign twice.\");\n        _;\n\n    }\n\n    modifier validateRecord(uint256 _ID) {\n        // Only allows new records to be created\n        require(!_records[_ID].isValue, \"Record with this ID already exists\");\n        _;\n    }\n\n    // Create new record\n    function newRecord (\n        uint256 _ID,\n        uint256 price,\n        string memory _tName,\n        string memory _date,\n        string memory hName\n    )\n    validateRecord(_ID) public {\n        Record storage _newrecord = _records[_ID];\n        _newrecord.pAddr = msg.sender;\n        _newrecord.ID = _ID;\n        _newrecord.testName = _tName;\n        _newrecord.date = _date;\n        _newrecord.hospitalName = hName;\n        _newrecord.price = price;\n        _newrecord.isValue = true;\n        _newrecord.signatureCount = 0;\n\n        recordsArr.push(_ID);\n        emit  recordCreated(_newrecord.ID, _tName, _date, hName, price);\n    }\n\n    // Function to sign a record\n    function signRecord(uint256 _ID) signOnly checkAuthBeforeSign(_ID) public {\n        Record storage records = _records[_ID];\n        records.signatures[msg.sender] = 1;\n        records.signatureCount++;\n\n        // Checks if the record has been signed by both the authorities to process insurance claim\n        if(records.signatureCount == 2)\n            emit  recordSigned(records.ID, records.testName, records.date, records.hospitalName, records.price);\n\n    }\n}\n"
  },
  {
    "path": "contracts/Migrations.sol",
    "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "migrations/2_deploy_HealthCare.js",
    "content": "var HealthCare = artifacts.require(\"./HealthCare.sol\");\nconst TO_LAB_ADMIN_ADDRESS = \"0xF6F2F51c07e44efE7BC25E0EC6B332f39d930ac0\"; // hard coded address from Ganache\n\nmodule.exports = function(deployer) {\n  deployer.deploy(HealthCare, TO_LAB_ADMIN_ADDRESS);\n};\n"
  },
  {
    "path": "truffle-config.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n};\n"
  },
  {
    "path": "truffle.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n   networks: {\n   development: {\n   host: \"localhost\",\n   port: 8545,\n   network_id: \"*\" // Match any network id\n  }\n }\n};\n"
  }
]