Create User API

Endpoint

POST https://doclin.kazico.in/api/auth/create_user.php

Description

Create a new system user. Passwords are hashed server-side.

Headers

Key Value
Content-Type application/x-www-form-urlencoded

Request Parameters

Field Type Required Description
username string Yes Mobile number or name
password string Yes Plain password (server hashes)
roles string/array Yes Comma-separated or JSON array
created_by string Yes Creator identifier
account_active string No Defaults to "yes"

Example cURL

curl --location 'https://doclin.kazico.in/api/auth/create_user.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=pass@123' \
--data-urlencode 'roles=admin,doctor,pharmacy,reception' \
--data-urlencode 'created_by=system'

Example Response

{
  "status": "success",
  "message": "User created successfully",
  "user": { "id": 1, "username": "admin", "roles": ["admin","doctor","pharmacy","reception"], "account_active":"yes", "created_by":"system" }
}

Login (Issue Access & Refresh Tokens)

Endpoint

POST https://doclin.kazico.in/api/auth/login.php

Description

Authenticate user and return access (JWT) and refresh tokens plus user profile.

Headers

Key Value
Content-Type application/x-www-form-urlencoded

Request Parameters

Field Type Required Description
username string Yes Mobile number or name
password string Yes User password

Example cURL

curl --location 'https://doclin.kazico.in/api/auth/login.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=pass@123'
Paste below line in Scripts tab in Postman to automatically use the active token all API
pm.environment.set("access_token", pm.response.json().access_token);
          

Example Response

{
  "status": "success",
  "message": "Login successful",
  "access_token": "",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "",
  "refresh_expires_at": "2025-12-20 13:55:00",
  "user": { "id": 1, "username": "admin", "roles": ["admin"], "account_active": "yes" }
}

Notes

  • Store refresh tokens securely (httpOnly cookie recommended).
  • Access token should be used in Authorization: Bearer <token> header.

Refresh Token

Endpoint

POST https://doclin.kazico.in/api/auth/refresh.php

Description

Exchange a valid refresh token for a new access token and a rotated refresh token.

Headers

Key Value
Content-Type application/x-www-form-urlencoded

Request Parameters

Field Type Required Description
refresh_token string Yes Refresh token received from login

Example cURL

curl --location 'https://doclin.kazico.in/api/auth/refresh.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'refresh_token='

Example Response

{
  "status": "success",
  "access_token": "",
  "expires_in": 3600,
  "refresh_token": "",
  "refresh_expires_at": "2025-12-21 12:55:00"
}

Notes

  • Old refresh token is removed on rotation.
  • Access tokens are not auto-extended — always call this endpoint to reissue tokens.

Logout / Revoke Tokens

Endpoint

POST https://doclin.kazico.in/api/auth/logout.php

Description

Revoke access (blacklist JWT) and delete refresh token from DB.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type application/x-www-form-urlencoded

Request Parameters

Field Type Required Description
refresh_token string No Refresh token to revoke (optional)

Example cURL

curl --location 'https://doclin.kazico.in/api/auth/logout.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'refresh_token='

Example Response

{ "status":"success", "message":"Logged out (tokens revoked)" }

Add Patient — Create Patient

Endpoint

POST https://doclin.kazico.in/api/patient/create.php

Description

Create a patient record. Returns autogenerated patient_id and patient_id_str.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type application/json

Request Parameters

Field Type Required Description
first_name string Yes Patient first name
last_name string Yes Patient last name
gender string Yes Male / Female / Other
mobile_no string Yes Primary mobile number
date_of_birth date No YYYY-MM-DD
age_years int No Age in years

Example cURL

curl --location 'https://doclin.kazico.in/api/patient/create.php' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "first_name": "Rahul",
  "last_name": "Mehta",
  "gender": "Male",
  "mobile_no": "9876543210",
  "date_of_birth": "1990-02-14"
}'

Example Response

{
  "success": true,
  "message": "Patient created",
  "patient_id": 102,
  "patient_id_str": "P000102"
}

Add Patient — Step 1: Update

Endpoint

POST https://doclin.kazico.in/api/patient/update_step1.php

Description

Update primary patient fields (requires patient_id).

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type application/json

Request Parameters

Field Type Required Description
patient_id int Yes ID returned from create
first_name string No Patient first name
last_name string No Patient last name
mobile_no string No Primary mobile

