MobiCare healthcare system uses smart contracts to handle procedure records and stores medical records in BlockChain.
MobiCare is a mobile application, It facilitates the methods of consultation and follow-up between doctors and their patients. It includes all required data about the patient including prescriptions, medical reports, radiology images, diagnoses, treatment plans, allergies, laboratory results, etc…, the patient is allowed to check them whenever he wants and also he can give access to his doctor to get and upload his medical records. The system also provides the patient with an alarm for medication appointments, where he is reminded of the date of each medication that he has entered. The application also allows doctors to upload videos that help spread awareness for users throughout the application and also allows the patient to like and write comments on these videos.
As we see, MobiCare has many components and uses many technologies to store its data. So, we can explain MobiCare architecture in four main components/technologies:
- Mobile Application.
- Relational Database.
- Document Data Store.
- BlockChain.
![Mobile Architecture](https://private-user-images.githubusercontent.com/81831838/250421450-dd5e8ead-9ef9-4bcb-a1f4-b3b66562ecca.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMjAwMzgsIm5iZiI6MTcyNDAxOTczOCwicGF0aCI6Ii84MTgzMTgzOC8yNTA0MjE0NTAtZGQ1ZThlYWQtOWVmOS00YmNiLWExZjQtYjNiNjY1NjJlY2NhLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE4VDIyMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIwODY0N2NiZDEyYjVlOTRhMTc2Njg1MGRlMjhiNDBjZDk2YzMxNTk5NDk4M2MyMmI4YWI5OWU0OWUxMjZmNDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.fi7JyVKBwChj_RMzKDqKVn0FcBYzp4hTTrFtNgretC8)
MVVM (Model-View-ViewModel) MVVM is useful to move business logic from view to ViewModel and Model. ViewModel is the mediator between View and Model which carry all user events and return back the result. The key benefits of using MVVM are Business logic is separate from UI. The view is independent from the ViewModel class and only reads the state from ViewModel Code will be easy to maintain and update in terms of logic & UI Easy to Write the test cases for the project
![Server-Side Architecture](https://private-user-images.githubusercontent.com/81831838/250421488-d5b304b8-68be-4484-9d0c-1bddfd505125.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMjAwMzgsIm5iZiI6MTcyNDAxOTczOCwicGF0aCI6Ii84MTgzMTgzOC8yNTA0MjE0ODgtZDViMzA0YjgtNjhiZS00NDg0LTlkMGMtMWJkZGZkNTA1MTI1LmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE4VDIyMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc5NzcyYjQxNzMxYjgxYzNmMWZjYzkzNmVlMTI1NGE2NzZkYjQ3MjlmNTZhZDUwMWZkNTY2ZjhhZDg3ODAzNTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.X9loEBgtk_xEOQsjJnW9rNxEpG4XogWXpDUtSe-ZQYw)
We worked with MVC architecture (Model, View, and Controller) by replacing the view part with REST APIs. Also, the server-side provides us with an authentication system that verifies the permission of each role (patient, doctor, and admin).
- Model is the data part.
- View is the REST APIs part.
- Controller is the request-response handler.
![Document Data Store](https://private-user-images.githubusercontent.com/81831838/250422270-2ffc7a81-8fd1-4d80-b783-61da7e462e30.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMjAwMzgsIm5iZiI6MTcyNDAxOTczOCwicGF0aCI6Ii84MTgzMTgzOC8yNTA0MjIyNzAtMmZmYzdhODEtOGZkMS00ZDgwLWI3ODMtNjFkYTdlNDYyZTMwLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE4VDIyMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc3YjA0MWY1ZDJiZDhiZTUwOWQ4ODJkZWM4MDhhNTNiYjFjOWNmOGY1M2U5MWUwNDE0NGI5N2Y2MTIzM2ZiZDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8slfyvNW1qQFF0PkVF30omawCqCHuUuEcSq8LDdVnng)
We used the Firestore feature in the Firebase - which is (BaaS) - as a document data store and authentication system. Firebase Firestore provides many features:
- application layers
- unidirectional data flow
- mutable and immutable state
- stream-based architecture
It facilitates dealing with data in several ways: Adding new features becomes easier because you can build upon the foundation that you already have. The codebase becomes easier to understand, and you're likely to spot some recurring patterns and conventions as you read the code. Components have clear responsibilities and don't do too many things. This happens by design if your architecture is highly composable. Entire classes of problems go away (more on this later). You can have different kinds of components, by defining separate application layers for different areas of concern (UI, logic, services)
![BlockChain Environment](https://private-user-images.githubusercontent.com/81831838/250421349-04b35763-d209-40bf-b92f-f2068246668b.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMjAwMzgsIm5iZiI6MTcyNDAxOTczOCwicGF0aCI6Ii84MTgzMTgzOC8yNTA0MjEzNDktMDRiMzU3NjMtZDIwOS00MGJmLWI5MmYtZjIwNjgyNDY2NjhiLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE4VDIyMjIxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYxMmFkZjVmYThmNTBjYzU2NWJhYjA3YjRkNzAyNmQwMDk0ZDMwNWZlNWZmNGZhYTIwYmFiYzQwOWYxYWFmMDQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TRV8wNLF4Nl-R6sHQ50yEebpFqadebDI8oCpjh4gLs8)
To connect to the blockchain network we used:
- Truffle: Building the smart contracts. compile and deploy our smart contracts. Dealing with our smart contracts.
- Ganache: Local blockchain network. Deploying our smart contract. Providing test accounts.
- Infura: Providing test Ethereum to deal with the blockchain network. Providing rpcURL and wsURL to our blockchain project.
- MetaMask: Private Wallet to deal with blockchain activities. Connected to Flutter to deal with the blockchain network.
- Sepolia Test Network: Deployed our smart contract on. Our blockchain network deals with our smart contract.
- Ethereum: The main network and the main cryptocurrency which our smart contract deals with. Any transaction created in the Sepolia test network must pay gas fees with Ethereum cryptocurrency.
- IPFS (Interplanetary File System): which we use to store our sensitive data - medical records - and respond with cid (content identifier), and then we store this cid in the blockchain network with the patient’s wallet address to access it when he wants.
- Web3.Storage: like Infura, it helps us to deal with IPFS to store and access our files in the IPFS Distributed network. It's a bridge between us and IPFS.