Skip to content

Latest commit

 

History

History
129 lines (109 loc) · 4.02 KB

UC15.md

File metadata and controls

129 lines (109 loc) · 4.02 KB

API Documentation for UC15 Emergency Health Records

Summary Table

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 query
404 Not Found - No matching patients
401 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 found
401 Unauthorized - User not authenticated

API Documentation Details

Authentication

Before making any requests, users (HCPs and Emergency Responders) need to authenticate through the iTrust2 system.

1. Search Emergency Health Records

1.1 Search by Name (S1)

  • 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'." }
    • Status: 404 Not Found
      • Content: { "error": "No matching patients found." }
    • Status: 401 Unauthorized
      • Content: { "error": "User not authenticated." }

1.2 Search by Username (S2)

  • 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'." }
    • Status: 404 Not Found
      • Content: { "error": "No matching patients found." }
    • Status: 401 Unauthorized
      • Content: { "error": "User not authenticated." }

2. View Patient's Emergency Health Records (S3)

  • 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." }
    • Status: 401 Unauthorized
      • Content: { "error": "User not authenticated." }

Considerations

  • The use of query parameters in the GET request allows you to specify the search type (name or username) 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.