Add CLI test

This commit is contained in:
James Agnew 2015-11-20 10:30:10 +01:00
parent 0b7f6c0f4a
commit c78be081ef
21 changed files with 4605 additions and 25 deletions

View File

@ -4,6 +4,7 @@ import java.util.Date;
import java.util.List;
import java.util.Set;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
@ -15,8 +16,11 @@ import ca.uhn.fhir.model.dstu2.resource.Observation;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.client.IGenericClient;
public class FhirDataModel {
@ -153,27 +157,58 @@ public class FhirDataModel {
public static void main(String[] args) {
tmp();
datatypes();
// START SNIPPET: observation
// Create an Observation instance
Observation observation = new Observation();
// Create a quantity datatype
QuantityDt q = new QuantityDt();
q.setValue(185);
q.setSystem("http://unitsofmeasure.org");
q.setCode("lbs");
// Give the observation a status
observation.setStatus(ObservationStatusEnum.FINAL);
// Put the datatype in the observation
observation.setValue(q);
// Give the observation a code (what kind of observation is this)
CodingDt coding = observation.getCode().addCoding();
coding.setCode("29463-7").setSystem("http://loinc.org").setDisplay("Body Weight");
// Create a quantity datatype
QuantityDt value = new QuantityDt();
value.setValue(83.9).setSystem("http://unitsofmeasure.org").setCode("kg");
observation.setValue(value);
// Set the reference range
observation.getReferenceRangeFirstRep().setLow(new SimpleQuantityDt(100));
observation.getReferenceRangeFirstRep().setHigh(new SimpleQuantityDt(200));
SimpleQuantityDt low = new SimpleQuantityDt();
low.setValue(45).setSystem("http://unitsofmeasure.org").setCode("kg");
observation.getReferenceRangeFirstRep().setLow(low);
SimpleQuantityDt high = new SimpleQuantityDt();
low.setValue(90).setSystem("http://unitsofmeasure.org").setCode("kg");
observation.getReferenceRangeFirstRep().setHigh(high);
// END SNIPPET: observation
}
private static void tmp() {
// Create a FHIR Context
FhirContext ctx = FhirContext.forDstu2();
// Create a client
IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2");
// Read a patient with the given ID
Patient patient = client
.read()
.resource(Patient.class)
.withId("952975")
.execute();
// Print the patient's name
String string = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
System.out.println(string);
}
public void namesHard() {

View File

@ -35,19 +35,20 @@ public class GenericClientExample {
public static void simpleExample() {
// START SNIPPET: simple
// We're connecting to a DSTU1 compliant server in this example
FhirContext ctx = FhirContext.forDstu1();
String serverBase = "http://fhirtest.uhn.ca/baseDstu1";
FhirContext ctx = FhirContext.forDstu2();
String serverBase = "http://fhirtest.uhn.ca/baseDstu2";
IGenericClient client = ctx.newRestfulGenericClient(serverBase);
// Perform a search
ca.uhn.fhir.model.api.Bundle results = client
Bundle results = client
.search()
.forResource(Patient.class)
.where(Patient.FAMILY.matches().value("duck"))
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
.execute();
System.out.println("Found " + results.size() + " patients named 'duck'");
System.out.println("Found " + results.getEntry().size() + " patients named 'duck'");
// END SNIPPET: simple
}

View File

@ -28,7 +28,7 @@ public class DependencyLogFactory {
try {
Class<IDependencyLog> clas = (Class<IDependencyLog>) Class.forName("ca.uhn.fhir.util.jar.DependencyLogImpl");
return clas.newInstance();
} catch (ReflectiveOperationException e) {
} catch (Exception e) {
ourLog.info("Could not log dependency.");
return null;
}

View File

@ -150,7 +150,7 @@
<artifactItem>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-example</artifactId>
<version>1.3-SNAPSHOT</version>
<version>1.4-SNAPSHOT</version>
<type>war</type>
<overWrite>true</overWrite>
<outputDirectory>target/classes</outputDirectory>

View File

@ -15,6 +15,8 @@ public class LoadingValidationSupport implements IValidationSupport {
private static FhirContext myCtx = FhirContext.forDstu2Hl7Org();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(LoadingValidationSupport.class);
@Override
public ValueSetExpansionComponent expandValueSet(FhirContext theContext, ConceptSetComponent theInclude) {
return null;
@ -25,8 +27,6 @@ public class LoadingValidationSupport implements IValidationSupport {
return null;
}
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(LoadingValidationSupport.class);
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
String resName = myCtx.getResourceDefinition(theClass).getName();

View File

@ -6,8 +6,13 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.commons.lang3.StringUtils.leftPad;
import static org.fusesource.jansi.Ansi.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@ -19,8 +24,12 @@ import org.apache.commons.lang3.text.WordUtils;
import org.fusesource.jansi.Ansi;
import com.phloc.commons.io.file.FileUtils;
import com.sun.tools.corba.se.idl.ParameterEntry;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.resource.StructureDefinition;
import ca.uhn.fhir.rest.method.MethodUtil;
import ca.uhn.fhir.rest.param.ParameterUtil;
import ca.uhn.fhir.rest.server.EncodingEnum;
import ca.uhn.fhir.validation.DefaultProfileValidationSupport;
import ca.uhn.fhir.validation.FhirInstanceValidator;
@ -28,6 +37,7 @@ import ca.uhn.fhir.validation.FhirValidator;
import ca.uhn.fhir.validation.SingleValidationMessage;
import ca.uhn.fhir.validation.ValidationResult;
import ca.uhn.fhir.validation.ValidationSupportChain;
import net.sf.saxon.expr.instruct.LocalParam;
import net.sf.saxon.om.Chain;
public class ValidateCommand extends BaseCommand {
@ -57,7 +67,7 @@ public class ValidateCommand extends BaseCommand {
retVal.addOption("s", "sch", false, "Validate using Schematrons");
retVal.addOption("p", "profile", false, "Validate using Profiles (StructureDefinition / ValueSet)");
retVal.addOption("r", "fetch-remote", false, "Allow fetching remote resources (in other words, if a resource being validated refers to an external StructureDefinition, Questionnaire, etc. this flag allows the validator to access the internet to try and fetch this resource)");
retVal.addOption(new Option("l", "fetch-local", true, "Fetch a profile locally and use it if referenced"));
retVal.addOption("e", "encoding", false, "File encoding (default is UTF-8)");
return retVal;
@ -91,9 +101,24 @@ public class ValidateCommand extends BaseCommand {
if (theCommandLine.hasOption("p")) {
FhirInstanceValidator instanceValidator = new FhirInstanceValidator();
val.registerValidatorModule(instanceValidator);
if (theCommandLine.hasOption("r")) {
instanceValidator.setValidationSupport(new ValidationSupportChain(new DefaultProfileValidationSupport(), new LoadingValidationSupport()));
ValidationSupportChain validationSupport = new ValidationSupportChain(new DefaultProfileValidationSupport());
if (theCommandLine.hasOption("l")) {
String localProfile = theCommandLine.getOptionValue("l");
ourLog.info("Loading profile: {}", localProfile);
String input;
try {
input = IOUtils.toString(new FileReader(new File(localProfile)));
} catch (IOException e) {
throw new ParseException("Failed to load file '" + localProfile + "' - Error: " + e.toString());
}
org.hl7.fhir.instance.model.StructureDefinition sd = (org.hl7.fhir.instance.model.StructureDefinition) MethodUtil.detectEncodingNoDefault(input).newParser(FhirContext.forDstu2Hl7Org()).parseResource(input);
instanceValidator.setStructureDefintion(sd);
}
if (theCommandLine.hasOption("r")) {
validationSupport.addValidationSupport(new LoadingValidationSupport());
}
instanceValidator.setValidationSupport(validationSupport);
}
val.setValidateAgainstStandardSchema(theCommandLine.hasOption("x"));

View File

@ -0,0 +1,28 @@
import org.junit.Test;
import ca.uhn.fhir.cli.App;
public class ValidateTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidateTest.class);
@Test
public void testValidateLocalProfile() {
String profilePath = ValidateTest.class.getResource("/uslab-patient.profile.xml").getFile();
String resourcePath = ValidateTest.class.getResource("/patient-uslab-example1.xml").getFile();
ourLog.info(profilePath);
ourLog.info(resourcePath);
App.main(new String[] {"validate", "-p", "-f", resourcePath, "-l", profilePath});
}
@Test
public void testValidateLocalProfileWithReferenced() {
String profilePath = ValidateTest.class.getResource("/nl/nl-core-patient.dstu2.xml").getFile();
String resourcePath = ValidateTest.class.getResource("/nl/patient-example-a.xml").getFile();
ourLog.info(profilePath);
ourLog.info(resourcePath);
App.main(new String[] {"validate", "-p", "-f", resourcePath, "-l", profilePath});
}
}

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<id value="nl-core-address-official"/>
<meta>
<lastUpdated value="2015-09-22T20:02:49.724+10:00"/>
</meta>
<url value="http://fhir.nl/fhir/StructureDefinition/nl-address-official"/>
<name value="nl-core-address-official"/>
<status value="draft"/>
<contact>
<name value="HL7 Netherlands"/>
</contact>
<date value="2015-09-22T20:02:49+10:00"/>
<description value="Base StructureDefinition for Extension Type"/>
<requirements value="The ability to add extensions in a structured way is what keeps FHIR resources simple."/>
<fhirVersion value="1.0.1"/>
<mapping>
<identity value="rim"/>
<uri value="http://hl7.org/v3"/>
<name value="RIM"/>
</mapping>
<kind value="datatype"/>
<constrainedType value="Extension"/>
<abstract value="false"/>
<contextType value="resource"/>
<context value="Address"/>
<base value="http://hl7.org/fhir/StructureDefinition/Extension"/>
<differential>
<element>
<path value="Extension"/>
<short value="Mark an address as an 'officially registered' address."/>
<definition value="Mark an address as an 'officially registered' address. In Dutch context that means it is registered in the Basisregistratie persoonsgegevens (BRP)"/>
<min value="0"/>
<max value="*"/>
<type>
<code value="Element"/>
</type>
<mapping>
<identity value="rim"/>
<map value="N/A"/>
</mapping>
</element>
<element>
<path value="Extension.url"/>
<representation value="xmlAttr"/>
<short value="identifies the meaning of the extension"/>
<definition value="Source of the definition for the extension code - a logical name or a URL."/>
<comments value="The definition may point directly to a computable or human-readable definition of the extensibility codes, or it may be a logical URI as declared in some other specification. The definition should be version specific. This will ideally be the URI for the Resource Profile defining the extension, with the code for the extension after a #."/>
<min value="1"/>
<max value="1"/>
<fixedUri value="http://fhir.nl/fhir/StructureDefinition/nl-address-official"/>
<mapping>
<identity value="rim"/>
<map value="N/A"/>
</mapping>
</element>
<element>
<path value="Extension.value[x]"/>
<short value="true if part of an official registry. false if it is not"/>
<definition value="When the value is true, this address is marked to be part of an official registry (Dutch realm: BRP). When the value is false, this address is explicitly marked as not part of an official registry."/>
<min value="1"/>
<max value="1"/>
<type>
<code value="boolean"/>
</type>
<meaningWhenMissing value="When an address is not marked explicitly as official=true|false than no information can be inferred from that."/>
<mapping>
<identity value="rim"/>
<map value="AD/@use[.='OR']"/>
</mapping>
</element>
</differential>
</StructureDefinition>

View File

@ -0,0 +1,312 @@
<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<id value="nl-core-address" />
<meta>
<lastUpdated value="2015-09-22T20:02:49.724+10:00" />
</meta>
<url value="http://fhir.nl/fhir/StructureDefinition/nl-core-address" />
<name value="nl-core-address" />
<status value="draft" />
<date value="2015-09-22T20:02:49+10:00" />
<description value="Base StructureDefinition for Address Type with additions for Dutch realm addresses. Dutch addresses break down Address.line in several parts and it is important to mark an address as being 'officially registered'." />
<requirements value="Need to be able to record postal addresses, along with notes about their use." />
<fhirVersion value="1.0.1" />
<mapping>
<identity value="v2" />
<uri value="http://hl7.org/v2" />
<name value="HL7 v2" />
</mapping>
<mapping>
<identity value="rim" />
<uri value="http://hl7.org/v3" />
<name value="RIM" />
</mapping>
<mapping>
<identity value="servd" />
<uri value="http://www.omg.org/spec/ServD/1.0/" />
<name value="ServD" />
</mapping>
<mapping>
<identity value="vcard" />
<uri value="http://w3.org/vcard" />
<name value="vCard" />
</mapping>
<mapping>
<identity value="BRP" />
<uri value="https://nl.wikipedia.org/wiki/Basisregistratie_Personen" />
<name value="Basisregistratie Personen" />
<comments value="Voorheen GBA - Gemeentelijke basisregistratie" />
</mapping>
<mapping>
<identity value="BRP.streetName" />
<name value="11.10 Straatnaam" />
</mapping>
<mapping>
<identity value="BRP.houseNumber" />
<name value="11.20 Huisnummer" />
</mapping>
<mapping>
<identity value="BRP.buildingNumberSuffix" />
<name value="11.30 Huisletter, 11.40 Huisnummertoevoeging" />
</mapping>
<mapping>
<identity value="BRP.additionalLocator" />
<name value="11.50 Aanduiding bij huisnummer" />
</mapping>
<mapping>
<identity value="BRP.city" />
<name value="11.70 Woonplaatsnaam" />
</mapping>
<mapping>
<identity value="BRP.postalCode" />
<name value="11.60 Postcode" />
</mapping>
<mapping>
<identity value="BRP.county" />
<name value="09.10 Gemeente van inschrijving" />
</mapping>
<kind value="datatype" />
<constrainedType value="Address" />
<abstract value="false" />
<base value="http://hl7.org/fhir/StructureDefinition/Address" />
<differential>
<element>
<path value="Address" />
<short value="A physical/postal address" />
<definition value="There is a variety of postal address formats defined around the world. This format defines a superset that is the basis for all addresses around the world and adds all relevant components to express Dutch addresses." />
<comments value="A Dutch Address is a proper FHIR Address. Systems that do not understand any of the extensions, will be able to render and work with a Dutch address. Dutch addresses make certain address parts seaprately communicable. These parts are required for use in true Dutch systems when dealing with Dutch addresses, but may not have value for international systems when information gets sent abroad.&#xD;&#xA;&#xD;&#xA;To have true compatibility an implementer SHOULD use the core Address parts as intended. To have addresses work for Dutch context, the implementer SHOULD in addition use the extension elements." />
<min value="0" />
<max value="*" />
<type>
<code value="Address" />
</type>
<condition value="nl-line-if-line-parts" />
<condition value="nl-streetname-if-official-and-other-line-parts" />
<constraint>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-expression">
<valueString value="line or extension.where(url in 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName' | 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber' | 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-buildingNumberSuffix' | 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-additionalLocator').empty" />
</extension>
<key value="nl-line-if-line-parts" />
<requirements value="This constraint ensures compatibility with systems that do not support Dutch extensions" />
<severity value="error" />
<human value="Address.line SHALL have a value if one of streetName|houseNumber|buildingNumberSuffix|additionalLocator has a value" />
<xpath value="not(f:extension[@url=('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName','http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber','http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-buildingNumberSuffix','http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-additionalLocator')]) or f:line" />
</constraint>
<constraint>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-expression">
<valueString value="extension.where(url ='http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName']) or (extension.where(url = 'http://fhir.nl/fhir/StructureDefinition/nl-address-official').valueBoolean.not() or extension.where(url in 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber' | 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-buildingNumberSuffix' | 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-additionalLocator').empty)" />
</extension>
<key value="nl-streetname-if-official-and-other-line-parts" />
<requirements value="This constraint checks conformance against the Dutch BRP constraints on address parts. However: when you only send postalCode + houseNumber which is enough for certain cases this may still be a valid address" />
<severity value="error" />
<human value="Address.streetName in an official address SHALL have a value if one of houseNumber|buildingNumberSuffix|additionalLocator has a value" />
<xpath value="not(f:extension[@url=('http://fhir.nl/fhir/StructureDefinition/nl-address-official')][f:valueBoolean/@value='true']) or not(f:extension[@url=('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber','http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-buildingNumberSuffix','http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-additionalLocator')]) or f:extension[@url='http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName']" />
</constraint>
<isSummary value="true" />
<mapping>
<identity value="v2" />
<map value="XAD" />
</mapping>
<mapping>
<identity value="rim" />
<map value="AD" />
</mapping>
<mapping>
<identity value="servd" />
<map value="Address" />
</mapping>
</element>
<element>
<path value="Address.extension" />
<slicing>
<discriminator value="url" />
<rules value="openAtEnd" />
</slicing>
</element>
<element>
<path value="Address.extension" />
<name value="official" />
<definition value="Address is from official registry" />
<requirements value="When 'true' certain address contraints apply." />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
<profile value="http://fhir.nl/fhir/StructureDefinition/nl-address-official" />
</type>
</element>
<element>
<path value="Address.extension" />
<name value="streetName" />
<requirements value="Basisregistratie Persoonsgegevens 11.10 Straatnaam" />
<alias value="straatnaam" />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
<profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName" />
</type>
</element>
<element>
<path value="Address.extension" />
<name value="houseNumber" />
<requirements value="Basisregistratie Persoonsgegevens 11.20 Huisnummer" />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
<profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber" />
</type>
</element>
<element>
<path value="Address.extension" />
<name value="buildingNumberSuffix" />
<requirements value="Basisregistratie Persoonsgegevens 11.30 Huisletter&#xD;&#xA;11.40 Huisnummertoevoeging" />
<alias value="huisnummertoevoeging" />
<alias value="huisletter" />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
<profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-buildingNumberSuffix" />
</type>
</element>
<element>
<path value="Address.extension" />
<name value="additionalLocator" />
<requirements value="Basisregistratie Persoonsgegevens 11.50 Aanduiding bij huisnummer" />
<alias value="aanduiding bij huisnummer" />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
<profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-additionalLocator" />
</type>
</element>
<element>
<path value="Address.city" />
<short value="Name of city, town etc." />
<definition value="The name of the city, town, village or other community or delivery center." />
<requirements value="Basisregistratie Persoonsgegevens 11.70 Woonplaatsnaam" />
<alias value="Municpality" />
<min value="0" />
<max value="1" />
<type>
<code value="string" />
</type>
<exampleString value="Erewhon" />
<isSummary value="true" />
<mapping>
<identity value="v2" />
<map value="XAD.3" />
</mapping>
<mapping>
<identity value="rim" />
<map value="AD.part[parttype = CTY]" />
</mapping>
<mapping>
<identity value="vcard" />
<map value="locality" />
</mapping>
<mapping>
<identity value="servd" />
<map value="./Jurisdiction" />
</mapping>
</element>
<element>
<path value="Address.district" />
<short value="District name (aka county)" />
<definition value="The name of the administrative area (county)." />
<comments value="District is sometimes known as county, but in some regions 'county' is used in place of city (municipality), so county name should be conveyed in city instead. In a Dutch address this element is used for the population of a &quot;gemeente&quot;" />
<requirements value="Basisregistratie Persoonsgegevens 09.10 Gemeente van inschrijving" />
<alias value="County" />
<alias value="gemeente" />
<min value="0" />
<max value="1" />
<type>
<code value="string" />
</type>
<exampleString value="Madison" />
<isSummary value="true" />
<mapping>
<identity value="v2" />
<map value="XAD.9" />
</mapping>
<mapping>
<identity value="rim" />
<map value="AD.part[parttype = CNT | CPA]" />
</mapping>
</element>
<element>
<path value="Address.state" />
<short value="Sub-unit of country (abbreviations ok)" />
<definition value="Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (i.e. US 2 letter state codes)." />
<alias value="Province" />
<alias value="Territory" />
<alias value="provincie" />
<min value="0" />
<max value="1" />
<type>
<code value="string" />
</type>
<isSummary value="true" />
<mapping>
<identity value="v2" />
<map value="XAD.4" />
</mapping>
<mapping>
<identity value="rim" />
<map value="AD.part[parttype = STA]" />
</mapping>
<mapping>
<identity value="vcard" />
<map value="region" />
</mapping>
<mapping>
<identity value="servd" />
<map value="./Region" />
</mapping>
</element>
<element>
<path value="Address.postalCode" />
<short value="Postal code for area" />
<definition value="A postal code designating a region defined by the postal service." />
<comments value="Dutch postal codes have pattern '\d{4}[A-Z]{2}' so they do not have spaces. Systems can easily render postal codes with a space if necessary." />
<alias value="Zip" />
<alias value="postcode" />
<min value="0" />
<max value="1" />
<type>
<code value="string" />
</type>
<exampleString value="9132" />
<condition value="nl-postal-code-pattern" />
<constraint>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-expression">
<valueString value="(country in 'nl' | 'nld' | 'nederland').not() or matches('^\\d{4}[A-Z]{2}$')" />
</extension>
<key value="nl-postal-code-pattern" />
<severity value="error" />
<human value="Dutch postal code pattern 'nnnnAA'" />
<xpath value="not(../f:country[lower-case(@value)=('nl','nld','nederland')]) or matches(@value,'^\d{4}[A-Z]{2}$')" />
</constraint>
<isSummary value="true" />
<mapping>
<identity value="v2" />
<map value="XAD.5" />
</mapping>
<mapping>
<identity value="rim" />
<map value="AD.part[parttype = ZIP]" />
</mapping>
<mapping>
<identity value="vcard" />
<map value="code" />
</mapping>
<mapping>
<identity value="servd" />
<map value="./PostalIdentificationCode" />
</mapping>
</element>
</differential>
</StructureDefinition>

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<meta>
<lastUpdated value="2015-09-22T20:02:49.724+10:00" />
</meta>
<url value="http://fhir.nl/fhir/StructureDefinition/nl-core-humanname-familyname-prefix" />
<name value="nl-core-humanname-familyname-prefix" />
<status value="draft" />
<contact>
<name value="HL7 Netherlands" />
</contact>
<date value="2015-09-22T20:02:49+10:00" />
<description value="Base StructureDefinition for Extension Type" />
<requirements value="The ability to add extensions in a structured way is what keeps FHIR resources simple." />
<fhirVersion value="1.0.1" />
<mapping>
<identity value="rim" />
<uri value="http://hl7.org/v3" />
<name value="RIM" />
</mapping>
<kind value="datatype" />
<constrainedType value="Extension" />
<abstract value="false" />
<contextType value="resource" />
<context value="HumanName" />
<base value="http://hl7.org/fhir/StructureDefinition/Extension" />
<differential>
<element>
<path value="Extension" />
<definition value="Optional Extensions Element - found in all resources." />
<min value="0" />
<max value="*" />
<type>
<code value="Element" />
</type>
<mapping>
<identity value="rim" />
<map value="N/A" />
</mapping>
</element>
<element>
<path value="Extension.extension" />
<slicing>
<discriminator value="url" />
<rules value="openAtEnd" />
</slicing>
</element>
<element>
<path value="Extension.extension" />
<name value="qualifier" />
<code>
<system value="http://hl7.org/fhir/v3/EntityNamePartQualifier" />
<code value="VV" />
</code>
<min value="1" />
<max value="1" />
</element>
<element>
<path value="Extension.url" />
<representation value="xmlAttr" />
<short value="identifies the meaning of the extension" />
<definition value="Source of the definition for the extension code - a logical name or a URL." />
<comments value="The definition may point directly to a computable or human-readable definition of the extensibility codes, or it may be a logical URI as declared in some other specification. The definition should be version specific. This will ideally be the URI for the Resource Profile defining the extension, with the code for the extension after a #." />
<min value="1" />
<max value="1" />
<type>
<code value="uri" />
</type>
<fixedUri value="http://fhir.nl/fhir/StructureDefinition/nl-core-humanname-familyname-prefix" />
<mapping>
<identity value="rim" />
<map value="N/A" />
</mapping>
</element>
<element>
<path value="Extension.value[x]" />
<short value="Family name prefix" />
<definition value="Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list)." />
<min value="0" />
<max value="1" />
<type>
<code value="string" />
</type>
<mapping>
<identity value="rim" />
<map value="N/A" />
</mapping>
</element>
</differential>
</StructureDefinition>

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<meta>
<lastUpdated value="2015-09-22T20:02:49.724+10:00" />
</meta>
<url value="http://fhir.nl/fhir/StructureDefinition/nl-core-humanname-familyname" />
<name value="nl-core-humanname-familyname" />
<status value="draft" />
<contact>
<name value="HL7 Netherlands" />
</contact>
<date value="2015-09-22T20:02:49+10:00" />
<description value="Base StructureDefinition for Extension Type" />
<requirements value="The ability to add extensions in a structured way is what keeps FHIR resources simple." />
<fhirVersion value="1.0.1" />
<mapping>
<identity value="rim" />
<uri value="http://hl7.org/v3" />
<name value="RIM" />
</mapping>
<kind value="datatype" />
<constrainedType value="Extension" />
<abstract value="false" />
<contextType value="resource" />
<context value="HumanName" />
<base value="http://hl7.org/fhir/StructureDefinition/Extension" />
<differential>
<element>
<path value="Extension" />
<definition value="Optional Extensions Element - found in all resources." />
<min value="0" />
<max value="*" />
<type>
<code value="Element" />
</type>
<mapping>
<identity value="rim" />
<map value="N/A" />
</mapping>
</element>
<element>
<path value="Extension.extension" />
<slicing>
<discriminator value="url" />
<rules value="openAtEnd" />
</slicing>
</element>
<element>
<path value="Extension.extension" />
<name value="qualifier" />
<code>
<system value="http://hl7.org/fhir/v3/EntityNamePartQualifier" />
<code value="VV" />
</code>
<min value="1" />
<max value="1" />
</element>
<element>
<path value="Extension.url" />
<representation value="xmlAttr" />
<short value="identifies the meaning of the extension" />
<definition value="Source of the definition for the extension code - a logical name or a URL." />
<comments value="The definition may point directly to a computable or human-readable definition of the extensibility codes, or it may be a logical URI as declared in some other specification. The definition should be version specific. This will ideally be the URI for the Resource Profile defining the extension, with the code for the extension after a #." />
<min value="1" />
<max value="1" />
<type>
<code value="uri" />
</type>
<fixedUri value="http://fhir.nl/fhir/StructureDefinition/nl-core-humanname-familyname-prefix" />
<mapping>
<identity value="rim" />
<map value="N/A" />
</mapping>
</element>
<element>
<path value="Extension.value[x]" />
<short value="Family name prefix" />
<definition value="Value of extension - may be a resource or one of a constrained set of the data types (see Extensibility in the spec for list)." />
<min value="0" />
<max value="1" />
<type>
<code value="string" />
</type>
<mapping>
<identity value="rim" />
<map value="N/A" />
</mapping>
</element>
</differential>
</StructureDefinition>

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<meta>
<lastUpdated value="2015-09-22T20:02:49.724+10:00" />
</meta>
<url value="http://fhir.nl/fhir/StructureDefinition/nl-core-humanname" />
<name value="nl-core-humanname" />
<status value="draft" />
<contact>
<name value="HL7 Netherlands" />
</contact>
<date value="2015-09-22T20:02:49+10:00" />
<description value="Base StructureDefinition for HumanName Type with additions for Dutch realm names. Dutch names break down the family into maximum of 4 parts that are important to know separately in some use cases." />
<requirements value="Need to be able to record names, along with notes about their use." />
<fhirVersion value="1.0.1" />
<mapping>
<identity value="v2" />
<uri value="http://hl7.org/v2" />
<name value="HL7 v2" />
</mapping>
<mapping>
<identity value="rim" />
<uri value="http://hl7.org/v3" />
<name value="RIM" />
</mapping>
<mapping>
<identity value="servd" />
<uri value="http://www.omg.org/spec/ServD/1.0/" />
<name value="ServD" />
</mapping>
<kind value="datatype" />
<constrainedType value="HumanName" />
<abstract value="false" />
<base value="http://hl7.org/fhir/StructureDefinition/HumanName" />
<differential>
<element>
<path value="HumanName" />
<short value="Name of a human - parts and usage" />
<definition value="A human's name with the ability to identify parts and usage." />
<comments value="Names may be changed, or repudiated, or people may have different names in different contexts. Names may be divided into parts of different type that have variable significance depending on context, though the division into parts does not always matter. With personal names, the different parts may or may not be imbued with some implicit meaning; various cultures associate different importance with the name parts and the degree to which systems must care about name parts around the world varies widely." />
<min value="0" />
<max value="*" />
<type>
<code value="HumanName" />
</type>
<isSummary value="true" />
<mapping>
<identity value="v2" />
<map value="XPN" />
</mapping>
<mapping>
<identity value="rim" />
<map value="EN (actually, PN)" />
</mapping>
<mapping>
<identity value="servd" />
<map value="ProviderName" />
</mapping>
</element>
<element>
<path value="HumanName.extension" />
<slicing>
<discriminator value="url" />
<rules value="openAtEnd" />
</slicing>
</element>
<element>
<path value="HumanName.extension" />
<name value="family-name-part1-prefix" />
<short value="family-name-part-prefix" />
<definition value="Optional Extensions Element - found in all resources." />
<alias value="voorvoegsel" />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
<profile value="http://fhir.nl/fhir/StructureDefinition/nl-core-humanname-familyname-prefix" />
</type>
</element>
<element>
<path value="HumanName.extension" />
<name value="family-name-part1" />
<short value="family-name-part" />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
</type>
</element>
<element>
<path value="HumanName.extension" />
<name value="family-name-part2-prefix" />
<short value="family-name-part2-prefix" />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
</type>
</element>
<element>
<path value="HumanName.extension" />
<name value="family-name-part2" />
<short value="family-name-part2" />
<min value="0" />
<max value="1" />
<type>
<code value="Extension" />
</type>
</element>
<element>
<path value="HumanName.family" />
<short value="Family name (often called 'Surname')" />
<definition value="The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father." />
<comments value="For family name, hyphenated names such as &quot;Smith-Jones&quot; are a single name, but names with spaces such as &quot;Smith Jones&quot; are broken into multiple parts." />
<min value="0" />
<max value="*" />
<isSummary value="true" />
</element>
</differential>
</StructureDefinition>

View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
<id value="nl-core-patient"/>
<meta>
<lastUpdated value="2015-09-22T20:02:49.724+10:00"/>
</meta>
<extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm">
<valueInteger value="5"/>
</extension>
<url value="http://fhir.nl/fhir/StructureDefinition/nl-core-patient"/>
<name value="nl-core-patient"/>
<status value="draft"/>
<contact>
<name value="HL7 Netherlands"/>
</contact>
<date value="2015-09-22T20:02:49+10:00"/>
<description value="National core Patient profile."/>
<requirements value="Tracking patient is the center of the healthcare process."/>
<fhirVersion value="1.0.1"/>
<mapping>
<identity value="rim"/>
<uri value="http://hl7.org/v3"/>
<name value="RIM"/>
</mapping>
<mapping>
<identity value="cda"/>
<uri value="http://hl7.org/v3/cda"/>
<name value="CDA (R2)"/>
</mapping>
<mapping>
<identity value="w5"/>
<uri value="http://hl7.org/fhir/w5"/>
<name value="W5 Mapping"/>
</mapping>
<mapping>
<identity value="v2"/>
<uri value="http://hl7.org/v2"/>
<name value="HL7 v2"/>
</mapping>
<mapping>
<identity value="loinc"/>
<uri value="http://loinc.org"/>
<name value="LOINC"/>
</mapping>
<kind value="resource"/>
<constrainedType value="Patient"/>
<abstract value="false"/>
<base value="http://hl7.org/fhir/StructureDefinition/Patient"/>
<differential>
<element>
<path value="Patient"/>
<short value="Information about an individual or animal receiving health care services"/>
<definition value="Demographics and other administrative information about an individual or animal receiving care or other health-related services."/>
<alias value="SubjectOfCare Client Resident"/>
<min value="0"/>
<max value="*"/>
<type>
<code value="Patient"/>
</type>
<mapping>
<identity value="rim"/>
<map value="Patient[classCode=PAT]"/>
</mapping>
<mapping>
<identity value="cda"/>
<map value="ClinicalDocument.recordTarget.patientRole"/>
</mapping>
<mapping>
<identity value="w5"/>
<map value="administrative.individual"/>
</mapping>
</element>
<element>
<path value="Patient.address"/>
<short value="Addresses for the individual"/>
<definition value="Addresses for the individual."/>
<comments value="Patient may have multiple addresses with different uses or applicable periods."/>
<requirements value="May need to keep track of patient addresses for contacting, billing or reporting requirements and also to help with identification."/>
<min value="0"/>
<max value="*"/>
<type>
<code value="Address"/>
<profile value="http://fhir.nl/fhir/StructureDefinition/nl-core-address"/>
</type>
<isSummary value="true"/>
<mapping>
<identity value="v2"/>
<map value="PID-11"/>
</mapping>
<mapping>
<identity value="rim"/>
<map value="addr"/>
</mapping>
<mapping>
<identity value="cda"/>
<map value=".addr"/>
</mapping>
</element>
</differential>
</StructureDefinition>

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<id value="nl-core-patient-example"/>
<meta>
<profile value="http://fhir.nl/fhir/StructureDefinition/nl-core-patient"/>
</meta>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<b>Generated Narrative with Details</b>
</p>
<p>
<b>id</b>: nl-core-patient-example</p>
<p>
<b>meta</b>: </p>
<p>
<b>identifier</b>: Medical record number = 654321 (usual)</p>
<p>
<b>active</b>: true</p>
<p>
<b>name</b>: Duck Donald (official)</p>
<p>
<b>gender</b>: male</p>
<p>
<b>address</b>: Woonplaats </p>
<p>
<b>photo</b>: </p>
<p>
<b>managingOrganization</b>:
<a href="Organization/1">ACME Healthcare, Inc</a>
</p>
</div>
</text>
<identifier>
<use value="usual"/>
<type>
<coding>
<system value="http://hl7.org/fhir/v2/0203"/>
<code value="MR"/>
</coding>
</type>
<system value="urn:oid:0.1.2.3.4.5.6.7"/>
<value value="654321"/>
</identifier>
<active value="true"/>
<name>
<use value="official"/>
<family value="Donald"/>
<given value="Duck"/>
</name>
<gender value="male"/>
<address>
<city value="Woonplaats"/>
</address>
<photo>
<contentType value="image/gif"/>
<data value="R0lGODlhEwARAPcAAAAAAAAA/+9aAO+1AP/WAP/eAP/eCP/eEP/eGP/nAP/nCP/nEP/nIf/nKf/n&#xD;&#xA;Uv/nWv/vAP/vCP/vEP/vGP/vIf/vKf/vMf/vOf/vWv/vY//va//vjP/3c//3lP/3nP//tf//vf//&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;////////////////////////////////////////////////////////////////////////////&#xD;&#xA;/////////////////////////////////////////////////////yH5BAEAAAEALAAAAAATABEA&#xD;&#xA;AAi+AAMIDDCgYMGBCBMSvMCQ4QCFCQcwDBGCA4cLDyEGECDxAoAQHjxwyKhQAMeGIUOSJJjRpIAG&#xD;&#xA;DS5wCDly4AALFlYOgHlBwwOSNydM0AmzwYGjBi8IHWoTgQYORg8QIGDAwAKhESI8HIDgwQaRDI1W&#xD;&#xA;XXAhK9MBBzZ8/XDxQoUFZC9IiCBh6wEHGz6IbNuwQoSpWxEgyLCXL8O/gAnylNlW6AUEBRIL7Og3&#xD;&#xA;KwQIiCXb9HsZQoIEUzUjNEiaNMKAAAA7"/>
</photo>
<contact>
<relationship>
<coding>
<system value="http://hl7.org/fhir/patient-contact-relationship"/>
<code value="owner"/>
</coding>
</relationship>
<organization>
<reference value="Organization/1"/>
<display value="Walt Disney Corporation"/>
</organization>
</contact>
<managingOrganization>
<reference value="Organization/1"/>
<display value="ACME Healthcare, Inc"/>
</managingOrganization>
<link>
<other>
<reference value="Patient/pat2"/>
</other>
<type value="seealso"/>
</link>
</Patient>

View File

@ -0,0 +1,3 @@
#!/bin/bash
java -jar ~/Development/HL7-GForge/fhir/trunk/build/publish/org.hl7.fhir.validator.jar patient-example-a.xml -defn ~/Development/HL7-GForge/fhir/trunk/build/publish/validation-min.xml.zip -profile nl-core-patient

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<id value="patient-uslab-example1"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
<b>Generated Narrative with Details</b>
</p>
<p>
<b>id</b>
: patient-uslab-example1
</p>
<p>
<b>identifier</b>
: 18547545 (USUAL)
</p>
<p>
<b>name</b>
: Todd G. Lerr (OFFICIAL)
</p>
<p>
<b>gender</b>
: male
</p>
<p>
<b>birthDate</b>
: Jun 7, 2012
</p>
<p>
<b>deceased</b>
: false
</p>
<p>
<b>address</b>
: 123 North 102nd Street Apt 4d Harrisburg PA 17102 USA (HOME)
</p>
</div>
</text>
<extension url="http://hl7.org/fhir/StructureDefinition/us-core-race">
<valueCodeableConcept>
<coding>
<code value="2106-3"/>
</coding>
</valueCodeableConcept>
</extension>
<extension url="http://hl7.org/fhir/StructureDefinition/us-core-ethnicity">
<valueCodeableConcept>
<coding>
<code value="2135-2"/>
</coding>
</valueCodeableConcept>
</extension>
<!-- EH: limit to single identifier that orderer can match to patient system can be URL -->
<identifier>
<use value="usual"/>
<system value="urn:oid:2.16.840.1.113883.3.72.5.30.2"/>
<value value="18547545"/>
</identifier>
<!-- name use limited to official and anonymous -->
<name>
<use value="official"/>
<family value="Lerr"/>
<given value="Todd"/>
<given value="G."/>
<suffix value="Jr"/>
</name>
<!-- use FHIR code system for male / female -->
<gender value="male"/>
<birthDate value="2012-06-07"/>
<deceasedBoolean value="false"/>
<address>
<use value="home"/>
<line value="123 North 102nd Street"/>
<line value="Apt 4d"/>
<city value="Harrisburg"/>
<state value="PA"/>
<postalCode value="17102"/>
<country value="USA"/>
</address>
</Patient>

File diff suppressed because it is too large Load Diff

View File

@ -39,6 +39,7 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IValid
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirInstanceValidator.class);
private BestPracticeWarningLevel myBestPracticeWarningLevel;
private DocumentBuilderFactory myDocBuilderFactory;
private StructureDefinition myStructureDefintion;
private IValidationSupport myValidationSupport;
/**
@ -125,6 +126,10 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IValid
myBestPracticeWarningLevel = theBestPracticeWarningLevel;
}
public void setStructureDefintion(StructureDefinition theStructureDefintion) {
myStructureDefintion = theStructureDefintion;
}
/**
* Sets the {@link IValidationSupport validation support} in use by this
* validator. Default is an instance of
@ -164,7 +169,7 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IValid
}
String resourceName = determineResourceName(document);
StructureDefinition profile = loadProfileOrReturnNull(messages, theCtx, resourceName);
StructureDefinition profile = myStructureDefintion != null ? myStructureDefintion : loadProfileOrReturnNull(messages, theCtx, resourceName);
if (profile != null) {
try {
v.validate(messages, document, profile);
@ -177,7 +182,7 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IValid
JsonObject json = gson.fromJson(theInput, JsonObject.class);
String resourceName = json.get("resourceType").getAsString();
StructureDefinition profile = loadProfileOrReturnNull(messages, theCtx, resourceName);
StructureDefinition profile = myStructureDefintion != null ? myStructureDefintion : loadProfileOrReturnNull(messages, theCtx, resourceName);
if (profile != null) {
try {
v.validate(messages, json, profile);

View File

@ -14,8 +14,18 @@ public class ValidationSupportChain implements IValidationSupport {
private List<IValidationSupport> myChain;
public ValidationSupportChain(IValidationSupport... theValidationSupportModules) {
/**
* Constructor
*/
public ValidationSupportChain() {
myChain = new ArrayList<IValidationSupport>();
}
/**
* Constructor
*/
public ValidationSupportChain(IValidationSupport... theValidationSupportModules) {
this();
for (IValidationSupport next : theValidationSupportModules) {
if (next != null) {
myChain.add(next);
@ -23,6 +33,10 @@ public class ValidationSupportChain implements IValidationSupport {
}
}
public void addValidationSupport(IValidationSupport theValidationSupport) {
myChain.add(theValidationSupport);
}
@Override
public ValueSetExpansionComponent expandValueSet(FhirContext theCtx, ConceptSetComponent theInclude) {
for (IValidationSupport next : myChain) {

View File

@ -1137,7 +1137,7 @@
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.01</version>
<version>1.1</version>
</signature>
</configuration>
</plugin>

View File

@ -6,7 +6,12 @@
<title>HAPI FHIR Changelog</title>
</properties>
<body>
<release version="1.3" date="TBD">
<release version="1.4" date="TBD">
<action type="fix">
Remove a dependency on Java 1.7 in
</action>
</release>
<release version="1.3" date="2015-11-14">
<action type="add">
Bump the version of a few dependencies to the
latest versions (dependent HAPI modules listed in brackets):