public void CreateGenereltBlodTrykk()
        {
            string path = Path.Combine(".", "TestData", "Generelt blodtrykk", "questionnaire-Blodtrykk-R4.xml");
            string xml;

            using (TextReader reader = new StreamReader(path))
                xml = reader.ReadToEnd();
            R4Model.Questionnaire r4Questionnaire = _r4XmlParser.Parse <R4Model.Questionnaire>(xml);

            FhirConverter converter     = new FhirConverter(FhirVersion.R3, FhirVersion.R4);
            Questionnaire questionnaire = converter.Convert <Questionnaire, R4Model.Questionnaire>(r4Questionnaire);

            questionnaire.SerializeResourceToDiskAsXml("questionnaire-Blodtrykk-R3.xml", FhirVersion.R3);
            questionnaire.SerializeResourceToDiskAsJson("questionnaire-Blodtrykk-R3.json", FhirVersion.R3);
        }
        public void CanR4ResourceConvertToR3()
        {
            // questionnaire-Bloodpressure-R4.xml
            string path = Path.Combine(".", "TestData", "questionnaire-Bloodpressure-R4.xml");
            string xml;

            using (TextReader reader = new StreamReader(path))
                xml = reader.ReadToEnd();
            R4Model.Questionnaire r4Questionnaire = _r4XmlParser.Parse <R4Model.Questionnaire>(xml);

            FhirConverter converter     = new FhirConverter(FhirVersion.R3, FhirVersion.R4);
            Questionnaire questionnaire = converter.Convert <Questionnaire, R4Model.Questionnaire>(r4Questionnaire);

            // ValueSet-blood-pressure-v2-cuffsize-R4.xml
            ValueSet valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "ValueSet-blood-pressure-v2-cuffsize-R4.xml"));

            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            // ValueSet-blood-pressure-v2-diastolicendpoint-R4.xml
            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "ValueSet-blood-pressure-v2-diastolicendpoint-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            // ValueSet-blood-pressure-v2-locationofmeasurement-R4.xml
            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "ValueSet-blood-pressure-v2-locationofmeasurement-R4.xml"));
            using (TextReader reader = new StreamReader(path))
                xml = reader.ReadToEnd();
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            // ValueSet-blood-pressure-v2-method-R4.xml
            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "ValueSet-blood-pressure-v2-method-R4.xml"));
            using (TextReader reader = new StreamReader(path))
                xml = reader.ReadToEnd();
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            FixContainedValueSetReferences(questionnaire.Contained.FindAll(r => r.ResourceType(FhirVersion.R3) == ResourceTypeWrapper.ValueSet), questionnaire.Item);

            questionnaire.SerializeResourceToDiskAsXml("questionnaire-Bloodpressure-R3.xml", FhirVersion.R3);
            questionnaire.SerializeResourceToDiskAsJson("questionnaire-Bloodpressure-R3.json", FhirVersion.R3);
        }
        public void CreateCovid19PandemiRegister()
        {
            string path = Path.Combine(".", "TestData", "covid-19-pandemiregister", "questionnaire-Rapport-R4.xml");
            string xml;

            using (TextReader reader = new StreamReader(path))
                xml = reader.ReadToEnd();
            R4Model.Questionnaire r4Questionnaire = _r4XmlParser.Parse <R4Model.Questionnaire>(xml);

            FhirConverter converter     = new FhirConverter(FhirVersion.R3, FhirVersion.R4);
            Questionnaire questionnaire = converter.Convert <Questionnaire, R4Model.Questionnaire>(r4Questionnaire);

            ValueSet valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-_testname_en_-R4.xml"));

            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-agens_at0043-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-agens-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-analysenavn_at0024-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-analysenavn-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-bildediagnostiskdiagnose-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-eksponeringssituasjon_at0045-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-eksponeringssituasjon-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-erdetnoentilstandertilstede_-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-innenlands_utenlands-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-innleggelsefra-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-iverksatt__at0005-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-iverksatt_-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-legemiddelibruk__at0024-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-legemiddelibruk_-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-legemiddelklasseibruk_-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-legemiddelklasse-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-legemiddelnavn_at0021-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-legemiddelnavn-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-navnpaaktiviteten_at0004-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-navnpaaktiviteten-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-navnpatilstand_at0004-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-navnpatilstand-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-reise_-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-tilstede__at0005-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-tilstede_-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-tilstedeværelse_at0046-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            valueSet = ConvertValueSetFromR4ToR3(Path.Combine(".", "TestData", "covid-19-pandemiregister", "ValueSet-report-v1-tilstedeværelse-R4.xml"));
            valueSet = RemoveDesignation(valueSet);
            questionnaire.Contained.Add(valueSet);

            FixContainedValueSetReferences(questionnaire.Contained.FindAll(r => r.ResourceType(FhirVersion.R3) == ResourceTypeWrapper.ValueSet), questionnaire.Item);

            questionnaire.SerializeResourceToDiskAsXml($"questionnaire-Covid19-Pandemiregister.xml", FhirVersion.R3);
            questionnaire.SerializeResourceToDiskAsJson("questionnaire-Covid19-Pandemiregister.json", FhirVersion.R3);
        }