Example cURL

curl --location 'https://doclin.kazico.in/api/patient/update_step1.php' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "patient_id": 102,
  "first_name": "Rahul",
  "last_name": "M.",
  "mobile_no": "9999988888"
}'

Example Response

{
  "success": true,
  "message": "Step1 updated",
  "affected_rows": 1
}

Add Patient — Step 2: Personal Details

Endpoint

POST https://doclin.kazico.in/api/patient/update_step2.php

Description

Height, weight, blood group, address and similar personal fields.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type application/json

Request Parameters

Field Type Required Description
patient_id int Yes Patient id
height_cm decimal No Height in cm
weight_kg decimal No Weight in kg
blood_group string No Blood group

Example cURL

curl --location 'https://doclin.kazico.in/api/patient/update_step2.php' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "patient_id": 102,
  "height_cm": 172,
  "weight_kg": 70,
  "blood_group": "O+"
}'

Example Response

{
  "success": true,
  "message": "Step2 updated"
}

Add Patient — Step 3: Lifestyle

Endpoint

POST https://doclin.kazico.in/api/patient/update_step3.php

Description

Smoking, alcohol, food preference, occupation and activity level.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type application/json

Request Parameters

Field Type Required Description
patient_id int Yes Patient id
smoking_habits string No Daily / Occasionally / Never
food_preference string No Veg / Non-Veg / Vegan
occupation string No Profession

Example cURL

curl --location 'https://doclin.kazico.in/api/patient/update_step3.php' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "patient_id": 102,
  "smoking_habits": "Never",
  "food_preference": "Veg",
  "occupation": "Software Engineer"
}'

Example Response

{
  "success": true,
  "message": "Step3 updated"
}

Add Patient — Step 4: Medical History

Endpoint

POST https://doclin.kazico.in/api/patient/update_step4.php

Description

Chronic diseases, surgeries, family history etc.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type application/json

Request Parameters

Field Type Required Description
patient_id int Yes Patient id
chronic_diseases text No Comma-separated or long text
surgeries text No Surgeries history
family_history_json json No Array (father/mother/siblings)

Example cURL

curl --location 'https://doclin.kazico.in/api/patient/update_step4.php' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "patient_id": 102,
  "chronic_diseases": "Hypertension",
  "family_history_json": ["Diabetes (Father)", "Asthma (Mother)"]
}'

Example Response

{
  "success": true,
  "message": "Step4 updated"
}

Add Patient — Step 5: Allergies

Endpoint

POST https://doclin.kazico.in/api/patient/update_step5.php

Description

Food, medicine and other allergies.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type application/json

Request Parameters

Field Type Required Description
patient_id int Yes Patient id
food_allergies text No Food-based allergies
medicine_allergies text No Medicine-based allergies

Example cURL

curl --location 'https://doclin.kazico.in/api/patient/update_step5.php' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "patient_id": 102,
  "food_allergies": "Peanuts",
  "medicine_allergies": "Penicillin"
}'

Example Response

{
  "success": true,
  "message": "Step5 updated"
}

Add Patient — Step 6: Birth History

Endpoint

POST https://doclin.kazico.in/api/patient/update_step6.php

Description

Birth details: delivery, gestation, birth weight, APGAR, etc.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type application/json

Request Parameters

Field Type Required Description
patient_id int Yes Patient id
mode_of_delivery string No Normal / C-section etc.
birth_weight_kg decimal No Birth weight

Example cURL

curl --location 'https://doclin.kazico.in/api/patient/update_step6.php' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--data '{
  "patient_id": 102,
  "mode_of_delivery": "Normal",
  "birth_weight_kg": 3.2
}'

Example Response

{
  "success": true,
  "message": "Step6 updated"
}

Uploads — Profile Photo Upload

Endpoint

POST https://doclin.kazico.in/api/patient/upload_profile.php

Description

Upload patient profile image; accepts multipart/form-data.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type multipart/form-data

Request Parameters (form)

Field Type Required Description
patient_id int Yes Patient ID
file file Yes Image file (jpg/png/webp)
save_to_files_table 0/1 No Insert record into patient_files

Example cURL

curl -F "patient_id=102" \
-F "file=@/path/to/photo.jpg" \
-F "save_to_files_table=1" \
-H "Authorization: Bearer {{access_token}}" \
"https://doclin.kazico.in/api/patient/upload_profile.php"

