// const express = require("express");
// const router = express.Router();
// const patientController = require("../controllers/patientController");

// /**
//  * @swagger
//  * tags:
//  *   name: Public Patients
//  *   description: Public (No Auth) Patient Management APIs
//  */

// // CREATE patient (Public)
// router.post(
//   "/create",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Patients']
//       #swagger.summary = 'Create patient (Public)'

//       #swagger.parameters['body'] = {
//         in: 'body',
//         description: 'Patient information',
//         required: true,
//         schema: {
//           name: 'John Doe',
//           phone: '9876543210',
//           email: 'john@example.com',
//           address: 'Hyderabad, India',
//           status: 'Active'
//         }
//       }
//     */
//     patientController.createPatient(req, res);
//   }
// );

// // GET all patients (Public)
// router.get(
//   "/",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Patients']
//       #swagger.summary = 'Get all patients (Public)'
//       #swagger.parameters['search'] = { in: 'query', type: 'string' }
//       #swagger.parameters['page'] = { in: 'query', type: 'number' }
//       #swagger.parameters['limit'] = { in: 'query', type: 'number' }
//     */
//     patientController.getPatients(req, res);
//   }
// );

// // GET patient by ID (Public)
// router.get(
//   "/:id",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Patients']
//       #swagger.summary = 'Get patient by ID (Public)'
//     */
//     patientController.getPatientById(req, res);
//   }
// );

// // UPDATE patient (Public)
// router.put(
//   "/:id",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Patients']
//       #swagger.summary = 'Update patient (Public)'
//     */
//     patientController.updatePatient(req, res);
//   }
// );

// // DELETE patient (Public)
// router.delete(
//   "/:id",
//   (req, res) => {
//     /*
//       #swagger.tags = ['Public Patients']
//       #swagger.summary = 'Delete patient (Public)'
//     */
//     patientController.deletePatient(req, res);
//   }
// );

// module.exports = router;

const express = require("express");
const router = express.Router();
const patientController = require("../controllers/patientController");

/**
 * @swagger
 * tags:
 *   name: Public Patients
 *   description: Public (No Auth) Patient Management APIs (orgId required)
 */


/**
 * ---------------------------------------
 * CREATE Patient (Public)
 * orgId must be sent in body
 * ---------------------------------------
 */
router.post("/create", (req, res) => {
  /*
    #swagger.tags = ['Public Patients']
    #swagger.summary = 'Create patient (Public)'
    #swagger.description = 'Create patient without authentication. orgId is required in body.'

    #swagger.parameters['body'] = {
      in: 'body',
      required: true,
      schema: {
        orgId: "64f5a2d8c9e4b3a1f0a12345",
        name: "John Doe",
        phone: "9876543210",
        email: "john@example.com",
        address: "Hyderabad, India",
        status: "Active"
      }
    }
  */
  patientController.createPatient(req, res);
});


/**
 * ---------------------------------------
 * GET All Patients (Public)
 * orgId must be sent in query
 * ---------------------------------------
 */
router.get("/", (req, res) => {
  /*
    #swagger.tags = ['Public Patients']
    #swagger.summary = 'Get all patients (Public)'
    #swagger.description = 'Fetch patients by orgId (required)'

    #swagger.parameters['orgId'] = {
      in: 'query',
      required: true,
      type: 'string',
      description: 'Organization ID'
    }

    #swagger.parameters['search'] = { in: 'query', type: 'string' }
    #swagger.parameters['page'] = { in: 'query', type: 'number' }
    #swagger.parameters['limit'] = { in: 'query', type: 'number' }
  */
  patientController.getPatients(req, res);
});


/**
 * ---------------------------------------
 * GET Patient By ID (Public)
 * orgId must be sent in query
 * ---------------------------------------
 */
router.get("/:id", (req, res) => {
  /*
    #swagger.tags = ['Public Patients']
    #swagger.summary = 'Get patient by ID (Public)'
    #swagger.description = 'Fetch patient by ID. orgId is required in query.'

    #swagger.parameters['orgId'] = {
      in: 'query',
      required: true,
      type: 'string'
    }
  */
  patientController.getPatientById(req, res);
});


/**
 * ---------------------------------------
 * UPDATE Patient (Public)
 * orgId must be sent in body
 * ---------------------------------------
 */
router.put("/:id", (req, res) => {
  /*
    #swagger.tags = ['Public Patients']
    #swagger.summary = 'Update patient (Public)'
    #swagger.description = 'Update patient without authentication. orgId required in body.'

    #swagger.parameters['body'] = {
      in: 'body',
      required: true,
      schema: {
        orgId: "64f5a2d8c9e4b3a1f0a12345",
        name: "Updated Name",
        phone: "9999999999",
        status: "Active"
      }
    }
  */
  patientController.updatePatient(req, res);
});


/**
 * ---------------------------------------
 * DELETE Patient (Public)
 * orgId must be sent in query
 * ---------------------------------------
 */
router.delete("/:id", (req, res) => {
  /*
    #swagger.tags = ['Public Patients']
    #swagger.summary = 'Delete patient (Public)'
    #swagger.description = 'Soft delete patient. orgId required in query.'

    #swagger.parameters['orgId'] = {
      in: 'query',
      required: true,
      type: 'string'
    }
  */
  patientController.deletePatient(req, res);
});

module.exports = router;

