To run this code, you need to have go set up and working in your environment.
Use the following command to start it:
go run main.go
Now, open a new terminal and follow along the following steps to test the functionality. Please make sure you're using the correct UUIDs when typing in the commands. I have included the ones I used when testing locally.
NOTE: I'm aware that my imports look weird. This is just how I was able to get it working locally.
curl -X POST 'http://localhost:8080/doctor/add' -H 'Content-Type: application/json' -d '{"first_name": "Robert", "last_name": "Malmstein"}'
curl -X GET http://localhost:8080/doctors
curl -X POST 'http://localhost:8080/doctor/add' -H 'Content-Type: application/json' -d '{"first_name": "Tim", "last_name": "Lin"}'
curl -X GET http://localhost:8080/doctor?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8
curl -X GET http://localhost:8080/doctors
curl -X GET 'http://localhost:8080/appointments?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8&date=2023-04-05'
curl -X POST 'http://localhost:8080/appointments?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8' -H 'Content-Type: application/json' -d '{"start_time": "2023-04-05 09:15:00", "end_time": "2023-04-05 09:30:00", "patient": {"first_name": "John", "last_name": "Doe"}, "kind": "New Patient"}'
curl -X POST 'http://localhost:8080/appointments?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8' -H 'Content-Type: application/json' -d '{"start_time": "2023-04-05 09:20:00", "end_time": "2023-04-05 09:30:00", "patient": {"first_name": "John", "last_name": "Doe"}, "kind": "New Patient"}'
You should see: Invalid appointment time
curl -X POST 'http://localhost:8080/appointments?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8' -H 'Content-Type: application/json' -d '{"start_time": "2023-04-05 09:15:00", "end_time": "2023-04-05 09:30:00", "patient": {"first_name": "Jane", "last_name": "Doe"}, "kind": "New Patient"}'
curl -X POST 'http://localhost:8080/appointments?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8' -H 'Content-Type: application/json' -d '{"start_time": "2023-04-05 09:15:00", "end_time": "2023-04-05 09:30:00", "patient": {"first_name": "Susy", "last_name": "Doe"}, "kind": "New Patient"}'
curl -X POST 'http://localhost:8080/appointments?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8' -H 'Content-Type: application/json' -d '{"start_time": "2023-04-05 09:15:00", "end_time": "2023-04-05 09:30:00", "patient": {"first_name": "BamBam", "last_name": "Doe"}, "kind": "New Patient"}'
You should see: Maximum number of appointments reached for this doctor
curl -X POST 'http://localhost:8080/appointments?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8' -H 'Content-Type: application/json' -d '{"start_time": "2023-04-05 09:30:00", "end_time": "2023-04-05 09:30:00", "patient": {"first_name": "Wowzer", "last_name": "Bowser"}, "kind": "New Patient"}'
curl -X DELETE 'http://localhost:8080/appointments?doctor_id=c1b6a4f5-dccb-458a-a506-2add802fe5b8&appointment_id=ebf4ceb3-4dd3-4ff1-9d7c-6da738ef4035'
curl -X GET http://localhost:8080/doctors