## Inspiration

Last week, one of our team members was admitted to the hospital with brain trauma. Doctors hesitated to treat them because of their lack of insight into the patient’s medical history. This prompted us to store EVERYONE’s health records on a single, decentralized chain. The catch? The process is end-to-end encrypted, ensuring only yourself and your designated providers can access your data.

## How we built it

Zorg was built across 3 verticals: a frontend client, a backend server, and the chain.

The frontend client…

We poured our hearts and ingenuity into crafting a seamless user interface, a harmonious blend of aesthetics and functionality designed to resonate across the spectrum of users. Our aim? To simplify the process for patients to effortlessly navigate and control their medical records while enabling doctors and healthcare providers to seamlessly access and request patient information. Leveraging the synergy of Bun, React, Next, and Shadcn, we crafted a performant portal. To safeguard privacy, we fortified client-side interactions with encryption, ensuring sensitive data remains inaccessible to central servers. This fusion of technology and design principles heralds a new era of secure, user-centric digital healthcare record keeping.

The backend server…

The backend server of Zorg is the crux of our mission to revolutionize healthcare records management, ensuring secure, fast, and reliable access to encrypted patient data. Utilizing Zig for its performance and security advantages, our backend encrypts health records using a doctor's public key and stores them on IPFS for decentralized access. These records are then indexed on the blockchain via unique identifiers (CIDs), ensuring both privacy and immutability.

Upon request, the system retrieves and decrypts the data for authorized users, transforming it into a vectorized format suitable for semantic search. This process not only safeguards patient information but also enables healthcare providers to efficiently parse through detailed medical histories. Our use of Zig ensures that these operations are executed swiftly, maintaining our commitment to providing immediate access to critical medical information while prioritizing patient privacy and data integrity.

The chain…

The chain stores the encrypted key and the CID, allowing seemless access to a patient’s file stored on decentralized storage (IPFS). The cool part? The complex protocols and keys governing this system is completely abstracted away and wrapped up modern UI/UX, giving easy access to senior citizens and care providers.

## Challenges we ran into

Our biggest challenges were during integration, near the end of the hackathon. We had divided the project, with each person focusing on a different area—machine learning and queries, blockchain and key sharing, encryption and IPFS, and the frontend design. However, when we began to put things together, we quickly realized that we had failed to communicate with each other the specific details of how each of our systems worked. As a result we had to spend a few hours just tweaking each of our systems so that they could work with each other.

Another smaller (but enjoyable!) challenge we faced was learning to use a new language (Zig!). We ended up building our entire encryption and decryption system in Zig (as it needed to be incredibly fast due to the potentially vast amounts of data it would be processing) and had to piece together both how to build these systems in Zig, and how to integrate the resulting Zig binaries into the rest of our project.

## What's next for Zorg

In the future, we hope to devise a cryptographically sound way to revoke access to records after they have been granted. Additionally, our system would best benefit the population if we were able to partner with the government to include patient private keys in something everyone carries with them like their phone or ID so that in an emergency situation, first responders can access the patient data and identify things like allergies to medications.
## Summary

OrganSafe is a revolutionary web application that tackles the growing health & security problem of black marketing of donated organs. The verification of organ recipients leverages the Ethereum Blockchain to provide critical security and prevent improper allocation for such a pivotal resource.

## Inspiration

