<?xml version="1.0"?>
<schema targetNamespace="http://ws.infotorg.no/xml/NAV/Aareg2/2015-09-21/Aareg2.xsd"
        xmlns:tns="http://ws.infotorg.no/xml/NAV/Aareg2/2015-09-21/Aareg2.xsd"
        xmlns="http://www.w3.org/2001/XMLSchema">

    <annotation>
        <documentation xml:lang="no">
            Datatyper for Arbeidsgiver- og arbeidstakerregisteret.

            © 2015 EVRY Norge AS
            Forfatter: Morten Haugen &lt;morten.haugen@ifront.no&gt;
        </documentation>
    </annotation>

    <element name="hentAntallAnsatte">
        <complexType>
            <sequence>
                <element name="orgnr" type="string" minOccurs="1" maxOccurs="1"/>
            </sequence>
        </complexType>
    </element>

    <element name="AntallAnsatte">
        <complexType>
            <sequence>
                <group ref="tns:status"/>
                <sequence minOccurs="0">
                    <group ref="tns:arbeidsgiver"/>
                    <element name="arbeidstakere" type="int" nillable="true"/>
                </sequence>
            </sequence>
        </complexType>
    </element>

    <group name="status">
        <sequence>
            <element name="statuskode">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="komplett"/>
                        <enumeration value="ikke_entydig"/>
                        <enumeration value="ingen"/>
                        <enumeration value="fortrolig"/>
                        <enumeration value="strengt_fortrolig"/>
                        <enumeration value="trunkert"/>
                        <enumeration value="utilgjengelig"/>
                        <enumeration value="opphoert"/>
                    </restriction>
                </simpleType>
            </element>
            <element name="statustekst" type="string"/>
        </sequence>
    </group>

    <group name="arbeidsforholdFilter">
        <sequence>
            <element name="statusArbeidsforhold" minOccurs="0">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="alle"/>
                        <enumeration value="aktiv"/>
                        <enumeration value="opphoert"/>
                    </restriction>
                </simpleType>
            </element>
            <element name="lovgivning" minOccurs="0">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="alle"/>
                        <enumeration value="ny"/>
                        <enumeration value="gammel"/>
                    </restriction>
                </simpleType>
            </element>
        </sequence>
    </group>

    <group name="enhet_treff">
        <sequence>
            <element name="orgnr" type="string"/>
            <element name="orgnrHovedenhet" type="string"/>
            <element name="navn" type="string"/>
            <element name="fadresse1" type="string"/>
            <element name="fadresse2" type="string"/>
            <element name="fadresse3" type="string"/>
            <element name="fpostnr" type="string"/>
            <element name="fpoststed" type="string"/>
            <element name="padresse1" type="string"/>
            <element name="padresse2" type="string"/>
            <element name="padresse3" type="string"/>
            <element name="ppostnr" type="string"/>
            <element name="ppoststed" type="string"/>
            <element name="kommunenr" type="string"/>
            <element name="kommune" type="string"/>
            <element name="opphoert" type="string"/>
            <element name="enhkode" type="string"/>
            <element name="enhtypeBeskr" type="string"/>
            <element name="historisk" type="boolean" minOccurs="0"/>
        </sequence>
    </group>

    <simpleType name="enhetstype">
        <restriction base="string">
            <enumeration value="juridisk"/>
            <enumeration value="bedrift"/>
            <enumeration value="alle"/>
        </restriction>
    </simpleType>

    <element name="hentTrefflisteArbeidsgiver">
        <complexType>
            <sequence>
                <choice>
                    <sequence>
                        <element name="orgnavn" type="string"/>
                        <element name="kommunenr" type="string" minOccurs="0"/>
                        <element name="postnr" type="string" minOccurs="0"/>
                        <element name="fylkenr" type="string" minOccurs="0"/>
                        <element name="inkluderOpphoerte" type="boolean"/>
                    </sequence>
                    <sequence>
                        <element name="etternavn" type="string"/>
                        <element name="fornavn" type="string" minOccurs="0"/>
                        <element name="mellomnavn" type="string" minOccurs="0"/>
                        <element name="fdato" type="date" minOccurs="0"/>
                        <element name="faarfra" minOccurs="0">
                            <simpleType>
                                <restriction base="positiveInteger">
                                    <totalDigits value="4" fixed="true"/>
                                    <minInclusive value="1900"/>
                                </restriction>
                            </simpleType>
                        </element>
                        <element name="faartil" minOccurs="0">
                            <simpleType>
                                <restriction base="positiveInteger">
                                    <totalDigits value="4" fixed="true"/>
                                    <minInclusive value="1900"/>
                                </restriction>
                            </simpleType>
                        </element>
                        <element name="alderfra" type="int" minOccurs="0"/>
                        <element name="aldertil" type="int" minOccurs="0"/>
                        <element name="kjoenn" minOccurs="0">
                            <simpleType>
                                <restriction base="string">
                                    <enumeration value="M"/>
                                    <enumeration value="K"/>
                                </restriction>
                            </simpleType>
                        </element>
                    </sequence>
                </choice>
                <element name="fonetisk" type="boolean"/>
            </sequence>
        </complexType>
    </element>

    <element name="TrefflisteArbeidsgiver">
        <complexType>
            <sequence>
                <group ref="tns:status"/>
                <element name="arbeidsgivere">
                    <complexType>
                        <sequence>
                            <element name="antall" type="int"/>
                            <element name="arbeidsgiver" minOccurs="0" maxOccurs="unbounded">
                                <complexType>
                                    <sequence>
                                        <group ref="tns:enhet_treff"/>
                                    </sequence>
                                </complexType>
                            </element>
                        </sequence>
                    </complexType>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="hentArbeidsgiver">
        <complexType>
            <sequence>
                <element name="arbeidsgiverId" type="string"/>
                <group ref="tns:arbeidsforholdFilter"/>
                <element name="datofra" type="date" minOccurs="0"/>
                <element name="datotil" type="date" minOccurs="0"/>
            </sequence>
        </complexType>
    </element>

    <group name="arbeidsgiver">
        <sequence>
            <element name="orgnr" type="string"/>
            <element name="orgnrHovedenhet" type="string"/>
            <element name="navnHovedenhet" type="string"/>
            <element name="navn" type="string"/>
            <element name="kjoenn" type="string" minOccurs="0"/>
            <element name="alder" type="string" minOccurs="0"/>
            <element name="fadresse1" type="string"/>
            <element name="fadresse2" type="string"/>
            <element name="fadresse3" type="string"/>
            <element name="fpostnr" type="string"/>
            <element name="fpoststed" type="string"/>
            <element name="padresse1" type="string"/>
            <element name="padresse2" type="string"/>
            <element name="padresse3" type="string"/>
            <element name="ppostnr" type="string"/>
            <element name="ppoststed" type="string"/>
            <element name="kommunenr" type="string"/>
            <element name="kommune" type="string"/>
            <element name="landkode" type="string"/>
            <element name="landtekst" type="string"/>
            <element name="etablert" type="string"/>
            <element name="enhkode" type="string"/>
            <element name="enhtypeBeskr" type="string"/>
            <element name="opphoert" type="boolean"/>
            <element name="virksomhetsoverdragelse" type="string" minOccurs="0"/>
        </sequence>
    </group>

    <element name="Arbeidsgiver">
        <complexType>
            <sequence>
                <group ref="tns:status"/>
                <sequence minOccurs="0">
                    <group ref="tns:arbeidsgiver"/>
                    <element name="arbeidstakere" type="boolean" nillable="true"/>
                    <element name="historikk" type="boolean" nillable="true"/>
                    <element name="underenheter" minOccurs="0">
                        <complexType>
                            <sequence>
                                <element name="antall" type="int"/>
                                <element name="underenhet" minOccurs="0" maxOccurs="unbounded">
                                    <complexType>
                                        <sequence>
                                            <group ref="tns:enhet_treff"/>
                                        </sequence>
                                    </complexType>
                                </element>
                            </sequence>
                        </complexType>
                    </element>
                    <element name="arbeidsforholdListe" minOccurs="0">
                        <complexType>
                            <sequence>
                                <element name="antall" type="int"/>
                                <element name="antallTot" type="int"/>
                                <element name="arbeidsforhold" minOccurs="0" maxOccurs="unbounded">
                                    <complexType>
                                        <sequence>
                                            <group ref="tns:arbeidsforholdOversikt"/>
                                        </sequence>
                                    </complexType>
                                </element>
                            </sequence>
                        </complexType>
                    </element>
                </sequence>
            </sequence>
        </complexType>
    </element>

    <group name="arbeidsavtale">
        <sequence>
            <element name="avtalt_arbeidstimer_per_uke" type="decimal"/>
            <element name="stillingsprosent" type="decimal"/>
        </sequence>
    </group>

    <simpleType name="ansattstatus">
        <restriction base="string">
            <enumeration value="aktiv"/>
            <enumeration value="opphoert"/>
            <enumeration value="alle"/>
        </restriction>
    </simpleType>

    <element name="hentArbeidstakere">
        <complexType>
            <sequence>
                <element name="orgnr" type="string"/>
                <element name="ansattstatus" type="tns:ansattstatus"/>
            </sequence>
        </complexType>
    </element>

    <element name="Arbeidstakere">
        <complexType>
            <sequence>
                <group ref="tns:status"/>
                <sequence minOccurs="0">
                    <element name="orgnr" type="string"/>
                    <element name="orgnrHovedenhet" type="string"/>
                    <element name="navn" type="string"/>
                    <element name="kommunenr" type="string"/>
                    <element name="kommunenavn" type="string"/>
                    <element name="arbeidstakereListe">
                        <complexType>
                            <sequence>
                                <element name="antall" type="int"/>
                                <element name="arbeidstaker" minOccurs="0" maxOccurs="unbounded">
                                    <complexType>
                                        <sequence>
                                            <element name="foedselsnr" type="string"/>
                                            <element name="etternavn" type="string"/>
                                            <element name="fornavn" type="string"/>
                                            <element name="mellomnavn" type="string"/>
                                            <element name="begyntdato" type="string"/>
                                            <element name="sluttetdato" type="string"/>
                                        </sequence>
                                    </complexType>
                                </element>
                            </sequence>
                        </complexType>
                    </element>
                </sequence>
            </sequence>
        </complexType>
    </element>

    <element name="hentAntallArbeidstakere">
        <complexType>
            <sequence>
                <element name="orgnr" type="string"/>
            </sequence>
        </complexType>
    </element>

    <element name="AntallArbeidstakere">
        <complexType>
            <sequence>
                <group ref="tns:status"/>
                <sequence minOccurs="0">
                    <group ref="tns:arbeidsgiver"/>
                    <element name="arbeidstakere" type="int"/>
                </sequence>
            </sequence>
        </complexType>
    </element>

    <element name="hentArbeidstaker">
        <complexType>
            <sequence>
                <element name="foedselsnr" type="string"/>
                <group ref="tns:arbeidsforholdFilter"/>
            </sequence>
        </complexType>
    </element>

    <element name="Arbeidstaker">
        <complexType>
            <sequence>
                <group ref="tns:status"/>
                <sequence minOccurs="0">
                    <element name="foedselsnr" type="string"/>
                    <element name="etternavn" type="string"/>
                    <element name="fornavn" type="string"/>
                    <element name="mellomnavn" type="string"/>
                    <element name="kjoenn" type="string"/>
                    <element name="alder" type="int"/>
                    <element name="arbeidsforholdListe">
                        <complexType>
                            <sequence>
                                <element name="antall" type="int"/>
                                <element name="arbeidsforhold" minOccurs="0" maxOccurs="unbounded">
                                    <complexType>
                                        <sequence>
                                            <group ref="tns:arbeidsforholdOversikt"/>
                                        </sequence>
                                    </complexType>
                                </element>
                            </sequence>
                        </complexType>
                    </element>
                </sequence>
            </sequence>
        </complexType>
    </element>

    <element name="hentTrefflisteArbeidstaker">
        <complexType>
            <sequence>
                <element name="etternavn" type="string"/>
                <element name="fornavn" type="string" minOccurs="0"/>
                <element name="mellomnavn" type="string" minOccurs="0"/>
                <element name="fonetisk" type="boolean"/>
                <element name="fdato" type="date" minOccurs="0"/>
                <element name="faarfra" minOccurs="0">
                    <simpleType>
                        <restriction base="positiveInteger">
                            <totalDigits value="4" fixed="true"/>
                            <minInclusive value="1900"/>
                        </restriction>
                    </simpleType>
                </element>
                <element name="faartil" minOccurs="0">
                    <simpleType>
                        <restriction base="positiveInteger">
                            <totalDigits value="4" fixed="true"/>
                            <minInclusive value="1900"/>
                        </restriction>
                    </simpleType>
                </element>
                <element name="alderfra" type="int" minOccurs="0"/>
                <element name="aldertil" type="int" minOccurs="0"/>
                <element name="kjoenn" minOccurs="0">
                    <simpleType>
                        <restriction base="string">
                            <enumeration value="M"/>
                            <enumeration value="K"/>
                        </restriction>
                    </simpleType>
                </element>
                <element name="maksAntall" type="int" minOccurs="0"/>
            </sequence>
        </complexType>
    </element>

    <element name="TrefflisteArbeidstaker">
        <complexType>
            <sequence>
                <group ref="tns:status"/>
                <element name="arbeidstakere">
                    <complexType>
                        <sequence>
                            <element name="antall" type="int"/>
                            <element name="arbeidstaker" minOccurs="0" maxOccurs="unbounded">
                                <complexType>
                                    <sequence>
                                        <group ref="tns:arbeidstaker_treff"/>
                                    </sequence>
                                </complexType>
                            </element>
                        </sequence>
                    </complexType>
                </element>
            </sequence>
        </complexType>
    </element>

    <group name="arbeidstaker_treff">
        <sequence>
            <element name="fodselsnr" type="string"/>
            <element name="etternavn" type="string"/>
            <element name="fornavn" type="string"/>
            <element name="mellomnavn" type="string"/>
            <element name="kjoenn" type="string"/>
            <element name="alder" type="int"/>
            <element name="historisk" minOccurs="0" type="boolean"/>
        </sequence>
    </group>

    <group name="arbeidsforhold">
        <sequence>
            <element name="arbeidsforholdId" type="string"/>
            <element name="agArbeidsforholdId" type="string" nillable="true"/>
            <element name="arbeidsgiver">
                <complexType>
                    <sequence>
                        <element name="arbeidsgiverId" type="string"/>
                        <element name="navn" type="string"/>
                        <element name="enhkode" type="string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="opplysningspliktig" minOccurs="0">
                <complexType>
                    <sequence>
                        <element name="arbeidsgiverId" type="string"/>
                        <element name="navn" type="string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="arbeidstaker">
                <complexType>
                    <sequence>
                        <element name="efnavn" type="string"/>
                        <element name="arbeidstakerId" type="string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="begyntdato" type="date"/>
            <element name="sluttetdato" type="date" minOccurs="0"/>
            <element name="registrertFoersteGang" type="date" minOccurs="0"/>
            <element name="arbeidsforholdstype" type="string"/>
            <element name="arbeidsforholdInnrapportertEtterAOrdningen" type="boolean"/>
            <element name="datoSistFunksjoneltOppdatert" type="date" minOccurs="0"/>
            <element name="datoSistBekreftet" type="date" minOccurs="0"/>
            <element name="arbeidsavtaler">
                <complexType>
                    <sequence>
                        <element name="arbeidsavtale" minOccurs="0" maxOccurs="unbounded">
                            <complexType>
                                <sequence>
                                    <element name="arbeidstidsordning" type="string" minOccurs="0"/>
                                    <element name="avloenningstype" type="string" minOccurs="0"/>
                                    <element name="yrkeskode" type="string"/>
                                    <element name="yrkestittel" type="string"/>
                                    <element name="avtaltArbeidstimerPerUke" type="string" minOccurs="0"/>
                                    <element name="timerIFullStilling" type="string" minOccurs="0"/>
                                    <element name="stillingsprosent" type="string" minOccurs="0"/>
                                    <element name="berAntTimerPerUke" type="string" minOccurs="0"/>
                                    <element name="sisteLoennsendringsdato" type="string" minOccurs="0"/>
                                    <element name="gyldighetsperiode_fom" type="date"/>
                                    <element name="gyldighetsperiode_tom" type="date" minOccurs="0"/>
                                    <element name="antallTimerGammeltAa" type="decimal" minOccurs="0"/>
                                    <element name="endringsdatoStillingsprosent" type="date" minOccurs="0"/>
                                    <element name="fartsomraade" type="string" minOccurs="0"/>
                                    <element name="skipsregister" type="string" minOccurs="0"/>
                                    <element name="skipstype" type="string" minOccurs="0"/>
                                </sequence>
                            </complexType>
                        </element>
                    </sequence>
                </complexType>
            </element>
            <element name="antallTimerForTimeloennet" minOccurs="0">
                <complexType>
                    <sequence>
                        <element name="timerIPerioden" minOccurs="0" maxOccurs="unbounded">
                            <complexType>
                                <sequence>
                                    <element name="periode" minOccurs="0">
                                        <complexType>
                                            <sequence>
                                                <element name="fom" type="date" minOccurs="0"/>
                                                <element name="tom" type="date" minOccurs="0"/>
                                            </sequence>
                                        </complexType>
                                    </element>
                                    <element name="antallTimer" type="decimal"/>
                                    <element name="rapporteringsperiode" type="string"/>
                                </sequence>
                            </complexType>
                        </element>
                    </sequence>
                </complexType>
            </element>
            <element name="permisjonOgPermittering" minOccurs="0">
                <complexType>
                    <sequence>
                        <element name="permisjonOgPermitteringIPeriode" minOccurs="0" maxOccurs="unbounded">
                            <complexType>
                                <sequence>
                                    <element name="permisjonsId" type="string"/>
                                    <element name="periode">
                                        <complexType>
                                            <sequence>
                                                <element name="fom" type="date" minOccurs="0"/>
                                                <element name="tom" type="date" minOccurs="0"/>
                                            </sequence>
                                        </complexType>
                                    </element>
                                    <element name="permisjonsprosent" type="decimal"/>
                                    <element name="permisjonOgPermittering" type="string"/>
                                </sequence>
                            </complexType>
                        </element>
                    </sequence>
                </complexType>
            </element>
            <element name="utenlandsopphold" minOccurs="0">
                <complexType>
                    <sequence>
                        <element name="utenlandsoppholdIPeriode" minOccurs="0" maxOccurs="unbounded">
                            <complexType>
                                <sequence>
                                    <element name="land" type="string"/>
                                    <element name="rapporteringsperiode" type="string"/>
                                    <element name="periode">
                                        <complexType>
                                            <sequence>
                                                <element name="fom" type="date" minOccurs="0"/>
                                                <element name="tom" type="date" minOccurs="0"/>
                                            </sequence>
                                        </complexType>
                                    </element>
                                </sequence>
                            </complexType>
                        </element>
                    </sequence>
                </complexType>
            </element>
            <!--<any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>-->
        </sequence>
    </group>

    <group name="arbeidsforholdOversikt">
        <sequence>
            <element name="arbeidsforholdId" type="string"/>
            <element name="agArbeidsforholdId" type="string" nillable="true"/>
            <element name="arbeidsgiver">
                <complexType>
                    <sequence>
                        <element name="orgnr" type="string"/>
                        <element name="navn" type="string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="arbeidstaker">
                <complexType>
                    <sequence>
                        <element name="efnavn" type="string"/>
                        <element name="arbeidstakerId" type="string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="begyntdato" type="date"/>
            <element name="sluttetdato" type="date" minOccurs="0"/>
            <element name="datoSistBekreftet" type="date" minOccurs="0"/>
            <element name="arbeidsforholdstype" type="string"/>
            <element name="arbeidsforholdInnrapportertEtterAOrdningen" type="boolean"/>
            <element name="arbeidsavtaler">
                <complexType>
                    <sequence>
                        <element name="arbeidsavtale" minOccurs="0" maxOccurs="unbounded">
                            <complexType>
                                <sequence>
                                    <element name="yrkeskode" type="string"/>
                                    <element name="yrkestittel" type="string"/>
                                    <element name="stillingsprosent" type="string" minOccurs="0"/>
                                    <element name="gyldighetsperiode_tom" type="date" minOccurs="0"/>
                                </sequence>
                            </complexType>
                        </element>
                    </sequence>
                </complexType>
            </element>
            <element name="permisjonOgPermittering" minOccurs="0">
                <complexType>
                    <sequence>
                        <element name="permisjonOgPermitteringIPeriode" minOccurs="0" maxOccurs="unbounded">
                            <complexType>
                                <sequence>
                                    <element name="permisjonsId" type="string"/>
                                    <element name="periode">
                                        <complexType>
                                            <sequence>
                                                <element name="fom" type="date" minOccurs="0"/>
                                                <element name="tom" type="date" minOccurs="0"/>
                                            </sequence>
                                        </complexType>
                                    </element>
                                    <element name="permisjonsprosent" type="decimal"/>
                                    <element name="permisjonOgPermittering" type="string"/>
                                </sequence>
                            </complexType>
                        </element>
                    </sequence>
                </complexType>
            </element>
        </sequence>
    </group>


    <element name="hentArbeidsforhold">
        <complexType>
            <sequence>
                <element name="arbeidsforholdId" type="string"/>
                <element name="arbeidstakerId" type="string"/>
            </sequence>
        </complexType>
    </element>

    <element name="Arbeidsforhold">
        <complexType>
            <sequence>
                <group ref="tns:status"/>
                <element name="arbeidsforhold">
                    <complexType>
                        <sequence>
                            <element name="arbeidsforhold" minOccurs="0" maxOccurs="unbounded">
                                <complexType>
                                    <sequence>
                                        <group ref="tns:arbeidsforhold"/>
                                    </sequence>
                                </complexType>
                            </element>
                        </sequence>
                    </complexType>
                </element>
            </sequence>
        </complexType>
    </element>

    <group name="arbeidsforhold_treff">
        <sequence>
            <group ref="tns:arbeidsforholdOversikt"/>
        </sequence>
    </group>

</schema>
