0

i have follow tables:

appointment
id
value
patient_id

patient
id
name
birthdate
race_id

How the best way to create API resource if I search patient by appointment value?

Option 1: GET /patient?appointment=111111
Option 2: GET /appointment/{value} and return JSON Patient
Option 3: using nested resources like GET /patient/{n}/appointment
Option 4: have any ideas?

tks

1 Answers1

1

Option 2 sounds better:

Only one change - use appointments instead of appointment.

GET /appointments/{value}

(Here I am assuming that you are having patient and patient's appointment summary data with you).

Your other options were -

Option 1: GET /patient?appointment=111111 - I would prefer query parameter instead of search parameter. See this - REST API Best practices: Where to put parameters?

Option 2: GET /appointment/{value} and return JSON Patient - This was close according to me.

Option 3: using nested resources like GET /patient/{n}/appointment - You need appointment data. Hene, use it after /appointment. i.e. /patients/appointments/{n}. (If you are going with this.)

Community
  • 1
  • 1
asg
  • 2,108
  • 3
  • 16
  • 24