Work

Graduation thesis

HealthChain

A graduation thesis that kept medical records on Ethereum and predicted diseases from symptoms; in its second version only the proof of a record goes on-chain.

Role
Co-author of a two-person thesis
Year
2025 (thesis), 2026 (v2)
Stack
Solidity, Hardhat, ethers.js, Flask, scikit-learn
Context
Graduation thesis, Computer Engineering, Fırat University

HealthChain is the graduation thesis I wrote with Deniz Bektaş in 2025 in Computer Engineering at Fırat University, supervised by Prof. Dr. Mehmet Karaköse. We combined a system that keeps medical records in an Ethereum smart contract with a decision-support module that predicts a disease from symptoms.

The problem

Patient data mostly sits on central servers. That was the thesis's starting point: the data is open to manipulation, reachable through a single point, and a privacy risk. The second need was on the user's side: someone who enters their symptoms should get quick, reliable first information.

The thesis prototype

The system has four components: an interface in HTML, Tailwind CSS and JavaScript, a Web3 layer through Ethers.js and MetaMask, the Solidity contract MedikalKayitSistemi.sol, and a prediction module served by Flask. The wallet address is the identity, and every transaction is signed in MetaMask. A patient can reach only their own record; the admin can list, update and delete every record through admin.html.

  1. WalletMetaMask connects, the wallet address is the identity
  2. RecordName and disease are written to the contract
  3. SymptomsThe list goes to POST /tahmin in Flask
  4. PredictionThe likely disease and precautions come back as JSON

For prediction we first tried a text-based LSTM; its accuracy stayed low and it tended to memorise. We trained a Random Forest with 200 trees in scikit-learn instead. We used the open “Disease Symptom Prediction Dataset”: each symptom became its severity weight, and the data was split 80/20 into training and test sets. The POST /tahmin endpoint in Flask takes the symptom list and returns the prediction and suggested precautions as JSON.

The results we reported in the thesis (2025):

Accuracy (thesis)93%
Mean F1 score (thesis)0.89
0.38 sprediction time (thesis)
200trees in the Random Forest (scikit-learn), served by Flask
8test scenarios on the local Hardhat network

These numbers belong to the thesis version, the Random Forest model served by Flask. The v2 below does not claim that those experiments were repeated under the new design.

What v2 changes

In the thesis prototype the patient's name and disease sat in the contract as plain text. HealthChain v2, the current version in the repository, reverses that decision. Its README states the rule: a public blockchain may prove integrity, but it must not become a database for private medical content.

The README also lists the problems of the old version: medical fields were written on-chain in plain text, the admin could change records without restriction, deployment details were hardcoded, generated dependencies were committed, and an AI credential had appeared in the source history.

Thesis prototype (2025)v2
Written on-chainName and disease, plain textSalted digest, author, timestamp, revocation flag
Record contentInside the contractIn the browser and the downloaded proof bundle
AdminLists, updates, deletesNone
Changing a recordUpdate and deleteAppend-only; the patient sets the revocation flag
AIDisease prediction with a Random ForestOptional educational notes, no diagnosis
ToolingHardhat, Ethers.js, Flask, scikit-learnHardhat 3, viem, Express 5
NetworkLocal Hardhat networkLocal Hardhat network

In v2 the content of a record does not leave the browser. The browser generates a random 32-byte salt and computes the digest SHA-256(salt_hex + ":" + canonical_json_payload). Only that digest, the author's wallet address, a timestamp and a revocation flag are written to the MedicalRecordRegistry.sol contract. The contract has no admin, no update and no delete. The patient uses setProviderAuthorization to authorise a provider who may add records on their behalf, and only the patient can mark a record as revoked.

Off-chain
Browser and wallet HTML, CSS, JavaScript and ethers.js. The record stays here.
Record payload (JSON)Record categoryRandom 32-byte saltDownloadable proof bundle
Optional AI endpoint Node.js and Express 5, calls the OpenAI Responses API. Requires explicit consent and does not log request bodies.
On-chain
MedicalRecordRegistry.sol One entry per record, append-only.
bytes32 dataHashsalted SHA-256 digestaddress authorauthoring walletuint64 createdAttimestampbool revokedrevocation flag
Data flow in HealthChain v2: the record stays in the browser, only its salted digest is written on-chain.

Writing a record and verifying it later takes six steps:

  1. RecordThe content is prepared in the browser
  2. Salt and digestRandom 32-byte salt, SHA-256
  3. SignatureaddRecord, from the patient's or an authorised provider's wallet
  4. ChainDigest, author and timestamp are written
  5. Proof bundleContent, salt, digest and transaction details download as JSON
  6. VerificationThe digest is recomputed locally and must match the one in the bundle

The AI side changed too. v2 has no Random Forest; in its place is an optional Node.js endpoint that calls the OpenAI Responses API. Its instructions prohibit diagnosis, prescription, dosing and medication changes, and the output is presented as educational notes.

Stack

Thesis (2025)
Solidity, Hardhat, Ethers.js, MetaMask, Flask, scikit-learn, Tailwind CSS
v2 contract
Solidity ^0.8.24, Hardhat 3, TypeScript, viem
v2 application
Node.js 22, Express 5, HTML, CSS, JavaScript, ethers.js
Process
GitHub Actions, Dependabot
Licence
MIT

Limits

The thesis prototype ran only on Hardhat's local network; the thesis mentions no deployment to a public testnet or mainnet. Its limitations section adds that gas costs would be high on a real network, a model trained on a limited dataset makes more errors on rare diseases, and the Flask API on a single server becomes a bottleneck under parallel requests.

v2 is a research prototype too. Its README lists no encrypted record database, no FHIR or HL7 support and no third-party audit. Wallets are pseudonymous, the AI output is not clinically validated, and no HIPAA, GDPR or KVKK compliance is claimed.

More work

Contact

Let's build
something together.

If you have a project, a role or just an idea in mind, write to me.

Reach me

Email[email protected] LinkedInin/emreocell GitHub@emreocell X@emreocell1219 Instagram@emre.ocel Redditu/emreocell