-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmergencyRoomController.java
55 lines (47 loc) · 1.62 KB
/
EmergencyRoomController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.example.demo;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class EmergencyRoomController
{
private final PatientService patientService;
@Autowired
public EmergencyRoomController(PatientService patientService)
{
this.patientService=patientService;
}
@PostMapping("/checkIn")
@ResponseBody
public String checkInPatient(
@RequestParam String firstName,
@RequestParam String lastName,
@RequestParam String dob,
@RequestParam String condition,
@RequestParam int urgency)
{
patientService.checkInPatient(firstName, lastName, dob, condition, urgency);
return "Patient " + firstName + " " + lastName + " has been checked in.";
}
@GetMapping("/attendNext")
@ResponseBody
public String attendNextPatient()
{
Patient patient = patientService.attendNextPatient();
if (patient == null)
{
return "No patients in the queue to attend.";
}
return "Attending to patient: " + patient.getFirstName();
}
@GetMapping("/patientLog")
@ResponseBody
public List<Patient> getPatientLog()
{
return patientService.getPatientLog();
}
}