import request from '@/utils/request.js'

// ─── Care Profiles ────────────────────────────────────────────────────────────
export const careProfileApi = {
  getList: (params) => request.get('/care/profiles', { params }),
  getDetail: (id) => request.get(`/care/profiles/${id}`),
  create: (data) => request.post('/care/profiles', data),
  update: (id, data) => request.put(`/care/profiles/${id}`, data),
  delete: (id) => request.delete(`/care/profiles/${id}`)
}

// ─── Care Plans ───────────────────────────────────────────────────────────────
export const carePlanApi = {
  getList: (params) => request.get('/care/plans', { params }),
  getDetail: (id) => request.get(`/care/plans/${id}`),
  create: (data) => request.post('/care/plans', data),
  update: (id, data) => request.put(`/care/plans/${id}`, data),
  delete: (id) => request.delete(`/care/plans/${id}`)
}

// ─── Care Records ─────────────────────────────────────────────────────────────
export const careRecordApi = {
  getList: (params) => request.get('/care/records', { params }),
  getDetail: (id) => request.get(`/care/records/${id}`),
  create: (data) => request.post('/care/records', data),
  update: (id, data) => request.put(`/care/records/${id}`, data),
  delete: (id) => request.delete(`/care/records/${id}`)
}

// ─── Care Exceptions ──────────────────────────────────────────────────────────
export const careExceptionApi = {
  getList: (params) => request.get('/care/exceptions', { params }),
  getDetail: (id) => request.get(`/care/exceptions/${id}`),
  create: (data) => request.post('/care/exceptions', data),
  update: (id, data) => request.put(`/care/exceptions/${id}`, data),
  handle: (id, data) => request.put(`/care/exceptions/${id}/handle`, data),
  resolve: (id, data) => request.put(`/care/exceptions/${id}/handle`, data) // alias → handle
}

// ─── Health Metrics ───────────────────────────────────────────────────────────
export const healthMetricApi = {
  getList: (params) => request.get('/care/health-metrics', { params }),
  create: (data) => request.post('/care/health-metrics', data)
  // Note: backend has no DELETE route; remove locally only
}