Example Response

{
  "success": true,
  "message": "Profile image uploaded",
  "file_path": "/uploads/patients/102/profile/profile_1732291282_ab12cd.png"
}

Uploads — ID Proof Upload

Endpoint

POST https://doclin.kazico.in/api/patient/upload_id_proof.php

Description

Upload patient ID proof (image or PDF) via multipart/form-data.

Headers

Key Value
Authorization Bearer {{access_token}}
Content-Type multipart/form-data

Request Parameters (form)

Field Type Required Description
patient_id int Yes Patient ID
file file Yes Image or PDF
proof_type string No Aadhaar, PAN, Passport

Example cURL

curl -F "patient_id=102" \
-F "file=@/path/to/idproof.pdf" \
-F "proof_type=Aadhaar" \
-H "Authorization: Bearer {{access_token}}" \
"https://doclin.kazico.in/api/patient/upload_id_proof.php"

Example Response

{
  "success": true,
  "message": "ID proof uploaded",
  "file_path": "/uploads/patients/102/id_proof/id_aadhaar_1732291132_ef98aa.pdf"
}

List Patients API

Endpoint

GET https://doclin.kazico.in/api/patient/list.php

Description

Paginated list of patients with search and sorting options.

Headers

Key Value
Authorization Bearer <JWT_TOKEN>

Query Parameters

Parameter Type Default Description
page int 1 Page number
per_page int 25 Results per page (max 200)
search string Search first/last name, mobile, ID
sort_by string created_at id, first_name, last_name, created_at
sort_dir string desc asc or desc

Example cURL

curl -X GET "https://doclin.kazico.in/api/patient/list.php" \
  -H "Authorization: Bearer <JWT_TOKEN>"

Example Response

{
  "success": true,
  "page": 1,
  "per_page": 25,
  "total": 123,
  "data": [
    {
      "id": 1,
      "patient_id_str": "PAT-0001",
      "first_name": "John",
      "last_name": "Doe",
      "mobile_no": "9876543210",
      "date_of_birth": "1990-01-01",
      "created_at": "2025-11-01 12:34:56"
    }
  ]
}

Patient Details API

Endpoint

GET https://doclin.kazico.in/api/patient/details.php

Description

Fetch full details of a single patient using id, patient_id_str, or mobile_no. Optional parameter skip_null can remove null fields from the response.

Headers

Key Value
Authorization Bearer <JWT Token>
Content-Type application/json or application/x-www-form-urlencoded

Request Parameters

Field Type Required Description
id integer No* Primary numeric patient ID
patient_id_str string No* External patient ID (e.g. P000001)
mobile_no string No* Digits-only mobile number
skip_null 0 or 1 No If 1, all null fields are removed from data in the response.

* At least one of id, patient_id_str, mobile_no must be provided.

Example cURL

curl --location 'https://doclin.kazico.in/api/patient/details.php?id=1&skip_null=1' \
--header 'Authorization: Bearer <token>'

Example Response (skip_null = 1)

{
  "status": "success",
  "message": "Patient fetched successfully.",
  "data": {
    "id": 1,
    "first_name": "Rahul",
    "last_name": "M.",
    "gender": "Male",
    "mobile_no": "9999988888",
    "patient_id_str": "P000001",
    "register_for": "Self",
    "created_at": "2025-11-22 13:44:56",
    "updated_at": "2025-11-22 13:46:31"
  }
}

Possible Errors

{
  "status": "error",
  "message": "Patient not found."
}

{
  "status": "error",
  "message": "Missing identifier. Provide one of: id, patient_id_str, or mobile_no."
}

{
  "status": "error",
  "message": "Unauthorized / Invalid Token"
}

{
  "status": "error",
  "message": "Server error",
  "debug": "..."   // only in development
}

Settings — Clinics API

Endpoint

POST/GET/PUT/DELETE https://doclin.kazico.in/api/settings/clinics.php

Description

Manage clinic names and locations used across the Doclin system. Supports full CRUD operations.

Headers

KeyValue
Content-Typeapplication/x-www-form-urlencoded
Acceptapplication/json
AuthorizationBearer <JWT token>

Request Parameters

FieldTypeRequiredDescription
namestringYes (create)Clinic name
locationstringNoClinic address or location
idintYes (for GET/PUT/DELETE)ID passed as query (?id=1)

