Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-J 16
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
22_23-J 16
22_23-J 16
Commits
4c3906f6
Commit
4c3906f6
authored
Jan 28, 2023
by
Ishini Kiridena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding EHR content IPFS completed
parent
bb8b426d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1973 additions
and
956 deletions
+1973
-956
ExpressBackend/.env
ExpressBackend/.env
+7
-1
ExpressBackend/.vscode/settings.json
ExpressBackend/.vscode/settings.json
+3
-0
ExpressBackend/package-lock.json
ExpressBackend/package-lock.json
+1894
-937
ExpressBackend/package.json
ExpressBackend/package.json
+4
-0
ExpressBackend/route/patient-routes/nft-route.js
ExpressBackend/route/patient-routes/nft-route.js
+65
-18
No files found.
ExpressBackend/.env
View file @
4c3906f6
...
@@ -4,4 +4,10 @@ DATABASE_URL="mongodb+srv://dbUser:1997Ishini%21@cluster0.lmazo.mongodb.net/rese
...
@@ -4,4 +4,10 @@ DATABASE_URL="mongodb+srv://dbUser:1997Ishini%21@cluster0.lmazo.mongodb.net/rese
SERVER_PORT=4000
SERVER_PORT=4000
STELLARPUBLICKEY="GB3U2F6MWAQ43O6J4AIUQXEMTK5XQZWURC3SF4D37DPBFRY4HCZGRBLG"
STELLARPUBLICKEY="GB3U2F6MWAQ43O6J4AIUQXEMTK5XQZWURC3SF4D37DPBFRY4HCZGRBLG"
STELLARSEED="SBUXCZ7F7G5Z3QK3NKM52UWVJWFSLEVVGQOCIEWEJY4DOYMYVOMUTS4B"
STELLARSEED="SBUXCZ7F7G5Z3QK3NKM52UWVJWFSLEVVGQOCIEWEJY4DOYMYVOMUTS4B"
AESKEY="QfTjWnZr4u7x!A%D"
AESKEY="QfTjWnZr4u7x!A%D"
\ No newline at end of file
IPFSPROJECTID="2KmA9x9x9odbbz9uA00GD5ZKOnv"
IPFSAPIKEY="975ea3b06bd36d434b57a315a86287ee"
IPFSHOST="ipfs.infura.io"
IPFSPORT=5001
IPFSPROTOCOL="https"
IPFSURL="https://ipfs.io/ipfs/"
\ No newline at end of file
ExpressBackend/.vscode/settings.json
0 → 100644
View file @
4c3906f6
{
"cSpell.words"
:
[
"ipfs"
]
}
ExpressBackend/package-lock.json
View file @
4c3906f6
This source diff could not be displayed because it is too large. You can
view the blob
instead.
ExpressBackend/package.json
View file @
4c3906f6
...
@@ -18,8 +18,11 @@
...
@@ -18,8 +18,11 @@
"cors"
:
"^2.8.5"
,
"cors"
:
"^2.8.5"
,
"crypto-js"
:
"^4.1.1"
,
"crypto-js"
:
"^4.1.1"
,
"express"
:
"^4.18.2"
,
"express"
:
"^4.18.2"
,
"html-to-image"
:
"^1.11.4"
,
"ipfs-infura"
:
"^1.1.9"
,
"mongoose"
:
"^6.8.0"
,
"mongoose"
:
"^6.8.0"
,
"node-htmlpdf"
:
"^1.0.4"
,
"node-htmlpdf"
:
"^1.0.4"
,
"request"
:
"^2.88.2"
,
"stellar-sdk"
:
"^10.4.1"
"stellar-sdk"
:
"^10.4.1"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
...
@@ -27,6 +30,7 @@
...
@@ -27,6 +30,7 @@
"@types/crypto-js"
:
"^4.1.1"
,
"@types/crypto-js"
:
"^4.1.1"
,
"@types/express"
:
"^4.17.15"
,
"@types/express"
:
"^4.17.15"
,
"@types/nodemon"
:
"^1.19.2"
,
"@types/nodemon"
:
"^1.19.2"
,
"@types/request"
:
"^2.48.8"
,
"dotenv"
:
"^16.0.3"
,
"dotenv"
:
"^16.0.3"
,
"nodemon"
:
"^2.0.20"
"nodemon"
:
"^2.0.20"
}
}
...
...
ExpressBackend/route/patient-routes/nft-route.js
View file @
4c3906f6
...
@@ -6,6 +6,9 @@ const Patient = require("./../../model/patient/patient");
...
@@ -6,6 +6,9 @@ const Patient = require("./../../model/patient/patient");
const
axios
=
require
(
"
axios
"
);
const
axios
=
require
(
"
axios
"
);
const
StellarSDK
=
require
(
"
stellar-sdk
"
);
const
StellarSDK
=
require
(
"
stellar-sdk
"
);
const
htmlpdf
=
require
(
"
node-htmlpdf
"
);
const
htmlpdf
=
require
(
"
node-htmlpdf
"
);
const
IPFS
=
require
(
"
ipfs-infura
"
);
const
fs
=
require
(
"
fs
"
);
const
request
=
require
(
"
request
"
);
let
currentHash
;
let
currentHash
;
let
genesisHash
;
let
genesisHash
;
let
isGenesisPassed
;
let
isGenesisPassed
;
...
@@ -259,25 +262,69 @@ router.post("/", async (req, res) => {
...
@@ -259,25 +262,69 @@ router.post("/", async (req, res) => {
htmlString
=
htmlString
+
`</body></html>`
;
htmlString
=
htmlString
+
`</body></html>`
;
console
.
log
(
"
HTML code for EHR generated
"
);
console
.
log
(
"
HTML code for EHR generated
"
);
//create the PDF document for EHR
//create the IPFS instance
let
path
=
`./patientehr/`
+
decryptedPatientKey
+
`-EHR.pdf`
;
const
ipfs
=
new
IPFS
({
let
pdfOptions
=
{
host
:
process
.
env
.
IPFSHOST
,
path
:
path
,
port
:
process
.
env
.
IPFSPORT
,
format
:
"
A4
"
,
protocol
:
process
.
env
.
IPFSPROTOCOL
,
};
projectId
:
process
.
env
.
IPFSPROJECTID
,
htmlpdf
projectSecret
:
process
.
env
.
IPFSAPIKEY
,
.
create
(
htmlString
,
pdfOptions
)
});
.
then
((
buff
)
=>
{
//add the EHR content to IPFS and get the hash
console
.
log
(
"
PDF created
"
);
ipfs
.
add
(
htmlString
)
.
then
((
response
)
=>
{
let
ipfsContentCID
=
response
.
toString
();
//!Use this when getting EHR
// request.post(
// {
// url: "https://ipfs.infura.io:5001/api/v0/cat",
// qs: {
// arg: hash,
// },
// headers: {
// Authorization:
// "Basic " +
// Buffer.from(
// process.env.IPFSPROJECTID + ":" + process.env.IPFSAPIKEY
// ).toString("base64"),
// },
// },
// (error, response, body) => {
// if (error) {
// console.log(error);
// } else {
// //create the PDF document for EHR
// let path = `./patientehr/` + decryptedPatientKey + `-EHR.pdf`;
// let pdfOptions = {
// path: path,
// format: "A4",
// };
// htmlpdf
// .create(htmlString, pdfOptions)
// .then((buff) => {
// console.log("PDF created");
// })
// .catch((errorWhenGeneratingPDF) => {
// console.log(
// "Error when generating PDF : " + errorWhenGeneratingPDF
// );
// console.log(
// "/patient/createnft - NFT creation and sharing failed"
// );
// return res.status(500).json({
// message:
// "Error when generating PDF : " +
// errorWhenGeneratingPDF,
// });
// });
// }
// }
// );
//TODO: create NFT request
})
})
.
catch
((
errorWhenGeneratingPDF
)
=>
{
.
catch
((
errorWhenAddingToIPFS
)
=>
{
console
.
log
(
console
.
log
(
errorWhenAddingToIPFS
);
"
Error when generating PDF :
"
+
errorWhenGeneratingPDF
);
console
.
log
(
"
/patient/createnft - NFT creation and sharing failed
"
);
return
res
.
status
(
500
).
json
({
message
:
"
Error when generating PDF :
"
+
errorWhenGeneratingPDF
,
});
});
});
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment