Merge pull request #488 from hapifhir/gg-202105-version-conversion-1
tidy up and document version conversion advisors
This commit is contained in:
commit
3c28b476f1
|
@ -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)
|
* 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
|
||||||
|
|
|
@ -33,14 +33,54 @@ package org.hl7.fhir.convertors;
|
||||||
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
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 {
|
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);
|
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;
|
* 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
|
||||||
// called when an r2 value set has a codeSystem in it
|
* 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;
|
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;
|
org.hl7.fhir.dstu3.model.CodeSystem getCodeSystem(org.hl7.fhir.dstu3.model.ValueSet src) throws FHIRException;
|
||||||
}
|
}
|
|
@ -33,16 +33,55 @@ package org.hl7.fhir.convertors;
|
||||||
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
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 {
|
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);
|
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;
|
* In R2, code systems are internal to value sets, but in subsequent versions, they
|
||||||
org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r4.model.Resource resource) throws FHIRException;
|
* exist as separate resources. The convertor will create the code system, and then
|
||||||
org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r4.model.Resource resource) throws FHIRException;
|
* call this routine for the host to decide what to do with it
|
||||||
|
*
|
||||||
// called when an r2 value set has a codeSystem in 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;
|
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;
|
org.hl7.fhir.r4.model.CodeSystem getCodeSystem(org.hl7.fhir.r4.model.ValueSet src) throws FHIRException;
|
||||||
}
|
}
|
|
@ -34,16 +34,41 @@ package org.hl7.fhir.convertors;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
|
||||||
public interface VersionConvertorAdvisor50 {
|
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);
|
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;
|
* In R2, code systems are internal to value sets, but in subsequent versions, they
|
||||||
org.hl7.fhir.dstu2016may.model.Resource convertR2016May(org.hl7.fhir.r5.model.Resource resource) throws FHIRException;
|
* exist as separate resources. The convertor will create the code system, and then
|
||||||
org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException;
|
* call this routine for the host to decide what to do with it
|
||||||
org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException;
|
*
|
||||||
|
* It can make it a contained resource, or it can put it somewhere else
|
||||||
// called when an r2 value set has a codeSystem in it
|
*
|
||||||
|
* @param tgtcs
|
||||||
|
* @param source
|
||||||
|
* @throws FHIRException
|
||||||
|
*/
|
||||||
void handleCodeSystem(org.hl7.fhir.r5.model.CodeSystem tgtcs, org.hl7.fhir.r5.model.ValueSet 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;
|
org.hl7.fhir.r5.model.CodeSystem getCodeSystem(org.hl7.fhir.r5.model.ValueSet src) throws FHIRException;
|
||||||
}
|
}
|
|
@ -52,9 +52,7 @@ public class Bundle10_30 {
|
||||||
for (org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t));
|
for (org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t));
|
||||||
if (src.hasFullUrlElement())
|
if (src.hasFullUrlElement())
|
||||||
tgt.setFullUrlElement(VersionConvertor_10_30.convertUri(src.getFullUrlElement()));
|
tgt.setFullUrlElement(VersionConvertor_10_30.convertUri(src.getFullUrlElement()));
|
||||||
org.hl7.fhir.dstu2.model.Resource res = advisor.convert(src.getResource());
|
org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_30.convertResource(src.getResource());
|
||||||
if (res == null)
|
|
||||||
res = VersionConvertor_10_30.convertResource(src.getResource());
|
|
||||||
tgt.setResource(res);
|
tgt.setResource(res);
|
||||||
if (src.hasSearch())
|
if (src.hasSearch())
|
||||||
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
|
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
|
||||||
|
|
|
@ -71,9 +71,7 @@ public class Bundle10_40 {
|
||||||
for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t));
|
for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t));
|
||||||
if (src.hasFullUrlElement())
|
if (src.hasFullUrlElement())
|
||||||
tgt.setFullUrlElement(VersionConvertor_10_40.convertUri(src.getFullUrlElement()));
|
tgt.setFullUrlElement(VersionConvertor_10_40.convertUri(src.getFullUrlElement()));
|
||||||
org.hl7.fhir.dstu2.model.Resource res = advisor.convertR2(src.getResource());
|
org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_40.convertResource(src.getResource());
|
||||||
if (res == null)
|
|
||||||
res = VersionConvertor_10_40.convertResource(src.getResource());
|
|
||||||
tgt.setResource(res);
|
tgt.setResource(res);
|
||||||
if (src.hasSearch())
|
if (src.hasSearch())
|
||||||
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
|
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
|
||||||
|
|
|
@ -71,9 +71,7 @@ public class Bundle10_50 {
|
||||||
for (org.hl7.fhir.r5.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t));
|
for (org.hl7.fhir.r5.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t));
|
||||||
if (src.hasFullUrlElement())
|
if (src.hasFullUrlElement())
|
||||||
tgt.setFullUrlElement(VersionConvertor_10_50.convertUri(src.getFullUrlElement()));
|
tgt.setFullUrlElement(VersionConvertor_10_50.convertUri(src.getFullUrlElement()));
|
||||||
org.hl7.fhir.dstu2.model.Resource res = advisor.convertR2(src.getResource());
|
org.hl7.fhir.dstu2.model.Resource res = VersionConvertor_10_50.convertResource(src.getResource());
|
||||||
if (res == null)
|
|
||||||
res = VersionConvertor_10_50.convertResource(src.getResource());
|
|
||||||
tgt.setResource(res);
|
tgt.setResource(res);
|
||||||
if (src.hasSearch())
|
if (src.hasSearch())
|
||||||
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
|
tgt.setSearch(convertBundleEntrySearchComponent(src.getSearch()));
|
||||||
|
|
|
@ -116,21 +116,6 @@ public class R2016MayToR4Loader extends BaseLoaderR4 implements IContextResource
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
cs.setId(vs.getId());
|
cs.setId(vs.getId());
|
||||||
|
|
|
@ -163,21 +163,6 @@ public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertor
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
cs.setId(vs.getId());
|
cs.setId(vs.getId());
|
||||||
|
@ -191,11 +176,5 @@ public class R2016MayToR5Loader extends BaseLoaderR5 implements VersionConvertor
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -113,10 +113,6 @@ public class R2ToR3Loader extends BaseLoaderR3 implements VersionConvertorAdviso
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Resource convert(org.hl7.fhir.dstu3.model.Resource resource) throws FHIRException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
|
|
|
@ -115,20 +115,6 @@ public class R2ToR4Loader extends BaseLoaderR4 implements VersionConvertorAdviso
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
cs.setId(vs.getId());
|
cs.setId(vs.getId());
|
||||||
|
|
|
@ -163,20 +163,6 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
cs.setId(vs.getId());
|
cs.setId(vs.getId());
|
||||||
|
@ -190,10 +176,5 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -125,20 +125,6 @@ public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
|
|
|
@ -166,21 +166,6 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
cs.setId(vs.getId());
|
cs.setId(vs.getId());
|
||||||
|
@ -194,9 +179,4 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -166,21 +166,6 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
cs.setId(vs.getId());
|
cs.setId(vs.getId());
|
||||||
|
@ -194,9 +179,4 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -163,21 +163,6 @@ public class R5ToR5Loader extends BaseLoaderR5 implements VersionConvertorAdviso
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
cs.setId(vs.getId());
|
cs.setId(vs.getId());
|
||||||
|
@ -191,9 +176,4 @@ public class R5ToR5Loader extends BaseLoaderR5 implements VersionConvertorAdviso
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.hl7.fhir.dstu3.model.Resource convertR3(org.hl7.fhir.r5.model.Resource resource) throws FHIRException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -89,10 +89,6 @@ public class IGPackConverter102 implements VersionConvertorAdvisor30 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Resource convert(org.hl7.fhir.dstu3.model.Resource resource) throws FHIRException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem tgtcs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem tgtcs, ValueSet vs) {
|
||||||
|
|
|
@ -46,20 +46,7 @@ public class IGR2ConvertorAdvisor implements VersionConvertorAdvisor40 {
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
|
|
|
@ -46,21 +46,6 @@ public class IGR2ConvertorAdvisor5 implements VersionConvertorAdvisor50 {
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
|
||||||
cs.setId(vs.getId());
|
cs.setId(vs.getId());
|
||||||
|
@ -71,9 +56,4 @@ public class IGR2ConvertorAdvisor5 implements VersionConvertorAdvisor50 {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.hl7.fhir.r4.model.Resource convertR4(org.hl7.fhir.r5.model.Resource resource) throws FHIRException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -50,20 +50,6 @@ public class NpmPackageVersionConverter {
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException {
|
public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException {
|
||||||
|
|
|
@ -1755,7 +1755,7 @@ public class ListResource extends DomainResource {
|
||||||
* Path: <b>List.subject</b><br>
|
* Path: <b>List.subject</b><br>
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@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";
|
public static final String SP_SUBJECT = "subject";
|
||||||
/**
|
/**
|
||||||
* <b>Fluent Client</b> search parameter constant for <b>subject</b>
|
* <b>Fluent Client</b> search parameter constant for <b>subject</b>
|
||||||
|
@ -1807,7 +1807,7 @@ public class ListResource extends DomainResource {
|
||||||
* Path: <b>List.source</b><br>
|
* Path: <b>List.source</b><br>
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@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";
|
public static final String SP_SOURCE = "source";
|
||||||
/**
|
/**
|
||||||
* <b>Fluent Client</b> search parameter constant for <b>source</b>
|
* <b>Fluent Client</b> search parameter constant for <b>source</b>
|
||||||
|
|
|
@ -1763,7 +1763,7 @@ public class ListResource extends DomainResource {
|
||||||
* Path: <b>List.subject</b><br>
|
* Path: <b>List.subject</b><br>
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@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";
|
public static final String SP_SUBJECT = "subject";
|
||||||
/**
|
/**
|
||||||
* <b>Fluent Client</b> search parameter constant for <b>subject</b>
|
* <b>Fluent Client</b> search parameter constant for <b>subject</b>
|
||||||
|
@ -1815,7 +1815,7 @@ public class ListResource extends DomainResource {
|
||||||
* Path: <b>List.source</b><br>
|
* Path: <b>List.source</b><br>
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@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";
|
public static final String SP_SOURCE = "source";
|
||||||
/**
|
/**
|
||||||
* <b>Fluent Client</b> search parameter constant for <b>source</b>
|
* <b>Fluent Client</b> search parameter constant for <b>source</b>
|
||||||
|
|
|
@ -329,6 +329,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
private String defWebRoot;
|
private String defWebRoot;
|
||||||
private boolean autoFixSliceNames;
|
private boolean autoFixSliceNames;
|
||||||
private XVerExtensionManager xver;
|
private XVerExtensionManager xver;
|
||||||
|
private boolean wantFixDifferentialFirstElementType;
|
||||||
|
|
||||||
public ProfileUtilities(IWorkerContext context, List<ValidationMessage> messages, ProfileKnowledgeProvider pkp, FHIRPathEngine fpe) {
|
public ProfileUtilities(IWorkerContext context, List<ValidationMessage> messages, ProfileKnowledgeProvider pkp, FHIRPathEngine fpe) {
|
||||||
super();
|
super();
|
||||||
|
@ -363,9 +364,15 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
public void setIgmode(boolean igmode) {
|
public void setIgmode(boolean igmode) {
|
||||||
this.igmode = igmode;
|
this.igmode = igmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWantFixDifferentialFirstElementType() {
|
||||||
|
return wantFixDifferentialFirstElementType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWantFixDifferentialFirstElementType(boolean wantFixDifferentialFirstElementType) {
|
||||||
|
this.wantFixDifferentialFirstElementType = wantFixDifferentialFirstElementType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isAutoFixSliceNames() {
|
public boolean isAutoFixSliceNames() {
|
||||||
return autoFixSliceNames;
|
return autoFixSliceNames;
|
||||||
}
|
}
|
||||||
|
@ -609,7 +616,8 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
derived.setSnapshot(new StructureDefinitionSnapshotComponent());
|
derived.setSnapshot(new StructureDefinitionSnapshotComponent());
|
||||||
|
|
||||||
try {
|
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
|
// 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
|
// 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 baseCursor = 0;
|
||||||
int diffCursor = 0; // we need a diff cursor because we can only look ahead, in the bound scoped by longer paths
|
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())
|
for (ElementDefinition e : derived.getDifferential().getElement())
|
||||||
e.clearUserData(GENERATED_IN_SNAPSHOT);
|
e.clearUserData(GENERATED_IN_SNAPSHOT);
|
||||||
|
@ -771,6 +777,29 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
derived.clearUserData("profileutils.snapshot.generating");
|
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<TypeRefComponent> 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) {
|
private void checkGroupConstraints(StructureDefinition derived) {
|
||||||
List<ElementDefinition> toRemove = new ArrayList<>();
|
List<ElementDefinition> toRemove = new ArrayList<>();
|
||||||
// List<ElementDefinition> processed = new ArrayList<>();
|
// List<ElementDefinition> processed = new ArrayList<>();
|
||||||
|
|
|
@ -86,6 +86,16 @@ public class XmlParser extends ParserBase {
|
||||||
public XmlParser(IWorkerContext context) {
|
public XmlParser(IWorkerContext context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String schemaPath;
|
||||||
|
|
||||||
|
public String getSchemaPath() {
|
||||||
|
return schemaPath;
|
||||||
|
}
|
||||||
|
public void setSchemaPath(String schemaPath) {
|
||||||
|
this.schemaPath = schemaPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isAllowXsiLocation() {
|
public boolean isAllowXsiLocation() {
|
||||||
|
@ -597,6 +607,9 @@ public class XmlParser extends ParserBase {
|
||||||
public void compose(Element e, IXMLWriter xml) throws Exception {
|
public void compose(Element e, IXMLWriter xml) throws Exception {
|
||||||
xml.start();
|
xml.start();
|
||||||
xml.setDefaultNamespace(e.getProperty().getXmlNamespace());
|
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);
|
composeElement(xml, e, e.getType(), true);
|
||||||
xml.end();
|
xml.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,10 +99,11 @@ public abstract class XmlParserBase extends ParserBase implements IParser {
|
||||||
public ParserType getType() {
|
public ParserType getType() {
|
||||||
return ParserType.XML;
|
return ParserType.XML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- in descendent generated code --------------------------------------
|
// -- 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 parseType(XmlPullParser xml, String type) throws XmlPullParserException, IOException, FHIRFormatError ;
|
||||||
abstract protected DataType parseAnyType(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 ;
|
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 IXMLWriter xml;
|
||||||
protected boolean htmlPretty;
|
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;
|
this.htmlPretty = htmlPretty;
|
||||||
xml = writer;
|
xml = writer;
|
||||||
xml.setDefaultNamespace(FHIR_NS);
|
xml.setDefaultNamespace(FHIR_NS);
|
||||||
|
if (schemaPath != null) {
|
||||||
|
xml.setSchemaLocation(FHIR_NS, Utilities.pathURL(schemaPath, resource.fhirType()+".xsd"));
|
||||||
|
}
|
||||||
composeResource(resource);
|
composeResource(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@ package org.hl7.fhir.r5.test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
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.CapabilityStatement;
|
||||||
import org.hl7.fhir.r5.model.CodeSystem;
|
import org.hl7.fhir.r5.model.CodeSystem;
|
||||||
import org.hl7.fhir.r5.model.CompartmentDefinition;
|
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.MessageDefinition;
|
||||||
import org.hl7.fhir.r5.model.NamingSystem;
|
import org.hl7.fhir.r5.model.NamingSystem;
|
||||||
import org.hl7.fhir.r5.model.OperationDefinition;
|
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.SearchParameter;
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
import org.hl7.fhir.r5.model.StructureMap;
|
import org.hl7.fhir.r5.model.StructureMap;
|
||||||
|
@ -40,4 +45,27 @@ class ResourceTests {
|
||||||
assertFalse(new GraphDefinition().supportsCopyright());
|
assertFalse(new GraphDefinition().supportsCopyright());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String SRC = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\r\n"+
|
||||||
|
"<Patient xmlns=\"http://hl7.org/fhir\">\r\n"+
|
||||||
|
" <name>\r\n"+
|
||||||
|
" <text value=\"Job Bloggs\"/>\r\n"+
|
||||||
|
" </name>\r\n"+
|
||||||
|
"</Patient>\r\n";
|
||||||
|
|
||||||
|
private String TGT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
|
||||||
|
"<Patient xmlns=\"http://hl7.org/fhir\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://hl7.org/fhir http://test.org/Patient.xsd\">"+
|
||||||
|
"<name>"+
|
||||||
|
"<text value=\"Job Bloggs\"/>"+
|
||||||
|
"</name>"+
|
||||||
|
"</Patient>";
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ public interface IXMLWriter {
|
||||||
|
|
||||||
public abstract void comment(String comment, boolean doPretty) throws IOException;
|
public abstract void comment(String comment, boolean doPretty) throws IOException;
|
||||||
public abstract void decorate(ElementDecoration decoration) 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 name) throws IOException;
|
||||||
public abstract void enter(String namespace, String name) throws IOException;
|
public abstract void enter(String namespace, String name) throws IOException;
|
||||||
|
|
|
@ -900,6 +900,12 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter {
|
||||||
public void decorate(ElementDecoration element) throws IOException {
|
public void decorate(ElementDecoration element) throws IOException {
|
||||||
// nothing...
|
// 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -108,21 +108,6 @@ public class NativeHostServices {
|
||||||
return false;
|
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
|
@Override
|
||||||
public void handleCodeSystem(CodeSystem tgtcs, ValueSet source) throws FHIRException {
|
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?
|
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;
|
private ValidationEngine validator;
|
||||||
|
|
|
@ -485,9 +485,9 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst
|
||||||
makeSnapshot(sd);
|
makeSnapshot(sd);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Process Note: Unable to generate snapshot for " + sd.present() + ": " + e.getMessage());
|
System.out.println("Process Note: Unable to generate snapshot for " + sd.present() + ": " + e.getMessage());
|
||||||
if (debug) {
|
// if (debug) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2757,7 +2757,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSuspiciousReference(String url) {
|
private boolean isSuspiciousReference(String url) {
|
||||||
if (!assumeValidRestReferences || url == null || Utilities.isAbsoluteUrl(url)) {
|
if (!assumeValidRestReferences || url == null || Utilities.isAbsoluteUrl(url) || url.startsWith("#")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String[] parts = url.split("\\/");
|
String[] parts = url.split("\\/");
|
||||||
|
|
Loading…
Reference in New Issue