Example cURL — Create

curl --location 'https://doclin.kazico.in/api/settings/clinics.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {{access_token}}' \
--data-urlencode 'name=Ghansoli Clinic' \
--data-urlencode 'location=Ghansoli, Navi Mumbai'

Example cURL — List

curl --location 'https://doclin.kazico.in/api/settings/clinics.php' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Get by ID

curl --location 'https://doclin.kazico.in/api/settings/clinics.php?id=1' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Update

curl --location --request PUT 'https://doclin.kazico.in/api/settings/clinics.php?id=1' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {{access_token}}' \
--data-urlencode 'name=Updated Clinic' \
--data-urlencode 'location=New Address'

Example cURL — Delete

curl --location --request DELETE 'https://doclin.kazico.in/api/settings/clinics.php?id=1' \
--header 'Authorization: Bearer {{access_token}}'

Example Response

{
  "status": "success",
  "message": "Clinic created successfully",
  "data": { "id": 5, "name": "Ghansoli Clinic", "location": "Ghansoli, Navi Mumbai" }
}

Settings — Departments API

Endpoint

POST/GET/PUT/DELETE https://doclin.kazico.in/api/settings/departments.php

Description

Create and manage medical departments (e.g. Dermatology, Pediatrics). Supports full CRUD.

Headers

KeyValue
Content-Typeapplication/x-www-form-urlencoded
Acceptapplication/json
AuthorizationBearer <JWT token>

Request Parameters

FieldTypeRequiredDescription
namestringYesDepartment name
idintYes (GET/PUT/DELETE)ID passed (?id=1)

Example cURL — Create

curl --location 'https://doclin.kazico.in/api/settings/departments.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {{access_token}}' \
--data-urlencode 'name=Dermatology'

Example cURL — List

curl --location 'https://doclin.kazico.in/api/settings/departments.php' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Get by ID

curl --location 'https://doclin.kazico.in/api/settings/departments.php?id=1' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Update

curl --location --request PUT 'https://doclin.kazico.in/api/settings/departments.php?id=1' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {{access_token}}' \
--data-urlencode 'name=Updated Department'

Example cURL — Delete

curl --location --request DELETE 'https://doclin.kazico.in/api/settings/departments.php?id=1' \
--header 'Authorization: Bearer {{access_token}}'

Example Response

{
  "status": "success",
  "message": "Department created",
  "data": { "id": 3, "name": "Dermatology" }
}

Settings — Doctors API

Endpoint

POST/GET/PUT/DELETE https://doclin.kazico.in/api/settings/doctors.php

Description

Manage doctor details including name, department, clinic assignment, phone, and email. Full CRUD supported. API responses include department and clinic names for display.

Headers

KeyValue
Content-Typeapplication/x-www-form-urlencoded
Acceptapplication/json
AuthorizationBearer <JWT token>

Request Parameters

FieldTypeRequiredDescription
namestringYesDoctor's name
department_idintYesID of department
clinic_idintYesClinic ID
phonestringNoPhone number
emailstringNoEmail address
idintYes (GET/PUT/DELETE)ID passed (?id=1)

Example cURL — Create

curl --location 'https://doclin.kazico.in/api/settings/doctors.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {{access_token}}' \
--data-urlencode 'name=Dr. Rohan Mehta' \
--data-urlencode 'department_id=2' \
--data-urlencode 'clinic_id=1' \
--data-urlencode 'phone=9988776655' \
--data-urlencode 'email=rohan@example.com'

Example cURL — List

curl --location 'https://doclin.kazico.in/api/settings/doctors.php' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Get by ID

curl --location 'https://doclin.kazico.in/api/settings/doctors.php?id=1' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Update

curl --location --request PUT 'https://doclin.kazico.in/api/settings/doctors.php?id=1' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {{access_token}}' \
--data-urlencode 'clinic_id=2' \
--data-urlencode 'phone=9876501234'

Example cURL — Delete

curl --location --request DELETE 'https://doclin.kazico.in/api/settings/doctors.php?id=1' \
--header 'Authorization: Bearer {{access_token}}'

Example Response

{
  "status": "success",
  "message": "Doctor created",
  "data": {
    "id": 10,
    "name": "Dr. Rohan Mehta",
    "department_id": 2,
    "department_name": "Dermatology",
    "clinic_id": 1,
    "clinic_name": "Ghansoli Clinic",
    "phone": "9988776655",
    "email": "rohan@example.com"
  }
}

