diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java index 97eb6e54cab..0e4be9cbec9 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java @@ -27,6 +27,7 @@ import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.validation.FhirValidator; import ca.uhn.fhir.validation.SingleValidationMessage; +import ca.uhn.fhir.validation.ValidationOptions; import ca.uhn.fhir.validation.ValidationResult; import com.google.common.base.Charsets; import com.helger.commons.io.file.FileHelper; @@ -37,10 +38,11 @@ import org.apache.commons.cli.ParseException; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.text.WordUtils; import org.fusesource.jansi.Ansi.Color; +import org.hl7.fhir.common.hapi.validation.support.LocalFileValidationSupport; +import org.hl7.fhir.common.hapi.validation.support.SnapshotGeneratingValidationSupport; import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; import org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport; import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; -import org.hl7.fhir.instance.model.api.IBaseResource; import java.io.File; import java.io.FileInputStream; @@ -136,13 +138,10 @@ public class ValidateCommand extends BaseCommand { FhirContext ctx = getFhirContext(); FhirValidator val = ctx.newValidator(); - IBaseResource localProfileResource = null; + ValidationOptions options = new ValidationOptions(); if (theCommandLine.hasOption("l")) { String localProfile = theCommandLine.getOptionValue("l"); - ourLog.info("Loading profile: {}", localProfile); - String input = loadFile(localProfile); - - localProfileResource = ca.uhn.fhir.rest.api.EncodingEnum.detectEncodingNoDefault(input).newParser(ctx).parseResource(input); + options.addProfile(localProfile); } if (theCommandLine.hasOption("p")) { @@ -164,7 +163,11 @@ public class ValidateCommand extends BaseCommand { case R4: { FhirInstanceValidator instanceValidator = new FhirInstanceValidator(ctx); val.registerValidatorModule(instanceValidator); - ValidationSupportChain validationSupport = new ValidationSupportChain(new DefaultProfileValidationSupport(ctx), new InMemoryTerminologyServerValidationSupport(ctx)); + ValidationSupportChain validationSupport = new ValidationSupportChain( + new DefaultProfileValidationSupport(ctx), + new InMemoryTerminologyServerValidationSupport(ctx), + new LocalFileValidationSupport(ctx), + new SnapshotGeneratingValidationSupport(ctx)); if (theCommandLine.hasOption("r")) { validationSupport.addValidationSupport((IValidationSupport) new LoadingValidationSupportDstu3()); @@ -182,7 +185,7 @@ public class ValidateCommand extends BaseCommand { ValidationResult results; try { - results = val.validateWithResult(contents); + results = val.validateWithResult(contents, options); } catch (DataFormatException e) { throw new CommandFailureException(Msg.code(1621) + e.getMessage()); } diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ValidateCommandTest.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ValidateCommandTest.java index 3b6be9de8df..a220698ff2e 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ValidateCommandTest.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ValidateCommandTest.java @@ -34,4 +34,18 @@ public class ValidateCommandTest { "-p", "-n", resourcePath}); } + + @Test + public void testValidateLocalProfileAndResourceR4() { + String patientJson = ValidateCommandTest.class.getResource("/validate/Patient.json").getFile(); + String patientProfile = ValidateCommandTest.class.getResource("/validate/PatientIn-Profil.json").getFile(); + ourLog.info(patientJson); + + App.main(new String[] { + "validate", + "--fhir-version", "r4", + "--profile", + "--file", patientJson, + "-l", patientProfile}); + } } diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/resources/validate/Patient.json b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/resources/validate/Patient.json new file mode 100644 index 00000000000..dca48d52966 --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/resources/validate/Patient.json @@ -0,0 +1,128 @@ +{ + "resourceType": "Patient", + "id": "ExamplePatientPatientFull", + "meta": { + "profile": [ + "https://www.medizininformatik-initiative.de/fhir/core/modul-person/StructureDefinition/Patient" + ] + }, + "identifier": [ + { + "use": "usual", + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MR" + } + ] + }, + "system": "https://www.example.org/fhir/sid/patienten", + "value": "42285243", + "assigner": { + "display": "Charit� � Universit�tsmedizin Berlin", + "identifier": { + "system": "https://www.medizininformatik-initiative.de/fhir/core/CodeSystem/core-location-identifier", + "value": "Charit�" + } + } + }, + { + "use": "official", + "type": { + "coding": [ + { + "system": "http://fhir.de/CodeSystem/identifier-type-de-basis", + "code": "GKV" + } + ] + }, + "system": "http://fhir.de/sid/gkv/kvid-10", + "value": "Z234567890", + "assigner": { + "identifier": { + "use": "official", + "value": "109519005", + "system": "http://fhir.de/sid/arge-ik/iknr" + } + } + }, + { + "use": "secondary", + "type": { + "coding": [ + { + "system": "http://fhir.de/CodeSystem/identifier-type-de-basis", + "code": "PKV" + } + ] + }, + "value": "123456", + "assigner": { + "display": "Signal Iduna" + } + } + ], + "name": [ + { + "use": "official", + "family": "Van-der-Dussen", + "_family": { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/humanname-own-name", + "valueString": "Van-der-Dussen" + } + ] + }, + "given": [ + "Maja", + "Julia" + ], + "prefix": [ + "Prof. Dr. med." + ], + "_prefix": [ + { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier", + "valueCode": "AC" + } + ] + } + ] + }, + { + "use": "maiden", + "family": "Haffer" + } + ], + "deceasedBoolean": false, + "address": [ + { + "type": "both", + "line": [ + "Anna-Louisa-Karsch Str. 2" + ], + "city": "Berlin", + "_city": { + "extension": [ + { + "url": "http://fhir.de/StructureDefinition/destatis/ags", + "valueCoding": { + "system": "http://fhir.de/sid/destatis/ags", + "code": "11000000" + } + } + ] + }, + "state": "DE-BE", + "postalCode": "10178", + "country": "DE" + } + ], + "managingOrganization": { + "reference": "Organization/Charite-Universitaetsmedizin-Berlin" + } +} diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/resources/validate/PatientIn-Profil.json b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/resources/validate/PatientIn-Profil.json new file mode 100644 index 00000000000..f7bae5b99dd --- /dev/null +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/resources/validate/PatientIn-Profil.json @@ -0,0 +1,880 @@ +{ + "resourceType": "StructureDefinition", + "id": "Profile-MII-Patient-PatientIn", + "url": "https://www.medizininformatik-initiative.de/fhir/core/modul-person/StructureDefinition/Patient", + "version": "2.0.0", + "name": "Profile_MII_Patient_PatientIn", + "title": "Profile - MI-I - Patient - PatientIn", + "status": "active", + "description": "Dieses Profil beschreibt eine PatientIn in der Medizininformatik-Initiative.", + "fhirVersion": "4.0.1", + "kind": "resource", + "abstract": false, + "type": "Patient", + "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient", + "derivation": "constraint", + "differential": { + "element": [ + { + "id": "Patient", + "path": "Patient", + "constraint": [ + { + "key": "mii-pat-1", + "severity": "error", + "human": "Falls die Geschlechtsangabe 'other' gewählt wird, muss die amtliche Differenzierung per Extension angegeben werden", + "expression": "gender.exists() and gender='other' implies gender.extension('http://fhir.de/StructureDefinition/gender-amtlich-de').exists()", + "source": "https://www.medizininformatik-initiative.de/fhir/core/modul-person/StructureDefinition/Patient" + } + ] + }, + { + "id": "Patient.id", + "path": "Patient.id", + "mustSupport": true + }, + { + "id": "Patient.meta", + "path": "Patient.meta", + "mustSupport": true + }, + { + "id": "Patient.meta.source", + "path": "Patient.meta.source", + "mustSupport": true + }, + { + "id": "Patient.meta.profile", + "path": "Patient.meta.profile", + "mustSupport": true + }, + { + "id": "Patient.identifier", + "path": "Patient.identifier", + "slicing": { + "discriminator": [ + { + "type": "pattern", + "path": "$this" + } + ], + "rules": "open" + }, + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV", + "path": "Patient.identifier", + "sliceName": "versichertenId_GKV", + "max": "1", + "type": [ + { + "code": "Identifier", + "profile": [ + "http://fhir.de/StructureDefinition/identifier-kvid-10" + ] + } + ], + "patternIdentifier": { + "type": { + "coding": [ + { + "system": "http://fhir.de/CodeSystem/identifier-type-de-basis", + "code": "GKV" + } + ] + } + }, + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV.type", + "path": "Patient.identifier.type", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV.system", + "path": "Patient.identifier.system", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV.value", + "path": "Patient.identifier.value", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV.assigner", + "path": "Patient.identifier.assigner", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV.assigner.identifier", + "path": "Patient.identifier.assigner.identifier", + "min": 1, + "type": [ + { + "code": "Identifier", + "profile": [ + "http://fhir.de/StructureDefinition/identifier-iknr" + ] + } + ], + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV.assigner.identifier.type", + "path": "Patient.identifier.assigner.identifier.type", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV.assigner.identifier.system", + "path": "Patient.identifier.assigner.identifier.system", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertenId_GKV.assigner.identifier.value", + "path": "Patient.identifier.assigner.identifier.value", + "mustSupport": true + }, + { + "id": "Patient.identifier:pid", + "path": "Patient.identifier", + "sliceName": "pid", + "type": [ + { + "code": "Identifier", + "profile": [ + "http://fhir.de/StructureDefinition/identifier-pid" + ] + } + ], + "patternIdentifier": { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MR" + } + ] + } + }, + "mustSupport": true + }, + { + "id": "Patient.identifier:pid.type", + "path": "Patient.identifier.type", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.identifier:pid.system", + "path": "Patient.identifier.system", + "mustSupport": true + }, + { + "id": "Patient.identifier:pid.value", + "path": "Patient.identifier.value", + "mustSupport": true + }, + { + "id": "Patient.identifier:pid.assigner", + "path": "Patient.identifier.assigner", + "type": [ + { + "code": "Reference", + "profile": [ + "https://www.medizininformatik-initiative.de/fhir/core/StructureDefinition/MII-Reference" + ] + } + ], + "mustSupport": true + }, + { + "id": "Patient.identifier:pid.assigner.identifier.type", + "path": "Patient.identifier.assigner.identifier.type", + "patternCodeableConcept": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "XX" + } + ] + }, + "mustSupport": true + }, + { + "id": "Patient.identifier:pid.assigner.identifier.system", + "path": "Patient.identifier.assigner.identifier.system", + "constraint": [ + { + "key": "mii-pat-1", + "severity": "error", + "human": "Entweder IKNR oder MII Core Location Identifier soll verwendet werden", + "expression": "$this = 'http://fhir.de/NamingSystem/arge-ik/iknr' or $this = 'https://www.medizininformatik-initiative.de/fhir/core/CodeSystem/core-location-identifier'", + "source": "https://www.medizininformatik-initiative.de/fhir/core/modul-person/StructureDefinition/Patient" + } + ] + }, + { + "id": "Patient.identifier:versichertennummer_pkv", + "path": "Patient.identifier", + "sliceName": "versichertennummer_pkv", + "max": "1", + "type": [ + { + "code": "Identifier", + "profile": [ + "http://fhir.de/StructureDefinition/identifier-pkv" + ] + } + ], + "patternIdentifier": { + "type": { + "coding": [ + { + "system": "http://fhir.de/CodeSystem/identifier-type-de-basis", + "code": "PKV" + } + ] + } + }, + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertennummer_pkv.use", + "path": "Patient.identifier.use", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertennummer_pkv.type", + "path": "Patient.identifier.type", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertennummer_pkv.value", + "path": "Patient.identifier.value", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertennummer_pkv.assigner", + "path": "Patient.identifier.assigner", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertennummer_pkv.assigner.identifier.type", + "path": "Patient.identifier.assigner.identifier.type", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertennummer_pkv.assigner.identifier.system", + "path": "Patient.identifier.assigner.identifier.system", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertennummer_pkv.assigner.identifier.value", + "path": "Patient.identifier.assigner.identifier.value", + "mustSupport": true + }, + { + "id": "Patient.identifier:versichertennummer_pkv.assigner.display", + "path": "Patient.identifier.assigner.display", + "mustSupport": true + }, + { + "id": "Patient.name", + "path": "Patient.name", + "slicing": { + "discriminator": [ + { + "type": "pattern", + "path": "$this" + } + ], + "rules": "open" + }, + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.name:name", + "path": "Patient.name", + "sliceName": "name", + "min": 1, + "max": "1", + "type": [ + { + "code": "HumanName", + "profile": [ + "http://fhir.de/StructureDefinition/humanname-de-basis" + ] + } + ], + "patternHumanName": { + "use": "official" + }, + "mustSupport": true + }, + { + "id": "Patient.name:name.use", + "path": "Patient.name.use", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.name:name.family", + "path": "Patient.name.family", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.name:name.family.extension", + "path": "Patient.name.family.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.name:name.family.extension:namenszusatz", + "path": "Patient.name.family.extension", + "sliceName": "namenszusatz", + "mustSupport": true + }, + { + "id": "Patient.name:name.family.extension:nachname", + "path": "Patient.name.family.extension", + "sliceName": "nachname", + "mustSupport": true + }, + { + "id": "Patient.name:name.family.extension:vorsatzwort", + "path": "Patient.name.family.extension", + "sliceName": "vorsatzwort", + "mustSupport": true + }, + { + "id": "Patient.name:name.given", + "path": "Patient.name.given", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.name:name.prefix", + "path": "Patient.name.prefix", + "mustSupport": true + }, + { + "id": "Patient.name:name.prefix.extension", + "path": "Patient.name.prefix.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.name:name.prefix.extension:prefix-qualifier", + "path": "Patient.name.prefix.extension", + "sliceName": "prefix-qualifier", + "max": "1", + "mustSupport": true + }, + { + "id": "Patient.name:geburtsname", + "path": "Patient.name", + "sliceName": "geburtsname", + "max": "1", + "type": [ + { + "code": "HumanName", + "profile": [ + "http://fhir.de/StructureDefinition/humanname-de-basis" + ] + } + ], + "patternHumanName": { + "use": "maiden" + }, + "mustSupport": true + }, + { + "id": "Patient.name:geburtsname.use", + "path": "Patient.name.use", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.name:geburtsname.family", + "path": "Patient.name.family", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.name:geburtsname.family.extension", + "path": "Patient.name.family.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.name:geburtsname.family.extension:namenszusatz", + "path": "Patient.name.family.extension", + "sliceName": "namenszusatz", + "mustSupport": true + }, + { + "id": "Patient.name:geburtsname.family.extension:nachname", + "path": "Patient.name.family.extension", + "sliceName": "nachname", + "mustSupport": true + }, + { + "id": "Patient.name:geburtsname.family.extension:vorsatzwort", + "path": "Patient.name.family.extension", + "sliceName": "vorsatzwort", + "mustSupport": true + }, + { + "id": "Patient.name:geburtsname.given", + "path": "Patient.name.given", + "max": "0" + }, + { + "id": "Patient.name:geburtsname.prefix", + "path": "Patient.name.prefix", + "max": "0" + }, + { + "id": "Patient.name:geburtsname.prefix.extension", + "path": "Patient.name.prefix.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.name:geburtsname.prefix.extension:prefix-qualifier", + "path": "Patient.name.prefix.extension", + "sliceName": "prefix-qualifier", + "max": "1", + "mustSupport": true + }, + { + "id": "Patient.gender", + "path": "Patient.gender", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.gender.extension", + "path": "Patient.gender.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.gender.extension:other-amtlich", + "path": "Patient.gender.extension", + "sliceName": "other-amtlich", + "max": "1", + "type": [ + { + "code": "Extension", + "profile": [ + "http://fhir.de/StructureDefinition/gender-amtlich-de" + ] + } + ], + "mustSupport": true + }, + { + "id": "Patient.birthDate", + "path": "Patient.birthDate", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.birthDate.extension", + "path": "Patient.birthDate.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.birthDate.extension:data-absent-reason", + "path": "Patient.birthDate.extension", + "sliceName": "data-absent-reason", + "type": [ + { + "code": "Extension", + "profile": [ + "http://hl7.org/fhir/StructureDefinition/data-absent-reason" + ] + } + ], + "mustSupport": true + }, + { + "id": "Patient.deceased[x]", + "path": "Patient.deceased[x]", + "mustSupport": true + }, + { + "id": "Patient.address", + "path": "Patient.address", + "slicing": { + "discriminator": [ + { + "type": "pattern", + "path": "$this" + } + ], + "rules": "open" + }, + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift", + "path": "Patient.address", + "sliceName": "Strassenanschrift", + "type": [ + { + "code": "Address", + "profile": [ + "http://fhir.de/StructureDefinition/address-de-basis" + ] + } + ], + "patternAddress": { + "type": "both" + }, + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.extension", + "path": "Patient.address.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.address:Strassenanschrift.extension:Stadtteil", + "path": "Patient.address.extension", + "sliceName": "Stadtteil", + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.type", + "path": "Patient.address.type", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.line", + "path": "Patient.address.line", + "min": 1, + "max": "3", + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.line.extension", + "path": "Patient.address.line.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.address:Strassenanschrift.line.extension:Strasse", + "path": "Patient.address.line.extension", + "sliceName": "Strasse", + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.line.extension:Hausnummer", + "path": "Patient.address.line.extension", + "sliceName": "Hausnummer", + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.line.extension:Adresszusatz", + "path": "Patient.address.line.extension", + "sliceName": "Adresszusatz", + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.line.extension:Postfach", + "path": "Patient.address.line.extension", + "sliceName": "Postfach", + "max": "0" + }, + { + "id": "Patient.address:Strassenanschrift.city", + "path": "Patient.address.city", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.city.extension", + "path": "Patient.address.city.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.address:Strassenanschrift.city.extension:gemeindeschluessel", + "path": "Patient.address.city.extension", + "sliceName": "gemeindeschluessel", + "max": "1", + "type": [ + { + "code": "Extension", + "profile": [ + "http://fhir.de/StructureDefinition/destatis/ags" + ] + } + ], + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.postalCode", + "path": "Patient.address.postalCode", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.address:Strassenanschrift.country", + "path": "Patient.address.country", + "min": 1, + "constraint": [ + { + "key": "pat-cnt-2or3-char", + "severity": "warning", + "human": "The content of the country element (if present) SHALL be selected EITHER from ValueSet ISO Country Alpha-2 http://hl7.org/fhir/ValueSet/iso3166-1-2 OR MAY be selected from ISO Country Alpha-3 Value Set http://hl7.org/fhir/ValueSet/iso3166-1-3, IF the country is not specified in value Set ISO Country Alpha-2 http://hl7.org/fhir/ValueSet/iso3166-1-2.", + "expression": "country.empty() or (country.memberOf('http://hl7.org/fhir/ValueSet/iso3166-1-2') or country.memberOf('http://hl7.org/fhir/ValueSet/iso3166-1-3'))", + "source": "https://www.medizininformatik-initiative.de/fhir/core/modul-person/StructureDefinition/Patient" + } + ], + "mustSupport": true + }, + { + "id": "Patient.address:Postfach", + "path": "Patient.address", + "sliceName": "Postfach", + "type": [ + { + "code": "Address", + "profile": [ + "http://fhir.de/StructureDefinition/address-de-basis" + ] + } + ], + "patternAddress": { + "type": "postal" + }, + "mustSupport": true + }, + { + "id": "Patient.address:Postfach.extension", + "path": "Patient.address.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.address:Postfach.extension:Stadtteil", + "path": "Patient.address.extension", + "sliceName": "Stadtteil", + "mustSupport": true + }, + { + "id": "Patient.address:Postfach.type", + "path": "Patient.address.type", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.address:Postfach.line", + "path": "Patient.address.line", + "min": 1, + "max": "3", + "mustSupport": true + }, + { + "id": "Patient.address:Postfach.line.extension", + "path": "Patient.address.line.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.address:Postfach.line.extension:Strasse", + "path": "Patient.address.line.extension", + "sliceName": "Strasse", + "max": "0" + }, + { + "id": "Patient.address:Postfach.line.extension:Hausnummer", + "path": "Patient.address.line.extension", + "sliceName": "Hausnummer", + "max": "0" + }, + { + "id": "Patient.address:Postfach.line.extension:Adresszusatz", + "path": "Patient.address.line.extension", + "sliceName": "Adresszusatz", + "max": "0" + }, + { + "id": "Patient.address:Postfach.line.extension:Postfach", + "path": "Patient.address.line.extension", + "sliceName": "Postfach", + "mustSupport": true + }, + { + "id": "Patient.address:Postfach.city", + "path": "Patient.address.city", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.address:Postfach.city.extension", + "path": "Patient.address.city.extension", + "slicing": { + "discriminator": [ + { + "type": "value", + "path": "url" + } + ], + "rules": "open" + } + }, + { + "id": "Patient.address:Postfach.city.extension:gemeindeschluessel", + "path": "Patient.address.city.extension", + "sliceName": "gemeindeschluessel", + "max": "1", + "type": [ + { + "code": "Extension", + "profile": [ + "http://fhir.de/StructureDefinition/destatis/ags" + ] + } + ], + "mustSupport": true + }, + { + "id": "Patient.address:Postfach.postalCode", + "path": "Patient.address.postalCode", + "min": 1, + "mustSupport": true + }, + { + "id": "Patient.address:Postfach.country", + "path": "Patient.address.country", + "min": 1, + "constraint": [ + { + "key": "pat-cnt-2or3-char", + "severity": "warning", + "human": "The content of the country element (if present) SHALL be selected EITHER from ValueSet ISO Country Alpha-2 http://hl7.org/fhir/ValueSet/iso3166-1-2 OR MAY be selected from ISO Country Alpha-3 Value Set http://hl7.org/fhir/ValueSet/iso3166-1-3, IF the country is not specified in value Set ISO Country Alpha-2 http://hl7.org/fhir/ValueSet/iso3166-1-2.", + "expression": "country.empty() or (country.memberOf('http://hl7.org/fhir/ValueSet/iso3166-1-2') or country.memberOf('http://hl7.org/fhir/ValueSet/iso3166-1-3'))", + "source": "https://www.medizininformatik-initiative.de/fhir/core/modul-person/StructureDefinition/Patient" + } + ], + "mustSupport": true + }, + { + "id": "Patient.link", + "path": "Patient.link", + "mustSupport": true + }, + { + "id": "Patient.link.other", + "path": "Patient.link.other", + "type": [ + { + "code": "Reference", + "profile": [ + "https://www.medizininformatik-initiative.de/fhir/core/StructureDefinition/MII-Reference" + ] + } + ], + "mustSupport": true + }, + { + "id": "Patient.link.type", + "path": "Patient.link.type", + "mustSupport": true + } + ] + } +} diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/LocalFileValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/LocalFileValidationSupport.java new file mode 100644 index 00000000000..b0685d88e01 --- /dev/null +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/LocalFileValidationSupport.java @@ -0,0 +1,39 @@ +package org.hl7.fhir.common.hapi.validation.support; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.support.IValidationSupport; +import ca.uhn.fhir.i18n.Msg; +import org.apache.commons.io.IOUtils; +import org.hl7.fhir.instance.model.api.IBaseResource; +import org.jetbrains.annotations.Nullable; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; + +import static org.apache.commons.lang3.StringUtils.defaultString; + +public class LocalFileValidationSupport implements IValidationSupport { + + final private FhirContext myCtx; + + public LocalFileValidationSupport(FhirContext ctx) { + this.myCtx = ctx; + } + + @Override + public FhirContext getFhirContext() { + return myCtx; + } + + @Nullable + @Override + public IBaseResource fetchStructureDefinition(String theUrl) { + try { + String contents = IOUtils.toString(new InputStreamReader(new FileInputStream(theUrl), "UTF-8")); + return myCtx.newJsonParser().parseResource(contents); + } catch (IOException e) { + return null; + } + } +} diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FhirInstanceValidator.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FhirInstanceValidator.java index 48e3a9a3138..9ad1b826fab 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FhirInstanceValidator.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FhirInstanceValidator.java @@ -229,7 +229,6 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta .setBestPracticeWarningLevel(getBestPracticeWarningLevel()) .setErrorForUnknownProfiles(isErrorForUnknownProfiles()) .setExtensionDomains(getExtensionDomains()) - .setValidatorResourceFetcher(validatorResourceFetcher) .setValidationPolicyAdvisor(validatorPolicyAdvisor) .setNoTerminologyChecks(isNoTerminologyChecks()) .setNoExtensibleWarnings(isNoExtensibleWarnings())