{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.gynaehub.com/schemas/anc-card.json",
  "title": "Antenatal Care Record (ANC Card) Schema",
  "description": "Standardized electronic clinical record structure for Antenatal Care (ANC) Card according to PHC MSDS and WHO 8-contact focused antenatal care model.",
  "type": "object",
  "required": [
    "patientDetails",
    "obstetricHistory",
    "currentPregnancyCalculations",
    "baselineInvestigations",
    "trimesterContacts"
  ],
  "properties": {
    "patientDetails": {
      "type": "object",
      "required": ["patientName", "husbandName", "cnic", "phone", "residence"],
      "properties": {
        "patientName": { "type": "string" },
        "husbandName": { "type": "string" },
        "age": { "type": "integer", "minimum": 12, "maximum": 60 },
        "cnic": { "type": "string", "pattern": "^[0-9]{5}-[0-9]{7}-[0-9]$" },
        "phone": { "type": "string" },
        "residence": { "type": "string" },
        "bloodGroup": {
          "type": "string",
          "enum": ["A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-"]
        }
      }
    },
    "obstetricHistory": {
      "type": "object",
      "required": ["gravida", "para", "abortions", "livingChildren"],
      "properties": {
        "gravida": { "type": "integer", "minimum": 1 },
        "para": { "type": "integer", "minimum": 0 },
        "abortions": { "type": "integer", "minimum": 0 },
        "livingChildren": { "type": "integer", "minimum": 0 },
        "previousCSections": { "type": "integer", "minimum": 0 },
        "previousStillbirths": { "type": "integer", "minimum": 0 },
        "previousPphHistory": { "type": "boolean" },
        "medicalConditions": {
          "type": "array",
          "items": { "type": "string" },
          "description": "e.g., Chronic hypertension, pre-gestational diabetes, cardiac disease, thyroid disorder"
        }
      }
    },
    "currentPregnancyCalculations": {
      "type": "object",
      "required": ["lmpDate", "eddDate"],
      "properties": {
        "lmpDate": { "type": "string", "format": "date" },
        "eddDate": { "type": "string", "format": "date" },
        "ultrasoundEdd": { "type": "string", "format": "date" },
        "plannedBirthFacility": { "type": "string" }
      }
    },
    "baselineInvestigations": {
      "type": "object",
      "properties": {
        "hemoglobinGdl": { "type": "number" },
        "bloodSugarFasting": { "type": "number" },
        "bloodSugarRandom": { "type": "number" },
        "hepatitisB": { "type": "string", "enum": ["Negative", "Positive", "Pending"] },
        "hepatitisC": { "type": "string", "enum": ["Negative", "Positive", "Pending"] },
        "hiv": { "type": "string", "enum": ["Negative", "Positive", "Pending"] },
        "vdrlSyphilis": { "type": "string", "enum": ["Negative", "Positive", "Pending"] },
        "urineCompleteExamination": { "type": "string" },
        "tetanusToxoidDoses": { "type": "integer", "minimum": 0, "maximum": 5 }
      }
    },
    "trimesterContacts": {
      "type": "array",
      "description": "Routine antenatal checkups documented across gestation.",
      "items": {
        "type": "object",
        "required": ["visitDate", "gestationalAgeWeeks", "bloodPressure", "weightKg"],
        "properties": {
          "visitNumber": { "type": "integer", "minimum": 1 },
          "visitDate": { "type": "string", "format": "date" },
          "gestationalAgeWeeks": { "type": "number", "minimum": 4, "maximum": 43 },
          "weightKg": { "type": "number" },
          "bloodPressure": {
            "type": "object",
            "required": ["systolic", "diastolic"],
            "properties": {
              "systolic": { "type": "integer" },
              "diastolic": { "type": "integer" }
            }
          },
          "pallor": { "type": "string", "enum": ["None", "Mild", "Moderate", "Severe"] },
          "pedalEdema": { "type": "string", "enum": ["Absent", "Mild (+)", "Moderate (++)", "Severe (+++)"] },
          "symphysisFundalHeightCm": { "type": "number" },
          "fetalPresentation": { "type": "string", "enum": ["Cephalic", "Breech", "Transverse", "Unstable"] },
          "fetalHeartRateBpm": { "type": "integer" },
          "supplementsPrescribed": {
            "type": "array",
            "items": { "type": "string" },
            "example": ["Iron 60mg", "Folic Acid 400mcg", "Calcium 1000mg"]
          },
          "dangerSignsScreening": { "type": "boolean" },
          "riskDisposition": {
            "type": "string",
            "enum": ["Routine low-risk continue ANC", "High-risk consult required", "Emergency specialist referral"]
          },
          "nextVisitDate": { "type": "string", "format": "date" }
        }
      }
    }
  }
}