The [World Health Organization (WHO)](https://slate.com/business/2010/12/can-economists-make-the-system-for-organ-transplants-more-humane-and-efficient.html) estimates that one in every five kidneys transplanted per year comes from the black market. There is a significant demand for solving this problem which impacts thousands of people every year who are struggling to find a donor for a significantly need transplant. Modern [research](https://ieeexplore.ieee.org/document/8974526) has shown that blockchain validation of organ donation transactions can help reduce this problem and authenticate transactions to ensure that donated organs go to the right place!

## What it does

OrganSafe facilitates organ donations with authentication via the Ethereum Blockchain. Users can start by registering on OrganSafe with their health information and desired donation and then application's algorithms will automatically match the users based on qualifying priority for available donations. Hospitals can easily track donations of organs and easily record when recipients receive their donation.

## How we built it

This application was built using React.js for the frontend of the platform, Python Flask for the backend and API endpoints, and Solidity+Web3.js for Ethereum Blockchain.

## Challenges we ran into

Some of the biggest challenges we ran into were connecting the different components of our project. We had three major components: frontend, backend, and the blockchain that were developed on that needed to be integrated together. This turned to be the biggest hurdle in our project that we needed to figure out. Dealing with the API endpoints and Solidarity integration was one of the problems we had to leave for future developments. One solution to a challenge we solved was dealing with difficulty of the backend development and setting up API endpoints. Without a persistent data storage in the backend, we attempted to implement basic storage using localStorage in the browser to facilitate a user experience. This allowed us to implement a majority of our features as a temporary fix for our demonstration. Some other challenges we faced included figuring certain syntactical elements to the new technologies we dealt (such as using Hooks and States in React.js). It was a great learning opportunity for our group as immersing ourselves in the project allowed us to become more familiar with each technology!

## Accomplishments that we're proud of

One notable accomplishment is that every member of our group interface with new technology that we had little to no experience with! Whether it was learning how to use React.js (such as learning about React fragments) or working with Web3.0 technology such as the Ethereum Blockchain (using MetaMask and Solidity), each member worked on something completely new! Although there were many components we simply just did not have the time to complete due to the scope of TreeHacks, we were still proud with being able to put together a minimum viable product in the end!

## What we learned

* Fullstack Web Development (with React.js frontend development and Python Flask backend development)
* Web3.0 & Security (with Solidity & Ethereum Blockchain)

## What's next for OrganSafe

After TreeHacks, OrganSafe will first look to tackle some of the potential areas that we did not get to finish during the time of the Hackathon. Our first step would be to finish development of the full stack web application that we intended by fleshing out our backend and moving forward from there. Persistent user data in a data base would also allow users and donors to continue to use the site even after an individual session. Furthermore, scaling both the site and the blockchain for the application would allow greater usage by a larger audience, allowing more recipients to be matched with donors.
## Inspiration

As three of our team members are international students, we encountered challenges when transferring our medical records from our home countries to the United States. Because of poor transferability of medical records, we would end up retaking vaccines we had already received in our home countries and wasted a lot of our time collecting our medical records. Moreover, even within the US, we noticed that medical records were often fragmented, with each hospital maintaining its own separate records. These experiences inspired us to create a solution that simplifies the secure transfer of medical records, making healthcare more efficient and accessible for everyone.

## What it does

HealthChain.ai allows for medical records to be parsed by AI, and stored as non-fungible tokens on the Ethereum blockchain. The blockchain takes away a central authority to remove long wait times for document requests and allows for easy access by record holders and hospitals. AI parsing allows for easy integration between differing hospital systems and international regulations.

## How we built it

Our frontend uses Next.js with tailwind and typescript, and is deployed on Vercel. We used OpenAI to process text input into json to store on our block chain. Our backend used Solidity to write our smart contracts, and broadcast it to the Ethereum block chain using the Alchemy API. We used custom NodeJS API calls to connect the Ethereum block chain to our frontend, and deployed this on vercel as well. This all integrates into the MetaMask API on our frontend which displays NFTs in your Ethereum wallet.

## Challenges we ran into

Our original plan was to use Aleo as our Blockchain of choice for our app. But after working with the Aleo’s developers we discovered that the chain's testnet was not working and we couldn't deploy our smart contract. We had to redevelop our Smart Contracts in Solidity and test on the Sepolia, one of the Ethereum testnet. Even then, learning how to navigate through the deployment process and getting the wallets to connect to the chain to interact with our Smart Contracts proved to be one of our biggest challenges.

## Accomplishments that we're proud of

We were able to upload our smart contract and able to retrieve data from the chain which allowed our use of the OpenAi API to parse the information retrieved into more understandable, formatted medical records. We are able to apply decentralized finance along with AI which is a huge challenge, we are proud to be able to pull this off.

## What we learned

Throughout the hacking of our project, we learned quite a lot such as concepts of Blockchain, cryptography and Machine Learning. On top of learning all these concepts we've learnt how to combine them together through frontend and API calls which is crucial in fullstack development.

## What's next for HealthChain.ai

In our upcoming version, we have exciting plans to introduce additional features that we envisioned during the project's development but were constrained by time. These enhancements encompass the integration of speech-to-text for recording medical records, the implementation of OCR technology to convert traditional paper medical records into electronic formats (EMRs), and a comprehensive user interface redesign to simplify the organization of personal medical records. Last but not least, we also want to collaborate with hospitals to bring accessible medical records to the mass market and listen to our customers on what they really want and need.