{
  "$id": "https://powercom-maquassihills.planetgis.co.za/MDM/Meters/Update/Schema",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "MDMID": { "type": "integer", "code": "MDMD" },
      "Name": { "type": ["string","null"], "code": "Name" },
      "Model": { "type": ["string","null"], "code": "Modl" },
      "PhaseType": { "type": ["string","null"], "code": "PhTy" },
      "Barcode": { "type": ["string","integer","null"], "code": "Brcd" },
      "UpCommType": { "type": ["string","null"], "code": "UpCT" },
      "Protocol": { "type": ["string","null"], "code": "Prtc" },
      "Prepayment": { "type": ["boolean","null"], "code": "Prpd" },
      "Relay": { "type": ["boolean","null"], "code": "Rely" },
      "MVMeter": { "type": ["boolean","null"], "code": "MVMt" },
      "NetMeter": { "type": ["boolean","null"], "code": "NtMt" },
      "CT": { "type": ["integer","null"], "code": "CT__" },
      "PT": { "type": ["integer","null"], "code": "PT__" },
      "Summarize": { "type": ["boolean","null"], "code": "Smrz" },
      "SummarizeType": { "type": ["string","null"], "code": "SmTy" },
      "ACMeter": { "type": ["boolean","null"], "code": "ACMt" },
      "PropertyId": { "type": ["integer","null"], "code": "PrId" },
      "CustomerName": { "type": ["string","null"], "code": "CsNm" },
      "AccountNum": { "type": ["string","null"], "code": "AcNm" },
      "DCUId": { "type": ["integer","null"], "code": "DCUd" },
      "Longitude": { "type": ["number","null"], "code": "Lngt" },
      "Latitude": { "type": ["number","null"], "code": "Lttd" },
      "Disabled": { "type": ["boolean","null"], "code": "Dsbl" },
      "StsBarcode": { "type": ["string","integer","null"], "code": "StBr" },
      "ConsumptionType": { "type": ["string","null"], "code": "CnTy" },
      "InstallationDate": { "type": ["string","null"], "format": "date", "code": "InDt" },
      "Email": { "type": ["string","null"], "code": "Emal" },
      "Mobile": { "type": ["string","null"], "code": "Mobl" },
      "LinkedOn": { "type": ["string","null"], "format": "date-time", "code": "LnOn" },
      "Address": { "type": ["string","null"], "code": "Adrs" },
      "GISKey": { "type": ["string","integer","null"], "code": "GSKy" },
      "TransformerId": { "type": ["integer","null"], "code": "TrId" }
    },
    "required": ["MDMID"],
    "calculated": {
      "I": { "sql": "Coalesce((SELECT FeatureId FROM f_powercom_meters WHERE MDMId=:MDMID), CreateEntity(754257545613586555, (SELECT Coalesce(iif(:DCUId IS NULL, 0, NULL), (SELECT FeatureId FROM f_powercom_dcus WHERE MDMId=:DCUId), 0/*Abort('DCU '||:DCUId||' not found')*/))))" },
      "P": { "condition": "HasKey(\"DCUId\")", "sql": "Coalesce(iif(:DCUId IS NULL, 0, NULL), (SELECT FeatureId FROM f_powercom_dcus WHERE MDMId=:DCUId), 0/*Abort('DCU '||:DCUId||' not found')*/)" },
      "G": { "condition": "HasKey(\"Latitude\") and HasKey(\"Longitude\")", "sql": "WGS84Point(:Latitude,:Longitude)" },  
      "L": { "condition": "HasKey(\"Name\")", "expression": "Name" }
    }
  }
}