<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- Elementi -->
	<xs:element name="Accertamenti" type="Stringa600Type"/>
	<xs:element name="ASL" type="AslType"/>
	<xs:element name="AssenzaPrognosi" type="SINOType"/>
	<xs:element name="AutopsiaGiudiziaria" type="SINOType"/>
	<xs:element name="Cap" type="CapType"/>
	<xs:element name="CauseCircostanze" type="Stringa600Type"/>
	<xs:element name="Certificato_Medico" type="CertificatoMedicoType"/>
	<xs:element name="Cittadinanza" type="Stringa80Type"/>
	<xs:element name="Civico" type="CivicoType"/>
	<xs:element name="CodiceFiscale" type="CodiceFiscaleType"/>
	<xs:element name="CodiceISTAT" type="IstatType"/>
	<xs:element name="Cognome" type="Stringa30Type"/>
	<xs:element name="ComuneEstero" type="Stringa70Type"/>
	<xs:element name="DataAbbandonoLavoro" type="DateType"/>
	<xs:element name="DataDecesso" type="DateType"/>
	<xs:element name="DataEvento" type="DateType"/>
	<xs:element name="DataFinePrognosi" type="DateType"/>
	<xs:element name="DataInizioPrognosi" type="DateType"/>
	<xs:element name="DataNascita" type="DateType"/>
	<xs:element name="DataVisita" type="DateType"/>
	<xs:element name="DatiComunali" type="DatiComunaliType"/>
	<xs:element name="DescrizioneEsitoLesioni" type="Stringa400Type"/>
	<xs:element name="DescrizioneInvaliditaRiconosciute" type="Stringa400Type"/>
	<xs:element name="Diagnosi" type="Stringa400Type"/>
	<xs:element name="Domicilio" type="DomicilioType"/>
	<xs:element name="DomicilioCureLavoratore" type="DomicilioCureLavoratoreType"/>
	<xs:element name="DomicilioLavoratore" type="DomicilioLavoratoreType"/>
	<xs:element name="ElencoCertificati" type="ElencoCertificatiType"/>
	<xs:element name="Email" type="EmailType"/>
	<xs:element name="EsameObiettivo" type="Stringa600Type"/>
	<xs:element name="EsitoLesioni" type="SINOType" />
	<xs:element name="InvaliditaRiconosciute" type="SINOType"/>
	<xs:element name="LuogoEvento" type="Stringa130Type"/>
	<xs:element name="MalattiaInfettiva" type="SINOType"/>
	<xs:element name="MansioneAttuale" type="Stringa70Type"/>
	<xs:element name="Nazione" type="NazioneType"/>
	<xs:element name="Nome" type="Stringa30Type"/>
	<xs:element name="Numero" type="NumTelefonoType"/>
	<xs:element name="OraAbbandonoLavoro" type="xs:time"/>
	<xs:element name="OraEvento" type="xs:time"/>
	<xs:element name="OsservazioniMedico" type="Stringa400Type"/>
	<xs:element name="Pec" type="EmailType"/>
	<xs:element name="PrefissoInternazionale" type="PrefInternazionaleType"/>
	<xs:element name="Prescrizioni" type="Stringa400Type"/>
	<xs:element name="Presso" type="Stringa80Type"/>
	<xs:element name="PrognosiR" type="SINOType"/>
	<xs:element name="RagioneSociale" type="RagioneSocialeType"/>
	<xs:element name="ResidenzaLavoratore" type="ResidenzaLavoratoreType"/>
	<xs:element name="Ricoverato" type="SINOType"/>
	<xs:element name="RiscontroDiagnostico" type="SINOType"/>
	<xs:element name="Sesso" type="FMType"/>
	<xs:element name="StrutturaRicovero" type="Stringa400Type"/>
	<xs:element name="TipoCertificato" type="PCDType"/>
