{
  "resourceType": "StructureDefinition",
  "id": "endpoint-er",
  "url": "http://electronichealth.se/fhir/NDI/StructureDefinition/endpoint-er",
  "version": "0.1.0",
  "name": "EndpointEr",
  "title": "Endpoint (ER)",
  "status": "active",
  "description": "This profile holds information about a technical address to an API.",
  "fhirVersion": "5.0.0",
  "mapping": [
    {
      "identity": "EndpointToAndpunktLogicalEr",
      "uri": "AndpunktLogicalEr"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Endpoint",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Endpoint",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Endpoint.extension:associatedServer",
        "path": "Endpoint.extension",
        "sliceName": "associatedServer",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/NDI/StructureDefinition/endpoint-associated-server-er"
            ]
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EndpointToAndpunktLogicalEr",
            "map": "urlTillAuktorisationsserver"
          }
        ]
      },
      {
        "id": "Endpoint.extension:associatedServer.extension:associatedServerType",
        "path": "Endpoint.extension.extension",
        "sliceName": "associatedServerType"
      },
      {
        "id": "Endpoint.extension:associatedServer.extension:associatedServerType.url",
        "path": "Endpoint.extension.extension.url",
        "mustSupport": true
      },
      {
        "id": "Endpoint.extension:associatedServer.extension:associatedServerType.value[x]",
        "path": "Endpoint.extension.extension.value[x]",
        "min": 1,
        "fixedCoding": {
          "code": "authorization",
          "system": "http://electronichealth.se/CodeSystem/server-types"
        },
        "mustSupport": true
      },
      {
        "id": "Endpoint.extension:associatedServer.extension:associatedServerType.value[x].system",
        "path": "Endpoint.extension.extension.value[x].system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Endpoint.extension:associatedServer.extension:associatedServerType.value[x].code",
        "path": "Endpoint.extension.extension.value[x].code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Endpoint.extension:associatedServer.extension:serverURL",
        "path": "Endpoint.extension.extension",
        "sliceName": "serverURL"
      },
      {
        "id": "Endpoint.extension:associatedServer.extension:serverURL.url",
        "path": "Endpoint.extension.extension.url",
        "mustSupport": true
      },
      {
        "id": "Endpoint.extension:associatedServer.extension:serverURL.value[x]",
        "path": "Endpoint.extension.extension.value[x]",
        "constraint": [
          {
            "key": "endpoint-security-url-er-1",
            "human": "The security url of an Endpoint must start with https:// followed by a combination of alphanumerical characters, slashes (/) and/or full stops (.)",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/endpoint-er",
            "severity": "error",
            "expression": "$this.matches('^https:\\/\\/[\\/\\.A-Öa-ö0-9]+$')"
          },
          {
            "key": "endpoint-security-url-er-2",
            "human": "The security url of an Endpoint must be a maximum of 255 characters",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/endpoint-er",
            "severity": "error",
            "expression": "$this.length() <= 255"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Endpoint.status",
        "path": "Endpoint.status",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/NDI/ValueSet/er-endpoint-statuses"
        },
        "mapping": [
          {
            "identity": "EndpointToAndpunktLogicalEr",
            "map": "status"
          }
        ]
      },
      {
        "id": "Endpoint.connectionType",
        "path": "Endpoint.connectionType",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "$this"
            }
          ],
          "rules": "open",
          "ordered": false,
          "description": "Slice on connectionType based on value set binding"
        },
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType.coding",
        "path": "Endpoint.connectionType.coding",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType.coding.system",
        "path": "Endpoint.connectionType.coding.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType.coding.code",
        "path": "Endpoint.connectionType.coding.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType:securityMethod",
        "path": "Endpoint.connectionType",
        "sliceName": "securityMethod",
        "min": 1,
        "max": "1",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://hl7.org/fhir/ValueSet/restful-security-service"
        },
        "mapping": [
          {
            "identity": "EndpointToAndpunktLogicalEr",
            "map": "sakerhetsmetod"
          }
        ]
      },
      {
        "id": "Endpoint.connectionType:securityMethod.coding",
        "path": "Endpoint.connectionType.coding",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType:securityMethod.coding.system",
        "path": "Endpoint.connectionType.coding.system",
        "min": 1,
        "fixedUri": "http://hl7.org/fhir/restful-security-service",
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType:securityMethod.coding.code",
        "path": "Endpoint.connectionType.coding.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType:protocol",
        "path": "Endpoint.connectionType",
        "sliceName": "protocol",
        "min": 0,
        "max": "*",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/NDI/ValueSet/er-endpoint-connection-type"
        },
        "mapping": [
          {
            "identity": "EndpointToAndpunktLogicalEr",
            "map": "protokoll"
          }
        ]
      },
      {
        "id": "Endpoint.connectionType:protocol.coding",
        "path": "Endpoint.connectionType.coding",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType:protocol.coding.system",
        "path": "Endpoint.connectionType.coding.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Endpoint.connectionType:protocol.coding.code",
        "path": "Endpoint.connectionType.coding.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Endpoint.name",
        "path": "Endpoint.name",
        "min": 1,
        "constraint": [
          {
            "key": "endpoint-name-er-1",
            "human": "The name of an Endpoint must contain alphanumerical characters, spaces and/or one or more of the following special characters: _-.,\\'()&/",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/endpoint-er",
            "severity": "error",
            "expression": "$this.matches('^[A-Öa-ö0-9 _-.,\\'()&/]+$')"
          },
          {
            "key": "endpoint-name-er-2",
            "human": "The name of an Endpoint must be a maximum of 255 characters",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/endpoint-er",
            "severity": "error",
            "expression": "$this.length() <= 255"
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EndpointToAndpunktLogicalEr",
            "map": "namn"
          }
        ]
      },
      {
        "id": "Endpoint.payload",
        "path": "Endpoint.payload",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EndpointToAndpunktLogicalEr",
            "map": "tillgangliggor(APILogicalEr)"
          }
        ]
      },
      {
        "id": "Endpoint.payload.extension",
        "path": "Endpoint.payload.extension",
        "min": 1
      },
      {
        "id": "Endpoint.payload.extension:apiSpecification",
        "path": "Endpoint.payload.extension",
        "sliceName": "apiSpecification",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/NDI/StructureDefinition/endpoint-payload-actor-definition-er"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Endpoint.address",
        "path": "Endpoint.address",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EndpointToAndpunktLogicalEr",
            "map": "adress"
          }
        ]
      }
    ]
  }
}