<?xml version="1.0" encoding="UTF-8"?>
<schema
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:ofm="http://minameddelanden.gov.se/schema/OfficialMatter/v4"
    xmlns:commonv4="http://minameddelanden.gov.se/schema/Common/v4"
    targetNamespace="http://minameddelanden.gov.se/schema/OfficialMatter/v4"
    elementFormDefault="qualified"
    version="4.0">

    <import namespace="http://minameddelanden.gov.se/schema/Common/v4" schemaLocation="Common.xsd"/>

    <element name="officialMatterExtension" type="ofm:officialMatterExtensionType"/>

    <complexType name="officialMatterExtensionType">
        <annotation>
            <documentation xml:lang="en">Covers event information regarding an event in an official matter.
                If present, this message is an event message regarding an official matter. In the
                documentation this is named "Kundarende".
            </documentation>
            <documentation xml:lang="sv">Konkret beskrivning av ett ärende enligt schema.
            </documentation>
        </annotation>
        <sequence>
            <element ref="commonv4:timestamp">
                <annotation>
                    <documentation xml:lang="en">The creation time and date for this message, originates
                        from the sending system.
                    </documentation>
                    <documentation xml:lang="sv">Obligatorisk. Skapandetid och datum för ärendet. Anges i
                        meddelandetexten, antingen med bara datum eller, då lämpligt, även med klockslag.
                    </documentation>
                </annotation>
            </element>
            <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded">
                <annotation>
                    <documentation xml:lang="en"></documentation>
                    <documentation xml:lang="sv">För framåtkompatibilitet kan man nyttja t.ex. ett externt
                        schema för att validera annan information kopplat till ett ärende.
                    </documentation>
                </annotation>
            </any>
            <element name="Identity" minOccurs="0">
                <annotation>
                    <documentation xml:lang="en">The identity of an official matter is not mandatory, but it can be
                        used to trace message conversations in the mailbox system and to enhance the experience
                        for the end user.
                    </documentation>
                    <documentation xml:lang="en">Identitet för ett ärende. Kan användas för att spåra
                        meddelandekonversationer i brevlådan.
                    </documentation>
                </annotation>
                <complexType>
                    <sequence>
                        <element name="EventId" type="ofm:idStringRestriction" minOccurs="0">
                            <annotation>
                                <documentation xml:lang="en">The globally unique identification (GUID) for this
                                    message in an official matter. This is always unique. In documentation this
                                    is named "HandelseID (kopplat till Kundhandelse)".
                                </documentation>
                                <documentation xml:lang="sv">HändelseID. En globalt unik identitet
                                    för händelsen.
                                </documentation>
                            </annotation>
                        </element>
                        <element name="OfficialMatterId" type="ofm:idStringRestriction" minOccurs="0">
                            <annotation>
                                <documentation xml:lang="en">Identification of the official matter. Many messages
                                    can belong to an official matter. In documentation this is named "KundarendeID
                                    (kopplat till ett Kundarende)".
                                </documentation>
                                <documentation xml:lang="sv">UrsprungshändelseID. En referens till ett tidigare
                                    ärende som gav upphov till detta ärende. Många meddelanden kan tillhöra
                                    en händelse.
                                </documentation>
                            </annotation>
                        </element>
                        <element name="PrecedingEventId" type="ofm:idStringRestriction" minOccurs="0">
                            <annotation>
                                <documentation xml:lang="en">The EventID of a previous event message. This can be a
                                    link between separate messages. Regardless of whether they belong to the same
                                    official matter if they at all have an id of an official matter. In
                                    documentation this is named "KorrespondensID (koppling mellan olika
                                    kundhandelsemeddelanden".
                                </documentation>
                                <documentation xml:lang="sv">KorrespondensID. En referens i ett ärende som
                                    avsändaren kan använda för att knyta samman korrespondenstrådar mellan parterna.
                                </documentation>
                            </annotation>
                        </element>
                    </sequence>
                </complexType>
            </element>
            <element name="MatterSubject" minOccurs="0">
                <annotation>
                    <documentation xml:lang="en">A subtype of subject, stating what this matter concerns. It can be
                        used to loosely couple event messages (that do not have a hard coupling via correlationID),
                        and could even span different government officials or other message producers. In
                        documentation this is named "Kundamne".
                    </documentation>
                    <documentation xml:lang="sv">Kundämne. Konkret information som anger vad som gäller för
                        just detta ärende.
                    </documentation>
                </annotation>
                <simpleType>
                    <restriction base="string">
                        <maxLength value="2000"/>
                    </restriction>
                </simpleType>
            </element>
            <element name="EventType" minOccurs="0">
                <annotation>
                    <documentation xml:lang="en">Describes a change of state, what new state an event puts an
                        ongoing matter in. This is a textual representation, however it should be restricted
                        so that unification between different actors is achieved. This restriction is not
                        described in the schema but rather in the documents governing the rules of document
                        content. In documentation this is named "Handelsetyp"
                    </documentation>
                    <documentation xml:lang="sv">Händelsetyp. Kan användas av enskilda grupper av avsändare
                        för att möjligggöra en bättre samordning med andra, kompletterande tjänster.
                    </documentation>
                </annotation>
                <simpleType>
                    <restriction base="string">
                        <maxLength value="2000"/>
                    </restriction>
                </simpleType>
            </element>
            <element name="MatterStatus" minOccurs="0">
                <annotation>
                    <documentation xml:lang="en">The state of an official matter, connected to a single event and
                        message. During the course of time, a matter can have different states. Each event can
                        change the state from one state to another, where the message/event keeps it state
                        presentation as an instant view of the matter. There can be three different states.
                    </documentation>
                    <documentation xml:lang="sv">Kundeärendestatus. Anger ansvarsförhållandet för att driva
                        ärendet vidare framåt. Ärendet kan ha följande status:
                        1) Åtgärd krävs av den enskilde,
                        2) Bearbetning pågår, ingen åtgärd krävs av den enskilde,
                        3) Avslutat, avsändaren kommer inte att vidta fler åtgärdet. Benämns i termerna
                        ”senderinitiative, recipientinitiative och closed”.
                    </documentation>
                </annotation>
                <simpleType>
                    <restriction base="string">
                        <enumeration value="senderinitiative">
                            <annotation>
                                <documentation xml:lang="en">This means that the sender has taken an initiative in a
                                    matter.
                                </documentation>
                                <documentation xml:lang="sv">Betyder att avsändaren har initiativet i ett ärende.
                                </documentation>
                            </annotation>
                        </enumeration>
                        <enumeration value="recipientinitiative">
                            <annotation>
                                <documentation xml:lang="en">This means that the recipient should take action in
                                    a matter, i.e. provide some kind of information in order to take the matter
                                    to the next step.
                                </documentation>
                                <documentation xml:lang="sv">Mottagaren har initiativet, åtgärd krävs av den enskilde.</documentation>
                            </annotation>
                        </enumeration>
                        <enumeration value="closed">
                            <annotation>
                                <documentation xml:lang="en">The matter is finished, will (probably) not generate any new events.
                                </documentation>
                                <documentation xml:lang="sv">Ärendet är avslutat.</documentation>
                            </annotation>
                        </enumeration>
                    </restriction>
                </simpleType>
            </element>
        </sequence>
    </complexType>

    <simpleType name="idStringRestriction">
        <restriction base="string">
            <maxLength value="255"/>
        </restriction>
    </simpleType>
</schema>
