├── EHR.sql ├── Health Record System.rar ├── README.md ├── Screenshot 2024-10-23 002706.png ├── Screenshot 2024-10-23 002714.png ├── Screenshot 2024-10-23 002804.png ├── Screenshot 2024-10-23 002837.png ├── Screenshot 2024-10-23 002847.png ├── Screenshot 2024-10-23 002900.png ├── Screenshot 2024-10-23 002920.png ├── Screenshot 2024-10-23 002948.png ├── __pycache__ ├── blockChain.cpython-311.pyc └── blockChain.cpython-39.pyc ├── app.py ├── blockChain.py ├── blocks ├── 1.json ├── 10.json ├── 2.json ├── 3.json ├── 4.json ├── 5.json ├── 6.json ├── 7.json ├── 8.json └── 9.json └── templates ├── addEHR.html ├── base.html ├── blockchain.html ├── book.html ├── doctor.html ├── doctorhome.html ├── doctorregister.html ├── index.html ├── patients.html └── patients_home.html /EHR.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `EHR` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 2 | use EHR; 3 | CREATE TABLE IF NOT EXISTS `patientsdata` ( 4 | `id` int(11) NOT NULL AUTO_INCREMENT, 5 | `username` varchar(255) NOT NULL, 6 | `password` varchar(255) NOT NULL, 7 | `email` varchar(100) NOT NULL, 8 | `phoneno` varchar(255) NOT NULL, 9 | PRIMARY KEY (`id`) 10 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; 11 | 12 | CREATE TABLE IF NOT EXISTS `record` ( 13 | `id` int(11) NOT NULL AUTO_INCREMENT, 14 | `recordid` varchar(255) NOT NULL, 15 | `pname` varchar(255) NOT NULL, 16 | `address` varchar(100) NOT NULL, 17 | `insurenceid` varchar(255) NOT NULL, 18 | `phone` varchar(255) NOT NULL, 19 | PRIMARY KEY (`id`) 20 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; 21 | 22 | CREATE TABLE IF NOT EXISTS `bookdata` ( 23 | `id` int(11) NOT NULL AUTO_INCREMENT, 24 | `username` varchar(255) NOT NULL, 25 | `age` int(255) NOT NULL, 26 | `temperature` varchar(255) NOT NULL, 27 | `time` varchar(255) NOT NULL, 28 | `pat_id` varchar(255), 29 | PRIMARY KEY (`id`) 30 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; 31 | 32 | CREATE TABLE IF NOT EXISTS `doctor` ( 33 | `id` int(11) NOT NULL AUTO_INCREMENT, 34 | `username` varchar(255) NOT NULL, 35 | `password` varchar(255) NOT NULL, 36 | `email` varchar(100) NOT NULL, 37 | `phoneno` varchar(255) NOT NULL, 38 | PRIMARY KEY (`id`) 39 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; 40 | 41 | select * from bookdata; 42 | -------------------------------------------------------------------------------- /Health Record System.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Health Record System.rar -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blockchain-based EHR System in Python 2 | 3 | ## Overview 4 | This project is a Blockchain-based Electronic Health Record (EHR) System developed using Python. It allows patients to book appointments, view their health records, and ensures the integrity of the data through blockchain technology. 5 | 6 | ![](https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/blob/e53cfeeffb44850010b842e28c8d42b66b3eb1cb/Screenshot%202024-10-23%20002804.png) 7 | 8 | ## Features 9 | - **Patient Appointment Booking:** Patients can schedule appointments with doctors. 10 | - **Health Record Management:** Patients can add their health records. 11 | - **Blockchain Integrity Check:** Users can check the integrity of the blocks with a simple interface. 12 | 13 | ### Integrity Check Example 14 | After filling in health records, the system displays the following: 15 | 16 | ![](https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/blob/e53cfeeffb44850010b842e28c8d42b66b3eb1cb/Screenshot%202024-10-23%20002706.png) 17 | ![](https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/blob/e53cfeeffb44850010b842e28c8d42b66b3eb1cb/Screenshot%202024-10-23%20002714.png) 18 | 19 | ## Technologies Used 20 | - Flask 21 | - Python 22 | - SQL 23 | - HTML 24 | - JSON 25 | 26 | ## Installation 27 | 1. Clone the repository: 28 | ```bash 29 | git clone https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python 30 | ``` 31 | 2. Navigate to the project directory: 32 | ```bash 33 | cd Blockchain-based-Electronic-health-Record-System-in-Python 34 | ``` 35 | 3. Run the application: 36 | ```bash 37 | python app.py 38 | ``` 39 | ## Usage 40 | - Open your browser and navigate to http://localhost:5000 to access the application. 41 | - Follow the on-screen instructions to book appointments and manage health records. 42 | 43 | ![](https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/blob/e53cfeeffb44850010b842e28c8d42b66b3eb1cb/Screenshot%202024-10-23%20002837.png) 44 | ![](https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/blob/e53cfeeffb44850010b842e28c8d42b66b3eb1cb/Screenshot%202024-10-23%20002847.png) 45 | ![](https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/blob/e53cfeeffb44850010b842e28c8d42b66b3eb1cb/Screenshot%202024-10-23%20002900.png) 46 | ![](https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/blob/e53cfeeffb44850010b842e28c8d42b66b3eb1cb/Screenshot%202024-10-23%20002920.png) 47 | ![](https://github.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/blob/e53cfeeffb44850010b842e28c8d42b66b3eb1cb/Screenshot%202024-10-23%20002948.png) 48 | 49 | -------------------------------------------------------------------------------- /Screenshot 2024-10-23 002706.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Screenshot 2024-10-23 002706.png -------------------------------------------------------------------------------- /Screenshot 2024-10-23 002714.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Screenshot 2024-10-23 002714.png -------------------------------------------------------------------------------- /Screenshot 2024-10-23 002804.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Screenshot 2024-10-23 002804.png -------------------------------------------------------------------------------- /Screenshot 2024-10-23 002837.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Screenshot 2024-10-23 002837.png -------------------------------------------------------------------------------- /Screenshot 2024-10-23 002847.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Screenshot 2024-10-23 002847.png -------------------------------------------------------------------------------- /Screenshot 2024-10-23 002900.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Screenshot 2024-10-23 002900.png -------------------------------------------------------------------------------- /Screenshot 2024-10-23 002920.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Screenshot 2024-10-23 002920.png -------------------------------------------------------------------------------- /Screenshot 2024-10-23 002948.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/Screenshot 2024-10-23 002948.png -------------------------------------------------------------------------------- /__pycache__/blockChain.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/__pycache__/blockChain.cpython-311.pyc -------------------------------------------------------------------------------- /__pycache__/blockChain.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/harshakalluri1403/Blockchain-based-Electronic-health-Record-System-in-Python/294bbcb1082e56ed24b9ddea8e96408942fff338/__pycache__/blockChain.cpython-39.pyc -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request, session, redirect, url_for 2 | from flask_mysqldb import MySQL 3 | import MySQLdb.cursors 4 | import re 5 | import blockChain 6 | 7 | app = Flask(__name__) 8 | 9 | app.secret_key = 'your secret key' 10 | app.config['MYSQL_HOST'] = 'localhost' 11 | app.config['MYSQL_USER'] = 'root' 12 | app.config['MYSQL_PASSWORD'] = '12345678' 13 | app.config['MYSQL_DB'] = 'EHR' 14 | 15 | mysql = MySQL(app) 16 | 17 | 18 | @app.route('/') 19 | @app.route('/index') 20 | def index(): 21 | return render_template('index.html') 22 | 23 | 24 | @app.route('/index.html') 25 | def home(): 26 | return render_template("index.html") 27 | 28 | 29 | @app.route('/doctor.html') 30 | def doctor(): 31 | return render_template('doctor.html') 32 | 33 | 34 | @app.route('/patients.html') 35 | def patients(): 36 | return render_template('patients.html') 37 | 38 | 39 | @app.route('/patients_home.html', methods=["post", "get"]) 40 | def patients_home(): 41 | return render_template("patients_home.html") 42 | 43 | 44 | @app.route('/addEHR.html') 45 | def addEHR(): 46 | return render_template('addEHR.html') 47 | 48 | 49 | @app.route('/book.html') 50 | def book(): 51 | return render_template('book.html') 52 | 53 | 54 | @app.route('/blockchain.html') 55 | def blockchain(): 56 | return render_template('blockchain.html') 57 | 58 | 59 | @app.route('/doctorregister.html') 60 | def doctorregiter(): 61 | return render_template("doctorregister.html") 62 | 63 | 64 | @app.route('/logout') 65 | def logout(): 66 | session.clear() 67 | return render_template('index.html') 68 | 69 | 70 | @app.route('/patientslogin', methods=["post", "get"]) 71 | def patientslogin(): 72 | if request.method == "get": 73 | return f"The URL /data is accessed directly. Try going to '/form' to submit form" 74 | else: 75 | msg = '' 76 | username = request.form["username"] 77 | password = request.form["password"] 78 | cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor) 79 | cursor.execute('SELECT * FROM patientsdata WHERE username = %s AND password = %s', ([username, password])) 80 | account = cursor.fetchone() 81 | if account: 82 | session['logged'] = True 83 | session['id'] = account['id'] 84 | session['username'] = account['username'] 85 | # Redirect to home page 86 | return render_template('patients_home.html', username=username) 87 | else: 88 | msg = 'Incorrect username/password!' 89 | return render_template('patients.html', msg=msg) 90 | 91 | 92 | @app.route("/patientsregister", methods=["post", "get"]) 93 | def patientsregister(): 94 | if request.method == "get": 95 | return f"The URL /data is accessed directly. Try going to '/form' to submit form" 96 | else: 97 | msg = '' 98 | username = request.form['username'] 99 | password = request.form['password'] 100 | email = request.form['email'] 101 | phone = request.form['phone_number'] 102 | cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor) 103 | cursor.execute('SELECT * FROM patientsdata WHERE username = %s', ([username],)) 104 | account = cursor.fetchone() 105 | if account: 106 | msg = 'Account already exists!' 107 | return render_template('patients.html', msg=msg) 108 | elif not re.match(r'[^@]+@[^@]+\.[^@]+', email): 109 | msg = 'Invalid email address!' 110 | return render_template('patients.html', msg=msg) 111 | elif not re.match(r'[A-Za-z0-9]+', username): 112 | msg = 'Username must contain only characters and numbers!' 113 | return render_template('patients.html', msg=msg) 114 | elif not username or not password or not email or not phone: 115 | msg = 'Please fill out the form!' 116 | return render_template('patients.html', msg=msg) 117 | else: 118 | 119 | cursor.execute('INSERT INTO patientsdata VALUES (NULL, %s, %s, %s, %s)', 120 | (username, password, email, phone)) 121 | mysql.connection.commit() 122 | msg = 'You have successfully registered!' 123 | return redirect(url_for('patients_home', msg=msg, username=username)) 124 | 125 | 126 | @app.route('/adddata', methods=['post', 'get']) 127 | def adddata(): 128 | if request.method == "get": 129 | return f"The URL /data is accessed directly. Try going to '/form' to submit form" 130 | else: 131 | msg = '' 132 | record_id = request.form['rid'] 133 | patient_name = request.form['name'] 134 | address = request.form['address'] 135 | insurence_id = request.form['iid'] 136 | phone = request.form['phone'] 137 | text = record_id + patient_name + address + insurence_id + phone 138 | print(type(text)) 139 | print(text) 140 | if len(text) < 1: 141 | return redirect(url_for('index')) 142 | try: 143 | make_proof = request.form['make_proof'] 144 | except Exception: 145 | make_proof = False 146 | blockChain.write_block(text, make_proof) 147 | 148 | if not record_id or not patient_name or not address or not insurence_id or not phone: 149 | msg = 'Please Fill All the Fields' 150 | return render_template('addEHR.html', msg=msg) 151 | else: 152 | cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor) 153 | cursor.execute('INSERT INTO record VALUES (NULL, %s, %s, %s, %s, %s)', 154 | (record_id, patient_name, address, insurence_id, phone)) 155 | mysql.connection.commit() 156 | msg = 'Data Successfully stored into Block chain' 157 | return render_template('blockchain.html', msg=msg) 158 | 159 | 160 | @app.route('/check', methods=['POST']) 161 | def integrity(): 162 | results = blockChain.check_blocks_integrity() 163 | if request.method == 'POST': 164 | return render_template('blockchain.html', results=results) 165 | return redirect(url_for('patients_home')) 166 | 167 | 168 | @app.route('/mining', methods=['POST']) 169 | def mining(): 170 | if request.method == 'POST': 171 | max_index = int(blockChain.get_next_block()) 172 | 173 | for i in range(2, max_index): 174 | blockChain.get_POW(i) 175 | return render_template('blockchain.html', querry=max_index) 176 | return redirect(url_for('patients_home')) 177 | 178 | 179 | @app.route('/bookdata', methods=['post', 'get']) 180 | def book_data(): 181 | if request.method == "get": 182 | return f"The URL /data is accessed directly. Try going to '/form' to submit form" 183 | else: 184 | msg = '' 185 | username = request.form['name'] 186 | age = request.form['age'] 187 | temperature = request.form['temp'] 188 | time = request.form['time'] 189 | patient_id = request.form['patid'] 190 | if not username or not age or not temperature or not time or not patient_id: 191 | msg = 'Please Fill All the Fields' 192 | return render_template('book.html', msg=msg) 193 | else: 194 | cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor) 195 | cursor.execute('INSERT INTO bookdata VALUES (NULL, %s, %s, %s, %s, %s)', 196 | (username, age, temperature, time, patient_id)) 197 | mysql.connection.commit() 198 | msg = 'Data Successfully stored into Block chain' 199 | return render_template('patients_home.html', msg=msg) 200 | 201 | 202 | @app.route('/doctorlogin', methods=['post', 'get']) 203 | def doctorlogin(): 204 | if request.method == "get": 205 | return f"The URL /data is accessed directly. Try going to '/form' to submit form" 206 | else: 207 | msg = '' 208 | username = request.form["username"] 209 | password = request.form["password"] 210 | cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor) 211 | cursor.execute('SELECT * FROM doctor WHERE username = %s AND password = %s', ([username, password])) 212 | account = cursor.fetchone() 213 | if account: 214 | session['logged'] = True 215 | session['id'] = account['id'] 216 | session['username'] = account['username'] 217 | cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor) 218 | cursor.execute("select * from bookdata") 219 | print("INN") 220 | data = cursor.fetchall() 221 | print(data) 222 | # Redirect to home page 223 | return render_template('doctorhome.html', data=data, username=username) 224 | 225 | else: 226 | msg = 'Incorrect username/password!' 227 | return render_template('doctor.html', msg=msg) 228 | 229 | 230 | @app.route('/dregister', methods=['post', 'get']) 231 | def docregister(): 232 | if request.method == "get": 233 | return f"The URL /data is accessed directly. Try going to '/form' to submit form" 234 | else: 235 | msg = '' 236 | username = request.form['username'] 237 | password = request.form['password'] 238 | email = request.form['email'] 239 | phone = request.form['phone'] 240 | cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor) 241 | cursor.execute('SELECT * FROM doctor WHERE username = %s', ([username],)) 242 | account = cursor.fetchone() 243 | if account: 244 | msg = 'Account already exists!' 245 | return render_template('doctor.html', msg=msg) 246 | elif not re.match(r'[^@]+@[^@]+\.[^@]+', email): 247 | msg = 'Invalid email address!' 248 | return render_template('doctor.html', msg=msg) 249 | elif not re.match(r'[A-Za-z0-9]+', username): 250 | msg = 'Username must contain only characters and numbers!' 251 | return render_template('doctor.html', msg=msg) 252 | elif not username or not password or not email or not phone: 253 | msg = 'Please fill out the form!' 254 | return render_template('doctor.html', msg=msg) 255 | else: 256 | 257 | cursor.execute('INSERT INTO doctor VALUES (NULL, %s, %s, %s, %s)', 258 | (username, password, email, phone)) 259 | mysql.connection.commit() 260 | msg = 'You have successfully registered!' 261 | return render_template('doctor.html', msg=msg, username=username) 262 | 263 | 264 | 265 | if __name__ == '__main__': 266 | app.run(debug=True, host='0.0.0.0', port=8000) 267 | -------------------------------------------------------------------------------- /blockChain.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import json 3 | import os 4 | from time import time 5 | 6 | BLOCKCHAIN_DIR = os.curdir + '/blocks/' 7 | 8 | 9 | def check_blocks_integrity(): 10 | result = list() 11 | cur_proof = - 1 12 | for i in range(2, int(get_next_block())): 13 | prev_index = str(i - 1) 14 | cur_index = str(i) 15 | tmp = {'block': '', 'result': '', 'proof': ''} 16 | try: 17 | file_dict = json.load(open(BLOCKCHAIN_DIR + cur_index + '.json')) 18 | cur_hash = file_dict['prev_hash'] 19 | cur_proof = file_dict['proof'] 20 | except Exception as e: 21 | print(e) 22 | 23 | try: 24 | prev_hash = hashlib.sha256(open(BLOCKCHAIN_DIR + prev_index + '.json', 'rb').read()).hexdigest() 25 | except Exception as e: 26 | print(e) 27 | 28 | tmp['block'] = prev_index 29 | tmp['proof'] = cur_proof 30 | if cur_hash == prev_hash: 31 | tmp['result'] = 'ok' 32 | else: 33 | tmp['result'] = 'error' 34 | result.append(tmp) 35 | return result 36 | 37 | 38 | def check_block(index): 39 | cur_index = str(index) 40 | prev_index = str(int(index) - 1) 41 | cur_proof = - 1 42 | cur_hash = 0 43 | prev_hash = 0 44 | tmp = {'block': '', 'result': '', 'proof': ''} 45 | try: 46 | file_dict = json.load(open(BLOCKCHAIN_DIR + cur_index + '.json')) 47 | cur_hash = file_dict['prev_hash'] 48 | cur_proof = file_dict['proof'] 49 | except Exception as e: 50 | print(e) 51 | try: 52 | prev_hash = hashlib.sha256(open(BLOCKCHAIN_DIR + prev_index + '.json', 'rb').read()).hexdigest() 53 | except Exception as e: 54 | print(e) 55 | tmp['block'] = prev_index 56 | tmp['proof'] = cur_proof 57 | if cur_hash == prev_hash: 58 | tmp['result'] = 'ok' 59 | else: 60 | tmp['result'] = 'error' 61 | return tmp 62 | 63 | 64 | def get_hash(file_name): 65 | file_name = str(file_name) 66 | if not file_name.endswith('.json'): 67 | file_name += '.json' 68 | try: 69 | with open(BLOCKCHAIN_DIR + file_name, 'rb') as file: 70 | return hashlib.sha256(file.read()).hexdigest() 71 | except Exception as e: 72 | print('File "' + file_name + '" does not exist!n', e) 73 | 74 | 75 | def get_next_block(): 76 | files = os.listdir(BLOCKCHAIN_DIR) 77 | index_list = [int(file.split('.')[0]) for file in files] 78 | cur_index = sorted(index_list)[-1] 79 | next_index = cur_index + 1 80 | return str(next_index) 81 | 82 | 83 | def is_valid_proof(last_proof, proof, difficulty): 84 | guess = f'{last_proof}{proof}'.encode() 85 | guess_hash = hashlib.sha256(guess).hexdigest() 86 | return guess_hash[:difficulty] == '0' * difficulty 87 | 88 | 89 | def get_POW(file_name, difficulty=1): 90 | # POW - proof of work 91 | file_name = str(file_name) 92 | if file_name.endswith('.json'): 93 | file_name = int(file_name.split('.')[0]) 94 | else: 95 | file_name = int(file_name) 96 | 97 | last_proof = json.load(open(BLOCKCHAIN_DIR + str(file_name - 1) + '.json'))['proof'] 98 | proof = 0 99 | while is_valid_proof(last_proof, proof, difficulty) is False: 100 | proof += 1 101 | cur_block = json.load(open(BLOCKCHAIN_DIR + str(file_name) + '.json')) 102 | cur_block['proof'] = proof 103 | cur_block['prev_hash'] = get_hash(str(file_name - 1)) 104 | with open(BLOCKCHAIN_DIR + str(file_name) + '.json', 'w') as file: 105 | json.dump(cur_block, file, indent=4, ensure_ascii=False) 106 | 107 | 108 | def write_block(text, make_proof=False): 109 | cur_index = get_next_block() 110 | prev_index = str(int(cur_index) - 1) 111 | prev_block_hash = get_hash(prev_index) 112 | data = {'text': text, 113 | 'prev_hash': prev_block_hash, 114 | 'timestamp': time(), 115 | 'proof': -1, 116 | 'index': cur_index 117 | } 118 | 119 | with open(BLOCKCHAIN_DIR + cur_index + '.json', 'w') as file: 120 | json.dump(data, file, indent=4, ensure_ascii=False) 121 | if make_proof is True: 122 | get_POW(str(cur_index)) 123 | 124 | 125 | if __name__ == '__main__': 126 | # for i in range(10): 127 | # write_block(str(i),True) 128 | for i in range(2, 10): 129 | print(check_block(str(i))) 130 | print(check_blocks_integrity()) 131 | -------------------------------------------------------------------------------- /blocks/1.json: -------------------------------------------------------------------------------- 1 | { 2 | "text" : "Genesis block", 3 | "hash": "", 4 | "timestamp": 0, 5 | "proof": -1, 6 | "index": "1" 7 | } -------------------------------------------------------------------------------- /blocks/10.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "1256hellohello1123123", 3 | "prev_hash": "0c8e985563ce0f7ec15570d1e8e6226e5fa4728c0086eb781b988b309ac335f9", 4 | "timestamp": 1729620202.0004756, 5 | "proof": 32, 6 | "index": "10" 7 | } -------------------------------------------------------------------------------- /blocks/2.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "02veluchennaiINS017339300411", 3 | "prev_hash": "83d7411b8069a6f1ffa6aeee6379f967a2d666eb65cc5cf4eeef318b058c5b55", 4 | "timestamp": 1651005918.7028801, 5 | "proof": 95, 6 | "index": "2" 7 | } -------------------------------------------------------------------------------- /blocks/3.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "01velchennaiINS017339300411", 3 | "prev_hash": "e41969ffd8a2aa522e946389edc9555d279ee12cb6c096008617458a06c906d1", 4 | "timestamp": 1651008645.9228165, 5 | "proof": 19, 6 | "index": "3" 7 | } -------------------------------------------------------------------------------- /blocks/4.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "01velchennaii017339300411", 3 | "prev_hash": "540408a8eb6ef287b876bb9699be5676ec1b3672d54f0d2d9b239eba2ee3d9f8", 4 | "timestamp": 1651008733.1406453, 5 | "proof": 32, 6 | "index": "4" 7 | } -------------------------------------------------------------------------------- /blocks/5.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "01velchennaiINS017339300411", 3 | "prev_hash": "994441658bf2f19ebd0338581f775aef7339f56ed5add31d4a88e810b0ff66e6", 4 | "timestamp": 1651008800.671047, 5 | "proof": 7, 6 | "index": "5" 7 | } -------------------------------------------------------------------------------- /blocks/6.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "01velchennaiINS017339300411", 3 | "prev_hash": "b782a208768e11d24f2b204789ee9d78de7d4e98e811e37f4e11a8b21a52769f", 4 | "timestamp": 1651009526.4303882, 5 | "proof": 19, 6 | "index": "6" 7 | } -------------------------------------------------------------------------------- /blocks/7.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "01velchennaiINS017339300411", 3 | "prev_hash": "df17b10592819e7ab4a825c999d707878986ee116947e6fc4dba8677559df8b2", 4 | "timestamp": 1651009542.7080693, 5 | "proof": 32, 6 | "index": "7" 7 | } -------------------------------------------------------------------------------- /blocks/8.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "02velchennaiINS017339300411", 3 | "prev_hash": "33eea40a78f43150e054da4d1db9e81e7330a588d644def9cbd7ee9d08869780", 4 | "timestamp": 1651009718.7829256, 5 | "proof": 7, 6 | "index": "8" 7 | } -------------------------------------------------------------------------------- /blocks/9.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "02velchennaiINS017339300411", 3 | "prev_hash": "64d0fd48559973e09fe6419d0cf5f17f67e1aa4cbf7b388cb937f352fec1544c", 4 | "timestamp": 1651009737.8883562, 5 | "proof": 19, 6 | "index": "9" 7 | } -------------------------------------------------------------------------------- /templates/addEHR.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Food Recommendation 6 | 131 | 132 | 133 |
134 |
135 |
Welcome
136 |
Enter your Details!
137 |
{{msg}}
138 |
139 | 140 |
141 | 142 |
143 |
144 | 145 |
146 | 147 |
148 |
149 | 150 |
151 | 152 |
153 |
154 | 155 |
156 | 157 |
158 |
159 | 160 |
161 | 162 |
163 | 164 |
165 |
166 | 167 | -------------------------------------------------------------------------------- /templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | BlockChain 11 | 12 | 13 | 14 | 15 | 16 |
{{msg}}
17 |
18 |
19 |
20 |

Check blocks integrity: just click

21 |
22 |
23 |
24 |
25 |
26 |
27 | {% block check %} 28 | 29 | {% endblock %} 30 |
31 |
32 |
33 | 34 | 35 |
36 |
37 |
38 |

Mining just try...

39 |
40 |
41 |
42 |
43 |
44 |
45 | {% block mining %} 46 | 47 | {% endblock %} 48 |
49 |
50 |
51 |
Go Back
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /templates/blockchain.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} {% block content %} 2 |
3 |
{% endblock %} {% block check %} 4 |
5 | 6 |
7 |
8 | 18 |
{% endblock %} 19 |
{% block mining %} 20 |
21 | 22 |
23 | {% if querry %} 24 |
25 | 28 | 29 |

{% endif %} 30 |


{% endblock %} 31 | 32 | -------------------------------------------------------------------------------- /templates/book.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Book Appointment 6 | 131 | 132 | 133 |
134 |
135 |
Welcome
136 |
137 | 138 |
139 | 140 |
141 |
142 | 143 |
144 | 145 |
146 |
147 | 148 |
149 | 150 |
151 |
152 | 153 |
154 | 155 |
156 |
157 | 158 |
159 | 160 |
161 | 162 |
163 |
164 | 165 | -------------------------------------------------------------------------------- /templates/doctor.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Doctor login 6 | 186 | 209 | 210 | 211 |
212 |
213 |
214 |
215 |

Log In

216 |

login here using your username and password

217 |
{{msg}}
218 |
219 |
220 |
221 | 222 |
223 | 224 |
225 | 226 |
227 | 230 |
231 |
232 |
233 | 234 | -------------------------------------------------------------------------------- /templates/doctorhome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Doctor Main Page 6 | 96 | 103 | 104 | 105 |
106 | 107 |

Booking Details

108 |

Welcome Doctor {{username}}

109 |
110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 |
S.NOUSERNAMEAGETEMPERATURETIMEPATIENT-ID
123 |
124 | 125 |
126 | 127 | 128 | {% for item in data %} 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | {% endfor %} 138 | 139 |
{{item.id}}{{item.username}}{{item.age}}{{item.temperature}}{{item.time}}{{item.pat_id}}
140 |
141 | 142 |
143 | 144 | 145 | 146 |
147 | Home 148 |
149 | 150 | -------------------------------------------------------------------------------- /templates/doctorregister.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Parent Register Page 6 | 132 | 133 | 134 |
135 |
136 |
{{msg}}
137 |
Welcome
138 |
Let's create your account!
139 |
140 | 141 |
142 | 143 |
144 |
145 | 146 |
147 | 148 |
149 |
150 | 151 |
152 | 153 |
154 |
155 | 156 |
157 | 158 |
159 | 160 |
161 |
162 | 163 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Welcome Page 6 | 167 | 168 | 169 |
170 | 177 |
178 | 179 | 184 | 185 |
186 |

Electronic Health Record System Using python with Block chain

187 |
188 |
189 |
190 | 191 | -------------------------------------------------------------------------------- /templates/patients.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Patients Login/Register Page 6 | 158 | 159 | 160 |
161 |
162 | 163 | 164 | 207 |
208 |
209 | 210 | -------------------------------------------------------------------------------- /templates/patients_home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Patients Home Page 6 | 234 | 235 | 236 |
237 |
CHILD
238 | 253 | 254 |
255 |
256 |

{{username}} Welcome to Medical Health Records System

257 |
258 |
259 |
260 | 261 | --------------------------------------------------------------------------------