Schedule — Appointments API

Endpoint

https://doclin.kazico.in/api/schedule/appointments.php

Description

Unified REST endpoint for appointment scheduling. Appointments now store only patient_id — patient details come from the patients table.

Fields (request / response)

FieldTypeDescription
idintPrimary key
patient_idintReference to patients.id (required)
clinic_idintClinic id
doctor_idintDoctor id
appointment_typestringConsultation / Follow-up / Teleconsult
duration_minutesintDuration in minutes
appointment_dateYYYY-MM-DDDate
appointment_timeHH:MMTime
case_idint|nullOptional case reference
service_typestringService / Procedure
notestextNotes
statusenumScheduled, Checked-In, Completed, Cancelled, No-Show
payment_statusenumPaid, Unpaid, Concession
referral_statusenumPaid, Unpaid, Concession
sourcestringWalk-in, Phone, Online, etc.
external_referencestringExternal id / partner reference
created_atdatetimeRecord creation timestamp
updated_atdatetimeLast update timestamp
deleted_atdatetime|nullSoft-delete timestamp (NULL if not deleted)

Notes

  • Do not pass patient name / mobile in appointment requests. Use patient_id.
  • Responses include a patient object with id, first_name, last_name, mobile_no, email and full_name.
  • Use prevent_overlaps: true in POST body to enable exact-match overlap checks (same doctor, date & time).

Create Appointment (POST)

curl --location 'https://doclin.kazico.in/api/schedule/appointments.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "patient_id": 42,
  "clinic_id": 1,
  "doctor_id": 12,
  "appointment_type": "Consultation",
  "duration_minutes": 20,
  "appointment_date": "2025-12-05",
  "appointment_time": "11:30",
  "service_type": "General Checkup",
  "notes": "First visit",
  "status": "Scheduled",
  "payment_status": "Unpaid",
  "referral_status": "Unpaid",
  "source": "Phone",
  "prevent_overlaps": true
}'

Example Response

{
  "message": "Appointment created",
  "id": 1254
}

Get Appointments (GET)

curl --location 'https://doclin.kazico.in/api/schedule/appointments.php?clinic_id=1&date=2025-12-05' \
--header 'Authorization: Bearer {{access_token}}'

Example Response

[
  {
    "id": 1254,
    "patient_id": 42,
    "clinic_id": 1,
    "doctor_id": 12,
    "appointment_date": "2025-12-05",
    "appointment_time": "11:30",
    "status": "Scheduled",
    "patient": {
      "id": 42,
      "title": "Ms.",
      "first_name": "Rita",
      "last_name": "Sharma",
      "mobile_no": "9876543210",
      "email": "rita@example.com",
      "full_name": "Ms. Rita Sharma"
    }
  }
]

Get Single Appointment (GET)

curl --location 'https://doclin.kazico.in/api/schedule/appointments.php?id=1254' \
--header 'Authorization: Bearer {{access_token}}'

Update Appointment (PUT)

curl --location --request PUT 'https://doclin.kazico.in/api/schedule/appointments.php?id=1254' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "appointment_time": "12:00",
  "status": "Checked-In",
  "payment_status": "Paid",
  "patient_id": 42
}'

Example Response

{
  "message": "Appointment updated",
  "rowCount": 1
}

Cancel Appointment (DELETE)

curl --location --request DELETE 'https://doclin.kazico.in/api/schedule/appointments.php?id=1254' \
--header 'Authorization: Bearer {{access_token}}'

Example Response

{
  "message": "Appointment cancelled (soft deleted)"
}

Vendors

Endpoint

https://doclin.kazico.in/api/settings/vendors.php

Description

Manage vendor records including name, addresses, contact details, GST information and status.

Fields

Field Type Required Description
namestringYesVendor name
addressstringNoPrimary address
billing_addressstringNoBilling address (optional)
contact_personstringNoPrimary contact person
emailstringNoEmail address
mobile_numberstringNoMobile number
company_numberstringNoCompany / landline number
gst_numberstringNoGSTIN identifier
statusstringNoActive / Inactive

List Vendors

GET https://doclin.kazico.in/api/settings/vendors.php

Get Vendor

GET https://doclin.kazico.in/api/settings/vendors.php?id={id}

Create Vendor

