This is api server which interacts with healtcare chaincode installed on hyperledger fabric basic_network.
Refer below urls.
https://github.com/hyperledger/fabric-samples
https://github.com/pramodramdas/digital_healthcare
- Bring fabric basic_network up
- Register chaincode from root folder
CORE_CHAINCODE_ID_NAME="healthcare:v0" npm start -- --peer.address localhost:7052
- Login to cli
docker exec -it cli bash
- Install chaincode
peer chaincode install -n healthcare -v v0 -l node --cafile /etc/hyperledger/configtx/ -p /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/digital_health_fabric/
- instantiate chaincode
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n healthcare -l node -v v0 -c '{"args":["init"]}'
- Optional invoke using cli,
peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n healthcare -c '{"Args":["registerPatient","patient5","20"]}'
- Remove any files from hfc-key-store folder
- Register admin to ca
node enrollAdmin.js
- Start server
node server.js
- Test chaincode and api
npm run test
- Register doctor
{ "name":"doctor1", "email": "doctor1", "password": "doctor1", "role": "doctor" }
- Register Patient
{ "name":"patient1", "email": "patient1", "password": "patient1", "age": "24", "role": "patient" }
- Login patient and doctor
POST /loginsame for doctor"email": "patient2", "password": "patient2" }
- Patient grant access to doctor (use patient authtoken)
{ "type": "grant", "doctorEmail": "doctor2", "org":"org1" }
- fetch patient info for doctor after access (use doctor authtoken, useremail=<patient_email>)
- fetch patient info for himself (use patient authtoken)
GET /getPatientInfo
- fetch doctor info for himself (use doctor authtoken)
GET /getDoctorInfo
- patient upload file, first user has encrypt a file with secret and upload that file to ipfs.
hash returned from ipfs after upload and secret shoul be provided in below api, this api will attach file info to patient{ "fileName":"abc.png", "fileType":"png", "secret":<ipfs file encryption secret>, "fileHash":<ipfs file hash> }
- patient retrieve file info (use patient authtoken, filehash=)
GET /getFileSecret
- doctor retrieve file info (use doctor authtoken, filehash=, useremail=<patient_email>)
GET /getFileSecret