diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 66d4d1f97..d9b47571f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ -* Issue 484 https://github.com/hapifhir/org.hl7.fhir.core/issues/484 * Update core R5 code to v4.6.0 (breaking changes to questionnaire, concept map, and other resources that are less important to core) - +* Fix compartment definitions of ListResource.source and subject for R3 and R4 +* Snapshot generator: fix problem checking types on logical models +* Do not flag internal references as suspicious +* XMLParser allows passing a schema location +* Issue 484 https://github.com/hapifhir/org.hl7.fhir.core/issues/484 diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor30.java index d43a785f1..cc7eb0da6 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor30.java @@ -33,14 +33,54 @@ package org.hl7.fhir.convertors; import org.hl7.fhir.exceptions.FHIRException; +/** + * This interface is passed into the version conversion routines when on of the + * converters is producing or converting R3 resources. + * + * The interface allows users of the code to + * 1. manage the life cycle of new resources created (or needed) during the conversion process + * 2. manage how unknown content etc is handled + * + * @author grahame + * + */ public interface VersionConvertorAdvisor30 { + + /** + * when processing a bundle, and converting from R3 to R2 whether to ignore an entry in the bundle. + * typically, return true when it's a resource that isn't handled, and you don't care. + * + * by default, always return false unless you know why not do this + * + * todo: why only R2? generalise this to all targets + * + * @param src + * @return + */ boolean ignoreEntry(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent src); - // called ? - org.hl7.fhir.dstu2.model.Resource convert(org.hl7.fhir.dstu3.model.Resource resource) throws FHIRException; - - // called when an r2 value set has a codeSystem in it + /** + * In R2, code systems are internal to value sets, but in subsequent versions, they + * exist as separate resources. The convertor will create the code system, and then + * call this routine for the host to decide what to do with it + * + * It can make it a contained resource, or it can put it somewhere else + * + * @param tgtcs + * @param source + * @throws FHIRException + */ void handleCodeSystem(org.hl7.fhir.dstu3.model.CodeSystem tgtcs, org.hl7.fhir.dstu3.model.ValueSet source) throws FHIRException; + /** + * when converting from R3 to R2, and converting a value set, the convertor will need + * to find the code system a value set is referring to, so it can include it inline. + * + * This routine should find the actual resource + * + * @param src + * @return + * @throws FHIRException + */ org.hl7.fhir.dstu3.model.CodeSystem getCodeSystem(org.hl7.fhir.dstu3.model.ValueSet src) throws FHIRException; } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor40.java index 0f6e2cae4..7a5774be8 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor40.java @@ -33,16 +33,55 @@ package org.hl7.fhir.convertors; import org.hl7.fhir.exceptions.FHIRException; + +/** + * This interface is passed into the version conversion routines when on of the + * converters is producing or converting R4 resources. + * + * The interface allows users of the code to + * 1. manage the life cycle of new resources created (or needed) during the conversion process + * 2. manage how unknown content etc is handled + * + * @author grahame + * + */ public interface VersionConvertorAdvisor40 { + + /** + * when processing a bundle, and converting from R4 to R2 whether to ignore an entry in the bundle. + * typically, return true when it's a resource that isn't handled, and you don't care. + * + * by default, always return false unless you know why not do this + * + * todo: why only R2? generalise this to all targets + * + * @param src + * @return + */ boolean ignoreEntry(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent src); - // called ? - org.hl7.fhir.dstu2.model.Resource convertR2(org.hl7.fhir.r4.model.Resource resource) throws FHIRException; - org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r4.model.Resource resource) throws FHIRException; - org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r4.model.Resource resource) throws FHIRException; - - // called when an r2 value set has a codeSystem in it + /** + * In R2, code systems are internal to value sets, but in subsequent versions, they + * exist as separate resources. The convertor will create the code system, and then + * call this routine for the host to decide what to do with it + * + * It can make it a contained resource, or it can put it somewhere else + * + * @param tgtcs + * @param source + * @throws FHIRException + */ void handleCodeSystem(org.hl7.fhir.r4.model.CodeSystem tgtcs, org.hl7.fhir.r4.model.ValueSet source) throws FHIRException; + /** + * when converting from R4 to R2, and converting a value set, the convertor will need + * to find the code system a value set is referring to, so it can include it inline. + * + * This routine should find the actual resource + * + * @param src + * @return + * @throws FHIRException + */ org.hl7.fhir.r4.model.CodeSystem getCodeSystem(org.hl7.fhir.r4.model.ValueSet src) throws FHIRException; } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor50.java index 0c697173a..25072549d 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertorAdvisor50.java @@ -34,16 +34,41 @@ package org.hl7.fhir.convertors; import org.hl7.fhir.exceptions.FHIRException; public interface VersionConvertorAdvisor50 { + /** + * when processing a bundle, and converting from R5 to R2 whether to ignore an entry in the bundle. + * typically, return true when it's a resource that isn't handled, and you don't care. + * + * by default, always return false unless you know why not do this + * + * todo: why only R2? generalise this to all targets + * + * @param src + * @return + */ boolean ignoreEntry(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent src); - // called ? - org.hl7.fhir.dstu2.model.Resource convertR2(org.hl7.fhir.r5.model.Resource resource) throws FHIRException; - org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r5.model.Resource resource) throws FHIRException; - org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException; - org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException; - - // called when an r2 value set has a codeSystem in it + /** + * In R2, code systems are internal to value sets, but in subsequent versions, they + * exist as separate resources. The convertor will create the code system, and then + * call this routine for the host to decide what to do with it + * + * It can make it a contained resource, or it can put it somewhere else + * + * @param tgtcs + * @param source + * @throws FHIRException + */ void handleCodeSystem(org.hl7.fhir.r5.model.CodeSystem tgtcs, org.hl7.fhir.r5.model.ValueSet source) throws FHIRException; + /** + * when converting from R5 to R2, and converting a value set, the convertor will need + * to find the code system a value set is referring to, so it can include it inline. + * + * This routine should find the actual resource + * + * @param src + * @return + * @throws FHIRException + */ org.hl7.fhir.r5.model.CodeSystem getCodeSystem(org.hl7.fhir.r5.model.ValueSet src) throws FHIRException; } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/Bundle10_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/Bundle10_30.java index 6ad1c12a9..23fb51626 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/Bundle10_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/Bundle10_30.java @@ -52,9 +52,7 @@ public class Bundle10_30 { for (org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); if (src.hasFullUrlElement()) tgt.setFullUrlElement(VersionConvertor_10_30.convertUri(src.getFullUrlElement())); - org.hl7.fhir.dstu2.model.Resource res = advisor.convert(src.getResource()); - if (res == null) - res = VersionConvertor_10_30.convertResource(src.getResource()); + org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_30.convertResource(src.getResource()); tgt.setResource(res); if (src.hasSearch()) tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch())); diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/Bundle10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/Bundle10_40.java index 35b7a9d56..4e413e43d 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/Bundle10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/Bundle10_40.java @@ -71,9 +71,7 @@ public class Bundle10_40 { for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); if (src.hasFullUrlElement()) tgt.setFullUrlElement(VersionConvertor_10_40.convertUri(src.getFullUrlElement())); - org.hl7.fhir.dstu2.model.Resource res = advisor.convertR2(src.getResource()); - if (res == null) - res = VersionConvertor_10_40.convertResource(src.getResource()); + org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_40.convertResource(src.getResource()); tgt.setResource(res); if (src.hasSearch()) tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch())); diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_50/Bundle10_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_50/Bundle10_50.java index 13a80b9d2..df8de9f2c 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_50/Bundle10_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_50/Bundle10_50.java @@ -71,9 +71,7 @@ public class Bundle10_50 { for (org.hl7.fhir.r5.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); if (src.hasFullUrlElement()) tgt.setFullUrlElement(VersionConvertor_10_50.convertUri(src.getFullUrlElement())); - org.hl7.fhir.dstu2.model.Resource res = advisor.convertR2(src.getResource()); - if (res == null) - res = VersionConvertor_10_50.convertResource(src.getResource()); + org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_50.convertResource(src.getResource()); tgt.setResource(res); if (src.hasSearch()) tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch())); diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2016MayToR4Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2016MayToR4Loader.java index 94249ead4..0e8eac879 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2016MayToR4Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2016MayToR4Loader.java @@ -116,21 +116,6 @@ public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResource return false; } - @Override - public org.hl7.fhir.dstu2.model.Resource convertR2(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public Resource convertR2016May(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { cs.setId(vs.getId()); diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2016MayToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2016MayToR5Loader.java index 4aa7b132a..90ef54953 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2016MayToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2016MayToR5Loader.java @@ -163,21 +163,6 @@ public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertor return false; } - @Override - public org.hl7.fhir.dstu2.model.Resource convertR2(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public Resource convertR2016May(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { cs.setId(vs.getId()); @@ -191,11 +176,5 @@ public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertor return null; } - @Override - public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR3Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR3Loader.java index 1bed6644a..33ef1d454 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR3Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR3Loader.java @@ -113,10 +113,6 @@ public class R2ToR3Loader extends BaseLoaderR3 implements VersionConvertorAdviso return false; } - @Override - public Resource convert(org.hl7.fhir.dstu3.model.Resource resource) throws FHIRException { - return null; - } @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR4Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR4Loader.java index 941acbd4b..40ec42877 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR4Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR4Loader.java @@ -115,20 +115,6 @@ public class R2ToR4Loader extends BaseLoaderR4 implements VersionConvertorAdviso return false; } - @Override - public Resource convertR2(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { cs.setId(vs.getId()); diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR5Loader.java index 07f64c869..91f69b4e2 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R2ToR5Loader.java @@ -163,20 +163,6 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader return false; } - @Override - public Resource convertR2(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { cs.setId(vs.getId()); @@ -190,10 +176,5 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader return null; } - @Override - public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R3ToR4Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R3ToR4Loader.java index 0691b1fe6..46ae2d6da 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R3ToR4Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R3ToR4Loader.java @@ -125,20 +125,6 @@ public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader return false; } - @Override - public org.hl7.fhir.dstu2.model.Resource convertR2(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public Resource convertR3(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R3ToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R3ToR5Loader.java index 07feac9ab..e08f45a33 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R3ToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R3ToR5Loader.java @@ -166,21 +166,6 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader return false; } - @Override - public org.hl7.fhir.dstu2.model.Resource convertR2(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { cs.setId(vs.getId()); @@ -194,9 +179,4 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader return null; } - @Override - public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R4ToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R4ToR5Loader.java index fa8af1b5f..3f9001daf 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R4ToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R4ToR5Loader.java @@ -166,21 +166,6 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader return false; } - @Override - public org.hl7.fhir.dstu2.model.Resource convertR2(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { cs.setId(vs.getId()); @@ -194,9 +179,4 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader return null; } - @Override - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R5ToR5Loader.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R5ToR5Loader.java index a71cb3705..1046b11e4 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R5ToR5Loader.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/loaders/R5ToR5Loader.java @@ -163,21 +163,6 @@ public class R5ToR5Loader extends BaseLoaderR5 implements VersionConvertorAdviso return false; } - @Override - public org.hl7.fhir.dstu2.model.Resource convertR2(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { cs.setId(vs.getId()); @@ -191,9 +176,4 @@ public class R5ToR5Loader extends BaseLoaderR5 implements VersionConvertorAdviso return null; } - @Override - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGPackConverter102.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGPackConverter102.java index 32cedac2d..385545f4b 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGPackConverter102.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGPackConverter102.java @@ -89,10 +89,6 @@ public class IGPackConverter102 implements VersionConvertorAdvisor30 { return false; } - @Override - public Resource convert(org.hl7.fhir.dstu3.model.Resource resource) throws FHIRException { - return null; - } @Override public void handleCodeSystem(CodeSystem tgtcs, ValueSet vs) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGR2ConvertorAdvisor.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGR2ConvertorAdvisor.java index ceac2feae..b2fe5bfa9 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGR2ConvertorAdvisor.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGR2ConvertorAdvisor.java @@ -46,20 +46,7 @@ public class IGR2ConvertorAdvisor implements VersionConvertorAdvisor40 { return false; } - @Override - public Resource convertR2(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - return null; - } @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGR2ConvertorAdvisor5.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGR2ConvertorAdvisor5.java index 132c2bcbe..20ae18af3 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGR2ConvertorAdvisor5.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/IGR2ConvertorAdvisor5.java @@ -46,21 +46,6 @@ public class IGR2ConvertorAdvisor5 implements VersionConvertorAdvisor50 { return false; } - @Override - public Resource convertR2(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem cs, ValueSet vs) { cs.setId(vs.getId()); @@ -71,9 +56,4 @@ public class IGR2ConvertorAdvisor5 implements VersionConvertorAdvisor50 { return null; } - @Override - public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException { - return null; - } - } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/NpmPackageVersionConverter.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/NpmPackageVersionConverter.java index 4f63e27fa..72282bd65 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/NpmPackageVersionConverter.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/NpmPackageVersionConverter.java @@ -50,20 +50,6 @@ public class NpmPackageVersionConverter { return false; } - @Override - public Resource convertR2(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - throw new Error("Not done yet"); - } - - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - throw new Error("Not done yet"); - } - - @Override - public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r4.model.Resource resource) throws FHIRException { - throw new Error("Not done yet"); - } @Override public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException { diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/ListResource.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/ListResource.java index 3a48c081a..4203569c2 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/ListResource.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/ListResource.java @@ -1755,7 +1755,7 @@ public class ListResource extends DomainResource { * Path: List.subject
*

