{
  "resourceType": "StructureDefinition",
  "url": "https://dedalus.cms.sermas.hgugm.org/fhir/StructureDefinition/CMS_Flag",
  "name": "CMS_Flag",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Flag",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Flag",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Flag.identifier.system",
        "path": "Flag.identifier.system",
        "short": "Default system in CMS",
        "definition": "http://apiframework..eu/id",
        "min": 1
      },
      {
        "id": "Flag.identifier.value",
        "path": "Flag.identifier.value",
        "short": "Value of the identifier depending on the HL7 message coming from the external system",
        "comment": "PRB.4 in case of PPR\r\nOBX.21 in case of ADT and OBX.2='ST' & OBX.3.3 = 'ALARM'",
        "min": 1
      },
      {
        "id": "Flag.status",
        "path": "Flag.status",
        "comment": "PPR: \r\nIF MSH-9.2 = 'PC1' and (PRB-1 = 'AD' OR PRB-1 is null) then 'active'\r\nELSE IF MSH-9.2 = 'PC3' and (PRB-1 = 'DE' OR PRB-1 is null) then 'inactive' \r\nEND\r\nADT: \r\nIF OBX-2 = 'ST' and OBX-3.3 = 'ALARM' then\r\n   IF OBX-11 = 'F' then 'active'\r\n   ELSE IF OBX-11 = 'D' then 'inactive'\r\n   END\r\nEND"
      },
      {
        "id": "Flag.category",
        "path": "Flag.category",
        "min": 2,
        "max": "2"
      },
      {
        "id": "Flag.category.coding.system",
        "path": "Flag.category.coding.system",
        "definition": "http://hl7.org/fhir/ValueSet/flag-category",
        "min": 1,
        "fixedUri": "http://hl7.org/fhir/ValueSet/flag-category"
      },
      {
        "id": "Flag.category.coding.code",
        "path": "Flag.category.coding.code",
        "definition": "PPR: destination_id = MappingConfig(PRB-3.1, FlagCategoryCode0)\r\nADT: IF OBX-2 = 'ST' and OBX-3.3 = 'ALARM' then destination_id = MappingConfig(OBX-21, FlagCategoryCode0)",
        "min": 1,
        "fixedCode": "PRB-3"
      },
      {
        "id": "Flag.category.coding.display",
        "path": "Flag.category.coding.display",
        "comment": "PPR: destination_desc = MappingConfig(PRB-3.1, FlagCategoryCode0)\r\nADT: IF OBX-2 = 'ST' and OBX-3.3 = 'ALARM' then destination_desc = MappingConfig(OBX-21, FlagCategoryCode0)",
        "min": 1,
        "fixedString": "PRB-3"
      },
      {
        "id": "Flag.category.text",
        "path": "Flag.category.text",
        "requirements": "PRB-3"
      },
      {
        "id": "Flag.code.coding",
        "path": "Flag.code.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Flag.code.coding.system",
        "path": "Flag.code.coding.system",
        "min": 1,
        "fixedUri": "http://terminology.hcis.eu/HCIS/alerta"
      },
      {
        "id": "Flag.code.coding.code",
        "path": "Flag.code.coding.code",
        "comment": "PPR: PRB-4\r\nADT: IF OBX-2 = 'ST' and OBX-3.3 = 'ALARM' then OBX-21",
        "min": 1
      },
      {
        "id": "Flag.code.coding.display",
        "path": "Flag.code.coding.display",
        "comment": "PPR: No problem display available in this type of messages. Will remain empty untill ADT is received.\r\nADT: IF OBX-2 = 'ST' and OBX-3.3 = 'ALARM' then OBX-5",
        "min": 1
      },
      {
        "id": "Flag.subject.reference",
        "path": "Flag.subject.reference",
        "min": 1,
        "fixedString": "Patient/HASH[PID-3.1]"
      },
      {
        "id": "Flag.period.start",
        "path": "Flag.period.start",
        "comment": "PPR:\r\nIF MSH-9.2 = 'PC1' and PRB-1 = 'AD' then\r\n   IF PRB-7 is not null then PRB-7\r\n   ELSE IF PRB-2 is not null then PRB-2\r\n   ELSE MSH-7\r\n   END\r\nEND\r\nADT:\r\nIF OBX-2 = 'ST' and OBX-3.3 = 'ALARM' then OBX-14",
        "min": 1
      },
      {
        "id": "Flag.period.end",
        "path": "Flag.period.end",
        "comment": "PPR: \r\nIF MSH-9.2 = 'PC3' and PRB-1 = 'DE' then\r\n   IF PRB-9 is not null then PRB-9\r\n   ELSE IF PRB-2 is not null then PRB-2\r\n   ELSE MSH-7\r\n   END\r\nEND\r\nADT:\r\nIF OBX-2 = 'ST' and OBX-3.3 = 'ALARM' then OBX-12\r\n\r\nFormat YYYY-MM-DDTHH:mm:ssZ",
        "min": 1
      }
    ]
  }
}