{
  "resourceType": "StructureDefinition",
  "id": "DOCUMENT-REFERENCE-LETTER-TEMPLATE",
  "url": "https://health.gov.on.ca/idms/fhir/StructureDefinition/IDMS-DocumentReference-Letter-Template",
  "version": "1.0.0",
  "name": "IDMSDocumentLetterTemplate",
  "title": "IDMS - DocumentReference - Letter Template",
  "status": "active",
  "description": "These are letter templates,  they need to be searchable by type, category, product type, submission type and review path",
  "fhirVersion": "5.0.0",
  "kind": "resource",
  "abstract": false,
  "type": "DocumentReference",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/DocumentReference",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "DocumentReference.identifier",
        "path": "DocumentReference.identifier",
        "short": "Template Identifier",
        "definition": "#### **_`IDMS:  This is the template's unique identifier. When a letter is generated this identfier is saved with the letter (see DocumentReference.content.profile.valueURI) so we can trace back which template was used.`_**",
        "min": 1
      },
      {
        "id": "DocumentReference.identifier.extension",
        "path": "DocumentReference.identifier.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.identifier.use",
        "path": "DocumentReference.identifier.use",
        "max": "0"
      },
      {
        "id": "DocumentReference.identifier.type",
        "path": "DocumentReference.identifier.type",
        "max": "0"
      },
      {
        "id": "DocumentReference.identifier.type.coding.system",
        "path": "DocumentReference.identifier.type.coding.system",
        "min": 1
      },
      {
        "id": "DocumentReference.identifier.type.coding.code",
        "path": "DocumentReference.identifier.type.coding.code",
        "min": 1
      },
      {
        "id": "DocumentReference.identifier.type.coding.display",
        "path": "DocumentReference.identifier.type.coding.display",
        "min": 1
      },
      {
        "id": "DocumentReference.identifier.system",
        "path": "DocumentReference.identifier.system",
        "short": "Primary File Number System",
        "definition": "IDMS's Primary File Number System",
        "min": 1,
        "fixedUri": "urn:idms:letter:template"
      },
      {
        "id": "DocumentReference.identifier.value",
        "path": "DocumentReference.identifier.value",
        "short": "Primary File Number",
        "definition": "#### **_`IDMS: Letter template unique identifier. Format urn:idms:template + template name +  .v  + version number    `_**",
        "min": 1
      },
      {
        "id": "DocumentReference.identifier.period",
        "path": "DocumentReference.identifier.period",
        "max": "0"
      },
      {
        "id": "DocumentReference.identifier.assigner",
        "path": "DocumentReference.identifier.assigner",
        "max": "0"
      },
      {
        "id": "DocumentReference.version",
        "path": "DocumentReference.version",
        "max": "0"
      },
      {
        "id": "DocumentReference.basedOn",
        "path": "DocumentReference.basedOn",
        "max": "0"
      },
      {
        "id": "DocumentReference.status",
        "path": "DocumentReference.status",
        "definition": "#### **_`IDMS:  This is mandatory according to FHIR, it will always be 'current'.`_**"
      },
      {
        "id": "DocumentReference.docStatus",
        "path": "DocumentReference.docStatus",
        "max": "0"
      },
      {
        "id": "DocumentReference.modality",
        "path": "DocumentReference.modality",
        "max": "0"
      },
      {
        "id": "DocumentReference.type",
        "path": "DocumentReference.type",
        "definition": "#### **_`IDMS:  This is the Letter Template Type.  Example 'NDSS - Complete'.`_**",
        "min": 1
      },
      {
        "id": "DocumentReference.type.extension",
        "path": "DocumentReference.type.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.type.coding",
        "path": "DocumentReference.type.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "DocumentReference.type.coding.extension",
        "path": "DocumentReference.type.coding.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.type.coding.system",
        "path": "DocumentReference.type.coding.system",
        "min": 1,
        "fixedUri": "https://health.gov.on.ca/idms/fhir/CodeSystem/IDMS-Internal"
      },
      {
        "id": "DocumentReference.type.coding.version",
        "path": "DocumentReference.type.coding.version",
        "max": "0"
      },
      {
        "id": "DocumentReference.type.coding.code",
        "path": "DocumentReference.type.coding.code",
        "min": 1,
        "binding": {
          "strength": "required",
          "valueSet": "https://health.gov.on.ca/idms/fhir/ValueSet/IDMS-DocumentReference-Letter-Types"
        }
      },
      {
        "id": "DocumentReference.type.coding.display",
        "path": "DocumentReference.type.coding.display"
      },
      {
        "id": "DocumentReference.type.coding.userSelected",
        "path": "DocumentReference.type.coding.userSelected",
        "max": "0"
      },
      {
        "id": "DocumentReference.type.text",
        "path": "DocumentReference.type.text",
        "max": "0"
      },
      {
        "id": "DocumentReference.category",
        "path": "DocumentReference.category",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "coding.version"
            }
          ],
          "rules": "open"
        },
        "short": "Classifications of the Letter Template",
        "definition": "#### **_`IDMS: Category, Product Type , Submission Type , Generic Type .`_**",
        "max": "4"
      },
      {
        "id": "DocumentReference.category:RequestCategory",
        "path": "DocumentReference.category",
        "sliceName": "RequestCategory",
        "max": "1"
      },
      {
        "id": "DocumentReference.category:RequestCategory.extension",
        "path": "DocumentReference.category.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:RequestCategory.coding",
        "path": "DocumentReference.category.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "DocumentReference.category:RequestCategory.coding.extension",
        "path": "DocumentReference.category.coding.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:RequestCategory.coding.system",
        "path": "DocumentReference.category.coding.system",
        "min": 1,
        "fixedUri": "https://health.gov.on.ca/idms/fhir/CodeSystem/Internal-Request-Category-Types"
      },
      {
        "id": "DocumentReference.category:RequestCategory.coding.version",
        "path": "DocumentReference.category.coding.version",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:RequestCategory.coding.code",
        "path": "DocumentReference.category.coding.code",
        "min": 1,
        "binding": {
          "strength": "required",
          "description": "Request Category",
          "valueSet": "https://health.gov.on.ca/idms/fhir/ValueSet/Request-Category"
        }
      },
      {
        "id": "DocumentReference.category:RequestCategory.coding.display",
        "path": "DocumentReference.category.coding.display",
        "min": 1
      },
      {
        "id": "DocumentReference.category:RequestCategory.coding.userSelected",
        "path": "DocumentReference.category.coding.userSelected",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:RequestCategory.text",
        "path": "DocumentReference.category.text",
        "short": "Distinquishes this as the ProductType Code,  has a fixed value of 'ProductType'",
        "max": "0",
        "fixedString": "RequestCategory"
      },
      {
        "id": "DocumentReference.category:ProductType",
        "path": "DocumentReference.category",
        "sliceName": "ProductType",
        "max": "1"
      },
      {
        "id": "DocumentReference.category:ProductType.extension",
        "path": "DocumentReference.category.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:ProductType.coding",
        "path": "DocumentReference.category.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "DocumentReference.category:ProductType.coding.extension",
        "path": "DocumentReference.category.coding.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:ProductType.coding.system",
        "path": "DocumentReference.category.coding.system",
        "short": "IDMS Product Submission Code System",
        "min": 1,
        "fixedUri": "https://health.gov.on.ca/idms/fhir/CodeSystem/Internal-Product-Types"
      },
      {
        "id": "DocumentReference.category:ProductType.coding.version",
        "path": "DocumentReference.category.coding.version",
        "short": "Type of Code",
        "definition": "This being used as the discriminator,  it is the type of code.  (The version of the code system is not relevant in IDMS so this is being reused)",
        "max": "0",
        "fixedString": "ProductType"
      },
      {
        "id": "DocumentReference.category:ProductType.coding.code",
        "path": "DocumentReference.category.coding.code",
        "short": "This is the Product Type Code",
        "min": 1,
        "binding": {
          "strength": "required",
          "description": "List of Product Types",
          "valueSet": "https://health.gov.on.ca/idms/fhir/ValueSet/IDMS-Product-Types"
        }
      },
      {
        "id": "DocumentReference.category:ProductType.coding.display",
        "path": "DocumentReference.category.coding.display",
        "short": "Display Value for the Product Type code",
        "min": 1
      },
      {
        "id": "DocumentReference.category:ProductType.coding.userSelected",
        "path": "DocumentReference.category.coding.userSelected",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:ProductType.text",
        "path": "DocumentReference.category.text",
        "short": "Distinquishes this as the ProductType Code,  has a fixed value of 'ProductType'",
        "max": "0",
        "fixedString": "ProductType"
      },
      {
        "id": "DocumentReference.category:SubmissionType",
        "path": "DocumentReference.category",
        "sliceName": "SubmissionType",
        "max": "1"
      },
      {
        "id": "DocumentReference.category:SubmissionType.extension",
        "path": "DocumentReference.category.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:SubmissionType.coding",
        "path": "DocumentReference.category.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "DocumentReference.category:SubmissionType.coding.extension",
        "path": "DocumentReference.category.coding.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:SubmissionType.coding.system",
        "path": "DocumentReference.category.coding.system",
        "min": 1,
        "fixedUri": "https://health.gov.on.ca/idms/fhir/CodeSystem/Internal-Submission-Types"
      },
      {
        "id": "DocumentReference.category:SubmissionType.coding.version",
        "path": "DocumentReference.category.coding.version",
        "short": "Type of Code",
        "definition": "This being used as the discriminator,  it is the type of code.  (The version of the code system is not relevant in IDMS so this is being reused)",
        "max": "0",
        "fixedString": "SubmissionType"
      },
      {
        "id": "DocumentReference.category:SubmissionType.coding.code",
        "path": "DocumentReference.category.coding.code",
        "short": "This is the Submission Code",
        "min": 1,
        "binding": {
          "strength": "required",
          "description": "Submission Types",
          "valueSet": "https://health.gov.on.ca/idms/fhir/ValueSet/IDMS-Submission-Types"
        }
      },
      {
        "id": "DocumentReference.category:SubmissionType.coding.display",
        "path": "DocumentReference.category.coding.display",
        "short": "This is the display Value for the Submission Code",
        "min": 1
      },
      {
        "id": "DocumentReference.category:SubmissionType.coding.userSelected",
        "path": "DocumentReference.category.coding.userSelected",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:SubmissionType.text",
        "path": "DocumentReference.category.text",
        "short": "Distinquishes this as the SubmissionType Code,  has a fixed value of 'SubmissionType'",
        "max": "0",
        "fixedString": "SubmissionType"
      },
      {
        "id": "DocumentReference.category:GenericClassification",
        "path": "DocumentReference.category",
        "sliceName": "GenericClassification",
        "max": "1"
      },
      {
        "id": "DocumentReference.category:GenericClassification.extension",
        "path": "DocumentReference.category.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:GenericClassification.coding",
        "path": "DocumentReference.category.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "DocumentReference.category:GenericClassification.coding.extension",
        "path": "DocumentReference.category.coding.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:GenericClassification.coding.system",
        "path": "DocumentReference.category.coding.system",
        "min": 1,
        "fixedUri": "https://health.gov.on.ca/idms/fhir/CodeSystem/Generic-Classification"
      },
      {
        "id": "DocumentReference.category:GenericClassification.coding.version",
        "path": "DocumentReference.category.coding.version",
        "short": "Type of Code",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:GenericClassification.coding.code",
        "path": "DocumentReference.category.coding.code",
        "binding": {
          "strength": "required",
          "description": "Request Types",
          "valueSet": "https://health.gov.on.ca/idms/fhir/ValueSet/IDMS-New-Generic-Classification"
        },
        "min": 1
      },
      {
        "id": "DocumentReference.category:GenericClassification.coding.display",
        "path": "DocumentReference.category.coding.display",
        "short": "This is the display Value for the Request Type",
        "min": 1
      },
      {
        "id": "DocumentReference.category:GenericClassification.coding.userSelected",
        "path": "DocumentReference.category.coding.userSelected",
        "max": "0"
      },
      {
        "id": "DocumentReference.category:GenericClassification.text",
        "path": "DocumentReference.category.text",
        "max": "0"
      },
      {
        "id": "DocumentReference.subject",
        "path": "DocumentReference.subject",
        "max": "0"
      },
      {
        "id": "DocumentReference.context",
        "path": "DocumentReference.context",
        "max": "0"
      },
      {
        "id": "DocumentReference.event",
        "path": "DocumentReference.event",
        "max": "0"
      },
      {
        "id": "DocumentReference.bodySite",
        "path": "DocumentReference.bodySite",
        "max": "0"
      },
      {
        "id": "DocumentReference.facilityType",
        "path": "DocumentReference.facilityType",
        "max": "0"
      },
      {
        "id": "DocumentReference.practiceSetting",
        "path": "DocumentReference.practiceSetting",
        "max": "0"
      },
      {
        "id": "DocumentReference.period",
        "path": "DocumentReference.period",
        "max": "0"
      },
      {
        "id": "DocumentReference.date",
        "path": "DocumentReference.date",
        "max": "0"
      },
      {
        "id": "DocumentReference.author",
        "path": "DocumentReference.author",
        "max": "0"
      },
      {
        "id": "DocumentReference.attester",
        "path": "DocumentReference.attester",
        "max": "0"
      },
      {
        "id": "DocumentReference.custodian",
        "path": "DocumentReference.custodian",
        "max": "0"
      },
      {
        "id": "DocumentReference.relatesTo",
        "path": "DocumentReference.relatesTo",
        "max": "0"
      },
      {
        "id": "DocumentReference.description",
        "path": "DocumentReference.description",
        "max": "0"
      },
      {
        "id": "DocumentReference.securityLabel",
        "path": "DocumentReference.securityLabel",
        "max": "0"
      },
      {
        "id": "DocumentReference.content",
        "path": "DocumentReference.content",
        "definition": "#### **_`IDMS: The letter template.`_**",
        "max": "1"
      },
      {
        "id": "DocumentReference.content.extension",
        "path": "DocumentReference.content.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.content.modifierExtension",
        "path": "DocumentReference.content.modifierExtension",
        "max": "0"
      },
      {
        "id": "DocumentReference.content.attachment",
        "path": "DocumentReference.content.attachment",
        "definition": "#### **_`IDMS:  Link to the letter template.`_**",
        "max": "1"
      },
      {
        "id": "DocumentReference.content.profile",
        "path": "DocumentReference.content.profile",
        "definition": "#### **_`IDMS:  For generated letters the template that was used to generate the letter. The 'valueCoding.display' element is populated with the template name.   `_**",
        "max": "0"
      },
      {
        "id": "DocumentReference.content.profile.extension",
        "path": "DocumentReference.content.profile.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.content.profile.modifierExtension",
        "path": "DocumentReference.content.profile.modifierExtension",
        "max": "0"
      }
    ]
  }
}