{"id":22912297,"url":"https://github.com/strongerprogrammer7/smartcontractpatients","last_synced_at":"2025-06-13T10:09:43.254Z","repository":{"id":276252592,"uuid":"577286074","full_name":"StrongerProgrammer7/SmartContractPatients","owner":"StrongerProgrammer7","description":"Prototype: Interaction patient with doctor through smart contract Ethereum","archived":false,"fork":false,"pushed_at":"2022-12-28T17:40:52.000Z","size":16641,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-13T10:09:21.194Z","etag":null,"topics":["html-css-javascript","solidity-contracts","web3js"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StrongerProgrammer7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-12T12:01:57.000Z","updated_at":"2025-01-30T16:36:46.000Z","dependencies_parsed_at":"2025-02-07T06:36:01.796Z","dependency_job_id":null,"html_url":"https://github.com/StrongerProgrammer7/SmartContractPatients","commit_stats":null,"previous_names":["strongerprogrammer7/smartcontractpatients"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/StrongerProgrammer7/SmartContractPatients","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrongerProgrammer7%2FSmartContractPatients","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrongerProgrammer7%2FSmartContractPatients/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrongerProgrammer7%2FSmartContractPatients/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrongerProgrammer7%2FSmartContractPatients/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StrongerProgrammer7","download_url":"https://codeload.github.com/StrongerProgrammer7/SmartContractPatients/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrongerProgrammer7%2FSmartContractPatients/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259624736,"owners_count":22886330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html-css-javascript","solidity-contracts","web3js"],"created_at":"2024-12-14T04:27:42.584Z","updated_at":"2025-06-13T10:09:43.203Z","avatar_url":"https://github.com/StrongerProgrammer7.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003csub\u003e**This work was done as part of the Course work by Author: Abdyukov Z.M. **\u003c/sub\u003e \n\u003ch3\u003eContent\u003c/h3\u003e\n\n[Brief introduction](https://github.com/StrongerProgrammer7/SmartContractPatients#-brief-introduction-)  \n[Development tools and Programming Language](https://github.com/StrongerProgrammer7/SmartContractPatients#development-tools-and-programming-language)  \n[Prototype architecture](https://github.com/StrongerProgrammer7/SmartContractPatients#prototype-architecture)  \n[Optimization contract](https://github.com/StrongerProgrammer7/SmartContractPatients#optimization-contract)  \n[Some problem and TODO:](https://github.com/StrongerProgrammer7/SmartContractPatients#some-problem-and-todo)  \n[View Prototype](https://github.com/StrongerProgrammer7/SmartContractPatients#-view-prototype-)  \n\n\n\u003cdiv align=\"center\"\u003e\n\u003ch1\u003eSmart contract EHTEREUM:\u003c/h1\u003e\n\u003ch2\u003eInteraction Patient with Doctor \u003c/h2\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3 align=\"center\"\u003e Brief introduction \u003c/h3\u003e\n \u003cp\u003eThe main goal of the work is to develop the architecture and prototype of a system of decentralized interaction between doctors and patients.\u003cbr\u003e\u003cbr\u003e\nThe scientific novelty of the work lies in the fact that a new approach to the interaction of the patient with doctors is proposed.\u003c/p\u003e\n    \u003ch4 align=\"center\"\u003eBlockchain in healthcare\u003c/h4\u003e\n    \u003cp align=\"justify\"\u003eWhen a medical record is generated and signed, it can be recorded in the blockchain, which gives patients proof and confidence that the record cannot be changed. These personal medical records can be encoded and stored on the blockchain using a private key so that they are accessible only to certain individuals, thereby ensuring confidentiality.\u003c/p\u003e\n    \u003ch4 align=\"center\"\u003eSmart Contract in healthcare\u003c/h4\u003e\n    \u003cp align=\"justify\"\u003eSmart contracts can make data accessible and transparent to both patients and doctors by working as a gatekeeper who manages who is given access to information. \u003c/p\u003e\n     \u003ch4 align=\"center\"\u003eIPFS\u003c/h4\u003e\n    \u003cp align=\"justify\"\u003eThe Interplanetary File System (IPFS) can be considered as a peer-to-peer distributed file system that seeks to connect all computing devices into a single file system. \u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3 align=\"center\"\u003eDevelopment tools and Programming Language\u003c/h3\u003e\n\u003cp align=\"justify\"\u003e For Smart Contract, i used Solidity and IDE Remix, also Personal Blockchain Ganache\u003c/p\u003e\n\u003cp align=\"justify\"\u003e For Web-Site, used HTML/CSS/JS and NodeJS (express,body-parser,browserify,dotenv,ejs,ejs-mate,express-fileupload,ganache,ipfs-core,ipfs-http-client,node-abort-controller,web3,web3-eth),\u003c/p\u003e\n\u003ccode\u003enpm install -S express body-parser browserify dotenv ejs ejs-mate express-fileupload ganache ipfs-core ipfs-http-client node-abort-controller web3 web3-eth\u003c/code\u003e \n\u003cp\u003e\u003cb\u003eNode v13.14.0 ,\u003cbr\u003enpm v6.14.4\u003c/b\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3 align=\"center\"\u003ePrototype architecture\u003c/h3\u003e\n\u003cp\u003eInteraction patient with doctor\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209840941-cff0bdb3-60c4-4bd9-827e-813d30aa29c0.png\"\u003e\u003c/p\u003e\n\u003cp\u003eInteraction Doctor with patient's contract\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209840742-9e23b6f1-ce36-41e4-ad08-79d6ec908e60.png\"\u003e\u003c/p\u003e\n\u003cp\u003eInteraction patient with contract\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209842086-e5868565-8098-44c0-8f74-fb11abade873.png\"\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3 align=\"center\"\u003eOptimization contract\u003c/h3\u003e\n\u003cp align=\"justify\"\u003e The developed prototype works with two contracts, with the contract of the patient \u003cb\u003e(Patient)\u003c/b\u003e and the contract that interacts with the contract of the patient \u003cb\u003e(addPatient)\u003c/b\u003e. The patient contract stores and processes data about a particular patient, and the patient does not have direct access to this contract. The second contract allows the patient to interact with the patient contract. Thus, each patient will have his own separate contract.\u003c/p\u003e\n  \u003cp align=\"justify\"\u003eSince each patient has his own personal contract, it puts a lot of pressure on the system and is quite an expensive operation. \u003cb\u003eIn this regard, the concept of \"Clone Factory\" from OpenZepplin is used\u003c/b\u003e, this library allows you to reduce the load on the system and reduce costs. It turns out this is due to the fact that the library works in the Assembly language, which directly works with memory. The essence of the library is that the patient's contract is first deployed, and then the main contract, which will create clones. Clones simply refer to the functions of the parent, thereby reducing their volume and increasing the processing speed, while each clone stores its own patient data\u003c/p\u003e\n\u003cp align=\"justify\"\u003e\n    The contract also contains a function that converts an integer to a string. This function requires optimization, since the cost is high for large numbers, and the larger the number, the higher the cost \u003cb\u003e(for example, for 9997779 the cost is 42676 gas).\u003c/b\u003e After the translation of the function into the Assembly language, the cost of the function has significantly decreased and with an increase in the number, it does not increase significantly (for example, for the same number the cost is already equal to \u003cb\u003e24576 gas\u003c/b\u003e and with an increase in the number, the cost increases by only a few hundred, against several thousand)\n\u003c/p\u003e\n\u003cp align=\"justify\"\u003eThe rest of the functions in the contract were not translated into the Assembly language significantly, since the Assembly language requires more time to learn, and the Solidity developers do not recommend using it often, due to the fact that, quoting from the Solidity language developers \u003cb\u003ethis is a way to access the virtual machine Ethereum is at a low level and this drops several important security features of Solidity.”\u003c/b\u003e\"\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3 align=\"center\"\u003eSome problem and TODO:\u003c/h3\u003e\n\u003cp align=\"justify\"\u003e\n      The first problem is \u003cb\u003ethe limited size of the contract\u003c/b\u003e. The developers of the Ethereum network and smart contracts have limited the size of contracts, which does not allow adding a lot of functionality. \u003cb\u003eThe maximum contract size is 24576 bytes\u003c/b\u003e, you can also use the built-in optimizer, but they also have a \"too deep stack\" limit of no more than 16 local variables. This was done in order to prevent DDos attacks. It is also possible to optimize the contract if it is translated into the Assembly (Assembler) language, but the developers strongly do not recommend it, since in this case there is work with memory, as a result of which it can cause problems in the Ethereum network. As a result, a smart contract can only be used with little functionality and a limited number of checks in the contract itself.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eThe second problem is that the contract is \u003cb\u003etoo expensive\u003c/b\u003e. The write functions are not expensive, but the display functions have nested loops, which greatly increases the price of the contract. \u003cb\u003eSo, for example, displaying one diagnosis costs 35,000 gas, if there are already two, then 70,000 gas.\u003c/b\u003e But I also note that the Ethereum network switched to “ProofOfStake” in the fall of 2022, perhaps next year the cost of computing will fall, and the contract will become cheaper.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eThe third problem is file storage. About 75 million people use cloud storage. Part of the campaign, another part uses intentionally, and still others only indirectly. The rest may not know about it, because there is simply no need. IPFS, on the other hand, is still a very young technology that requires development, testing and implementation to the masses (for example, a default installation along with the OS).\u003cb\u003e As a result, the use of IPFS as a storage is not very advisable in the near future, since in addition to those mentioned above, there are few users, and, therefore, the data will be loaded for a long time, and the receipt can also be long.\u003c/b\u003e\u003c/p\u003e\n\u003cp align=\"justify\"\u003eAlso, \u003cb\u003ethe developed application is only partially decentralized, as it works on the basis of a central node - a server.\u003c/b\u003e For an application to be fully decentralized, the contract must be published to IPFS and the application deployed to a distributed file system. Only in this case, the dependence on the central node will disappear and the application will be truly decentralized.\u003c/p\u003e\n\u003cp\u003e Cost(gas): Contract Creation (Patient) - 4764952, (addPatient) - 2224094 ,\u003cbr\u003e Register - 362839, \u003cbr\u003e Show BaseInfo - 58385, Show all diagnosis - 248218, Show history - 246536\u003c/p\u003e\n\u003ch4\u003eTODO: \u003c/h4\u003e\n\n+ 1. Contract optimization: learn Solc and apply\n\n+ 2. WebSite optimization (the main page slows down)\n\n+ 3. WebSite: remove jQuery (only used for slider), manually create slider\n\n+ 4. Test on large volumes of data\n\n+ 5. In case of successful solution of the problems above, create an Android App\n\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3 align=\"center\"\u003e View Prototype \u003c/h3\u003e\n\u003cp align=\"center\"\u003e MAIN PAGE \u003c/p\u003e\n\u003cvideo src='https://user-images.githubusercontent.com/71569051/209843339-80a5c747-c117-4e0f-b797-0973439b64fd.mp4' width=100px autoplay\u003e\u003c/video\u003e\n\u003cp align=\"center\"\u003e Chapter Patient \u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209844796-e684c547-6eff-4b46-8456-b3506c4a8228.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e Chapter Doctor\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209844812-38c34d39-6df8-41a6-b8c7-2ae0a7e231c9.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e Show Base info \u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209844820-92f4b4c6-83d2-445c-bfe0-e2840a1c4619.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e Check connect: circle is check connect with wallet, check mark is connect with contract\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209845019-f09c4b36-4ce8-40b5-ae43-b1ccc227423c.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e Register Form \u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209845519-22f03c6d-b76d-4c60-a715-a7e29ce78b01.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e Success Register \u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209845605-bc97cd67-9d58-4f17-9ee4-ef3222f53048.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e Success access \u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209845658-aeb1e251-0417-42e6-83bc-60221fcb1434.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e Set diagnosis Form \u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209845698-f830d13b-4d20-4c16-9570-a59737226faf.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e Info diagnos \u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209845727-964a7f51-01a5-4497-aaf5-9b94a3a3fcda.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e History \u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/71569051/209845766-78e8bdb1-95c7-48fd-8a96-1f903bf4347e.png\"\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003ch4\u003e Author: Abdyukov Z.M. \u003c/h4\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongerprogrammer7%2Fsmartcontractpatients","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrongerprogrammer7%2Fsmartcontractpatients","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongerprogrammer7%2Fsmartcontractpatients/lists"}