{
  "resourceType": "StructureDefinition",
  "id": "ncdhc-composition-estimated-date-birth",
  "url": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-composition-estimated-date-birth",
  "version": "dv0.0.1",
  "name": "NCDHCEstimatedDateOfBirthComposition",
  "title": "NCDHC Estimated Date of Birth Composition",
  "status": "draft",
  "date": "2020-03-20",
  "publisher": "National Children's Digital Health Collaborative (NCDHC)",
  "copyright": "Copyright © 2020 Australian Digital Health Agency - All rights reserved. This content is licensed under a Creative Commons Attribution 4.0 International License. See https://creativecommons.org/licenses/by/4.0/.",
  "fhirVersion": "3.0.2",
  "kind": "resource",
  "abstract": false,
  "type": "Composition",
  "baseDefinition": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-composition-base",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Composition",
        "path": "Composition",
        "short": "NCDHC Estimated Date of Birth Composition"
      },
      {
        "id": "Composition.type.coding",
        "path": "Composition.type.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Composition.type.coding.system",
        "path": "Composition.type.coding.system",
        "min": 1,
        "fixedUri": "http://hl7.org.au/fhir/ch/v1/CodeSystem/ncdhc-hi-type-1"
      },
      {
        "id": "Composition.type.coding.code",
        "path": "Composition.type.coding.code",
        "min": 1
      },
      {
        "id": "Composition.class.coding",
        "path": "Composition.class.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Composition.class.coding.system",
        "path": "Composition.class.coding.system",
        "min": 1,
        "fixedUri": "http://hl7.org.au/fhir/ch/v1/CodeSystem/ncdhc-document-class-1"
      },
      {
        "id": "Composition.class.coding.code",
        "path": "Composition.class.coding.code",
        "min": 1
      },
      {
        "id": "Composition.subject",
        "path": "Composition.subject",
        "type": [
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-patient-expectant-mother"
          }
        ]
      },
      {
        "id": "Composition.encounter",
        "path": "Composition.encounter",
        "type": [
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-dphr-encounter",
            "aggregation": [
              "bundled"
            ]
          }
        ]
      },
      {
        "id": "Composition.attester.party",
        "path": "Composition.attester.party",
        "short": "An organisation/practitioner who has attested to the accuracy of the composition/document.",
        "type": [
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-patient-expectant-mother",
            "aggregation": [
              "bundled"
            ]
          },
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/StructureDefinition/au-practitioner",
            "aggregation": [
              "bundled"
            ]
          },
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/StructureDefinition/au-organisation",
            "aggregation": [
              "bundled"
            ]
          }
        ]
      },
      {
        "id": "Composition.section",
        "path": "Composition.section",
        "slicing": {
          "discriminator": [
            {
              "type": "pattern",
              "path": "code"
            }
          ],
          "rules": "closed"
        },
        "mustSupport": true
      },
      {
        "id": "Composition.section.title",
        "path": "Composition.section.title",
        "mustSupport": true
      },
      {
        "id": "Composition.section.code",
        "path": "Composition.section.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Composition.section.text",
        "path": "Composition.section.text",
        "mustSupport": true
      },
      {
        "id": "Composition.section.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Composition.section:EDB",
        "path": "Composition.section",
        "sliceName": "EDB",
        "short": "Estimated date of delivery",
        "min": 1,
        "max": "1",
        "constraint": [
          {
            "key": "inv-cmp-edb-001",
            "severity": "error",
            "human": "There is exactly one Estimated Date of Birth observation",
            "expression": "entry.resolve().code.coding.where(system='http://snomed.info/sct' and code='161714006').count()=1"
          },
          {
            "key": "inv-cmp-edb-002",
            "severity": "error",
            "human": "There is at most one Estimated Date of Birth from Last Period observation",
            "expression": "entry.resolve().code.coding.where(system='http://snomed.info/sct' and code='289206005').count()<2"
          },
          {
            "key": "inv-cmp-edb-003",
            "severity": "error",
            "human": "There is at most one Obsteteric Ultrasound Scan observation",
            "expression": "entry.resolve().code.coding.where(system='http://snomed.info/sct' and code='268445003').count()<2"
          },
          {
            "key": "inv-cmp-edb-004",
            "severity": "error",
            "human": "There is at most one EDB by Clinical Examination observation",
            "expression": "entry.resolve().code.coding.where(system='http://snomed.info/sct' and code='1384451000168107').count()<2"
          },
          {
            "key": "inv-cmp-edb-005",
            "severity": "error",
            "human": "There is at most one Fetal Gestational Age at Ultrasound Observation",
            "expression": "entry.resolve().code.coding.where(system='http://snomed.info/sct' and code='57036006').count()<2"
          },
          {
            "key": "inv-cmp-edb-006",
            "severity": "error",
            "human": "There is at most one EDB Consistent between Last Menstrual Period and antenatal Ultrasound Scan observation",
            "expression": "entry.resolve().code.coding.where(system='http://snomed.info/sct' and code='1377101000168100').count()<2"
          }
        ]
      },
      {
        "id": "Composition.section:EDB.title",
        "path": "Composition.section.title",
        "fixedString": "Estimated date of delivery"
      },
      {
        "id": "Composition.section:EDB.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "system": "http://snomed.info/sct",
              "code": "161714006"
            }
          ]
        }
      },
      {
        "id": "Composition.section:EDB.entry",
        "path": "Composition.section.entry",
        "type": [
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-observation-estimated-date-birth"
          },
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-observation-estimated-date-birth-last-period"
          },
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-observation-ultrasound-scan-obstetric"
          },
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-observation-edb-by-clinical-examination"
          },
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-observation-fetal-gestational-age-at-ultrasound"
          },
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-observation-edb-consistent-lmp-us"
          }
        ]
      },
      {
        "id": "Composition.section:obstet-hist",
        "path": "Composition.section",
        "sliceName": "obstet-hist",
        "max": "1",
        "constraint": [
          {
            "key": "inv-cmp-edb-007",
            "severity": "error",
            "human": "There is at most one Breastfeeding at Time of Conception observation",
            "expression": "entry.resolve().code.coding.where(system='http://snomed.info/sct' and code='1376561000168109').count()<2"
          },
          {
            "key": "inv-cmp-edb-008",
            "severity": "error",
            "human": "There is at most one Hormonal contraception observation",
            "expression": "entry.resolve().code.coding.where(system='http://snomed.info/sct' and code='1376571000168103').count()<2"
          }
        ]        
      },
      {
        "id": "Composition.section:obstet-hist.title",
        "path": "Composition.section.title",
        "fixedString": "Obstetric history"
      },
      {
        "id": "Composition.section:obstet-hist.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "system": "http://snomed.info/sct",
              "code": "248983002"
            }
          ]
        }
      },
      {
        "id": "Composition.section:obstet-hist.entry",
        "path": "Composition.section.entry",
        "type": [
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-observation-breastfeeding-time-conception"
          },
          {
            "code": "Reference",
            "targetProfile": "http://hl7.org.au/fhir/ch/v1/StructureDefinition/ncdhc-observation-hormonal-contraception-at-time-of-conception"
          }
        ]
      }
    ]
  }
}