{
    "resourceType": "http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition",
    "resource": "Bundle",
    "id": "ViewDefinition-Medicatiegegevens",
    "title": "Medicatiegebruik en -afspraken",
    "select": [
        {
            "unionAll": [
                {
                    "column": [
                        {
                            "path": "meta.extension('http://hl7.org/fhir/4.0/StructureDefinition/extension-Meta.source').valueUri",
                            "name": "Bron",
                            "description": "Lookup adhv uri (AGB-Z of OID) <code>&lt;adressering-base&gt;/Organization?identifier=&lt;.meta.tag.code&gt;</code> en gebruik dan <code>Organization.name</code>",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "nvt"
                                }
                            ]
                        },
                        {
                            "path": "extension('http://nictiz.nl/fhir/StructureDefinition/zib-Medication-PeriodOfUse').valuePeriod.start",
                            "name": "Start",
                            "description": "",
                            "type": "dateTime",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksperiode::TijdsInterval/startDatumTijd"
                                }
                            ]
                        },
                        {
                            "path": "extension('http://nictiz.nl/fhir/StructureDefinition/zib-Medication-PeriodOfUse').valuePeriod.end",
                            "name": "Eind",
                            "description": "",
                            "type": "dateTime",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksperiode::TijdsInterval/eindDatumTijd"
                                }
                            ]
                        },
                        {
                            "path": "medication.display",
                            "name": "Medicatie",
                            "description": "",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Afgesprokengeneesmiddel::Product"
                                }
                            ]
                        },
                        {
                            "path": "dosageInstruction.text | extension('http://nictiz.nl/fhir/StructureDefinition/ext-RenderedDosageInstruction').valueString",
                            "name": "Dosering & instructies",
                            "description": "N.B. Als text niet beschikbaar dan samenstellen uit discrete informatie en markeren met een icoontje &#9432;",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksinstructie/Omschrijving, Gebruiksinstructie/AanvullendeInstructie"
                                }
                            ]
                        },
                        {
                            "path": "iif(exists(dosageInstruction.route.text), dosageInstruction.route.text, dosageInstruction.route.coding.display)",
                            "name": "Toedieningsweg",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksinstructie/Toedieningsweg"
                                }
                            ]
                        },
                        {
                            "path": "modifierExtension.where(url='http://nictiz.nl/fhir/StructureDefinition/zib-Medication-StopType').valueCodeableConcept.coding.display",
                            "name": "Stop type",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "StopType"
                                }
                            ]
                        },
                        {
                            "path": "medication.resolve().form.coding.display",
                            "name": "+Medicatie vorm",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Afgesprokengeneesmiddel::FarmaceutischProduct/FarmaceutischeVorm"
                                }
                            ]
                        },
                        {
                            "path": "authoredOn",
                            "name": "+Afspraakdatum",
                            "type": "dateTime",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "MedicatieafspraakDatumTijd"
                                }
                            ]
                        },
                        {
                            "path": "requester.agent.display | requester.display",
                            "name": "+Voorschrijver",
                            "description": "<b>LET OP:</b> <code>requester.display</code> is een FHIR R4 veld",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Voorschrijver::Zorgverlener"
                                }
                            ]
                        }
                    ],
                    "forEach": "entry.resource.where(resourceType='MedicationRequest')"
                },
                {
                    "column": [
                        {
                            "path": "meta.extension('http://hl7.org/fhir/4.0/StructureDefinition/extension-Meta.source').valueUri",
                            "name": "Bron",
                            "description": "Lookup adhv uri (AGB-Z of OID) <code>&lt;adressering-base&gt;/Organization?identifier=&lt;.meta.tag.code&gt;</code> en gebruik dan <code>Organization.name</code>",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "nvt"
                                }
                            ]
                        },
                        {
                            "path": "effectivePeriod.start",
                            "name": "Start",
                            "description": "",
                            "type": "dateTime",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksperiode::TijdsInterval/startDatumTijd"
                                }
                            ]
                        },
                        {
                            "path": "effectivePeriod.end",
                            "name": "Eind",
                            "description": "",
                            "type": "dateTime",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksperiode::TijdsInterval/eindDatumTijd"
                                }
                            ]
                        },
                        {
                            "path": "medication.display",
                            "name": "Medicatie",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksproduct"
                                }
                            ]
                        },
                        {
                            "path": "dosage.text",
                            "name": "Dosering & instructies",
                            "description": "N.B. Als gegenereerd uit discrete informatie dan wordt deze gemarkeerd met een icoontje &#9432;",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksinstructie/Omschrijving, Gebruiksinstructie/AanvullendeInstructie"
                                }
                            ]
                        },
                        {
                            "path": "dosage.route.text",
                            "name": "Toedieningsweg",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksinstructie/Toedieningsweg"
                                }
                            ]
                        },
                        {
                            "path": "''",
                            "name": "Stop type",
                            "description": "Niet van toepassing bij MedicationStatement",
                            "type": "string"
                        },
                        {
                            "path": "medication.resolve().form.coding.display",
                            "name": "+Medicatie vorm",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Gebruiksproduct::FarmaceutischProduct/FarmaceutischeVorm"
                                }
                            ]
                        },
                        {
                            "path": "dateAsserted",
                            "name": "+Registratiedatum",
                            "type": "dateTime",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "MedicatieGebruikDatumTijd"
                                }
                            ]
                        },
                        {
                            "path": "extension('http://nictiz.nl/fhir/StructureDefinition/zib-MedicationUse-Prescriber').valueReference.display",
                            "name": "+Voorschrijver",
                            "type": "string",
                            "tag": [
                                {
                                    "name": "Zib element",
                                    "value": "Voorschrijver::Zorgverlener"
                                }
                            ]
                        },
                        {
                            "path": "'huidig'",
                            "name": "+Type",
                            "type": "string"
                        }
                    ],
                    "forEach": "entry.resource.where(resourceType='MedicationStatement')"
                }
            ]
        }
    ]
}