<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="urn:wales.nhs.uk/nwis/isd/datareturn"
    targetNamespace="urn:wales.nhs.uk/nwis/isd/datareturn"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    version="0.2">
    <xs:annotation>
        <xs:documentation>This schema document contains element declarations for the data items
            making up the data entities.</xs:documentation>
        <xs:documentation> v0-1: Initial drafting from Substance Misuse Data Set Business Definition
            document 20130926 </xs:documentation>
        <xs:documentation>v0-2: Revised after team review, mostly rearrangements of text and some
            name changes for clarity - see top schema for documentation.</xs:documentation>
		    <xs:documentation>v0-3: Allow non-key fields to be empty.</xs:documentation>
        <xs:documentation>v0-4: Changes to reflect Substance Misuse Data Set Business Definition 0.5</xs:documentation>
    </xs:annotation>
    <xs:include
        schemaLocation="DataReturnDatatypes-v0-4.xsd"/>
    <xs:annotation>
        <xs:documentation> Elements for Referral Details </xs:documentation>
    </xs:annotation>
    <xs:element
        name="AgencyCode"
        type="alphaNumeric6"/>
    <xs:element
        name="AgencyClientNumber"
        type="alphaNumericUpTo15"/>
    <xs:element
        name="DateOfReferral"
        type="xs:date"/>
    <xs:element
        name="SourceOfReferral"
        type="optionalAlphaNumeric2"/>
    <xs:annotation>
        <xs:documentation> Elements for Client Details </xs:documentation>
    </xs:annotation>
    <xs:element
        name="SurnameInitial"
        type="alpha1"/>
    <xs:element
        name="ForenameInitial"
        type="alpha1"/>
    <xs:element
        name="DateOfBirth"
        type="xs:date"/>
    <xs:element
        name="Gender"
        type="digit1"/>
    <xs:element
        name="EthnicCategory"
        type="optionalAlpha1"/>
    <xs:element
        name="ShortPostcode"
        type="shortPostcodeType"/>
    <xs:element
        name="NHSnumber"
        type="optionalNHSnumberType"/>
    <xs:element
      name="LocalAuthority"
      type="optionalDigit3"/>
  <xs:annotation>
        <xs:documentation> Elements for Assessment Details </xs:documentation>
    </xs:annotation>
    <xs:element
        name="AssessmentDate"
        type="xs:date"/>
    <xs:element
        name="PreviouslyTreated"
        type="optionalDigit1"/>
    <xs:element
        name="ExServicesPersonnel"
        type="optionalDigit1"/>
    <xs:element
        name="ParentalResponsibility"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="ChildrenLivingInHousehold"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="ProblemSubstance1"
        type="optionalDigit4"/>
    <xs:element
        name="ProblemSubstance2"
        type="optionalDigit4"/>
    <xs:element
        name="ProblemSubstance3"
        type="optionalDigit4"/>
    <xs:element
        name="InjectingStatus"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="HepatitisB-VacStatus"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="BBV-VacStatus"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="MentalHealthIssues"
        type="optionalDigit1"/>
    <xs:element
        name="AccommodationNeed"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="EmploymentStatus"
        type="optionalAlphaNumeric2"/>
    <xs:annotation>
        <xs:documentation> Elements for Treatment Modality Details </xs:documentation>
    </xs:annotation>
    <xs:element
        name="TreatmentModalityKind"
        type="alphaNumeric2"/>
    <xs:element
        name="ModalityReferralDate"
        type="xs:date"/>
    <xs:element
        name="ModalityFirstApptOfferedDate"
        type="optionalDate"/>
    <xs:element
        name="ModalityStartDate"
        type="optionalDate"/>
    <xs:element
        name="ModalityEndDate"
        type="optionalDate"/>
    <xs:element
        name="ModalityExitStatus"
        type="optionalAlphaNumeric2"/>
    <xs:annotation>
        <xs:documentation> Elements for Treatment Outcome Profile (TOP) Details </xs:documentation>
    </xs:annotation>
    <xs:element
        name="TOPnumber"
        type="digit6"/>
    <xs:element
        name="TOPinterviewDate"
        type="xs:date"/>
  <xs:element
        name="TreatmentStage"
        type="optionalAlphaNumeric2"
      />
    <xs:element
        name="DaysAlcoholUsed"
        type="optionalAlphaNumeric2">
        <xs:annotation>
            <xs:documentation> The number of days the client has consumed alcohol in the last 28 days 
                (4 weeks) prior to the TOP interview date, as stated by the client.</xs:documentation> 
            <xs:documentation>2 character alpha numeric value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="DaysOpiateUsed"
        type="optionalAlphaNumeric2">
        <xs:annotation>
            <xs:documentation>The number of days the client has taken opiates in the last 28 days 
                (4 weeks) prior to the TOP interview date, as stated by the client.</xs:documentation>
            <xs:documentation>2 character alpha numeric value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="DaysCrackUsed"
        type="optionalAlphaNumeric2">
        <xs:annotation>
            <xs:documentation>The number of days the client has taken crack in the last 28 days 
                (4 weeks) prior to the TOP interview date, as stated by the client.</xs:documentation>
            <xs:documentation>2 character alpha numeric value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="DaysCocaineUsed"
        type="optionalAlphaNumeric2">
        <xs:annotation>
            <xs:documentation>The number of days the client has taken cocaine in the last 28 days 
                (4 weeks) prior to the TOP interview date, as stated by the client.</xs:documentation>
          <xs:documentation>2 character alpha numeric value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="DaysAmphetaminesUsed"
        type="optionalAlphaNumeric2">
        <xs:annotation>
            <xs:documentation>The number of days the client has taken amphetamine in the last 28 days 
                (4 weeks) prior to the TOP interview date, as stated by the client.</xs:documentation>
          <xs:documentation>2 character alpha numeric value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="DaysCannabisUsed"
        type="optionalAlphaNumeric2">
        <xs:annotation>
            <xs:documentation>The number of days the client has taken cannabis in the last 28 days 
                (4 weeks) prior to the TOP interview date, as stated by the client.</xs:documentation>
          <xs:documentation>2 character alpha numeric value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="OtherProblemSubstance"
        type="optionalDigit4">
        <xs:annotation>
            <xs:documentation>This should be completed if the client has used any other substance within 
                the last 28 days (4 weeks) prior to the TOP interview date other than alcohol, opiates, 
                crack, cocaine, amphetamines and cannabis).</xs:documentation>
            <xs:documentation>4 digit integer value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="DaysOtherSubstanceUsed"
        type="optionalAlphaNumeric2">
        <xs:annotation>
            <xs:documentation>The number of days the client has taken the “other problem substance” 
                in the last 28 days (4 weeks) prior to the TOP interview date, as stated by the client.</xs:documentation>
          <xs:documentation>2 character alpha numeric value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="DaysInjected"
        type="optionalAlphaNumeric2">
        <xs:annotation>
            <xs:documentation>The total number of days the client has injected non prescribed drugs in 
                the last 28 days (4 weeks) prior to the TOP interview date, as stated by the client.</xs:documentation>
          <xs:documentation>2 character alpha numeric value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="InjectedSharedSharp"
        type="optionalDigit1">
        <xs:annotation>
            <xs:documentation> Whether injected with Needle or Syringe Used by Someone Else </xs:documentation>
            <xs:documentation>1 digit integer value.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element
        name="DaysShoplifting"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="DaysDrugSelling"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="CriminalOffenceStatus"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="AssaultOrViolence"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="PsychologicalHealthStatus"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="DaysPaidWork"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="DaysCollegeOrSchool"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="PhysicalHealthStatus"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="UrgentHousingProblemStatus"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="RiskOfEvictionStatus"
        type="optionalAlphaNumeric2"/>
    <xs:element
        name="QualityOfLifeStatus"
        type="optionalAlphaNumeric2"/>
  <xs:annotation>
    <xs:documentation> Elements for Discharge Details </xs:documentation>
  </xs:annotation>
  <xs:element
      name="DateContactEnded"
      type="xs:date"/>
  <xs:element
      name="ReasonContactEnded"
      type="optionalAlphaNumeric2"/>
</xs:schema>