POST https://doclin.kazico.in/api/settings/vendors.php

Update Vendor

PUT https://doclin.kazico.in/api/settings/vendors.php?id={id}

Delete Vendor

DELETE https://doclin.kazico.in/api/settings/vendors.php?id={id}

Example cURL (Create Vendor)

curl --location 'https://doclin.kazico.in/api/settings/vendors.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "name": "ABC Medical Supplies",
  "address": "Industrial Estate",
  "billing_address": "PO Box 22",
  "contact_person": "John Doe",
  "email": "contact@abc.com",
  "mobile_number": "9876543210",
  "company_number": "02212345678",
  "gst_number": "27AAAAA0000A1Z5",
  "status": "Active"
}'

Example Response

{
  "message": "Vendor created",
  "id": 12
}

Notes

  • All calls require Authorization: Bearer <access_token>.
  • DELETE may be replaced with status update for soft delete.

Medicines — CRUD

Endpoint

https://doclin.kazico.in/api/settings/medicines.php

Description

Full CRUD for medicines. Uses a single table to store product/brand/compound, packaging info (units per strip, strips per box, units per pack), pricing (purchase price, MRP), discount and GST info, and canonical stock in base units. Authentication is required — send Authorization: Bearer <access_token>.

Key Fields

FieldTypeRequiredDescription
product_namestringYese.g. Dolo 650
brand_namestringYesManufacturer
compound_namestringYesActive ingredient
base_unitstringNoSmallest unit (tablet, capsule, ml). Set for tab/cap products.
units_per_stripintNoe.g. 10 (for blister/strip)
strips_per_boxintNoe.g. 10 (for boxes containing strips)
units_per_packintNoExplicit total units per pack (optional)
default_sellingstringNoDefault selling granularity: 'unit'/'strip'/'pack'
purchase_price, mrpdecimalNoPricing
default_discount, max_discount, gst_ratedecimalNoDiscount & tax rules
stock_base_unitsbigintNoAuthoritative stock in base units (tablets)

Example cURL — Create (tablets in box)

curl --location 'https://doclin.kazico.in/api/settings/medicines.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "product_name":"Dolo 650",
  "brand_name":"Pfizer",
  "compound_name":"Paracetamol",
  "base_unit":"tablet",
  "pack_type":"box",
  "units_per_strip":10,
  "strips_per_box":10,
  "default_selling":"strip",
  "purchase_price":10.00,
  "mrp":20.00,
  "default_discount":5.00,
  "gst_rate":12.00,
  "max_discount":15.00,
  "stock_base_units":125
}'

Example cURL — Update

curl --location --request PUT 'https://doclin.kazico.in/api/settings/medicines.php?id=123' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{ "stock_base_units": 200 }'

Notes

  • All requests require Authorization: Bearer <access_token>.
  • Prefer using the dedicated stock API (stock movements ledger) to change stock_base_units; seeding on create is allowed.
  • default_selling controls UI/pos defaults: some SKUs sell by unit, some by strip or pack.

Stock Movement API

Endpoint

POST https://doclin.kazico.in/api/stock/move.php

Description

This endpoint handles all changes to medicine stock. Every inbound or outbound quantity is logged in the stock ledger and the medicines.stock_base_units snapshot is updated in a single atomic transaction.

Supports two methods:

  • Packaging-aware updates (packs / strips / units)
  • Direct base-unit delta (change_in_base_units)
Also accepts an optional amount to record the monetary value of the movement. Authentication is required for all requests.

Parameters

FieldTypeRequiredDescription
medicine_idintYesMedicine to update
change_typestringNoin = add stock, out = subtract stock. If omitted, direction inferred from values.
qty_packsintNoPacks/boxes count
qty_stripsintNoStrips count
qty_unitsintNoLoose units (tablets/capsules)
change_in_base_unitsintNoDirect delta (+/-). Overrides packaging calculations.
reasonstringNoReason for change (purchase, sale, adjustment, invoice, return...)
referencestringNoPO number, Invoice number, etc.
amountdecimalNoMonetary value of the movement (optional)

Stock Behaviour

  • The API converts all packaging into base units (e.g., tablets).
  • The movement is recorded in stock_movements.
  • The medicine's stock_base_units is updated inside the same transaction.
  • The response includes updated stock_display (boxes, strips, units).

Example cURL — Inbound (Purchase)

