<!--
		SIF Infrastructure Specification 3.7

		(January 21, 2025)
		
		Infrastructure Version: 3.7
		
		license: 
		    name: Apache  2.0
        identifier: Apache-2.0
        url: 'https://home.a4l.org/legal/'
	-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sifassociation.org/infrastructure/3.7" targetNamespace="http://www.sifassociation.org/infrastructure/3.7" elementFormDefault="qualified" version="3.7">
  <xs:complexType name="codeSetType">
    <xs:annotation>
      <xs:appinfo>
        <sifChar />
        <privacyRating />
      </xs:appinfo>
      <xs:documentation>The Code Set Registry Service provides a way for all legal codes to be defined outside of the SIF Specification while allowing changes (additions and replacements) of external code set values to be easily verified by the recipient so as not to break existing Consumer / Provider interoperability.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="zone" type="xs:token">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>M</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>If this is tied to a specific zone it is specified here, otherwise "environment-global" indicates applicability to all zones in the Environment.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="version" type="versionType">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>M</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>The official major, minor, and revision version of the code set.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="timestamp" type="xs:dateTime">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>M</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>The date and time of the last change to this code set. So that only updates can be queried efficiently (where applicable).</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="source" minOccurs="0" type="uriType">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>C</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation>URL to an external code set whose values are not (yet) present in the system.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="codeItems" minOccurs="0" type="codeItemsType">
        <xs:annotation>
          <xs:appinfo>
            <sifChar>O</sifChar>
            <privacyRating />
          </xs:appinfo>
          <xs:documentation />
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="id" use="optional">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:annotation>
            <xs:appinfo>
              <sifChar>O</sifChar>
              <privacyRating />
            </xs:appinfo>
            <xs:documentation />
          </xs:annotation>
          <xs:minLength value="0" xmlns:xs="http://www.w3.org/2001/XMLSchema" />
          <xs:maxLength value="128" xmlns:xs="http://www.w3.org/2001/XMLSchema" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>

  <xs:element name="codeSet" type="codeSetType">
    <xs:key name="codeSetKey1">
      <xs:selector xpath="." />
      <xs:field xpath="@id" />
    </xs:key>
  </xs:element>

  <xs:complexType name="codeSetCollectionType">
    <xs:sequence>
      <xs:element name="codeSet" type="codeSetType" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="codeSets" type="codeSetCollectionType" />

</xs:schema>