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
2bbbbe66
Commit
2bbbbe66
authored
May 15, 2023
by
Kiridena I.T.K_IT19981840
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'user-req-acceptance-and-rejection' into 'master'
user request acceptance completed See merge request
!41
parents
453b4aac
5b953d38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
11 deletions
+58
-11
ExpressBackend/route/practitioner-routes/acceptance-route.js
ExpressBackend/route/practitioner-routes/acceptance-route.js
+8
-4
emma-frontend/components/practitionerscreens/patientRequestsView.js
...end/components/practitionerscreens/patientRequestsView.js
+50
-7
No files found.
ExpressBackend/route/practitioner-routes/acceptance-route.js
View file @
2bbbbe66
...
...
@@ -7,10 +7,14 @@ const Requests = require("./../../model/patient/request");
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
//Get the payload
const
decryptedPatientKey
=
req
.
body
.
patient
;
const
decryptedPractitionerKey
=
req
.
body
.
practitionerkey
;
const
decryptedPractitionerSeed
=
req
.
body
.
practitionerseed
;
const
decryptedStatus
=
req
.
body
.
status
;
const
decryptedPatientKey
=
DecryptWithServerKey
(
req
.
body
.
patient
);
const
decryptedPractitionerKey
=
DecryptWithServerKey
(
req
.
body
.
practitionerkey
);
const
decryptedPractitionerSeed
=
DecryptWithServerKey
(
req
.
body
.
practitionerseed
);
const
decryptedStatus
=
DecryptWithServerKey
(
req
.
body
.
status
);
let
timestamp
;
//check the condition
...
...
emma-frontend/components/practitionerscreens/patientRequestsView.js
View file @
2bbbbe66
...
...
@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
import
{
LOCALBACKEND
}
from
"
../../env
"
;
import
{
Button
,
StyleSheet
,
View
,
Text
}
from
"
react-native
"
;
import
AsyncStorage
from
"
@react-native-async-storage/async-storage
"
;
import
EncryptWithServerKey
from
"
../../services/encryptByServerKey
"
;
export
default
function
PatientRequests
()
{
const
[
data
,
setData
]
=
useState
([]);
...
...
@@ -44,18 +45,60 @@ export default function PatientRequests() {
return
(
<
View
key
=
{
item
.
_id
}
>
<
Text
>
Key
:
{
item
.
patient
}
<
/Text
>
<
Button
title
=
"
Accept
"
onPress
=
{()
=>
handleAcceptance
(
item
)}
><
/Button
>
<
Button
title
=
"
Reject
"
onPress
=
{()
=>
handleDecline
(
item
)}
><
/Button
>
<
Button
title
=
"
Accept
"
onPress
=
{()
=>
handleAcceptance
(
item
,
"
Accepted
"
)}
><
/Button
>
<
Button
title
=
"
Reject
"
onPress
=
{()
=>
handleAcceptance
(
item
,
"
Rejected
"
)}
><
/Button
>
<
/View
>
);
};
const
handleAcceptance
=
async
(
item
)
=>
{
console
.
log
(
"
Accepted
"
);
};
const
handleAcceptance
=
async
(
item
,
status
)
=>
{
//get the practitioner keys
try
{
const
practitionerKey
=
await
AsyncStorage
.
getItem
(
"
practitionerStellarPublicKey
"
);
const
practitionerSecretKey
=
await
AsyncStorage
.
getItem
(
"
practitionerStellarSecretKey
"
);
const
handleDecline
=
async
(
item
)
=>
{
console
.
log
(
"
Rejected
"
);
const
encryptedPractitionerKey
=
EncryptWithServerKey
(
practitionerKey
);
const
encryptedPractitionerSeed
=
EncryptWithServerKey
(
practitionerSecretKey
);
const
encryptedPatientKey
=
EncryptWithServerKey
(
item
.
patient
);
const
encryptedStatus
=
EncryptWithServerKey
(
status
);
const
acceptanceObj
=
{
patient
:
encryptedPatientKey
,
practitionerkey
:
encryptedPractitionerKey
,
practitionerseed
:
encryptedPractitionerSeed
,
status
:
encryptedStatus
,
};
const
acceptanceUrl
=
LOCALBACKEND
+
"
/practitioner/request
"
;
try
{
const
acceptanceResponse
=
await
fetch
(
acceptanceUrl
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
(
acceptanceObj
),
});
const
responseData
=
await
acceptanceResponse
.
json
();
console
.
log
(
responseData
);
}
catch
(
errorWhenSendingAcceptance
)
{
console
.
log
(
"
Error when sending payload
"
);
}
}
catch
(
errorWheGettingKeyPair
)
{
console
.
log
(
"
Getting key pair from async failed
"
);
}
};
return
(
...
...
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