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
60a371d2
Commit
60a371d2
authored
May 17, 2023
by
Ishini Kiridena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New collections
parent
b1c22fc3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
41 deletions
+150
-41
ExpressBackend/model/stellar/assetCodeWithPractitioner.js
ExpressBackend/model/stellar/assetCodeWithPractitioner.js
+11
-0
ExpressBackend/model/stellar/assetKeyFull.js
ExpressBackend/model/stellar/assetKeyFull.js
+10
-0
ExpressBackend/route/patient-routes/nft-route.js
ExpressBackend/route/patient-routes/nft-route.js
+67
-37
ExpressBackend/route/practitioner-routes/get-assetcode-practitioner-route.js
...e/practitioner-routes/get-assetcode-practitioner-route.js
+34
-0
ExpressBackend/route/practitioner-routes/requestnft-route.js
ExpressBackend/route/practitioner-routes/requestnft-route.js
+25
-4
ExpressBackend/server.js
ExpressBackend/server.js
+3
-0
No files found.
ExpressBackend/model/stellar/assetCodeWithPractitioner.js
0 → 100644
View file @
60a371d2
const
mongoose
=
require
(
"
mongoose
"
);
const
AssetCodeWithPractitioner
=
new
mongoose
.
Schema
({
assetcode
:
String
,
to
:
String
,
});
module
.
exports
=
mongoose
.
model
(
"
AssetCodeWithPractitioner
"
,
AssetCodeWithPractitioner
);
ExpressBackend/model/stellar/assetKeyFull.js
0 → 100644
View file @
60a371d2
const
mongoose
=
require
(
"
mongoose
"
);
const
AssetKeyFullInfo
=
new
mongoose
.
Schema
({
assetcode
:
String
,
key
:
String
,
to
:
String
,
cid
:
String
,
});
module
.
exports
=
mongoose
.
model
(
"
AssetKeyFullInfo
"
,
AssetKeyFullInfo
);
ExpressBackend/route/patient-routes/nft-route.js
View file @
60a371d2
...
...
@@ -13,6 +13,7 @@ const RSAEncrypt = require("./../../services/rsaEncoder");
const
GenerateAESKey
=
require
(
"
./../../services/aesKeyGenerator
"
);
const
EncryptionService
=
require
(
"
./../../services/encryptionservice
"
);
const
AssetKey
=
require
(
"
./../../model/stellar/assetkeys
"
);
const
AssetKeyFullInfo
=
require
(
"
./../../model/stellar/assetKeyFull
"
);
const
CreateTrustline
=
require
(
"
./../../services/trustlineCreator
"
);
const
GetIssuerPair
=
require
(
"
./../../services/getIssuerKeyPairFromDB
"
);
const
DoManageData
=
require
(
"
./../../services/manageDataForAsset
"
);
...
...
@@ -416,50 +417,79 @@ router.post("/", async (req, res) => {
decryptedPractitionerKey
,
DecryptWithServerKey
(
issuerKeyPair
.
issuerKey
)
)
.
then
((
success
)
=>
{
.
then
(
async
(
success
)
=>
{
if
(
success
)
{
console
.
log
(
"
Payment operation from patient to practitioner success
"
);
//Update the NFT req collection
UpdateNFTRequestStatus
(
decryptedAssetCode
)
.
then
((
success
)
=>
{
if
(
success
)
{
res
.
status
(
200
).
json
({
message
:
"
NFT EHR issued successfully
"
,
});
console
.
log
(
"
/patient/createnft - NFT creation and sharing success
"
);
}
else
{
console
.
log
(
"
NFT Request update failed
"
);
console
.
log
(
"
/patient/createnft - NFT creation and sharing failed
"
);
return
res
.
status
(
500
).
json
({
message
:
"
NFT Request update failed
"
,
});
}
})
.
catch
((
errorWhenUpdatingCollection
)
=>
{
console
.
log
(
"
Error updating NFT request status :
"
,
errorWhenUpdatingCollection
);
console
.
log
(
"
/patient/createnft - NFT creation and sharing failed
"
//add to the AssetKeyFullInfoDB
const
assetFullObj
=
new
AssetKeyFullInfo
({
assetcode
:
decryptedAssetCode
,
key
:
encodedAesKey
,
cid
:
ipfsContentCID
,
to
:
decryptedPractitionerKey
,
});
try
{
const
saveInFullDB
=
await
assetFullObj
.
save
();
console
.
log
(
"
Full details added to collection
"
);
//Update the NFT req collection
UpdateNFTRequestStatus
(
decryptedAssetCode
)
.
then
((
success
)
=>
{
if
(
success
)
{
res
.
status
(
200
).
json
({
message
:
"
NFT EHR issued successfully
"
,
});
console
.
log
(
"
/patient/createnft - NFT creation and sharing success
"
);
}
else
{
console
.
log
(
"
NFT Request update failed
"
);
console
.
log
(
"
/patient/createnft - NFT creation and sharing failed
"
);
return
res
.
status
(
500
).
json
({
message
:
"
NFT Request update failed
"
,
});
}
})
.
catch
(
(
errorWhenUpdatingCollection
)
=>
{
console
.
log
(
"
Error updating NFT request status :
"
,
errorWhenUpdatingCollection
);
console
.
log
(
"
/patient/createnft - NFT creation and sharing failed
"
);
return
res
.
status
(
500
).
json
({
message
:
"
Error updating NFT request status :
"
,
errorWhenUpdatingCollection
,
});
}
);
return
res
.
status
(
500
).
json
({
message
:
"
Error updating NFT request status :
"
,
errorWhenUpdatingCollection
,
});
}
catch
(
errorWhenAddingToFullInfo
)
{
console
.
log
(
"
Adding NFT details to full info collection failed :
"
,
errorWhenAddingToFullInfo
);
console
.
log
(
"
/patient/createnft - NFT creation and sharing failed
"
);
return
res
.
status
(
500
).
json
({
message
:
"
Adding NFT details to full info collection failed
"
,
});
}
}
else
{
console
.
log
(
"
NFT payment operation failed from patient to practitioner
"
...
...
ExpressBackend/route/practitioner-routes/get-assetcode-practitioner-route.js
0 → 100644
View file @
60a371d2
const
express
=
require
(
"
express
"
);
const
router
=
express
.
Router
();
const
AssetCodeWithPractitioner
=
require
(
"
./../../model/stellar/assetCodeWithPractitioner
"
);
router
.
get
(
"
./:practitionerKey
"
,
async
(
req
,
res
)
=>
{
const
practitionerKey
=
req
.
params
.
practitionerKey
;
try
{
const
assetKey
=
await
AssetCodeWithPractitioner
.
findOne
({
to
:
practitionerKey
,
});
console
.
log
(
assetKey
);
res
.
status
(
200
).
json
({
assetcode
:
assetKey
.
assetcode
,
});
console
.
log
(
"
/practitioner/getassetcode - getting asset code for the practitioner success
"
);
}
catch
(
errorWhenGettingAssetCode
)
{
console
.
log
(
"
Error when getting practitioner asset code : Error :
"
,
errorWhenGettingAssetCode
);
console
.
log
(
"
/practitioner/getasssetcode - failed
"
);
res
.
status
(
500
).
json
({
error
:
"
Getting all practitioners requests failed :
"
,
errorWhenGettingPatientRequests
,
});
}
});
module
.
exports
=
router
;
ExpressBackend/route/practitioner-routes/requestnft-route.js
View file @
60a371d2
...
...
@@ -5,6 +5,7 @@ const DecryptWithServerKey = require("./../../services/decryptionservice");
const
StellarSdk
=
require
(
"
stellar-sdk
"
);
const
CreateTrustline
=
require
(
"
./../../services/trustlineCreator
"
);
const
NFTRequest
=
require
(
"
./../../model/stellar/nftRequests
"
);
const
AssetCodeWithPractitioner
=
require
(
"
./../../model/stellar/assetCodeWithPractitioner
"
);
const
GenerateRandomAssetCode
=
require
(
"
./../../services/assetCodeGenerator
"
);
require
(
"
dotenv
"
).
config
();
...
...
@@ -38,11 +39,31 @@ router.post("/", async (req, res) => {
});
try
{
const
saveRequest
=
await
nftRequestObj
.
save
();
console
.
log
(
"
NFT request saved to database :
"
+
saveRequest
);
res
.
status
(
200
).
json
({
message
:
"
NFT request saved to database
"
,
//save the asset code details in the DB
const
assetCodeVsPractitioner
=
new
AssetCodeWithPractitioner
({
assetcode
:
assetCode
,
to
:
practitionerPK
,
});
console
.
log
(
"
/practitioner/requestnft - requesting NFT success
"
);
try
{
const
saveAssetCodeVsPrac
=
await
assetCodeVsPractitioner
.
save
();
console
.
log
(
"
NFT request saved to database :
"
+
saveRequest
);
res
.
status
(
200
).
json
({
message
:
"
NFT request saved to database
"
,
});
console
.
log
(
"
/practitioner/requestnft - requesting NFT success
"
);
}
catch
(
errorWhenSavingPractitionerVsAssetCodeInDB
)
{
console
.
log
(
"
Error when adding asset code practitioner request to DB :
"
,
errorWhenSavingPractitionerVsAssetCodeInDB
);
console
.
log
(
"
/practitioner/requestnft - requesting NFT failed
"
);
return
res
.
status
(
500
).
json
({
message
:
"
Error when adding NFT request to DB :
"
,
errorWhenSavingPractitionerVsAssetCodeInDB
,
});
}
}
catch
(
errorWhenAddingRequestToDB
)
{
console
.
log
(
"
Error when adding NFT request to DB :
"
,
...
...
ExpressBackend/server.js
View file @
60a371d2
...
...
@@ -63,6 +63,9 @@ app.use("/practitioner/login", practitionerLogin);
const
treatingPatients
=
require
(
"
./route/practitioner-routes/get-treating-patients-route
"
);
app
.
use
(
"
/practitioner/treatingPatients
"
,
treatingPatients
);
const
assetCodes
=
require
(
"
./route/practitioner-routes/get-assetcode-practitioner-route
"
);
app
.
use
(
"
/practitioner/getassetcode
"
,
assetCodes
);
app
.
listen
(
process
.
env
.
SERVER_PORT
,
()
=>
console
.
log
(
"
Server started on port
"
+
process
.
env
.
SERVER_PORT
)
);
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