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
b1c22fc3
Commit
b1c22fc3
authored
May 17, 2023
by
Kiridena I.T.K_IT19981840
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'get-all-treating-patients' into 'master'
treating patients and EHR requests See merge request
!43
parents
923e3b9b
73aec267
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
169 additions
and
5 deletions
+169
-5
ExpressBackend/route/practitioner-routes/get-treating-patients-route.js
.../route/practitioner-routes/get-treating-patients-route.js
+30
-0
ExpressBackend/route/practitioner-routes/requestnft-route.js
ExpressBackend/route/practitioner-routes/requestnft-route.js
+4
-4
ExpressBackend/server.js
ExpressBackend/server.js
+3
-0
emma-frontend/App.js
emma-frontend/App.js
+2
-0
emma-frontend/components/practitionerscreens/mainViewWithMenu.js
...ontend/components/practitionerscreens/mainViewWithMenu.js
+1
-1
emma-frontend/components/practitionerscreens/treatingPatients.js
...ontend/components/practitionerscreens/treatingPatients.js
+129
-0
No files found.
ExpressBackend/route/practitioner-routes/get-treating-patients-route.js
0 → 100644
View file @
b1c22fc3
const
express
=
require
(
"
express
"
);
const
router
=
express
.
Router
();
const
UserRequest
=
require
(
"
./../../model/patient/request
"
);
router
.
get
(
"
/:practitionerKey
"
,
async
(
req
,
res
)
=>
{
const
practitionerKey
=
req
.
params
.
practitionerKey
;
try
{
const
patientData
=
await
UserRequest
.
find
({
practitioner
:
practitionerKey
,
status
:
"
Accepted
"
,
});
res
.
status
(
200
).
json
({
message
:
"
Patient data
"
,
data
:
patientData
,
});
console
.
log
(
"
/treatingPatients - Getting all patient details success
"
);
}
catch
(
errorWhenGettingThePatients
)
{
console
.
log
(
"
Getting all treatments : ERROR :
"
,
errorWhenGettingThePatients
);
console
.
log
(
"
/treatingPatients - Getting all patient details failed
"
);
res
.
status
(
500
).
json
({
error
:
"
Getting all patient details failed :
"
,
errorWhenGettingThePatients
,
});
}
});
module
.
exports
=
router
;
ExpressBackend/route/practitioner-routes/requestnft-route.js
View file @
b1c22fc3
...
...
@@ -9,10 +9,10 @@ const GenerateRandomAssetCode = require("./../../services/assetCodeGenerator");
require
(
"
dotenv
"
).
config
();
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
const
practitionerPK
=
req
.
body
.
practitionerkey
;
const
practitionerSK
=
req
.
body
.
practitionerseed
;
const
patientKey
=
req
.
body
.
patient
;
const
practitionerRSA
=
req
.
body
.
practitionerrsa
;
const
practitionerPK
=
DecryptWithServerKey
(
req
.
body
.
practitionerkey
)
;
const
practitionerSK
=
DecryptWithServerKey
(
req
.
body
.
practitionerseed
)
;
const
patientKey
=
DecryptWithServerKey
(
req
.
body
.
patient
)
;
const
practitionerRSA
=
DecryptWithServerKey
(
req
.
body
.
practitionerrsa
)
;
//take the issuer key for the patient from the data base
const
issuerRes
=
await
GetIssuer
(
"
patients
"
,
patientKey
);
...
...
ExpressBackend/server.js
View file @
b1c22fc3
...
...
@@ -60,6 +60,9 @@ app.use("/practitioner/practitionerrequests", practitionerUserReqs);
const
practitionerLogin
=
require
(
"
./route/practitioner-routes/login-route
"
);
app
.
use
(
"
/practitioner/login
"
,
practitionerLogin
);
const
treatingPatients
=
require
(
"
./route/practitioner-routes/get-treating-patients-route
"
);
app
.
use
(
"
/practitioner/treatingPatients
"
,
treatingPatients
);
app
.
listen
(
process
.
env
.
SERVER_PORT
,
()
=>
console
.
log
(
"
Server started on port
"
+
process
.
env
.
SERVER_PORT
)
);
emma-frontend/App.js
View file @
b1c22fc3
...
...
@@ -23,6 +23,7 @@ import PractitionerMainView from "./components/practitionerscreens/mainViewWithM
import
PatientRequests
from
"
./components/practitionerscreens/patientRequestsView
"
;
import
PatientLogin
from
"
./components/patientscreens/registration/login
"
;
import
PractitionerLogin
from
"
./components/practitionerscreens/login
"
;
import
TreatingPatients
from
"
./components/practitionerscreens/treatingPatients
"
;
const
Stack
=
createStackNavigator
();
...
...
@@ -130,6 +131,7 @@ export default function App() {
name
=
"
PractitionerLogin
"
component
=
{
PractitionerLogin
}
/
>
<
Stack
.
Screen
name
=
"
TreatingPatients
"
component
=
{
TreatingPatients
}
/
>
<
/Stack.Navigator
>
)
:
(
<
SplashScreenComponent
/>
...
...
emma-frontend/components/practitionerscreens/mainViewWithMenu.js
View file @
b1c22fc3
...
...
@@ -7,7 +7,7 @@ export default function PractitionerMainView({ navigation }) {
};
const
handleRequesting
=
()
=>
{
console
.
log
(
"
Request NFT
"
);
navigation
.
navigate
(
"
TreatingPatients
"
);
};
return
(
...
...
emma-frontend/components/practitionerscreens/treatingPatients.js
0 → 100644
View file @
b1c22fc3
import
{
useEffect
,
useState
}
from
"
react
"
;
import
{
LOCALBACKEND
}
from
"
../../env
"
;
import
{
Button
,
StyleSheet
,
View
,
Text
,
Alert
}
from
"
react-native
"
;
import
AsyncStorage
from
"
@react-native-async-storage/async-storage
"
;
import
EncryptWithServerKey
from
"
../../services/encryptByServerKey
"
;
import
Toast
from
"
react-native-toast-message
"
;
export
default
function
TreatingPatients
({
navigation
})
{
const
[
data
,
setData
]
=
useState
([]);
useEffect
(()
=>
{
fetchRequests
();
},
[]);
const
fetchRequests
=
async
()
=>
{
//get key from async storage
try
{
const
practitionerKey
=
await
AsyncStorage
.
getItem
(
"
practitionerStellarPublicKey
"
);
try
{
const
requestUrl
=
LOCALBACKEND
+
`/practitioner/treatingPatients/
${
practitionerKey
}
`
;
console
.
log
(
requestUrl
);
const
response
=
await
fetch
(
requestUrl
);
const
json
=
await
response
.
json
();
setData
(
json
.
data
);
}
catch
(
errorFetchingRequests
)
{
console
.
log
(
"
Error when fetching request data :
"
,
errorFetchingRequests
);
}
}
catch
(
errorWhenGettingKey
)
{
console
.
log
(
"
Error when getting the public key from the async storage :
"
,
errorWhenGettingKey
);
}
};
const
renderItem
=
(
item
)
=>
{
return
(
<
View
key
=
{
item
.
_id
}
>
<
Text
>
Key
:
{
item
.
patient
}
<
/Text
>
<
Button
title
=
"
Request EHR
"
onPress
=
{()
=>
handleRequesting
(
item
)}
><
/Button
>
<
/View
>
);
};
const
handleRequesting
=
async
(
item
)
=>
{
//get the practitioner keys
try
{
const
practitionerKey
=
await
AsyncStorage
.
getItem
(
"
practitionerStellarPublicKey
"
);
const
practitionerSecretKey
=
await
AsyncStorage
.
getItem
(
"
practitionerStellarSecretKey
"
);
const
practitionerRsaKey
=
await
AsyncStorage
.
getItem
(
"
practitionerRsaPublicKey
"
);
//send the post request for requesting NFT
const
encryptedPractitionerKey
=
EncryptWithServerKey
(
practitionerKey
);
const
encryptedPractitionerSeed
=
EncryptWithServerKey
(
practitionerSecretKey
);
const
encryptedRsaKey
=
EncryptWithServerKey
(
practitionerRsaKey
);
const
encryptedPatientKey
=
EncryptWithServerKey
(
item
.
patient
);
const
requestOj
=
{
practitionerkey
:
encryptedPractitionerKey
,
practitionerseed
:
encryptedPractitionerSeed
,
patient
:
encryptedPatientKey
,
practitionerrsa
:
encryptedRsaKey
,
};
const
nftRequestEnndpoint
=
LOCALBACKEND
+
`/practitioner/requestnft`
;
try
{
const
nftRequestResponse
=
await
fetch
(
nftRequestEnndpoint
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
(
requestOj
),
});
Toast
.
show
({
type
:
"
success
"
,
// 'success', 'error', 'info', 'warning'
text1
:
"
Request added
"
,
visibilityTime
:
3000
,
// Duration to show the toast in milliseconds
autoHide
:
true
,
});
const
responseData
=
await
nftRequestResponse
.
json
();
}
catch
(
error
)
{
console
.
error
(
"
Error when calling the request NFT
"
);
}
}
catch
(
errorWheGettingKeyPair
)
{
console
.
error
(
"
Error when getting keypair
"
);
}
};
return
(
<
View
style
=
{
styles
.
container
}
>
{
data
.
map
((
item
)
=>
renderItem
(
item
))}
<
Toast
ref
=
{(
ref
)
=>
Toast
.
setRef
(
ref
)}
/
>
<
/View
>
);
}
const
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
justifyContent
:
"
center
"
,
alignItems
:
"
center
"
,
},
text
:
{
fontSize
:
24
,
fontWeight
:
"
bold
"
,
},
});
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