curl --location 'https://doclin.kazico.in/api/stock/move.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "medicine_id": 123,
  "change_type": "in",
  "qty_packs": 2,
  "qty_strips": 0,
  "qty_units": 0,
  "reason": "purchase",
  "reference": "PO-123",
  "amount": 1800.50
}'

Example cURL — Outbound (Invoice / Billing)

curl --location 'https://doclin.kazico.in/api/stock/move.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "medicine_id": 123,
  "change_type": "out",
  "qty_strips": 1,
  "qty_units": 3,
  "reason": "invoice",
  "reference": "INV-456",
  "amount": 150.00
}'

Example cURL — Direct Base Units Change

curl --location 'https://doclin.kazico.in/api/stock/move.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "medicine_id": 123,
  "change_in_base_units": -15,
  "reason": "sale",
  "reference": "INV-789",
  "amount": 120.00
}'

Example Response

{
  "success": true,
  "movement": {
    "medicine_id": 123,
    "packaging_context": "1 strips, 3 units",
    "change_in_base_units": -13,
    "reason": "invoice",
    "reference": "INV-456"
  },
  "new_stock": 112,
  "medicine": {
    "id": 123,
    "product_name": "Dolo 650",
    "stock_base_units": 112,
    "stock_display": "1 box, 1 strip, 2 tablets"
  }
}

Notes

  • Either send packaging quantities OR change_in_base_units.
  • If both are sent, change_in_base_units takes precedence.
  • Stock never becomes inconsistent because movement + medicine update use the same transaction.
  • amount can be used later for valuation, weighted average costing, supplier reports, etc.

Invoice API

Endpoints

GET    https://doclin.kazico.in/api/invoice/invoices.php
GET    https://doclin.kazico.in/api/invoice/invoices.php?id={invoice_id}
POST   https://doclin.kazico.in/api/invoice/invoices.php
PUT    https://doclin.kazico.in/api/invoice/invoices.php?id={invoice_id}
DELETE https://doclin.kazico.in/api/invoice/invoices.php?id={invoice_id}
  

Description

REST API for managing pharmacy invoices with full stock integration.

The API enforces server-side calculations, packaging-aware quantities, and authoritative stock movements through /api/stock/move.php.

DELETE does not physically remove data. It performs an invoice cancellation workflow and reverses stock for all invoice items.

Authentication is required for all requests.

Invoice Master Parameters (POST / PUT)

FieldTypeRequiredDescription
invoice_nostringYesUnique invoice number
invoice_datedateYesInvoice date (YYYY-MM-DD)
customer_idintYesCustomer ID
doctor_idintYesDoctor ID
grand_totaldecimalYesTotal amount (validated server-side)
paid_amountdecimalNoAmount paid (default 0)

Invoice Item Parameters

FieldTypeRequiredDescription
medicine_idintYesMedicine ID (authoritative)
qty_packsintNoPackaging quantity (exactly one qty field required)
qty_stripsintNoPackaging quantity (exactly one qty field required)
qty_unitsintNoLoose units (exactly one qty field required)
discount_percentdecimalYesDiscount percentage

Computed & Derived Fields

  • Base units are computed using packaging_helpers.php.
  • Unit rate, GST %, and pricing are fetched from the medicines table.
  • Line totals are calculated server-side.
  • grand_total must exactly match the sum of computed line totals.
  • payment_status is derived:
    • UNPAID → paid = 0
    • PARTIAL → paid < grand_total
    • PAID → paid ≥ grand_total

Invoice Lifecycle & Stock Behaviour

  • POST — Creates invoice and reduces stock.
  • PUT — Updates invoice and reconciles stock using quantity differences.
  • DELETE — Cancels invoice and reverses stock fully.
  • No invoice is physically deleted; cancelled invoices remain for audit.

Example cURL — Create Invoice

curl --location 'https://doclin.kazico.in/api/invoice/invoices.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "invoice_no": "INV-1001",
  "invoice_date": "2025-01-10",
  "customer_id": 21,
  "doctor_id": 5,
  "grand_total": 1180.00,
  "paid_amount": 1000.00,
  "items": [
    {
      "medicine_id": 12,
      "qty_strips": 1,
      "discount_percent": 5
    },
    {
      "medicine_id": 8,
      "qty_units": 10,
      "discount_percent": 0
    }
  ]
}'

Example cURL — Get Invoice

