{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.gynaehub.com/schemas/referral-slip.json",
  "title": "Maternal & Neonatal Emergency Referral Slip Schema",
  "description": "Standardized electronic clinical transfer and referral slip schema for obstetrics and neonatology according to PHC MSDS referral protocols.",
  "type": "object",
  "required": [
    "referralDateTime",
    "referringFacility",
    "receivingFacility",
    "patientDetails",
    "reasonForReferral",
    "clinicalSummaryAndFindings",
    "treatmentGivenPriorToTransfer",
    "transportAndHandoverStaff"
  ],
  "properties": {
    "referralDateTime": { "type": "string", "format": "date-time" },
    "urgencyLevel": {
      "type": "string",
      "enum": ["Emergency (Immediate Life/Fetal Threat)", "Urgent (< 2 hours)", "Elective / Non-Urgent"]
    },
    "referringFacility": {
      "type": "object",
      "required": ["facilityName", "providerName", "contactNumber"],
      "properties": {
        "facilityName": { "type": "string" },
        "providerName": { "type": "string" },
        "qualification": { "type": "string", "example": "Midwife / LHV / Obstetrician" },
        "contactNumber": { "type": "string" }
      }
    },
    "receivingFacility": {
      "type": "object",
      "required": ["facilityName", "department"],
      "properties": {
        "facilityName": { "type": "string" },
        "department": { "type": "string", "example": "Labor Ward / ICU / Neonatal ICU" },
        "priorNotificationGiven": { "type": "boolean" },
        "contactPersonNotified": { "type": "string" }
      }
    },
    "patientDetails": {
      "type": "object",
      "required": ["patientName", "cnic", "age", "gravida", "para"],
      "properties": {
        "patientName": { "type": "string" },
        "cnic": { "type": "string" },
        "age": { "type": "integer" },
        "gravida": { "type": "integer" },
        "para": { "type": "integer" },
        "gestationalAgeWeeks": { "type": "number" },
        "bloodGroup": { "type": "string" }
      }
    },
    "reasonForReferral": {
      "type": "string",
      "example": "Severe preeclampsia with visual disturbances, uncontrolled BP 170/110 mmHg, non-reassuring fetal heart sounds."
    },
    "clinicalSummaryAndFindings": {
      "type": "object",
      "required": ["bloodPressure", "pulse", "cervicalDilationCm", "fetalHeartRateBpm"],
      "properties": {
        "bloodPressure": { "type": "string" },
        "pulse": { "type": "integer" },
        "temperatureCelsius": { "type": "number" },
        "respiratoryRate": { "type": "integer" },
        "cervicalDilationCm": { "type": "string" },
        "membraneStatus": { "type": "string" },
        "fetalHeartRateBpm": { "type": "integer" }
      }
    },
    "treatmentGivenPriorToTransfer": {
      "type": "object",
      "required": ["medicationsAdministered", "ivAccessDetails"],
      "properties": {
        "medicationsAdministered": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "drug": { "type": "string" },
              "dose": { "type": "string" },
              "timeGiven": { "type": "string" }
            }
          }
        },
        "ivAccessDetails": { "type": "string", "example": "18G IV cannula left arm, IV Ringer Lactate @ 100 mL/hr" },
        "catheterizationDone": { "type": "boolean" }
      }
    },
    "transportAndHandoverStaff": {
      "type": "object",
      "required": ["accompanyingStaffName", "ambulanceServiceUsed"],
      "properties": {
        "accompanyingStaffName": { "type": "string" },
        "accompanyingStaffDesignation": { "type": "string" },
        "ambulanceServiceUsed": { "type": "string", "example": "Rescue 1122" }
      }
    }
  }
}