*/ - @SearchParamDefinition(name="subject", path="List.subject", description="If all resources have the same subject", type="reference", target={Device.class, Group.class, Location.class, Patient.class } ) + @SearchParamDefinition(name="subject", path="List.subject", description="If all resources have the same subject", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={Device.class, Group.class, Location.class, Patient.class } ) public static final String SP_SUBJECT = "subject"; /** * Fluent Client search parameter constant for subject @@ -1807,7 +1807,7 @@ public class ListResource extends DomainResource { * Path: List.source
*

*/ - @SearchParamDefinition(name="source", path="List.source", description="Who and/or what defined the list contents (aka Author)", type="reference", target={Device.class, Patient.class, Practitioner.class } ) + @SearchParamDefinition(name="source", path="List.source", description="Who and/or what defined the list contents (aka Author)", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Practitioner") }, target={Device.class, Patient.class, Practitioner.class } ) public static final String SP_SOURCE = "source"; /** * Fluent Client search parameter constant for source diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/ListResource.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/ListResource.java index 120414399..190a18c59 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/ListResource.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/ListResource.java @@ -1763,7 +1763,7 @@ public class ListResource extends DomainResource { * Path: List.subject
*

*/ - @SearchParamDefinition(name="subject", path="List.subject", description="If all resources have the same subject", type="reference", target={Device.class, Group.class, Location.class, Patient.class } ) + @SearchParamDefinition(name="subject", path="List.subject", description="If all resources have the same subject", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={Device.class, Group.class, Location.class, Patient.class } ) public static final String SP_SUBJECT = "subject"; /** * Fluent Client search parameter constant for subject @@ -1815,7 +1815,7 @@ public class ListResource extends DomainResource { * Path: List.source
*

*/ - @SearchParamDefinition(name="source", path="List.source", description="Who and/or what defined the list contents (aka Author)", type="reference", target={Device.class, Patient.class, Practitioner.class, PractitionerRole.class } ) + @SearchParamDefinition(name="source", path="List.source", description="Who and/or what defined the list contents (aka Author)", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Practitioner") }, target={Device.class, Patient.class, Practitioner.class, PractitionerRole.class } ) public static final String SP_SOURCE = "source"; /** * Fluent Client search parameter constant for source diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index 88489aa6c..6aefc6650 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -329,6 +329,7 @@ public class ProfileUtilities extends TranslatingUtilities { private String defWebRoot; private boolean autoFixSliceNames; private XVerExtensionManager xver; + private boolean wantFixDifferentialFirstElementType; public ProfileUtilities(IWorkerContext context, List messages, ProfileKnowledgeProvider pkp, FHIRPathEngine fpe) { super(); @@ -363,9 +364,15 @@ public class ProfileUtilities extends TranslatingUtilities { public void setIgmode(boolean igmode) { this.igmode = igmode; } + + public boolean isWantFixDifferentialFirstElementType() { + return wantFixDifferentialFirstElementType; + } + + public void setWantFixDifferentialFirstElementType(boolean wantFixDifferentialFirstElementType) { + this.wantFixDifferentialFirstElementType = wantFixDifferentialFirstElementType; + } - - public boolean isAutoFixSliceNames() { return autoFixSliceNames; } @@ -609,7 +616,8 @@ public class ProfileUtilities extends TranslatingUtilities { derived.setSnapshot(new StructureDefinitionSnapshotComponent()); try { - checkDifferential(derived.getDifferential().getElement(), derived.getType(), derived.getUrl()); + checkDifferential(derived.getDifferential().getElement(), typeName(derived.getType()), derived.getUrl()); + checkDifferentialBaseType(derived); // so we have two lists - the base list, and the differential list // the differential list is only allowed to include things that are in the base list, but @@ -620,8 +628,6 @@ public class ProfileUtilities extends TranslatingUtilities { int baseCursor = 0; int diffCursor = 0; // we need a diff cursor because we can only look ahead, in the bound scoped by longer paths - if (derived.hasDifferential() && !derived.getDifferential().getElementFirstRep().getPath().contains(".") && !derived.getDifferential().getElementFirstRep().getType().isEmpty()) - throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_DIFFERENTIAL_ELEMENT)); for (ElementDefinition e : derived.getDifferential().getElement()) e.clearUserData(GENERATED_IN_SNAPSHOT); @@ -771,6 +777,29 @@ public class ProfileUtilities extends TranslatingUtilities { derived.clearUserData("profileutils.snapshot.generating"); } + public void checkDifferentialBaseType(StructureDefinition derived) throws Error { + if (derived.hasDifferential() && !derived.getDifferential().getElementFirstRep().getPath().contains(".") && !derived.getDifferential().getElementFirstRep().getType().isEmpty()) { + if (wantFixDifferentialFirstElementType && typeMatchesAncestor(derived.getDifferential().getElementFirstRep().getType(), derived.getBaseDefinition())) { + derived.getDifferential().getElementFirstRep().getType().clear(); + } else { + throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_DIFFERENTIAL_ELEMENT)); + } + } + } + + private boolean typeMatchesAncestor(List type, String baseDefinition) { + StructureDefinition sd = context.fetchResource(StructureDefinition.class, baseDefinition); + return sd != null && type.size() == 1 && sd.getType().equals(type.get(0).getCode()); + } + + private String typeName(String type) { + if (Utilities.isAbsoluteUrl(type)) { + return type.substring(type.lastIndexOf("/")+1); + } else { + return type; + } + } + private void checkGroupConstraints(StructureDefinition derived) { List toRemove = new ArrayList<>(); // List processed = new ArrayList<>(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java index 3b01a0ab3..4fbe39b18 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java @@ -86,6 +86,16 @@ public class XmlParser extends ParserBase { public XmlParser(IWorkerContext context) { super(context); } + + private String schemaPath; + + public String getSchemaPath() { + return schemaPath; + } + public void setSchemaPath(String schemaPath) { + this.schemaPath = schemaPath; + } + public boolean isAllowXsiLocation() { @@ -597,6 +607,9 @@ public class XmlParser extends ParserBase { public void compose(Element e, IXMLWriter xml) throws Exception { xml.start(); xml.setDefaultNamespace(e.getProperty().getXmlNamespace()); + if (schemaPath != null) { + xml.setSchemaLocation(FormatUtilities.FHIR_NS, Utilities.pathURL(schemaPath, e.fhirType()+".xsd")); + } composeElement(xml, e, e.getType(), true); xml.end(); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParserBase.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParserBase.java index b9643e3aa..ce36fe83e 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParserBase.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParserBase.java @@ -99,10 +99,11 @@ public abstract class XmlParserBase extends ParserBase implements IParser { public ParserType getType() { return ParserType.XML; } - + + // -- in descendent generated code -------------------------------------- - abstract protected Resource parseResource(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError ; + abstract protected Resource parseResource(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError ; abstract protected DataType parseType(XmlPullParser xml, String type) throws XmlPullParserException, IOException, FHIRFormatError ; abstract protected DataType parseAnyType(XmlPullParser xml, String type) throws XmlPullParserException, IOException, FHIRFormatError ; abstract protected void composeType(String prefix, DataType type) throws IOException ; @@ -268,6 +269,14 @@ public abstract class XmlParserBase extends ParserBase implements IParser { protected IXMLWriter xml; protected boolean htmlPretty; + private String schemaPath; + + public String getSchemaPath() { + return schemaPath; + } + public void setSchemaPath(String schemaPath) { + this.schemaPath = schemaPath; + } @@ -382,6 +391,9 @@ public abstract class XmlParserBase extends ParserBase implements IParser { this.htmlPretty = htmlPretty; xml = writer; xml.setDefaultNamespace(FHIR_NS); + if (schemaPath != null) { + xml.setSchemaLocation(FHIR_NS, Utilities.pathURL(schemaPath, resource.fhirType()+".xsd")); + } composeResource(resource); } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java index d1ec769f1..1bdd2815f 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java @@ -2,6 +2,10 @@ package org.hl7.fhir.r5.test; import static org.junit.jupiter.api.Assertions.*; +import java.io.IOException; + +import org.hl7.fhir.r5.formats.IParser.OutputStyle; +import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.CapabilityStatement; import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.CompartmentDefinition; @@ -12,6 +16,7 @@ import org.hl7.fhir.r5.model.ImplementationGuide; import org.hl7.fhir.r5.model.MessageDefinition; import org.hl7.fhir.r5.model.NamingSystem; import org.hl7.fhir.r5.model.OperationDefinition; +import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.SearchParameter; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureMap; @@ -40,4 +45,27 @@ class ResourceTests { assertFalse(new GraphDefinition().supportsCopyright()); } + private String SRC = "\r\n\r\n"+ + "\r\n"+ + " \r\n"+ + " \r\n"+ + " \r\n"+ + "\r\n"; + + private String TGT = ""+ + ""+ + ""+ + ""+ + ""+ + ""; + + @Test + void testSchemaLocation() throws IOException { + XmlParser xml = new XmlParser(); + xml.setSchemaPath("http://test.org"); + xml.setOutputStyle(OutputStyle.NORMAL); + Resource res = xml.parse(SRC); + String output = xml.composeString(res); + assertEquals(TGT, output); + } } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/IXMLWriter.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/IXMLWriter.java index 87b5773ca..2be6e0e6e 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/IXMLWriter.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/IXMLWriter.java @@ -60,6 +60,7 @@ public interface IXMLWriter { public abstract void comment(String comment, boolean doPretty) throws IOException; public abstract void decorate(ElementDecoration decoration) throws IOException; + public abstract void setSchemaLocation(String ns, String loc) throws IOException; public abstract void enter(String name) throws IOException; public abstract void enter(String namespace, String name) throws IOException; diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java index 3854919cf..65753df7f 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java @@ -900,6 +900,12 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter { public void decorate(ElementDecoration element) throws IOException { // nothing... } + @Override + public void setSchemaLocation(String ns, String loc) throws IOException { + namespace("http://www.w3.org/2001/XMLSchema-instance", "xsi"); + attribute("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation", ns+" "+loc); + + } } \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java index 00b5cb9db..f54d8d2a7 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/NativeHostServices.java @@ -108,21 +108,6 @@ public class NativeHostServices { return false; } - @Override - public org.hl7.fhir.dstu2016may.model.Resource convertR2016May(Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu2.model.Resource convertR2(Resource resource) throws FHIRException { - return null; - } - - @Override - public org.hl7.fhir.dstu3.model.Resource convertR3(Resource resource) throws FHIRException { - return null; - } - @Override public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException { } @@ -132,12 +117,6 @@ public class NativeHostServices { throw new FHIRException("Code systems cannot be handled at this time"); // what to do? need thread local storage? } - @Override - public org.hl7.fhir.r4.model.Resource convertR4(Resource resource) throws FHIRException { - // still to do - return null; - } - } private ValidationEngine validator; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java index 7e71fa3d6..ae3bc199c 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java @@ -485,9 +485,9 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst makeSnapshot(sd); } catch (Exception e) { System.out.println("Process Note: Unable to generate snapshot for " + sd.present() + ": " + e.getMessage()); - if (debug) { +// if (debug) { e.printStackTrace(); - } +// } } } } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index 7fb09409f..a20839f05 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -2757,7 +2757,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } private boolean isSuspiciousReference(String url) { - if (!assumeValidRestReferences || url == null || Utilities.isAbsoluteUrl(url)) { + if (!assumeValidRestReferences || url == null || Utilities.isAbsoluteUrl(url) || url.startsWith("#")) { return false; } String[] parts = url.split("\\/");