{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.gynaehub.com/schemas/discharge-summary.json",
  "title": "Postpartum & Newborn Discharge Summary Schema",
  "description": "Standardized electronic clinical discharge summary schema for mother and infant following delivery according to PHC MSDS.",
  "type": "object",
  "required": [
    "admissionAndDischargeDates",
    "maternalOutcome",
    "newbornOutcome",
    "dischargeMedications",
    "followUpAndDangerSignsAdvice"
  ],
  "properties": {
    "admissionAndDischargeDates": {
      "type": "object",
      "required": ["admissionDate", "dischargeDate"],
      "properties": {
        "admissionDate": { "type": "string", "format": "date" },
        "dischargeDate": { "type": "string", "format": "date" }
      }
    },
    "maternalOutcome": {
      "type": "object",
      "required": ["modeOfDelivery", "perinealStatus", "bloodLossEstimatedMl", "postpartumComplications"],
      "properties": {
        "modeOfDelivery": {
          "type": "string",
          "enum": ["Spontaneous Vaginal Delivery (SVD)", "Instrumental (Vacuum/Forceps)", "Elective Cesarean Section", "Emergency Cesarean Section"]
        },
        "deliveryDateTime": { "type": "string", "format": "date-time" },
        "perinealStatus": {
          "type": "string",
          "enum": ["Intact", "1st Degree Tear", "2nd Degree Tear / Episiotomy Repaired", "3rd/4th Degree Tear Repaired"]
        },
        "bloodLossEstimatedMl": { "type": "integer" },
        "postpartumComplications": {
          "type": "array",
          "items": { "type": "string" },
          "example": ["None", "Managed PPH", "Pregnancy Induced Hypertension"]
        },
        "dischargeVitals": {
          "type": "object",
          "properties": {
            "bloodPressure": { "type": "string" },
            "pulse": { "type": "integer" },
            "temperatureCelsius": { "type": "number" },
            "lochia": { "type": "string", "enum": ["Normal Rubra", "Serosa", "Offensive / Excessive"] }
          }
        }
      }
    },
    "newbornOutcome": {
      "type": "object",
      "required": ["sex", "birthWeightKg", "apgarScore1Min", "apgarScore5Min", "immediateVaccinesGiven"],
      "properties": {
        "sex": { "type": "string", "enum": ["Male", "Female", "Ambiguous"] },
        "birthWeightKg": { "type": "number" },
        "apgarScore1Min": { "type": "integer", "minimum": 0, "maximum": 10 },
        "apgarScore5Min": { "type": "integer", "minimum": 0, "maximum": 10 },
        "breastfeedingInitiatedWithin1Hour": { "type": "boolean" },
        "immediateVaccinesGiven": {
          "type": "object",
          "properties": {
            "bcg": { "type": "boolean" },
            "opv0": { "type": "boolean" },
            "hepB0": { "type": "boolean" }
          }
        },
        "congenitalAnomaliesNoted": { "type": "string" }
      }
    },
    "dischargeMedications": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["drugName", "dosage", "frequency", "durationDays"],
        "properties": {
          "drugName": { "type": "string" },
          "dosage": { "type": "string" },
          "frequency": { "type": "string" },
          "durationDays": { "type": "integer" },
          "instructions": { "type": "string" }
        }
      }
    },
    "followUpAndDangerSignsAdvice": {
      "type": "object",
      "required": ["postpartumCheckupDate", "redFlagEducationConfirmed"],
      "properties": {
        "postpartumCheckupDate": { "type": "string", "format": "date" },
        "redFlagEducationConfirmed": { "type": "boolean" },
        "contraceptionCounseled": { "type": "boolean" }
      }
    }
  }
}