<!-- Definizione Tipi Complessi -->
	<xs:complexType name="ElencoCertificatiType">
		<xs:sequence>
			<xs:element ref="Certificato_Medico" maxOccurs="20"/>
		</xs:sequence>
		<xs:attribute name="Versione" type="VersioneType"/>
		<xs:attribute name="CodiceAzienda" type="CodiceFornitoreType" use="optional"/>
	</xs:complexType>

	<xs:complexType name="CertificatoMedicoType">
		<xs:sequence>
			<xs:element name="Medico" type="DatiMedicoType"/>
			<xs:element name="DatiCertificato" type="DatiCertificatoType"/>
			<xs:element name="DatoreLavoro" type="DatoreLavoroType"/>
			<xs:element name="Lavoratore" type="LavoratoreType"/>
			<xs:element name="Evento" type="EventoType"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="LavoratoreType">
		<xs:sequence>
			<xs:element name="Anagrafica" type="AnagraficaType"/>
			<xs:element ref="ResidenzaLavoratore"/>
			<xs:element ref="DomicilioLavoratore" minOccurs="0"/>
			<xs:element ref="DomicilioCureLavoratore" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="DatiCertificatoType">
		<xs:sequence>
            <xs:element name="IdentificativoCertificatoUtente" type="IdentificativoCertificatoType"/>
			<xs:element ref="CodiceISTAT"/>
			<xs:element ref="DataVisita"/>
			<xs:element ref="MalattiaInfettiva"/>
			<xs:element ref="DataDecesso" minOccurs="0"/>
			<xs:element ref="AutopsiaGiudiziaria" minOccurs="0"/>
			<xs:element ref="RiscontroDiagnostico" minOccurs="0"/>
			<xs:element ref="EsitoLesioni" minOccurs="0"/>
			<xs:element ref="DescrizioneEsitoLesioni" minOccurs="0"/>
			<xs:element ref="TipoCertificato"/>
			<xs:element ref="EsameObiettivo" minOccurs="0"/>
			<xs:element ref="Diagnosi"/>
			<xs:choice minOccurs="0">
				<xs:element name="PrognosiNormale" type="PrognosiNormaleType"/>
				<xs:element ref="AssenzaPrognosi"/>
				<xs:element name="PrognosiRiservata" type="PrognosiRiservataType"/>
			</xs:choice>
			<xs:element ref="Prescrizioni" minOccurs="0"/>
			<xs:element ref="OsservazioniMedico" minOccurs="0"/>	
			<xs:element ref="InvaliditaRiconosciute" minOccurs="0"/>
			<xs:element ref="DescrizioneInvaliditaRiconosciute" minOccurs="0"/>			
			<xs:element ref="Ricoverato" minOccurs="0"/>
			<xs:element ref="StrutturaRicovero" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="EventoType">
		<xs:sequence>
			<xs:element ref="DataEvento"/>
			<xs:element ref="OraEvento" minOccurs="0"/>
			<xs:element ref="LuogoEvento"/>
			<xs:element ref="DatiComunali"/>
			<xs:element name="Indirizzo" type="IndirizzoType" minOccurs="0"/>
			<xs:element ref="Civico" minOccurs="0"/>
			<xs:element ref="DataAbbandonoLavoro" minOccurs="0"/>
			<xs:element ref="OraAbbandonoLavoro" minOccurs="0"/>
			<xs:element ref="CauseCircostanze"/>
			<xs:element ref="Accertamenti" minOccurs="0"/>				
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="DatoreLavoroType">
		<xs:sequence>
			<xs:element ref="RagioneSociale" minOccurs="0"/>
			<xs:element ref="Domicilio" minOccurs="0"/>
			<xs:element ref="MansioneAttuale" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="DatiMedicoType">
		<xs:sequence>
			<xs:element ref="CodiceFiscale"/>
			<xs:element name="Cognome" type="Stringa30TypeNoBlank"/>
			<xs:element name="Nome" type="Stringa30TypeNoBlank"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="AnagraficaType">
		<xs:sequence>
			<xs:element ref="CodiceFiscale"/>
			<xs:element ref="Cognome"/>
			<xs:element ref="Nome"/>
			<xs:element ref="Sesso"/>
			<xs:element ref="DataNascita"/>
			<xs:element ref="Cittadinanza"/>
			<xs:element ref="DatiComunali"/>			
			<xs:element ref="Email" minOccurs="0"/>
			<xs:element ref="Pec" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ResidenzaLavoratoreType">
		<xs:sequence>
			<xs:element name="Indirizzo" type="IndirizzoType"/>
			<xs:element ref="Cap" minOccurs="0"/>
			<xs:element ref="DatiComunali"/>
			<xs:element ref="Civico"/>
			<xs:element ref="ASL" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="DomicilioLavoratoreType">
		<xs:sequence>
			<xs:element name="Indirizzo" type="IndirizzoType" minOccurs="0"/>
			<xs:element ref="Cap" minOccurs="0"/>
			<xs:element ref="DatiComunali" minOccurs="0"/>
			<xs:element ref="Civico" minOccurs="0" />
			<xs:element ref="ASL" minOccurs="0"/>
			<xs:element name="RecapitiTelefonici" type="RecapitiTelefoniciType" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="DomicilioCureLavoratoreType">
		<xs:sequence>
			<xs:element name="Indirizzo" type="IndirizzoType" minOccurs="0"/>
			<xs:element ref="Cap" minOccurs="0"/>
			<xs:element ref="DatiComunali" minOccurs="0"/>
			<xs:element ref="Civico" minOccurs="0"/>
			<xs:element ref="ASL" minOccurs="0"/>
			<xs:element ref="Presso" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="DatiComunaliType">
		<xs:sequence>
			<xs:element ref="CodiceISTAT" minOccurs="0"/>
			<xs:element ref="Nazione"/>
			<xs:element ref="ComuneEstero" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="RecapitiTelefoniciType">
		<xs:all>
			<xs:element name="Telefono" type="TelefonoType" minOccurs="0"/>
			<xs:element name="Cellulare" type="TelefonoType" minOccurs="0"/>
		</xs:all>
	</xs:complexType>
	
	<xs:complexType name="TelefonoType">
		<xs:all>
			<xs:element ref="PrefissoInternazionale"/>
			<xs:element ref="Numero"/>
		</xs:all>
	</xs:complexType>

	<xs:complexType name="PrognosiNormaleType">
		<xs:sequence>
			<xs:element ref="DataInizioPrognosi"/>
			<xs:element ref="DataFinePrognosi"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="PrognosiRiservataType">
		<xs:sequence>
			<xs:element ref="PrognosiR" />
			<xs:element ref="DataInizioPrognosi" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
	
	<xs:complexType name="DomicilioType">
		<xs:sequence>
			<xs:element name="Indirizzo" type="IndirizzoDatoreType" minOccurs="0"/>
			<xs:element ref="Cap" minOccurs="0"/>
			<xs:element ref="CodiceISTAT" minOccurs="0"/>		
			<xs:element ref="Civico" minOccurs="0"/>
			<xs:element ref="ASL" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
	<!-- Definizione Tipi Semplici -->	
	<xs:simpleType name="PrefInternazionaleType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="5"/>
			<xs:pattern value="[0-9+]{0,5}"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="NumTelefonoType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="15"/>
			<xs:pattern value="[0-9]{0,15}"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="AslType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="5"/>
			<xs:pattern value="[a-zA-Z]{2}\d{3}"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="CapType">
		<xs:restriction base="xs:string">
			<xs:pattern value="\d{5}"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="CivicoType">
		<xs:restriction base="xs:string">
			<xs:pattern value="[a-zA-Z0-9/.\\-]{1,5}"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="CodiceFornitoreType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="9"/>
			<xs:pattern value="\d+"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="CodiceFiscaleType">
		<xs:restriction base="xs:string">
			<xs:pattern value="[A-Z]{6}[0-9LMNPQRSTUV]{2}[A-Z][0-9LMNPQRSTUV]{2}[A-Z][0-9LMNPQRSTUV]{3}[A-Z]"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="FMType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="M"/>
			<xs:enumeration value="F"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="IndirizzoType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="50"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="IndirizzoDatoreType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="50"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="IstatType">
		<xs:restriction base="xs:string">
			<xs:pattern value="\d{6}"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="NazioneType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="4"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="PCDType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="P"/>
			<xs:enumeration value="C"/>
			<xs:enumeration value="D"/>
			<!--  -->
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="RagioneSocialeType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="70"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="SINOType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="S"/>
			<xs:enumeration value="N"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa30Type">
		<xs:restriction base="xs:string">
			<xs:maxLength value="30"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa30TypeNoBlank">
		<xs:restriction base="xs:string">
			<xs:minLength value="1"/>
			<xs:maxLength value="30"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa70Type">
		<xs:restriction base="xs:string">
			<xs:maxLength value="70"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa80Type">
		<xs:restriction base="xs:string">
			<xs:maxLength value="80"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa100Type">
		<xs:restriction base="xs:string">
			<xs:maxLength value="100"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa130Type">
		<xs:restriction base="xs:string">
			<xs:maxLength value="130"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa150Type">
		<xs:restriction base="xs:string">
			<xs:maxLength value="150"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa400Type">
		<xs:restriction base="xs:string">
			<xs:maxLength value="400"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Stringa600Type">
		<xs:restriction base="xs:string">
			<xs:maxLength value="600"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="DateType">
		<xs:restriction base="xs:date">
			<xs:minInclusive value="1900-01-01"/>
			<xs:pattern value="\d{4}-\d{2}-\d{2}"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="IdentificativoCertificatoType">
		<xs:restriction base="xs:string">
			<xs:maxLength value="20"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="EmailType">
		<xs:restriction base="xs:string"> 
			<xs:pattern value="[^@]+@[^\.]+\..+"/>
			<xs:maxLength value="200"/>
		</xs:restriction> 
	</xs:simpleType>
	<xs:simpleType name="VersioneType">
		<xs:restriction base="xs:string"> 
			<xs:pattern value="2.1"/>
		</xs:restriction> 
	</xs:simpleType>
</xs:schema>