curl --location 'https://doclin.kazico.in/api/invoice/invoices.php?id=123' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Update Invoice

curl --location 'https://doclin.kazico.in/api/invoice/invoices.php?id=123' \
--request PUT \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "grand_total": 950.00,
  "items": [
    {
      "medicine_id": 12,
      "qty_units": 5,
      "discount_percent": 5
    }
  ]
}'

Example cURL — Cancel Invoice (DELETE)

curl --location 'https://doclin.kazico.in/api/invoice/invoices.php?id=123' \
--request DELETE \
--header 'Authorization: Bearer {{access_token}}'

Example Response

{
  "success": true,
  "invoice_id": 123,
  "payment_status": "PARTIAL"
}

Notes

  • Exactly one quantity field must be sent per item.
  • Frontend values are never trusted for calculations.
  • All stock changes go through /api/stock/move.php.
  • Cancelled invoices cannot be modified.
  • This design preserves auditability and stock integrity.

Invoice Returns API

Endpoints

GET    https://doclin.kazico.in/api/invoice/returns.php
GET    https://doclin.kazico.in/api/invoice/returns.php?id={return_id}
GET    https://doclin.kazico.in/api/invoice/returns.php?invoice_id={invoice_id}
POST   https://doclin.kazico.in/api/invoice/returns.php
PUT    https://doclin.kazico.in/api/invoice/returns.php?id={return_id}
DELETE https://doclin.kazico.in/api/invoice/returns.php?id={return_id}
  

Description

REST API for handling medicine returns against invoices.

The return system supports partial returns, maintains full audit history, and ensures accurate stock reconciliation using the central stock movement engine.

Returns never modify the original invoice.
All returned quantities are recorded as separate return documents.

DELETE does not remove data. It performs a return cancellation workflow and reverses stock accordingly.

Authentication is required for all requests.

Return Master Parameters (POST / PUT)

FieldTypeRequiredDescription
invoice_idintYesOriginal invoice ID
return_nostringYes (POST)Unique return number
return_datedateYesReturn date (YYYY-MM-DD)
reasonstringNoReason for return

Return Item Parameters

FieldTypeRequiredDescription
medicine_idintYesMedicine being returned
qty_packsintNoPackaging quantity (exactly one qty field required)
qty_stripsintNoPackaging quantity (exactly one qty field required)
qty_unitsintNoLoose units (exactly one qty field required)

Validation Rules

  • Exactly one quantity field must be provided per item.
  • Returned quantity cannot exceed sold quantity minus already returned quantity.
  • Base units are calculated using packaging_helpers.php.
  • Refund amount is calculated server-side using the original invoice unit rate.

Return Lifecycle & Stock Behaviour

  • POST — Creates return and adds stock back.
  • PUT — Updates return and reconciles stock using quantity differences.
  • DELETE — Cancels return and removes stock again.
  • No return is physically deleted; cancelled returns remain for audit.

Example cURL — Create Return

curl --location 'https://doclin.kazico.in/api/invoice/returns.php' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "invoice_id": 123,
  "return_no": "RET-1001",
  "return_date": "2025-01-15",
  "reason": "Customer returned unused medicine",
  "items": [
    {
      "medicine_id": 12,
      "qty_strips": 2
    }
  ]
}'

Example cURL — Get Return

curl --location 'https://doclin.kazico.in/api/invoice/returns.php?id=10' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Get Returns for Invoice

curl --location 'https://doclin.kazico.in/api/invoice/returns.php?invoice_id=123' \
--header 'Authorization: Bearer {{access_token}}'

Example cURL — Update Return

curl --location 'https://doclin.kazico.in/api/invoice/returns.php?id=10' \
--request PUT \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data '{
  "items": [
    {
      "medicine_id": 12,
      "qty_units": 5
    }
  ]
}'

Example cURL — Cancel Return (DELETE)

curl --location 'https://doclin.kazico.in/api/invoice/returns.php?id=10' \
--request DELETE \
--header 'Authorization: Bearer {{access_token}}'

Example Response

{
  "success": true,
  "return_id": 10,
  "refund_amount": 320.00
}

Notes

  • Returns do not alter original invoices.
  • All stock changes go through /api/stock/move.php.
  • Partial and multiple returns per invoice are supported.
  • Cancelled returns cannot be modified.
  • This design ensures inventory accuracy and audit compliance.