Function | Endpoint | Method | Request Payload | Success Response | Error Responses |
---|---|---|---|---|---|
Search Emergency Health Records | /api/emergency_health_records/search |
GET |
searchType (String), searchQuery (String) |
200 OK - List of Patients |
400 Bad Request - Invalid search type or query404 Not Found - No matching patients401 Unauthorized - User not authenticated |
View Patient's Emergency Health Records | /api/emergency_health_records/view/{patientUsername} |
GET |
patientUsername (String) |
200 OK - Patient's Emergency Health Record |
404 Not Found - Patient not found401 Unauthorized - User not authenticated |
Before making any requests, users (HCPs and Emergency Responders) need to authenticate through the iTrust2 system.
-
Endpoint:
/api/emergency_health_records/search
-
Method:
GET
-
Query Parameters:
searchType
(String): Type of search, set to "name".searchQuery
(String): The search query for the specified search type.
-
Success Response:
- Status: 200 OK
- Content:
{ "patients": [ { "firstName": "Siegwardof", "lastName": "Catarina", // ... other patient details }, // ... other patients ] }
-
Error Responses:
- Status: 400 Bad Request
- Content:
{ "error": "Invalid search type. Must be 'name'." }
- Content:
- Status: 404 Not Found
- Content:
{ "error": "No matching patients found." }
- Content:
- Status: 401 Unauthorized
- Content:
{ "error": "User not authenticated." }
- Content:
- Status: 400 Bad Request
-
Endpoint:
/api/emergency_health_records/search
-
Method:
GET
-
Query Parameters:
searchType
(String): Type of search, set to "username".searchQuery
(String): The search query for the specified search type.
-
Success Response:
- Status: 200 OK
- Content:
{ "patients": [ { "firstName": "Siegwardof", "lastName": "Catarina", // ... other patient details }, // ... other patients ] }
-
Error Responses:
- Status: 400 Bad Request
- Content:
{ "error": "Invalid search type. Must be 'username'." }
- Content:
- Status: 404 Not Found
- Content:
{ "error": "No matching patients found." }
- Content:
- Status: 401 Unauthorized
- Content:
{ "error": "User not authenticated." }
- Content:
- Status: 400 Bad Request
-
Endpoint:
/api/emergency_health_records/view/{patientUsername}
-
Method:
GET
-
Request Parameters:
patientUsername
(String): Username of the selected patient.
-
Success Response:
- Status: 200 OK
- Content:
{ "firstName": "Siegwardof", "lastName": "Catarina", "age": 45, "dob": "1978-05-12", "gender": "Male", "bloodType": "AB+", "diagnoses": [ { "code": "D001", "description": "Example Diagnosis 1", "date": "2023-11-14" }, // More diagnoses... ], "prescriptions": [ { "id": "P001", "medication": "Medicine ABC", "date": "2023-11-12" }, // More prescriptions... ] }
-
Error Responses:
- Status: 404 Not Found
- Content:
{ "error": "Patient not found." }
- Content:
- Status: 401 Unauthorized
- Content:
{ "error": "User not authenticated." }
- Content:
- Status: 404 Not Found
- The use of query parameters in the GET request allows you to specify the search type (
name
orusername
) and the search query. - Error responses provide information about the nature of the error, allowing the client to handle it appropriately.
- Authentication is still a critical part of the API, ensuring that only authorized users can access the data.