Merge branch 'master' into logging_interceptor

This commit is contained in:
Mark Iantorno 2021-11-08 16:10:36 -05:00 committed by GitHub
commit f5de73921a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 594 additions and 612 deletions

View File

@ -1 +1,2 @@
* Updating client logger to log both req and resp * Updating client logger to log both req and resp
* Refactoring of converter loader and misc packages.

View File

@ -37,9 +37,9 @@ import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_40; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
import org.hl7.fhir.convertors.loaders.R2016MayToR4Loader; import org.hl7.fhir.convertors.loaders.loaderR4.R2016MayToR4Loader;
import org.hl7.fhir.convertors.loaders.R2ToR4Loader; import org.hl7.fhir.convertors.loaders.loaderR4.R2ToR4Loader;
import org.hl7.fhir.convertors.loaders.R3ToR4Loader; import org.hl7.fhir.convertors.loaders.loaderR4.R3ToR4Loader;
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor; import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.conformance.ProfileUtilities; import org.hl7.fhir.r4.conformance.ProfileUtilities;

View File

@ -29,7 +29,7 @@ package org.hl7.fhir.convertors;
*/ */
import org.hl7.fhir.convertors.loaders.R2ToR3Loader; import org.hl7.fhir.convertors.loaders.loaderR3.R2ToR3Loader;
import org.hl7.fhir.dstu3.context.SimpleWorkerContext; import org.hl7.fhir.dstu3.context.SimpleWorkerContext;
import org.hl7.fhir.dstu3.elementmodel.Manager; import org.hl7.fhir.dstu3.elementmodel.Manager;
import org.hl7.fhir.dstu3.elementmodel.Manager.FhirFormat; import org.hl7.fhir.dstu3.elementmodel.Manager.FhirFormat;

View File

@ -1,74 +0,0 @@
package org.hl7.fhir.convertors.loaders;
import org.hl7.fhir.dstu3.context.SimpleWorkerContext.IContextResourceLoader;
import org.hl7.fhir.dstu3.model.Resource;
public abstract class BaseLoaderR3 implements IContextResourceLoader {
protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/";
protected final String URL_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/";
protected final String URL_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
private final String[] types;
private final ILoaderKnowledgeProvider lkp;
protected boolean patchUrls;
protected boolean killPrimitives;
public BaseLoaderR3(String[] types, ILoaderKnowledgeProvider lkp) {
super();
this.types = types;
this.lkp = lkp;
}
public String[] getTypes() {
return types;
}
public boolean isPatchUrls() {
return patchUrls;
}
public BaseLoaderR3 setPatchUrls(boolean patchUrls) {
this.patchUrls = patchUrls;
return this;
}
public boolean isKillPrimitives() {
return killPrimitives;
}
public BaseLoaderR3 setKillPrimitives(boolean killPrimitives) {
this.killPrimitives = killPrimitives;
return this;
}
public String getResourcePath(Resource resource) {
return lkp.getResourcePath(resource);
}
public void setPath(Resource r) {
String path = lkp.getResourcePath(r);
if (path != null) {
r.setUserData("path", path);
}
}
public interface ILoaderKnowledgeProvider {
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
}
public static class NullLoaderKnowledgeProvider implements ILoaderKnowledgeProvider {
@Override
public String getResourcePath(Resource resource) {
return null;
}
}
}

View File

@ -1,74 +0,0 @@
package org.hl7.fhir.convertors.loaders;
import org.hl7.fhir.r4.context.SimpleWorkerContext.IContextResourceLoader;
import org.hl7.fhir.r4.model.Resource;
public abstract class BaseLoaderR4 implements IContextResourceLoader {
protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/";
protected final String URL_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/";
protected final String URL_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
private final String[] types;
private final ILoaderKnowledgeProvider lkp;
protected boolean patchUrls;
protected boolean killPrimitives;
public BaseLoaderR4(String[] types, ILoaderKnowledgeProvider lkp) {
super();
this.types = types;
this.lkp = lkp;
}
public String[] getTypes() {
return types;
}
public boolean isPatchUrls() {
return patchUrls;
}
public BaseLoaderR4 setPatchUrls(boolean patchUrls) {
this.patchUrls = patchUrls;
return this;
}
public boolean isKillPrimitives() {
return killPrimitives;
}
public BaseLoaderR4 setKillPrimitives(boolean killPrimitives) {
this.killPrimitives = killPrimitives;
return this;
}
public String getResourcePath(Resource resource) {
return lkp.getResourcePath(resource);
}
public void setPath(Resource r) {
String path = lkp.getResourcePath(r);
if (path != null) {
r.setUserData("path", path);
}
}
public interface ILoaderKnowledgeProvider {
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
}
public static class NullLoaderKnowledgeProvider implements ILoaderKnowledgeProvider {
@Override
public String getResourcePath(Resource resource) {
return null;
}
}
}

View File

@ -0,0 +1,43 @@
package org.hl7.fhir.convertors.loaders.loaderR3;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hl7.fhir.dstu3.context.SimpleWorkerContext.IContextResourceLoader;
import org.hl7.fhir.dstu3.model.Resource;
import javax.annotation.Nonnull;
@Accessors(chain = true)
public abstract class BaseLoaderR3 implements IContextResourceLoader {
protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/";
protected final String URL_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/";
protected final String URL_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
@Getter private final String[] types;
private final ILoaderKnowledgeProviderR3 lkp;
@Getter @Setter protected boolean patchUrls;
@Getter @Setter protected boolean killPrimitives;
public BaseLoaderR3(@Nonnull String[] types, @Nonnull ILoaderKnowledgeProviderR3 lkp) {
super();
this.types = types;
this.lkp = lkp;
}
public String getResourcePath(Resource resource) {
return lkp.getResourcePath(resource);
}
public void setPath(Resource r) {
String path = lkp.getResourcePath(r);
if (path != null) {
r.setUserData("path", path);
}
}
}

View File

@ -0,0 +1,13 @@
package org.hl7.fhir.convertors.loaders.loaderR3;
import org.hl7.fhir.dstu3.model.Resource;
public interface ILoaderKnowledgeProviderR3 {
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
}

View File

@ -0,0 +1,10 @@
package org.hl7.fhir.convertors.loaders.loaderR3;
import org.hl7.fhir.dstu3.model.Resource;
public class NullLoaderKnowledgeProviderR3 implements ILoaderKnowledgeProviderR3 {
@Override
public String getResourcePath(Resource resource) {
return null;
}
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR3;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -55,7 +55,7 @@ public class R2ToR3Loader extends BaseLoaderR3 {
private final BaseAdvisor_10_30 advisor_10_30 = new BaseAdvisor_10_30(); private final BaseAdvisor_10_30 advisor_10_30 = new BaseAdvisor_10_30();
public R2ToR3Loader() { public R2ToR3Loader() {
super(new String[0], new NullLoaderKnowledgeProvider()); super(new String[0], new NullLoaderKnowledgeProviderR3());
} }
@Override @Override

View File

@ -0,0 +1,42 @@
package org.hl7.fhir.convertors.loaders.loaderR4;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hl7.fhir.r4.context.SimpleWorkerContext.IContextResourceLoader;
import org.hl7.fhir.r4.model.Resource;
import javax.annotation.Nonnull;
@Accessors(chain = true)
public abstract class BaseLoaderR4 implements IContextResourceLoader {
protected final String URL_BASE = "http://hl7.org/fhir/";
protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/";
protected final String URL_DSTU2016MAY = "http://hl7.org/fhir/1.4/";
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/";
protected final String URL_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
@Getter private final String[] types;
private final ILoaderKnowledgeProviderR4 lkp;
@Getter @Setter protected boolean patchUrls;
@Getter @Setter protected boolean killPrimitives;
public BaseLoaderR4(@Nonnull String[] types, @Nonnull ILoaderKnowledgeProviderR4 lkp) {
super();
this.types = types;
this.lkp = lkp;
}
public String getResourcePath(Resource resource) {
return lkp.getResourcePath(resource);
}
public void setPath(Resource r) {
String path = lkp.getResourcePath(r);
if (path != null) {
r.setUserData("path", path);
}
}
}

View File

@ -0,0 +1,13 @@
package org.hl7.fhir.convertors.loaders.loaderR4;
import org.hl7.fhir.r4.model.Resource;
public interface ILoaderKnowledgeProviderR4 {
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
}

View File

@ -0,0 +1,10 @@
package org.hl7.fhir.convertors.loaders.loaderR4;
import org.hl7.fhir.r4.model.Resource;
public class NullLoaderKnowledgeProviderR4 implements ILoaderKnowledgeProviderR4 {
@Override
public String getResourcePath(Resource resource) {
return null;
}
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR4;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR4;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -55,7 +55,7 @@ public class R2ToR4Loader extends BaseLoaderR4 {
private final BaseAdvisor_10_40 advisor = new BaseAdvisor_10_40(); private final BaseAdvisor_10_40 advisor = new BaseAdvisor_10_40();
public R2ToR4Loader() { public R2ToR4Loader() {
super(new String[0], new NullLoaderKnowledgeProvider()); super(new String[0], new NullLoaderKnowledgeProviderR4());
} }
@Override @Override

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR4;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -54,7 +54,7 @@ public class R3ToR4Loader extends BaseLoaderR4 implements IContextResourceLoader
private final BaseAdvisor_30_40 advisor = new BaseAdvisor_30_40(); private final BaseAdvisor_30_40 advisor = new BaseAdvisor_30_40();
public R3ToR4Loader() { public R3ToR4Loader() {
super(new String[0], new NullLoaderKnowledgeProvider()); super(new String[0], new NullLoaderKnowledgeProviderR4());
} }
@Override @Override

View File

@ -1,6 +1,9 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR5;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
@ -9,6 +12,7 @@ import org.hl7.fhir.utilities.npm.NpmPackage;
import java.io.IOException; import java.io.IOException;
@Accessors(chain = true)
public abstract class BaseLoaderR5 implements IContextResourceLoader { public abstract class BaseLoaderR5 implements IContextResourceLoader {
protected final String URL_BASE = "http://hl7.org/fhir/"; protected final String URL_BASE = "http://hl7.org/fhir/";
@ -17,39 +21,17 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/"; protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/";
protected final String URL_R4 = "http://hl7.org/fhir/4.0/"; protected final String URL_R4 = "http://hl7.org/fhir/4.0/";
protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"; protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace";
protected boolean patchUrls; @Getter @Setter protected boolean patchUrls;
protected boolean killPrimitives; @Getter @Setter protected boolean killPrimitives;
protected String[] types; @Getter protected String[] types;
protected ILoaderKnowledgeProvider lkp; protected ILoaderKnowledgeProviderR5 lkp;
public BaseLoaderR5(String[] types, ILoaderKnowledgeProvider lkp) { public BaseLoaderR5(String[] types, ILoaderKnowledgeProviderR5 lkp) {
super(); super();
this.types = types; this.types = types;
this.lkp = lkp; this.lkp = lkp;
} }
public String[] getTypes() {
return types;
}
public boolean isPatchUrls() {
return patchUrls;
}
public BaseLoaderR5 setPatchUrls(boolean patchUrls) {
this.patchUrls = patchUrls;
return this;
}
public boolean isKillPrimitives() {
return killPrimitives;
}
public BaseLoaderR5 setKillPrimitives(boolean killPrimitives) {
this.killPrimitives = killPrimitives;
return this;
}
public String getResourcePath(Resource resource) { public String getResourcePath(Resource resource) {
return lkp.getResourcePath(resource); return lkp.getResourcePath(resource);
} }
@ -84,27 +66,4 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
} }
} }
public interface ILoaderKnowledgeProvider {
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
ILoaderKnowledgeProvider forNewPackage(NpmPackage npm) throws JsonSyntaxException, IOException;
}
public static class NullLoaderKnowledgeProvider implements ILoaderKnowledgeProvider {
@Override
public String getResourcePath(Resource resource) {
return null;
}
@Override
public ILoaderKnowledgeProvider forNewPackage(NpmPackage npm) {
return this;
}
}
} }

View File

@ -0,0 +1,19 @@
package org.hl7.fhir.convertors.loaders.loaderR5;
import com.google.gson.JsonSyntaxException;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.utilities.npm.NpmPackage;
import java.io.IOException;
public interface ILoaderKnowledgeProviderR5 {
/**
* get the path for references to this resource.
*
* @param resource
* @return null if not tracking paths
*/
String getResourcePath(Resource resource);
ILoaderKnowledgeProviderR5 forNewPackage(NpmPackage npm) throws JsonSyntaxException, IOException;
}

View File

@ -0,0 +1,16 @@
package org.hl7.fhir.convertors.loaders.loaderR5;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.utilities.npm.NpmPackage;
public class NullLoaderKnowledgeProviderR5 implements ILoaderKnowledgeProviderR5 {
@Override
public String getResourcePath(Resource resource) {
return null;
}
@Override
public ILoaderKnowledgeProviderR5 forNewPackage(NpmPackage npm) {
return this;
}
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR5;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -53,7 +53,7 @@ public class R2016MayToR5Loader extends BaseLoaderR5 {
private final BaseAdvisor_14_50 advisor = new BaseAdvisor_14_50(); private final BaseAdvisor_14_50 advisor = new BaseAdvisor_14_50();
public R2016MayToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) { public R2016MayToR5Loader(String[] types, ILoaderKnowledgeProviderR5 lkp) {
super(types, lkp); super(types, lkp);
} }

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR5;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -53,7 +53,7 @@ public class R2ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
private final BaseAdvisor_10_50 advisor = new BaseAdvisor_10_50(); private final BaseAdvisor_10_50 advisor = new BaseAdvisor_10_50();
public R2ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) { public R2ToR5Loader(String[] types, ILoaderKnowledgeProviderR5 lkp) {
super(types, lkp); super(types, lkp);
} }

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR5;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -53,7 +53,7 @@ public class R3ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
private final BaseAdvisor_30_50 advisor = new BaseAdvisor_30_50(); private final BaseAdvisor_30_50 advisor = new BaseAdvisor_30_50();
public R3ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) { public R3ToR5Loader(String[] types, ILoaderKnowledgeProviderR5 lkp) {
super(types, lkp); super(types, lkp);
} }

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR5;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -53,7 +53,7 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
private final BaseAdvisor_40_50 advisor = new BaseAdvisor_40_50(); private final BaseAdvisor_40_50 advisor = new BaseAdvisor_40_50();
public R4ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) { public R4ToR5Loader(String[] types, ILoaderKnowledgeProviderR5 lkp) {
super(types, lkp); super(types, lkp);
} }

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.loaders; package org.hl7.fhir.convertors.loaders.loaderR5;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -50,7 +50,7 @@ public class R5ToR5Loader extends BaseLoaderR5 {
// TODO Grahame, will this ever be populated? No conversion is being done? // TODO Grahame, will this ever be populated? No conversion is being done?
private final List<CodeSystem> cslist = new ArrayList<>(); private final List<CodeSystem> cslist = new ArrayList<>();
public R5ToR5Loader(String[] types, ILoaderKnowledgeProvider lkp) { public R5ToR5Loader(String[] types, ILoaderKnowledgeProviderR5 lkp) {
super(types, lkp); super(types, lkp);
} }

View File

@ -30,6 +30,7 @@ package org.hl7.fhir.convertors.misc;
*/ */
import org.hl7.fhir.convertors.misc.adl.ADLImporter;
import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xml.XMLUtil; import org.hl7.fhir.utilities.xml.XMLUtil;

View File

@ -34,6 +34,7 @@ package org.hl7.fhir.convertors.misc;
*/ */
import org.fhir.ucum.UcumEssenceService; import org.fhir.ucum.UcumEssenceService;
import org.hl7.fhir.convertors.misc.ccda.CCDAConverter;
import org.hl7.fhir.dstu3.context.SimpleWorkerContext; import org.hl7.fhir.dstu3.context.SimpleWorkerContext;
import org.hl7.fhir.dstu3.formats.IParser; import org.hl7.fhir.dstu3.formats.IParser;
import org.hl7.fhir.dstu3.formats.IParser.OutputStyle; import org.hl7.fhir.dstu3.formats.IParser.OutputStyle;

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.misc; package org.hl7.fhir.convertors.misc.adl;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -133,20 +133,20 @@ public class ADLImporter {
// load data and protocol // load data and protocol
Element definition = XMLUtil.getNamedChild(adl, "definition"); Element definition = XMLUtil.getNamedChild(adl, "definition");
NodeTreeEntry root = new NodeTreeEntry(); NodeTreeEntry root = new NodeTreeEntry();
root.typeName = XMLUtil.getNamedChild(definition, "rm_type_name").getTextContent(); root.setTypeName(XMLUtil.getNamedChild(definition, "rm_type_name").getTextContent());
root.atCode = XMLUtil.getNamedChild(definition, "node_id").getTextContent(); root.setAtCode(XMLUtil.getNamedChild(definition, "node_id").getTextContent());
root.name = generateToken(root.atCode, true); root.setName(generateToken(root.getAtCode(), true));
sd.setName(root.name); sd.setName(root.getName());
root.cardinality = readCardinality("root", XMLUtil.getNamedChild(definition, "occurrences")); root.setCardinality(readCardinality("root", XMLUtil.getNamedChild(definition, "occurrences")));
set.clear(); set.clear();
XMLUtil.getNamedChildren(definition, "attributes", set); XMLUtil.getNamedChildren(definition, "attributes", set);
for (Element item : set) { for (Element item : set) {
// we're actually skipping this level - we don't care about data protocol etc. // we're actually skipping this level - we don't care about data protocol etc.
Element attributes = item; // XMLUtil.getNamedChild(XMLUtil.getNamedChild(item, "children"), "attributes"); Element attributes = item; // XMLUtil.getNamedChild(XMLUtil.getNamedChild(item, "children"), "attributes");
loadChildren(root.atCode, root, attributes); loadChildren(root.getAtCode(), root, attributes);
} }
dumpChildren("", root); dumpChildren("", root);
genElements(sd, root.name, root); genElements(sd, root.getName(), root);
// save // save
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dest), sd); new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dest), sd);
@ -156,20 +156,20 @@ public class ADLImporter {
private void genElements(StructureDefinition sd, String path, NodeTreeEntry item) throws Exception { private void genElements(StructureDefinition sd, String path, NodeTreeEntry item) throws Exception {
ElementDefinition ed = sd.getSnapshot().addElement(); ElementDefinition ed = sd.getSnapshot().addElement();
ed.setPath(path); ed.setPath(path);
ed.setMax(item.cardinality.max); ed.setMax(item.getCardinality().getMax());
ed.setMin(Integer.parseInt(item.cardinality.min)); ed.setMin(Integer.parseInt(item.getCardinality().getMin()));
ed.setShort(texts.get(item.atCode).text); ed.setShort(texts.get(item.getAtCode()).getText());
ed.setDefinition(texts.get(item.atCode).description); ed.setDefinition(texts.get(item.getAtCode()).getDescription());
ed.setComment(texts.get(item.atCode).comment); ed.setComment(texts.get(item.getAtCode()).getComment());
Element te = findTypeElement(item.typeName); Element te = findTypeElement(item.getTypeName());
if (te.hasAttribute("profile")) if (te.hasAttribute("profile"))
ed.addType().setCode(te.getAttribute("fhir")).setProfile(te.getAttribute("profile")); ed.addType().setCode(te.getAttribute("fhir")).setProfile(te.getAttribute("profile"));
else else
ed.addType().setCode(te.getAttribute("fhir")); ed.addType().setCode(te.getAttribute("fhir"));
ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax()); ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
for (NodeTreeEntry child : item.children) { for (NodeTreeEntry child : item.getChildren()) {
genElements(sd, path + "." + child.name, child); genElements(sd, path + "." + child.getName(), child);
} }
} }
@ -185,13 +185,13 @@ public class ADLImporter {
} }
private void dumpChildren(String prefix, NodeTreeEntry item) throws Exception { private void dumpChildren(String prefix, NodeTreeEntry item) throws Exception {
Element te = findTypeElement(item.typeName); Element te = findTypeElement(item.getTypeName());
if (te.hasAttribute("profile")) if (te.hasAttribute("profile"))
System.out.println(prefix + item.atCode + " [" + item.cardinality.min + ".." + item.cardinality.max + "]:" + te.getAttribute("fhir") + "{" + te.getAttribute("profile") + "} // " + item.name + " = " + texts.get(item.atCode).text); System.out.println(prefix + item.getAtCode() + " [" + item.getCardinality().getMin() + ".." + item.getCardinality().getMax() + "]:" + te.getAttribute("fhir") + "{" + te.getAttribute("profile") + "} // " + item.getName() + " = " + texts.get(item.getAtCode()).getText());
else else
System.out.println(prefix + item.atCode + " [" + item.cardinality.min + ".." + item.cardinality.max + "]:" + te.getAttribute("fhir") + " // " + item.name + " = " + texts.get(item.atCode).text); System.out.println(prefix + item.getAtCode() + " [" + item.getCardinality().getMin() + ".." + item.getCardinality().getMax() + "]:" + te.getAttribute("fhir") + " // " + item.getName() + " = " + texts.get(item.getAtCode()).getText());
for (NodeTreeEntry child : item.children) for (NodeTreeEntry child : item.getChildren())
dumpChildren(prefix + " ", child); dumpChildren(prefix + " ", child);
} }
@ -200,22 +200,22 @@ public class ADLImporter {
XMLUtil.getNamedChildren(attributes, "children", set); XMLUtil.getNamedChildren(attributes, "children", set);
for (Element e : set) { for (Element e : set) {
NodeTreeEntry item = new NodeTreeEntry(); NodeTreeEntry item = new NodeTreeEntry();
item.typeName = XMLUtil.getNamedChild(e, "rm_type_name").getTextContent(); item.setTypeName(XMLUtil.getNamedChild(e, "rm_type_name").getTextContent());
item.atCode = XMLUtil.getNamedChild(e, "node_id").getTextContent(); item.setAtCode(XMLUtil.getNamedChild(e, "node_id").getTextContent());
item.name = generateToken(item.atCode, false); item.setName(generateToken(item.getAtCode(), false));
item.cardinality = readCardinality(path + "/" + item.atCode, XMLUtil.getNamedChild(e, "occurrences")); item.setCardinality(readCardinality(path + "/" + item.getAtCode(), XMLUtil.getNamedChild(e, "occurrences")));
parent.children.add(item); parent.getChildren().add(item);
Element attr = XMLUtil.getNamedChild(e, "attributes"); Element attr = XMLUtil.getNamedChild(e, "attributes");
String type = attr.getAttribute("xsi:type"); String type = attr.getAttribute("xsi:type");
if ("C_SINGLE_ATTRIBUTE".equals(type)) { if ("C_SINGLE_ATTRIBUTE".equals(type)) {
check(path, item.typeName, "ELEMENT", "type for simple element: " + item.typeName); check(path, item.getTypeName(), "ELEMENT", "type for simple element: " + item.getTypeName());
checkCardSingle(path, XMLUtil.getNamedChild(attr, "existence")); checkCardSingle(path, XMLUtil.getNamedChild(attr, "existence"));
Element c = XMLUtil.getNamedChild(attr, "children"); Element c = XMLUtil.getNamedChild(attr, "children");
checkCardSingle(path, XMLUtil.getNamedChild(c, "occurrences")); checkCardSingle(path, XMLUtil.getNamedChild(c, "occurrences"));
item.typeName = XMLUtil.getNamedChild(c, "rm_type_name").getTextContent(); item.setTypeName(XMLUtil.getNamedChild(c, "rm_type_name").getTextContent());
} else { } else {
check(path, item.typeName, "CLUSTER", "type for complex element"); check(path, item.getTypeName(), "CLUSTER", "type for complex element");
loadChildren(path + "/" + item.atCode, item, attr); loadChildren(path + "/" + item.getAtCode(), item, attr);
} }
} }
} }
@ -261,11 +261,11 @@ public class ADLImporter {
check(path, XMLUtil.getNamedChild(element, "upper_included").getTextContent(), "true", "Cardinality check"); check(path, XMLUtil.getNamedChild(element, "upper_included").getTextContent(), "true", "Cardinality check");
check(path, XMLUtil.getNamedChild(element, "lower_unbounded").getTextContent(), "false", "Cardinality check"); check(path, XMLUtil.getNamedChild(element, "lower_unbounded").getTextContent(), "false", "Cardinality check");
Cardinality card = new Cardinality(); Cardinality card = new Cardinality();
card.min = XMLUtil.getNamedChild(element, "lower").getTextContent(); card.setMin(XMLUtil.getNamedChild(element, "lower").getTextContent());
if ("true".equals(XMLUtil.getNamedChild(element, "upper_unbounded").getTextContent())) if ("true".equals(XMLUtil.getNamedChild(element, "upper_unbounded").getTextContent()))
card.max = "*"; card.setMax("*");
else else
card.max = XMLUtil.getNamedChild(element, "upper").getTextContent(); card.setMax(XMLUtil.getNamedChild(element, "upper").getTextContent());
return card; return card;
} }
@ -293,50 +293,4 @@ public class ADLImporter {
throw new Exception(message + ". Expected '" + expected + "' but found '" + found.trim() + "', at " + path); throw new Exception(message + ". Expected '" + expected + "' but found '" + found.trim() + "', at " + path);
} }
public class Cardinality {
private String min;
private String max;
}
public class TextSet {
private String text;
private String description;
private String comment;
public String getText() {
return text;
}
public void setText(String value) {
this.text = value;
}
public String getDescription() {
return description;
}
public void setDescription(String value) {
this.description = value;
}
public String getComment() {
return comment;
}
public void setComment(String value) {
this.comment = value;
}
}
public class NodeTreeEntry {
private final List<NodeTreeEntry> children = new ArrayList<NodeTreeEntry>();
private String name;
private String atCode;
private String typeName;
private Cardinality cardinality;
}
} }

View File

@ -0,0 +1,9 @@
package org.hl7.fhir.convertors.misc.adl;
import lombok.Data;
@Data
public class Cardinality {
private String min;
private String max;
}

View File

@ -0,0 +1,15 @@
package org.hl7.fhir.convertors.misc.adl;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class NodeTreeEntry {
private final List<NodeTreeEntry> children = new ArrayList<NodeTreeEntry>();
private String name;
private String atCode;
private String typeName;
private Cardinality cardinality;
}

View File

@ -0,0 +1,11 @@
package org.hl7.fhir.convertors.misc.adl;
import lombok.Data;
@Data
public class TextSet {
private String text;
private String description;
private String comment;
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.misc; package org.hl7.fhir.convertors.misc.argonaut;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -33,6 +33,10 @@ package org.hl7.fhir.convertors.misc;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.fhir.ucum.UcumEssenceService; import org.fhir.ucum.UcumEssenceService;
import org.fhir.ucum.UcumService; import org.fhir.ucum.UcumService;
import org.hl7.fhir.convertors.misc.CDAUtilities;
import org.hl7.fhir.convertors.misc.ccda.CcdaExtensions;
import org.hl7.fhir.convertors.misc.Convert;
import org.hl7.fhir.convertors.misc.ConverterBase;
import org.hl7.fhir.dstu3.context.SimpleWorkerContext; import org.hl7.fhir.dstu3.context.SimpleWorkerContext;
import org.hl7.fhir.dstu3.formats.IParser.OutputStyle; import org.hl7.fhir.dstu3.formats.IParser.OutputStyle;
import org.hl7.fhir.dstu3.formats.JsonParser; import org.hl7.fhir.dstu3.formats.JsonParser;
@ -84,18 +88,18 @@ public class ArgonautConverter extends ConverterBase {
private final UcumService ucumSvc; private final UcumService ucumSvc;
// private ValidationEngine validator; // private ValidationEngine validator;
private final SimpleWorkerContext context; private final SimpleWorkerContext context;
private final Map<String, Map<String, Integer>> sections = new HashMap<String, Map<String, Integer>>(); private final Map<String, Map<String, Integer>> sections = new HashMap<>();
private final Map<String, Practitioner> practitionerCache = new HashMap<String, Practitioner>(); private final Map<String, Practitioner> practitionerCache = new HashMap<>();
private final Set<String> oids = new HashSet<String>(); private final Set<String> oids = new HashSet<>();
private final Map<String, ZipGenerator> zipsX = new HashMap<String, ZipGenerator>(); private final Map<String, ZipGenerator> zipsX = new HashMap<>();
private final Map<String, ZipGenerator> zipsJ = new HashMap<String, ZipGenerator>(); private final Map<String, ZipGenerator> zipsJ = new HashMap<>();
private final Map<String, Stats> stats = new HashMap<String, Stats>(); private final Map<String, Stats> stats = new HashMap<>();
public int perfCount; public int perfCount;
int errors = 0; int errors = 0;
int warnings = 0; int warnings = 0;
Map<String, Integer> procCodes = new HashMap<String, Integer>(); Map<String, Integer> procCodes = new HashMap<>();
Map<String, Integer> condCodes = new HashMap<String, Integer>(); Map<String, Integer> condCodes = new HashMap<>();
Map<String, Integer> allergyCodes = new HashMap<String, Integer>(); Map<String, Integer> allergyCodes = new HashMap<>();
private String destFolder; private String destFolder;
private ZipGenerator zipJ; private ZipGenerator zipJ;
private ZipGenerator zipX; private ZipGenerator zipX;
@ -150,7 +154,7 @@ public class ArgonautConverter extends ConverterBase {
System.out.println("Statistics:"); System.out.println("Statistics:");
for (String n : sorted(stats.keySet())) { for (String n : sorted(stats.keySet())) {
Stats s = stats.get(n); Stats s = stats.get(n);
System.out.println(" " + n + ": generated " + s.instances + ", errors " + s.errors + ", warnings " + s.warnings); System.out.println(" " + n + ": generated " + s.getInstances() + ", errors " + s.getErrors() + ", warnings " + s.getWarnings());
} }
System.out.println("OIDs:"); System.out.println("OIDs:");
@ -169,7 +173,7 @@ public class ArgonautConverter extends ConverterBase {
} }
private List<String> sorted(Set<String> keys) { private List<String> sorted(Set<String> keys) {
List<String> names = new ArrayList<String>(); List<String> names = new ArrayList<>();
names.addAll(keys); names.addAll(keys);
Collections.sort(names); Collections.sort(names);
return names; return names;
@ -189,17 +193,17 @@ public class ArgonautConverter extends ConverterBase {
Convert convert = new Convert(cda, ucumSvc, "-0400"); Convert convert = new Convert(cda, ucumSvc, "-0400");
convert.setGenerateMissingExtensions(true); convert.setGenerateMissingExtensions(true);
Context context = new Context(); Context context = new Context();
context.baseId = Utilities.changeFileExt(filename, ""); context.setBaseId(Utilities.changeFileExt(filename, ""));
context.encClass = clss; context.setEncClass(clss);
makeSubject(cda, convert, doc, context, context.baseId + "-patient"); makeSubject(cda, convert, doc, context, context.getBaseId() + "-patient");
makeAuthor(cda, convert, doc, context, context.baseId + "-author"); makeAuthor(cda, convert, doc, context, context.getBaseId() + "-author");
makeEncounter(cda, convert, doc, context, context.baseId + "-encounter"); makeEncounter(cda, convert, doc, context, context.getBaseId() + "-encounter");
Element body = cda.getDescendent(doc, "component/structuredBody"); Element body = cda.getDescendent(doc, "component/structuredBody");
for (Element c : cda.getChildren(body, "component")) { for (Element c : cda.getChildren(body, "component")) {
processSection(cda, convert, context, cda.getChild(c, "section")); processSection(cda, convert, context, cda.getChild(c, "section"));
} }
oids.addAll(convert.getOids()); oids.addAll(convert.getOids());
saveResource(context.encounter); saveResource(context.getEncounter());
makeBinary(sourceFolder, filename, context); makeBinary(sourceFolder, filename, context);
makeDocumentReference(cda, convert, doc, context); makeDocumentReference(cda, convert, doc, context);
zipJ.close(); zipJ.close();
@ -249,7 +253,7 @@ public class ArgonautConverter extends ConverterBase {
if (sections.containsKey(name)) if (sections.containsKey(name))
section = sections.get(name); section = sections.get(name);
else { else {
section = new HashMap<String, Integer>(); section = new HashMap<>();
sections.put(name, section); sections.put(name, section);
} }
iterateChildren(section, "/", child); iterateChildren(section, "/", child);
@ -340,7 +344,7 @@ public class ArgonautConverter extends ConverterBase {
zipsJ.get(rn).addBytes(resource.getId() + ".json", srcJ, false); zipsJ.get(rn).addBytes(resource.getId() + ".json", srcJ, false);
zipsX.get(rn).addBytes(resource.getId() + ".xml", srcX, false); zipsX.get(rn).addBytes(resource.getId() + ".xml", srcX, false);
Stats ss = stats.get(rn); Stats ss = stats.get(rn);
ss.instances++; ss.setInstances(ss.getInstances() + 1);
String profile = resource.getUserString("profile"); String profile = resource.getUserString("profile");
validate(srcX, profile, resource, ss); validate(srcX, profile, resource, ss);
@ -370,11 +374,11 @@ public class ArgonautConverter extends ConverterBase {
} }
System.out.println(" " + m.getLevel().toCode() + ": " + m.getMessage() + " @ " + m.getLocation()); System.out.println(" " + m.getLevel().toCode() + ": " + m.getMessage() + " @ " + m.getLocation());
if (m.getLevel() == IssueSeverity.WARNING) { if (m.getLevel() == IssueSeverity.WARNING) {
stats.warnings++; stats.setWarnings(stats.getWarnings() + 1);
warnings++; warnings++;
} }
if (m.getLevel() == IssueSeverity.ERROR || m.getLevel() == IssueSeverity.FATAL) { if (m.getLevel() == IssueSeverity.ERROR || m.getLevel() == IssueSeverity.FATAL) {
stats.errors++; stats.setErrors(stats.getErrors() + 1);
errors++; errors++;
} }
} }
@ -464,15 +468,15 @@ public class ArgonautConverter extends ConverterBase {
if (prv != null) if (prv != null)
pat.setManagingOrganization(new Reference().setReference("Organization/" + processOrganization(prv, cda, convert, context).getId())); pat.setManagingOrganization(new Reference().setReference("Organization/" + processOrganization(prv, cda, convert, context).getId()));
context.subjectRef = new Reference().setDisplay(b.toString()).setReference("Patient/" + pat.getId()); context.setSubjectRef(new Reference().setDisplay(b.toString()).setReference("Patient/" + pat.getId()));
saveResource(pat); saveResource(pat);
} }
private Organization processOrganization(Element oo, CDAUtilities cda, Convert convert, Context context) throws Exception { private Organization processOrganization(Element oo, CDAUtilities cda, Convert convert, Context context) throws Exception {
Organization org = new Organization(); Organization org = new Organization();
org.setId(context.baseId + "-organization-" + context.orgId); org.setId(context.getBaseId() + "-organization-" + context.getOrgId());
org.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/org-daf-daforganization"); org.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/org-daf-daforganization");
context.orgId++; context.setOrgId(context.getOrgId() + 1);
for (Element e : cda.getChildren(oo, "id")) for (Element e : cda.getChildren(oo, "id"))
org.getIdentifier().add(convert.makeIdentifierFromII(e)); org.getIdentifier().add(convert.makeIdentifierFromII(e));
for (Element e : cda.getChildren(oo, "addr")) for (Element e : cda.getChildren(oo, "addr"))
@ -523,7 +527,7 @@ public class ArgonautConverter extends ConverterBase {
Element a = cda.getChild(doc, "author"); Element a = cda.getChild(doc, "author");
scanSection("Author", a); scanSection("Author", a);
Practitioner author = processPerformer(cda, convert, context, a, "assignedAuthor", "assignedPerson"); Practitioner author = processPerformer(cda, convert, context, a, "assignedAuthor", "assignedPerson");
context.authorRef = new Reference().setDisplay(author.getUserString("display")).setReference("Practitioner/" + author.getId()); context.setAuthorRef(new Reference().setDisplay(author.getUserString("display")).setReference("Practitioner/" + author.getId()));
return author; return author;
} }
@ -585,8 +589,8 @@ public class ArgonautConverter extends ConverterBase {
Encounter enc = new Encounter(); Encounter enc = new Encounter();
enc.setId(id); enc.setId(id);
enc.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/encounter-daf-dafencounter"); enc.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/encounter-daf-dafencounter");
context.encounter = enc; context.setEncounter(enc);
enc.setSubject(context.subjectRef); enc.setSubject(context.getSubjectRef());
for (Element e : cda.getChildren(ee, "id")) for (Element e : cda.getChildren(ee, "id"))
enc.getIdentifier().add(convert.makeIdentifierFromII(e)); enc.getIdentifier().add(convert.makeIdentifierFromII(e));
@ -601,7 +605,7 @@ public class ArgonautConverter extends ConverterBase {
enc.setStatus(EncounterStatus.FINISHED); enc.setStatus(EncounterStatus.FINISHED);
else else
enc.setStatus(EncounterStatus.INPROGRESS); enc.setStatus(EncounterStatus.INPROGRESS);
enc.setClass_(context.encClass); enc.setClass_(context.getEncClass());
Element dd = cda.getChild(ee, "dischargeDispositionCode"); Element dd = cda.getChild(ee, "dischargeDispositionCode");
if (dd != null) { if (dd != null) {
@ -656,26 +660,26 @@ public class ArgonautConverter extends ConverterBase {
private void processProcedureSection(CDAUtilities cda, Convert convert, Element sect, Context context) throws Exception { private void processProcedureSection(CDAUtilities cda, Convert convert, Element sect, Context context) throws Exception {
scanSection("Procedures", sect); scanSection("Procedures", sect);
ListResource list = new ListResource(); ListResource list = new ListResource();
list.setId(context.baseId + "-list-procedures"); list.setId(context.getBaseId() + "-list-procedures");
// list.setUserData("profile", "") none? // list.setUserData("profile", "") none?
list.setSubject(context.subjectRef); list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sect, "code")), null)); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sect, "code")), null));
list.setTitle(cda.getChild(sect, "title").getTextContent()); list.setTitle(cda.getChild(sect, "title").getTextContent());
list.setStatus(ListStatus.CURRENT); list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT); list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.now); list.setDateElement(context.getNow());
list.setSource(context.authorRef); list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(sect, "text")); buildNarrative(list, cda.getChild(sect, "text"));
int i = 0; int i = 0;
for (Element c : cda.getChildren(sect, "entry")) { for (Element c : cda.getChildren(sect, "entry")) {
Element p = cda.getChild(c, "procedure"); Element p = cda.getChild(c, "procedure");
Procedure proc = new Procedure(); Procedure proc = new Procedure();
proc.setId(context.baseId + "-procedure-" + i); proc.setId(context.getBaseId() + "-procedure-" + i);
proc.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/procedure-daf-dafprocedure"); proc.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/procedure-daf-dafprocedure");
i++; i++;
proc.setSubject(context.subjectRef); proc.setSubject(context.getSubjectRef());
proc.setContext(new Reference().setReference("Encounter/" + context.encounter.getId())); proc.setContext(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
list.addEntry().setItem(new Reference().setReference("Procedure/" + proc.getId())); list.addEntry().setItem(new Reference().setReference("Procedure/" + proc.getId()));
proc.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(p, "code")), null)); proc.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(p, "code")), null));
recordProcedureCode(proc.getCode()); recordProcedureCode(proc.getCode());
@ -725,32 +729,32 @@ public class ArgonautConverter extends ConverterBase {
private void processReasonForEncounter(CDAUtilities cda, Convert convert, Element sect, Context context) throws Exception { private void processReasonForEncounter(CDAUtilities cda, Convert convert, Element sect, Context context) throws Exception {
scanSection("Reason", sect); scanSection("Reason", sect);
context.encounter.addReason().setText(cda.getChild(sect, "text").getTextContent()); context.getEncounter().addReason().setText(cda.getChild(sect, "text").getTextContent());
} }
private void processProblemsSection(CDAUtilities cda, Convert convert, Element sect, Context context) throws Exception { private void processProblemsSection(CDAUtilities cda, Convert convert, Element sect, Context context) throws Exception {
scanSection("Problems", sect); scanSection("Problems", sect);
ListResource list = new ListResource(); ListResource list = new ListResource();
list.setId(context.baseId + "-list-problems"); list.setId(context.getBaseId() + "-list-problems");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafproblemlist"); list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafproblemlist");
list.setSubject(context.subjectRef); list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sect, "code")), null)); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sect, "code")), null));
list.setTitle(cda.getChild(sect, "title").getTextContent()); list.setTitle(cda.getChild(sect, "title").getTextContent());
list.setStatus(ListStatus.CURRENT); list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT); list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.now); list.setDateElement(context.getNow());
list.setSource(context.authorRef); list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(sect, "text")); buildNarrative(list, cda.getChild(sect, "text"));
int i = 0; int i = 0;
for (Element c : cda.getChildren(sect, "entry")) { for (Element c : cda.getChildren(sect, "entry")) {
Element pca = cda.getChild(c, "act"); // problem concern act Element pca = cda.getChild(c, "act"); // problem concern act
Condition cond = new Condition(); Condition cond = new Condition();
cond.setId(context.baseId + "-problem-" + i); cond.setId(context.getBaseId() + "-problem-" + i);
cond.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/condition-daf-dafcondition"); cond.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/condition-daf-dafcondition");
i++; i++;
cond.setSubject(context.subjectRef); cond.setSubject(context.getSubjectRef());
cond.setContext(new Reference().setReference("Encounter/" + context.encounter.getId())); cond.setContext(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
cond.setVerificationStatus(getVerificationStatusFromAct(cda.getChild(pca, "statusCode"))); cond.setVerificationStatus(getVerificationStatusFromAct(cda.getChild(pca, "statusCode")));
cond.setAssertedDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(pca, "effectiveTime"), "low"))); cond.setAssertedDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(pca, "effectiveTime"), "low")));
@ -795,14 +799,14 @@ public class ArgonautConverter extends ConverterBase {
private void processAllergiesSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception { private void processAllergiesSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
scanSection("Allergies", section); scanSection("Allergies", section);
ListResource list = new ListResource(); ListResource list = new ListResource();
list.setId(context.baseId + "-list-allergies"); list.setId(context.getBaseId() + "-list-allergies");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafallergylist"); list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafallergylist");
list.setSubject(context.subjectRef); list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null)); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
list.setTitle(cda.getChild(section, "title").getTextContent()); list.setTitle(cda.getChild(section, "title").getTextContent());
list.setStatus(ListStatus.CURRENT); list.setStatus(ListStatus.CURRENT);
list.setDateElement(context.now); list.setDateElement(context.getNow());
list.setSource(context.authorRef); list.setSource(context.getAuthorRef());
list.setMode(ListMode.SNAPSHOT); list.setMode(ListMode.SNAPSHOT);
buildNarrative(list, cda.getChild(section, "text")); buildNarrative(list, cda.getChild(section, "text"));
@ -810,10 +814,10 @@ public class ArgonautConverter extends ConverterBase {
for (Element c : cda.getChildren(section, "entry")) { for (Element c : cda.getChildren(section, "entry")) {
Element apa = cda.getChild(c, "act"); // allergy problem act Element apa = cda.getChild(c, "act"); // allergy problem act
AllergyIntolerance ai = new AllergyIntolerance(); AllergyIntolerance ai = new AllergyIntolerance();
ai.setId(context.baseId + "-allergy-" + i); ai.setId(context.getBaseId() + "-allergy-" + i);
ai.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/allergyintolerance-daf-dafallergyintolerance"); ai.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/allergyintolerance-daf-dafallergyintolerance");
i++; i++;
ai.setPatient(context.subjectRef); ai.setPatient(context.getSubjectRef());
ai.setAssertedDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(apa, "effectiveTime"), "low"))); ai.setAssertedDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(apa, "effectiveTime"), "low")));
boolean found = false; boolean found = false;
@ -859,15 +863,15 @@ public class ArgonautConverter extends ConverterBase {
private void processVitalSignsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception { private void processVitalSignsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
scanSection("Vital Signs", section); scanSection("Vital Signs", section);
ListResource list = new ListResource(); ListResource list = new ListResource();
list.setId(context.baseId + "-list-vitalsigns"); list.setId(context.getBaseId() + "-list-vitalsigns");
//. list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafproblemlist"); no list //. list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafproblemlist"); no list
list.setSubject(context.subjectRef); list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null)); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
list.setTitle(cda.getChild(section, "title").getTextContent()); list.setTitle(cda.getChild(section, "title").getTextContent());
list.setStatus(ListStatus.CURRENT); list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT); list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.now); list.setDateElement(context.getNow());
list.setSource(context.authorRef); list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(section, "text")); buildNarrative(list, cda.getChild(section, "text"));
int i = 0; int i = 0;
@ -876,11 +880,11 @@ public class ArgonautConverter extends ConverterBase {
for (Element oc : cda.getChildren(org, "component")) { for (Element oc : cda.getChildren(org, "component")) {
Element o = cda.getChild(oc, "observation"); // problem concern act Element o = cda.getChild(oc, "observation"); // problem concern act
Observation obs = new Observation(); Observation obs = new Observation();
obs.setId(context.baseId + "-vitals-" + i); obs.setId(context.getBaseId() + "-vitals-" + i);
obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-vitalsigns-dafvitalsigns"); obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-vitalsigns-dafvitalsigns");
i++; i++;
obs.setSubject(context.subjectRef); obs.setSubject(context.getSubjectRef());
obs.setContext(new Reference().setReference("Encounter/" + context.encounter.getId())); obs.setContext(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null)); obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null));
boolean found = false; boolean found = false;
@ -909,27 +913,27 @@ public class ArgonautConverter extends ConverterBase {
scanSection("Results", section); scanSection("Results", section);
ListResource list = new ListResource(); ListResource list = new ListResource();
list.setId(context.baseId + "-list-results"); list.setId(context.getBaseId() + "-list-results");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafresultlist"); list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafresultlist");
list.setSubject(context.subjectRef); list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null)); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
list.setTitle(cda.getChild(section, "title").getTextContent()); list.setTitle(cda.getChild(section, "title").getTextContent());
list.setStatus(ListStatus.CURRENT); list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT); list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.now); list.setDateElement(context.getNow());
list.setSource(context.authorRef); list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(section, "text")); buildNarrative(list, cda.getChild(section, "text"));
context.obsId = 0; context.setObsId(0);
for (Element c : cda.getChildren(section, "entry")) { for (Element c : cda.getChildren(section, "entry")) {
Element org = cda.getChild(c, "organizer"); Element org = cda.getChild(c, "organizer");
if (org != null) { if (org != null) {
Observation panel = new Observation(); Observation panel = new Observation();
panel.setId(context.baseId + "-results-" + context.obsId); panel.setId(context.getBaseId() + "-results-" + context.getObsId());
panel.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobspanel"); panel.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobspanel");
context.obsId++; context.setObsId(context.getObsId() + 1);
panel.setSubject(context.subjectRef); panel.setSubject(context.getSubjectRef());
panel.setContext(new Reference().setReference("Encounter/" + context.encounter.getId())); panel.setContext(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
panel.setStatus(ObservationStatus.FINAL); panel.setStatus(ObservationStatus.FINAL);
boolean found = false; boolean found = false;
for (Element e : cda.getChildren(org, "id")) { for (Element e : cda.getChildren(org, "id")) {
@ -971,10 +975,10 @@ public class ArgonautConverter extends ConverterBase {
private Observation processObservation(CDAUtilities cda, Convert convert, Context context, Element o) throws Exception { private Observation processObservation(CDAUtilities cda, Convert convert, Context context, Element o) throws Exception {
Observation obs = new Observation(); Observation obs = new Observation();
obs.setId(context.baseId + "-results-" + context.obsId); obs.setId(context.getBaseId() + "-results-" + context.getObsId());
context.obsId++; context.setObsId(context.getObsId() + 1);
obs.setSubject(context.subjectRef); obs.setSubject(context.getSubjectRef());
obs.setContext(new Reference().setReference("Encounter/" + context.encounter.getId())); obs.setContext(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
obs.setStatus(ObservationStatus.FINAL); obs.setStatus(ObservationStatus.FINAL);
obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime"))); obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime")));
obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null)); obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null));
@ -1015,11 +1019,11 @@ public class ArgonautConverter extends ConverterBase {
for (Element c : cda.getChildren(section, "entry")) { for (Element c : cda.getChildren(section, "entry")) {
Element o = cda.getChild(c, "observation"); Element o = cda.getChild(c, "observation");
Observation obs = new Observation(); Observation obs = new Observation();
obs.setId(context.baseId + "-smoking-" + (i == 0 ? "" : Integer.toString(i))); obs.setId(context.getBaseId() + "-smoking-" + (i == 0 ? "" : Integer.toString(i)));
obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-smokingstatus-dafsmokingstatus"); obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-smokingstatus-dafsmokingstatus");
i++; i++;
obs.setSubject(context.subjectRef); obs.setSubject(context.getSubjectRef());
obs.setContext(new Reference().setReference("Encounter/" + context.encounter.getId())); obs.setContext(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), new Coding().setSystem("http://loinc.org").setCode("72166-2"))); obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), new Coding().setSystem("http://loinc.org").setCode("72166-2")));
boolean found = false; boolean found = false;
@ -1039,25 +1043,25 @@ public class ArgonautConverter extends ConverterBase {
private void processMedicationsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception { private void processMedicationsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
scanSection("Medications", section); scanSection("Medications", section);
ListResource list = new ListResource(); ListResource list = new ListResource();
list.setId(context.baseId + "-list-medications"); list.setId(context.getBaseId() + "-list-medications");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafmedicationlist"); list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafmedicationlist");
list.setSubject(context.subjectRef); list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null)); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
list.setTitle(cda.getChild(section, "title").getTextContent()); list.setTitle(cda.getChild(section, "title").getTextContent());
list.setStatus(ListStatus.CURRENT); list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT); list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.now); list.setDateElement(context.getNow());
list.setSource(context.authorRef); list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(section, "text")); buildNarrative(list, cda.getChild(section, "text"));
int i = 0; int i = 0;
for (Element c : cda.getChildren(section, "entry")) { for (Element c : cda.getChildren(section, "entry")) {
Element sa = cda.getChild(c, "substanceAdministration"); // allergy problem act Element sa = cda.getChild(c, "substanceAdministration"); // allergy problem act
MedicationStatement ms = new MedicationStatement(); MedicationStatement ms = new MedicationStatement();
ms.setId(context.baseId + "-medication-" + i); ms.setId(context.getBaseId() + "-medication-" + i);
ms.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/medicationstatement-daf-dafmedicationstatement"); ms.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/medicationstatement-daf-dafmedicationstatement");
i++; i++;
ms.setSubject(context.subjectRef); ms.setSubject(context.getSubjectRef());
boolean found = false; boolean found = false;
for (Element e : cda.getChildren(sa, "id")) { for (Element e : cda.getChildren(sa, "id")) {
@ -1084,7 +1088,7 @@ public class ArgonautConverter extends ConverterBase {
dosage.setDose(convert.makeQuantityFromPQ(qty)); dosage.setDose(convert.makeQuantityFromPQ(qty));
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(" invalid dose quantity '" + qty.getAttribute("value") + " " + qty.getAttribute("unit") + "' (" + e.getClass().getName() + ") in " + context.baseId); System.out.println(" invalid dose quantity '" + qty.getAttribute("value") + " " + qty.getAttribute("unit") + "' (" + e.getClass().getName() + ") in " + context.getBaseId());
} }
dosage.setRoute(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sa, "routeCode")), null)); dosage.setRoute(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sa, "routeCode")), null));
Type t = convert.makeSomethingFromGTS(cda.getChildren(sa, "effectiveTime")); Type t = convert.makeSomethingFromGTS(cda.getChildren(sa, "effectiveTime"));
@ -1114,25 +1118,25 @@ public class ArgonautConverter extends ConverterBase {
private void processEncountersSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception { private void processEncountersSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
scanSection("Encounters", section); scanSection("Encounters", section);
ListResource list = new ListResource(); ListResource list = new ListResource();
list.setId(context.baseId + "-list-encounters"); list.setId(context.getBaseId() + "-list-encounters");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafencounterlist"); list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafencounterlist");
list.setSubject(context.subjectRef); list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null)); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
list.setTitle(cda.getChild(section, "title").getTextContent()); list.setTitle(cda.getChild(section, "title").getTextContent());
list.setStatus(ListStatus.CURRENT); list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT); list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.now); list.setDateElement(context.getNow());
list.setSource(context.authorRef); list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(section, "text")); buildNarrative(list, cda.getChild(section, "text"));
int i = 0; int i = 0;
for (Element c : cda.getChildren(section, "entry")) { for (Element c : cda.getChildren(section, "entry")) {
Element ee = cda.getChild(c, "encounter"); // allergy problem act Element ee = cda.getChild(c, "encounter"); // allergy problem act
Encounter enc = new Encounter(); Encounter enc = new Encounter();
enc.setId(context.baseId + "-encounter-" + i); enc.setId(context.getBaseId() + "-encounter-" + i);
enc.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/encounter-daf-dafencounter"); enc.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/encounter-daf-dafencounter");
i++; i++;
enc.setSubject(context.subjectRef); enc.setSubject(context.getSubjectRef());
list.addEntry().setItem(new Reference().setReference("Encounter/" + enc.getId())); list.addEntry().setItem(new Reference().setReference("Encounter/" + enc.getId()));
for (Element e : cda.getChildren(ee, "id")) for (Element e : cda.getChildren(ee, "id"))
@ -1187,26 +1191,26 @@ public class ArgonautConverter extends ConverterBase {
private void processImmunizationsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception { private void processImmunizationsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
scanSection("Immunizations", section); scanSection("Immunizations", section);
ListResource list = new ListResource(); ListResource list = new ListResource();
list.setId(context.baseId + "-list-immunizations"); list.setId(context.getBaseId() + "-list-immunizations");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafimmunizationlist"); list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafimmunizationlist");
list.setSubject(context.subjectRef); list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null)); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
list.setTitle(cda.getChild(section, "title").getTextContent()); list.setTitle(cda.getChild(section, "title").getTextContent());
list.setStatus(ListStatus.CURRENT); list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT); list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.now); list.setDateElement(context.getNow());
list.setSource(context.authorRef); list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(section, "text")); buildNarrative(list, cda.getChild(section, "text"));
int i = 0; int i = 0;
for (Element c : cda.getChildren(section, "entry")) { for (Element c : cda.getChildren(section, "entry")) {
Element sa = cda.getChild(c, "substanceAdministration"); // allergy problem act Element sa = cda.getChild(c, "substanceAdministration"); // allergy problem act
Immunization imm = new Immunization(); Immunization imm = new Immunization();
imm.setId(context.baseId + "-immunization-" + i); imm.setId(context.getBaseId() + "-immunization-" + i);
imm.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/immunization-daf-dafimmunization"); imm.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/immunization-daf-dafimmunization");
i++; i++;
imm.setPatient(context.subjectRef); imm.setPatient(context.getSubjectRef());
imm.setEncounter(new Reference().setReference("Encounter/" + context.encounter.getId())); imm.setEncounter(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
imm.setNotGiven("true".equals(sa.getAttribute("negationInd"))); imm.setNotGiven("true".equals(sa.getAttribute("negationInd")));
imm.setStatus(convertImmunizationStatus(cda.getChild(sa, "statusCode"))); imm.setStatus(convertImmunizationStatus(cda.getChild(sa, "statusCode")));
boolean found = false; boolean found = false;
@ -1273,7 +1277,7 @@ public class ArgonautConverter extends ConverterBase {
private void makeBinary(String sourceFolder, String filename, Context context) throws Exception { private void makeBinary(String sourceFolder, String filename, Context context) throws Exception {
Binary binary = new Binary(); Binary binary = new Binary();
binary.setId(context.baseId + "-binary"); binary.setId(context.getBaseId() + "-binary");
binary.setContentType("application/hl7-v3+xml"); binary.setContentType("application/hl7-v3+xml");
binary.setContent(IOUtils.toByteArray(new FileInputStream(Utilities.path(sourceFolder, filename)))); binary.setContent(IOUtils.toByteArray(new FileInputStream(Utilities.path(sourceFolder, filename))));
saveResource(binary); saveResource(binary);
@ -1282,22 +1286,22 @@ public class ArgonautConverter extends ConverterBase {
private void makeDocumentReference(CDAUtilities cda, Convert convert, Element doc, Context context) throws Exception { private void makeDocumentReference(CDAUtilities cda, Convert convert, Element doc, Context context) throws Exception {
scanSection("document", doc); scanSection("document", doc);
DocumentReference ref = new DocumentReference(); DocumentReference ref = new DocumentReference();
ref.setId(context.baseId + "-document"); ref.setId(context.getBaseId() + "-document");
ref.setMasterIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "id"))); ref.setMasterIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "id")));
ref.setSubject(context.subjectRef); ref.setSubject(context.getSubjectRef());
ref.setType(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(doc, "code")), null)); ref.setType(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(doc, "code")), null));
ref.addAuthor(context.authorRef); ref.addAuthor(context.getAuthorRef());
ref.setCreatedElement(convert.makeDateTimeFromTS(cda.getChild(doc, "effectiveTime"))); ref.setCreatedElement(convert.makeDateTimeFromTS(cda.getChild(doc, "effectiveTime")));
ref.setIndexedElement(InstantType.now()); ref.setIndexedElement(InstantType.now());
ref.setStatus(DocumentReferenceStatus.CURRENT); ref.setStatus(DocumentReferenceStatus.CURRENT);
ref.addSecurityLabel(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(doc, "confidentialityCode")), null)); ref.addSecurityLabel(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(doc, "confidentialityCode")), null));
DocumentReferenceContentComponent cnt = ref.addContent(); DocumentReferenceContentComponent cnt = ref.addContent();
cnt.getAttachment().setContentType("application/hl7-v3+xml").setUrl("Binary/" + context.baseId).setLanguage(convertLanguage(cda.getChild(doc, "language"))); cnt.getAttachment().setContentType("application/hl7-v3+xml").setUrl("Binary/" + context.getBaseId()).setLanguage(convertLanguage(cda.getChild(doc, "language")));
// for (Element ti : cda.getChildren(doc, "templateId")) // for (Element ti : cda.getChildren(doc, "templateId"))
// cnt.addFormat().setSystem("urn:oid:1.3.6.1.4.1.19376.1.2.3").setCode(value)("urn:oid:"+ti.getAttribute("root")); // cnt.addFormat().setSystem("urn:oid:1.3.6.1.4.1.19376.1.2.3").setCode(value)("urn:oid:"+ti.getAttribute("root"));
ref.setContext(new DocumentReferenceContextComponent()); ref.setContext(new DocumentReferenceContextComponent());
ref.getContext().setPeriod(convert.makePeriodFromIVL(cda.getChild(cda.getChild(doc, "serviceEvent"), "effectiveTime"))); ref.getContext().setPeriod(convert.makePeriodFromIVL(cda.getChild(cda.getChild(doc, "serviceEvent"), "effectiveTime")));
for (CodeableConcept cc : context.encounter.getType()) for (CodeableConcept cc : context.getEncounter().getType())
ref.getContext().addEvent(cc); ref.getContext().addEvent(cc);
ref.setDescription(cda.getChild(doc, "title").getTextContent()); ref.setDescription(cda.getChild(doc, "title").getTextContent());
ref.setCustodian(new Reference().setReference("Organization/" + processOrganization(cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), cda, convert, context).getId())); ref.setCustodian(new Reference().setReference("Organization/" + processOrganization(cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), cda, convert, context).getId()));
@ -1371,23 +1375,4 @@ public class ArgonautConverter extends ConverterBase {
System.out.println(); System.out.println();
} }
public class Context {
public String baseId;
public Reference authorRef;
public Encounter encounter;
public Coding encClass;
public int obsId;
public DateTimeType now = DateTimeType.now();
public int orgId;
public Reference subjectRef;
}
public class Stats {
public int instances;
public int errors;
public int warnings;
}
} }

View File

@ -0,0 +1,19 @@
package org.hl7.fhir.convertors.misc.argonaut;
import lombok.Data;
import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.DateTimeType;
import org.hl7.fhir.dstu3.model.Encounter;
import org.hl7.fhir.dstu3.model.Reference;
@Data
public class Context {
private String baseId;
private Reference authorRef;
private Encounter encounter;
private Coding encClass;
private int obsId;
private DateTimeType now = DateTimeType.now();
private int orgId;
private Reference subjectRef;
}

View File

@ -0,0 +1,10 @@
package org.hl7.fhir.convertors.misc.argonaut;
import lombok.Data;
@Data
public class Stats {
private int instances;
private int errors;
private int warnings;
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.misc; package org.hl7.fhir.convertors.misc.ccda;
@ -35,6 +35,8 @@ package org.hl7.fhir.convertors.misc;
import org.fhir.ucum.UcumService; import org.fhir.ucum.UcumService;
import org.hl7.fhir.convertors.misc.CDAUtilities;
import org.hl7.fhir.convertors.misc.Convert;
import org.hl7.fhir.dstu3.context.IWorkerContext; import org.hl7.fhir.dstu3.context.IWorkerContext;
import org.hl7.fhir.dstu3.model.*; import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.AllergyIntolerance.*; import org.hl7.fhir.dstu3.model.AllergyIntolerance.*;

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.misc; package org.hl7.fhir.convertors.misc.ccda;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.

View File

@ -0,0 +1,15 @@
package org.hl7.fhir.convertors.misc.iso21090;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
class DataType {
private final List<Property> properties = new ArrayList<>();
private boolean isAbstract;
private String name;
private String doco;
private String parent;
}

View File

@ -0,0 +1,17 @@
package org.hl7.fhir.convertors.misc.iso21090;
import lombok.Data;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
public class EnumValueSet {
private final List<String> codes = new ArrayList<>();
private final Map<String, String> members = new HashMap<>();
private String name;
private String template;
private String system;
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.misc; package org.hl7.fhir.convertors.misc.iso21090;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -62,8 +62,8 @@ import java.util.*;
public class ISO21090Importer { public class ISO21090Importer {
private final Map<String, EnumValueSet> bindings = new HashMap<String, EnumValueSet>(); private final Map<String, EnumValueSet> bindings = new HashMap<>();
private final Map<String, DataType> types = new HashMap<String, DataType>(); private final Map<String, DataType> types = new HashMap<>();
private IWorkerContext ctxt; private IWorkerContext ctxt;
private Element schema; private Element schema;
@ -92,64 +92,64 @@ public class ISO21090Importer {
private void generateType(DataType dt) throws Exception { private void generateType(DataType dt) throws Exception {
StructureDefinition sd = new StructureDefinition(); StructureDefinition sd = new StructureDefinition();
sd.setId(dt.name); sd.setId(dt.getName());
sd.setUrl("http://hl7.org/fhir/iso21090/StructureDefinition/" + sd.getId()); sd.setUrl("http://hl7.org/fhir/iso21090/StructureDefinition/" + sd.getId());
sd.setName(dt.name + " data type"); sd.setName(dt.getName() + " data type");
sd.setStatus(PublicationStatus.ACTIVE); sd.setStatus(PublicationStatus.ACTIVE);
sd.setExperimental(false); sd.setExperimental(false);
sd.setPublisher("HL7 / ISO"); sd.setPublisher("HL7 / ISO");
sd.setDate(new Date()); sd.setDate(new Date());
sd.setDescription(dt.doco); sd.setDescription(dt.getDoco());
sd.setKind(StructureDefinitionKind.LOGICAL); sd.setKind(StructureDefinitionKind.LOGICAL);
sd.setAbstract(Utilities.existsInList(dt.name, "HXIT", "QTY")); sd.setAbstract(Utilities.existsInList(dt.getName(), "HXIT", "QTY"));
sd.setType("Element"); sd.setType("Element");
if (dt.parent == null) if (dt.getParent() == null)
sd.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element"); sd.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
else else
sd.setBaseDefinition("http://hl7.org/fhir/iso21090/StructureDefinition/" + dt.parent); sd.setBaseDefinition("http://hl7.org/fhir/iso21090/StructureDefinition/" + dt.getParent());
sd.setDerivation(TypeDerivationRule.SPECIALIZATION); sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
ElementDefinition ed = sd.getDifferential().addElement(); ElementDefinition ed = sd.getDifferential().addElement();
ed.setPath(dt.name); ed.setPath(dt.getName());
produceProperties(sd.getDifferential().getElement(), dt.name, dt.properties, true, false); produceProperties(sd.getDifferential().getElement(), dt.getName(), dt.getProperties(), true, false);
produceProperties(sd.getDifferential().getElement(), dt.name, dt.properties, false, false); produceProperties(sd.getDifferential().getElement(), dt.getName(), dt.getProperties(), false, false);
ed = sd.getSnapshot().addElement(); ed = sd.getSnapshot().addElement();
ed.setPath(dt.name); ed.setPath(dt.getName());
if (dt.parent != null) if (dt.getParent() != null)
addParentProperties(sd.getSnapshot().getElement(), dt.name, dt.parent, true, true); addParentProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getParent(), true, true);
produceProperties(sd.getSnapshot().getElement(), dt.name, dt.properties, true, true); produceProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getProperties(), true, true);
if (dt.parent != null) if (dt.getParent() != null)
addParentProperties(sd.getSnapshot().getElement(), dt.name, dt.parent, false, true); addParentProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getParent(), false, true);
produceProperties(sd.getSnapshot().getElement(), dt.name, dt.properties, false, true); produceProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getProperties(), false, true);
ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax()); ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\iso21090\\StructureDefinition-" + dt.name + ".xml"), sd); new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\iso21090\\StructureDefinition-" + dt.getName() + ".xml"), sd);
} }
private void addParentProperties(List<ElementDefinition> elements, String name, String parent, boolean attrMode, boolean snapshot) throws FHIRFormatError { private void addParentProperties(List<ElementDefinition> elements, String name, String parent, boolean attrMode, boolean snapshot) throws FHIRFormatError {
DataType dt = types.get(parent); DataType dt = types.get(parent);
if (dt == null) if (dt == null)
throw new Error("No find " + parent); throw new Error("No find " + parent);
if (dt.parent != null) if (dt.getParent() != null)
addParentProperties(elements, name, dt.parent, attrMode, snapshot); addParentProperties(elements, name, dt.getParent(), attrMode, snapshot);
produceProperties(elements, name, dt.properties, attrMode, snapshot); produceProperties(elements, name, dt.getProperties(), attrMode, snapshot);
} }
private void produceProperties(List<ElementDefinition> elements, String name, List<Property> properties, boolean attrMode, boolean snapshot) throws FHIRFormatError { private void produceProperties(List<ElementDefinition> elements, String name, List<Property> properties, boolean attrMode, boolean snapshot) throws FHIRFormatError {
for (Property p : properties) { for (Property p : properties) {
if (p.isattr == attrMode) { if (p.isIsattr() == attrMode) {
ElementDefinition ed = new ElementDefinition(); ElementDefinition ed = new ElementDefinition();
elements.add(ed); elements.add(ed);
ed.setPath(name + "." + p.name); ed.setPath(name + "." + p.getName());
if (p.type.startsWith("xsd:")) if (p.getType().startsWith("xsd:"))
ToolingExtensions.addStringExtension(ed.addType(), ToolingExtensions.EXT_XML_TYPE, p.type); ToolingExtensions.addStringExtension(ed.addType(), ToolingExtensions.EXT_XML_TYPE, p.getType());
else else
ed.addType().setCode(p.type); ed.addType().setCode(p.getType());
ed.setMin(p.min); ed.setMin(p.getMin());
ed.setMax(p.max == Integer.MAX_VALUE ? "*" : Integer.toString(p.max)); ed.setMax(p.getMax() == Integer.MAX_VALUE ? "*" : Integer.toString(p.getMax()));
ed.setDefinition(p.doco); ed.setDefinition(p.getDoco());
if (p.isattr) if (p.isIsattr())
ed.addRepresentation(PropertyRepresentation.XMLATTR); ed.addRepresentation(PropertyRepresentation.XMLATTR);
if (p.binding != null) if (p.getBinding() != null)
ed.getBinding().setStrength(BindingStrength.REQUIRED).setValueSet(new UriType("http://hl7.org/fhir/iso21090/ValueSet/" + p.binding)); ed.getBinding().setStrength(BindingStrength.REQUIRED).setValueSet(new UriType("http://hl7.org/fhir/iso21090/ValueSet/" + p.getBinding()));
if (snapshot) if (snapshot)
ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax()); ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
} }
@ -157,22 +157,22 @@ public class ISO21090Importer {
} }
private void generateValueSet(EnumValueSet evs) throws Exception { private void generateValueSet(EnumValueSet evs) throws Exception {
ValueSet bvs = ctxt.fetchResource(ValueSet.class, evs.template); ValueSet bvs = ctxt.fetchResource(ValueSet.class, evs.getTemplate());
if (bvs == null) if (bvs == null)
throw new Exception("Did not find template value set " + evs.template); throw new Exception("Did not find template value set " + evs.getTemplate());
ValueSet vs = bvs.copy(); ValueSet vs = bvs.copy();
vs.getCompose().getInclude().clear(); vs.getCompose().getInclude().clear();
vs.getIdentifier().clear(); vs.getIdentifier().clear();
vs.setName("ISO 20190 " + evs.name + " Enumeration"); vs.setName("ISO 20190 " + evs.getName() + " Enumeration");
vs.setId(evs.name); vs.setId(evs.getName());
vs.setUrl("http://hl7.org/fhir/iso21090/ValueSet/" + vs.getId()); vs.setUrl("http://hl7.org/fhir/iso21090/ValueSet/" + vs.getId());
vs.setDate(new Date()); vs.setDate(new Date());
vs.setExperimental(false); vs.setExperimental(false);
ConceptSetComponent inc = vs.getCompose().addInclude().setSystem(evs.system); ConceptSetComponent inc = vs.getCompose().addInclude().setSystem(evs.getSystem());
for (String code : evs.codes) { for (String code : evs.getCodes()) {
inc.addConcept().setCode(code); inc.addConcept().setCode(code);
} }
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\iso21090\\ValueSet-" + evs.name + ".xml"), vs); new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\iso21090\\ValueSet-" + evs.getName() + ".xml"), vs);
} }
private void processDataTypes() { private void processDataTypes() {
@ -190,19 +190,19 @@ public class ISO21090Importer {
private void processDataType(String n, Element type) { private void processDataType(String n, Element type) {
DataType dt = new DataType(); DataType dt = new DataType();
types.put(n, dt); types.put(n, dt);
dt.name = n; dt.setName(n);
dt.doco = getDoco(type); dt.setDoco(getDoco(type));
Element cnt; Element cnt;
Element ext = XMLUtil.getNamedChild(XMLUtil.getNamedChild(type, "xsd:complexContent"), "xsd:extension"); Element ext = XMLUtil.getNamedChild(XMLUtil.getNamedChild(type, "xsd:complexContent"), "xsd:extension");
if (ext != null) { if (ext != null) {
dt.parent = ext.getAttribute("base"); dt.setParent(ext.getAttribute("base"));
cnt = XMLUtil.getFirstChild(ext); cnt = XMLUtil.getFirstChild(ext);
} else { } else {
cnt = XMLUtil.getFirstChild(type); cnt = XMLUtil.getFirstChild(type);
} }
if (cnt.getTagName().equals("xsd:annotation")) if (cnt.getTagName().equals("xsd:annotation"))
cnt = XMLUtil.getNextSibling(cnt); cnt = XMLUtil.getNextSibling(cnt);
System.out.println(n + " (" + dt.parent + ")"); System.out.println(n + " (" + dt.getParent() + ")");
while (cnt != null) { while (cnt != null) {
if (cnt.getTagName().equals("xsd:attribute")) { if (cnt.getTagName().equals("xsd:attribute")) {
processAttribute(dt, cnt); processAttribute(dt, cnt);
@ -224,44 +224,44 @@ public class ISO21090Importer {
private void processElement(DataType dt, Element elem) { private void processElement(DataType dt, Element elem) {
Property prop = new Property(); Property prop = new Property();
prop.name = elem.getAttribute("name"); prop.setName(elem.getAttribute("name"));
prop.min = Integer.parseInt(elem.getAttribute("minOccurs")); prop.setMin(Integer.parseInt(elem.getAttribute("minOccurs")));
prop.max = "unbounded".equals(elem.getAttribute("maxOccurs")) ? Integer.MAX_VALUE : Integer.parseInt(elem.getAttribute("maxOccurs")); prop.setMax("unbounded".equals(elem.getAttribute("maxOccurs")) ? Integer.MAX_VALUE : Integer.parseInt(elem.getAttribute("maxOccurs")));
prop.type = elem.getAttribute("type"); prop.setType(elem.getAttribute("type"));
prop.doco = getDoco(elem); prop.setDoco(getDoco(elem));
dt.properties.add(prop); dt.getProperties().add(prop);
System.out.println(" " + prop.name + " : " + prop.type + " [" + prop.min + ".." + prop.max + "]"); System.out.println(" " + prop.getName() + " : " + prop.getType() + " [" + prop.getMin() + ".." + prop.getMax() + "]");
} }
private void processAttribute(DataType dt, Element attr) { private void processAttribute(DataType dt, Element attr) {
Property prop = new Property(); Property prop = new Property();
prop.name = attr.getAttribute("name"); prop.setName(attr.getAttribute("name"));
prop.type = attr.getAttribute("type"); prop.setType(attr.getAttribute("type"));
if (!prop.type.startsWith("xsd:")) { if (!prop.getType().startsWith("xsd:")) {
if (Utilities.noString(prop.type)) if (Utilities.noString(prop.getType()))
prop.type = "xsd:string"; prop.setType("xsd:string");
else if (bindings.containsKey(prop.type)) { else if (bindings.containsKey(prop.getType())) {
prop.binding = prop.type; prop.setBinding(prop.getType());
prop.type = "xsd:string"; prop.setType("xsd:string");
} else if (prop.type.startsWith("set_") && bindings.containsKey(prop.type.substring(4))) { } else if (prop.getType().startsWith("set_") && bindings.containsKey(prop.getType().substring(4))) {
prop.binding = prop.type.substring(4); prop.setBinding(prop.getType().substring(4));
prop.type = "xsd:string"; prop.setType("xsd:string");
prop.max = Integer.MAX_VALUE; prop.setMax(Integer.MAX_VALUE);
} else if ("Uid".equals(prop.type)) } else if ("Uid".equals(prop.getType()))
prop.type = "xsd:string"; prop.setType("xsd:string");
else if ("Code".equals(prop.type)) else if ("Code".equals(prop.getType()))
prop.type = "xsd:token"; prop.setType("xsd:token");
else if ("Decimal".equals(prop.type)) else if ("Decimal".equals(prop.getType()))
prop.type = "xsd:decimal"; prop.setType("xsd:decimal");
else else
throw new Error("Unknown type " + prop.type + " on " + dt.name + "." + prop.name); throw new Error("Unknown type " + prop.getType() + " on " + dt.getName() + "." + prop.getName());
} }
prop.min = "optional".equals(attr.getAttribute("use")) ? 0 : 1; prop.setMin("optional".equals(attr.getAttribute("use")) ? 0 : 1);
prop.max = 1; prop.setMax(1);
prop.doco = getDoco(attr); prop.setDoco(getDoco(attr));
prop.isattr = true; prop.setIsattr(true);
dt.properties.add(prop); dt.getProperties().add(prop);
System.out.println(" " + prop.name + " : " + prop.type + " [" + prop.min + ".." + prop.max + "]"); System.out.println(" " + prop.getName() + " : " + prop.getType() + " [" + prop.getMin() + ".." + prop.getMax() + "]");
} }
private void processEnums() { private void processEnums() {
@ -280,7 +280,7 @@ public class ISO21090Importer {
private void processEnum(String n, Element en) { private void processEnum(String n, Element en) {
EnumValueSet vs = new EnumValueSet(); EnumValueSet vs = new EnumValueSet();
bindings.put(n, vs); bindings.put(n, vs);
vs.name = n; vs.setName(n);
String v3n; String v3n;
if (n.contains("EntityName")) if (n.contains("EntityName"))
v3n = n + "R2"; v3n = n + "R2";
@ -296,12 +296,12 @@ public class ISO21090Importer {
v3n = "TelecommunicationCapabilities"; v3n = "TelecommunicationCapabilities";
else else
v3n = n; v3n = n;
vs.system = "http://hl7.org/fhir/v3-" + v3n; vs.setSystem("http://hl7.org/fhir/v3-" + v3n);
vs.template = "http://hl7.org/fhir/ValueSet/v3-" + v3n; vs.setTemplate("http://hl7.org/fhir/ValueSet/v3-" + v3n);
System.out.println("Enum: " + n + " == " + vs.system); System.out.println("Enum: " + n + " == " + vs.getSystem());
while (en != null) { while (en != null) {
vs.codes.add(en.getAttribute("value")); vs.getCodes().add(en.getAttribute("value"));
vs.members.put(en.getAttribute("value"), getDoco(en)); vs.getMembers().put(en.getAttribute("value"), getDoco(en));
en = XMLUtil.getNextSibling(en); en = XMLUtil.getNextSibling(en);
} }
} }
@ -319,30 +319,4 @@ public class ISO21090Importer {
schema = doc.getDocumentElement(); schema = doc.getDocumentElement();
} }
private class Property {
private boolean isattr;
private String name;
private int min;
private int max;
private String type;
private String doco;
private String binding;
}
private class DataType {
private final List<Property> properties = new ArrayList<Property>();
private boolean isAbstract;
private String name;
private String doco;
private String parent;
}
public class EnumValueSet {
private final List<String> codes = new ArrayList<String>();
private final Map<String, String> members = new HashMap<String, String>();
private String name;
private String template;
private String system;
}
} }

View File

@ -0,0 +1,14 @@
package org.hl7.fhir.convertors.misc.iso21090;
import lombok.Data;
@Data
class Property {
private boolean isattr;
private String name;
private int min;
private int max;
private String type;
private String doco;
private String binding;
}

View File

@ -0,0 +1,24 @@
package org.hl7.fhir.convertors.misc.searchparam;
import lombok.Data;
@Data
public class SPRelationship {
private final String r4;
private final String r3;
private final String r2b;
private final String r2;
public String getByCode(String code) {
if ("R4".equals(code))
return r4;
if ("R3".equals(code))
return r3;
if ("R2b".equals(code))
return r2b;
if ("R2".equals(code))
return getR2();
return null;
}
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.misc; package org.hl7.fhir.convertors.misc.searchparam;
/* /*
Copyright (c) 2011+, HL7, Inc. Copyright (c) 2011+, HL7, Inc.
@ -135,17 +135,17 @@ public class SearchParameterProcessor {
for (String s : list4) { for (String s : list4) {
boolean ok = false; boolean ok = false;
for (SPRelationship t : list) { for (SPRelationship t : list) {
if (s.equals(t.r4)) if (s.equals(t.getR4()))
ok = true; ok = true;
} }
if (!ok) if (!ok)
System.out.println("R4 missing : " + s); System.out.println("R4 missing : " + s);
} }
for (SPRelationship sp : list) { for (SPRelationship sp : list) {
if (!Utilities.noString(sp.r4)) { if (!Utilities.noString(sp.getR4())) {
boolean ok = list4.contains(sp.r4); boolean ok = list4.contains(sp.getR4());
if (!ok) if (!ok)
System.out.println("R4 extra : " + sp.r4); System.out.println("R4 extra : " + sp.getR4());
} }
} }
} }
@ -154,17 +154,17 @@ public class SearchParameterProcessor {
for (String s : list3) { for (String s : list3) {
boolean ok = false; boolean ok = false;
for (SPRelationship t : list) { for (SPRelationship t : list) {
if (s.equals(t.r3)) if (s.equals(t.getR3()))
ok = true; ok = true;
} }
if (!ok) if (!ok)
System.out.println("R3 : " + s); System.out.println("R3 : " + s);
} }
for (SPRelationship sp : list) { for (SPRelationship sp : list) {
if (!Utilities.noString(sp.r3)) { if (!Utilities.noString(sp.getR3())) {
boolean ok = list3.contains(sp.r3); boolean ok = list3.contains(sp.getR3());
if (!ok) if (!ok)
System.out.println("R3 extra : " + sp.r3); System.out.println("R3 extra : " + sp.getR3());
} }
} }
} }
@ -173,17 +173,17 @@ public class SearchParameterProcessor {
for (String s : list2b) { for (String s : list2b) {
boolean ok = false; boolean ok = false;
for (SPRelationship t : list) { for (SPRelationship t : list) {
if (s.equals(t.r2b)) if (s.equals(t.getR2b()))
ok = true; ok = true;
} }
if (!ok) if (!ok)
System.out.println("R2b : " + s); System.out.println("R2b : " + s);
} }
for (SPRelationship sp : list) { for (SPRelationship sp : list) {
if (!Utilities.noString(sp.r2b)) { if (!Utilities.noString(sp.getR2b())) {
boolean ok = list2b.contains(sp.r2b); boolean ok = list2b.contains(sp.getR2b());
if (!ok) if (!ok)
System.out.println("R2b extra : " + sp.r2b); System.out.println("R2b extra : " + sp.getR2b());
} }
} }
} }
@ -192,17 +192,17 @@ public class SearchParameterProcessor {
for (String s : list2) { for (String s : list2) {
boolean ok = false; boolean ok = false;
for (SPRelationship t : list) { for (SPRelationship t : list) {
if (s.equals(t.r2)) if (s.equals(t.getR2()))
ok = true; ok = true;
} }
if (!ok) if (!ok)
System.out.println("R2 : " + s); System.out.println("R2 : " + s);
} }
for (SPRelationship sp : list) { for (SPRelationship sp : list) {
if (!Utilities.noString(sp.r2)) { if (!Utilities.noString(sp.getR2())) {
boolean ok = list2.contains(sp.r2); boolean ok = list2.contains(sp.getR2());
if (!ok) if (!ok)
System.out.println("R2 extra : " + sp.r2); System.out.println("R2 extra : " + sp.getR2());
} }
} }
} }
@ -278,49 +278,5 @@ public class SearchParameterProcessor {
System.out.println("Map loaded - " + list.size() + " entries"); System.out.println("Map loaded - " + list.size() + " entries");
} }
public class SPRelationship {
private final String r4;
private final String r3;
private final String r2b;
private final String r2;
public SPRelationship(String r4, String r3, String r2b, String r2) {
super();
this.r4 = r4;
this.r3 = r3;
this.r2b = r2b;
this.r2 = r2;
}
public String getR4() {
return r4;
}
public String getR3() {
return r3;
}
public String getR2b() {
return r2b;
}
public String getR2() {
return r2;
}
public String getByCode(String code) {
if ("R4".equals(code))
return r4;
if ("R3".equals(code))
return r3;
if ("R2b".equals(code))
return r2b;
if ("R2".equals(code))
return r2;
return null;
}
}
} }

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.misc; package org.hl7.fhir.convertors.misc.utg;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;

View File

@ -1,6 +1,6 @@
package org.hl7.fhir.validation; package org.hl7.fhir.validation;
import org.hl7.fhir.convertors.loaders.*; import org.hl7.fhir.convertors.loaders.loaderR5.*;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.context.SimpleWorkerContext;
@ -42,15 +42,15 @@ public class ValidatorUtils {
if (Utilities.noString(version)) if (Utilities.noString(version))
return null; return null;
if (version.startsWith("1.0")) if (version.startsWith("1.0"))
return new R2ToR5Loader(new String[]{"Conformance", "StructureDefinition", "ValueSet", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new BaseLoaderR5.NullLoaderKnowledgeProvider()); return new R2ToR5Loader(new String[]{"Conformance", "StructureDefinition", "ValueSet", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5());
if (version.startsWith("1.4")) if (version.startsWith("1.4"))
return new R2016MayToR5Loader(new String[]{"Conformance", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new BaseLoaderR5.NullLoaderKnowledgeProvider()); // special case return new R2016MayToR5Loader(new String[]{"Conformance", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5()); // special case
if (version.startsWith("3.0")) if (version.startsWith("3.0"))
return new R3ToR5Loader(new String[]{"CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new BaseLoaderR5.NullLoaderKnowledgeProvider()); return new R3ToR5Loader(new String[]{"CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5());
if (version.startsWith("4.0")) if (version.startsWith("4.0"))
return new R4ToR5Loader(new String[]{"CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new BaseLoaderR5.NullLoaderKnowledgeProvider()); return new R4ToR5Loader(new String[]{"CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5());
if (version.startsWith("5.0")) if (version.startsWith("5.0"))
return new R5ToR5Loader(new String[]{"CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new BaseLoaderR5.NullLoaderKnowledgeProvider()); return new R5ToR5Loader(new String[]{"CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire", "ConceptMap", "StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5());
return null; return null;
} }

View File

@ -14,15 +14,12 @@ import java.util.Map.Entry;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50;
import org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50;
import org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.hl7.fhir.convertors.loaders.BaseLoaderR5.NullLoaderKnowledgeProvider; import org.hl7.fhir.convertors.loaders.loaderR5.NullLoaderKnowledgeProviderR5;
import org.hl7.fhir.convertors.loaders.R4ToR5Loader; import org.hl7.fhir.convertors.loaders.loaderR5.R4ToR5Loader;
import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.FHIRFormatError;
@ -116,7 +113,7 @@ public class ComparisonTests {
BaseWorkerContext bc = (BaseWorkerContext) context; BaseWorkerContext bc = (BaseWorkerContext) context;
boolean dupl = bc.isAllowLoadingDuplicates(); boolean dupl = bc.isAllowLoadingDuplicates();
bc.setAllowLoadingDuplicates(true); bc.setAllowLoadingDuplicates(true);
context.loadFromPackage(npm, new R4ToR5Loader(new String[] { "CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProvider())); context.loadFromPackage(npm, new R4ToR5Loader(new String[] { "CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5()));
bc.setAllowLoadingDuplicates(dupl); bc.setAllowLoadingDuplicates(dupl);
} }

View File

@ -17,7 +17,7 @@ import java.util.zip.ZipInputStream;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.hl7.fhir.convertors.loaders.R3ToR4Loader; import org.hl7.fhir.convertors.loaders.loaderR4.R3ToR4Loader;
import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.FHIRFormatError;

View File

@ -46,11 +46,11 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.fhir.ucum.UcumEssenceService; import org.fhir.ucum.UcumEssenceService;
import org.hl7.fhir.convertors.loaders.BaseLoaderR5.NullLoaderKnowledgeProvider; import org.hl7.fhir.convertors.loaders.loaderR5.NullLoaderKnowledgeProviderR5;
import org.hl7.fhir.convertors.loaders.R2016MayToR5Loader; import org.hl7.fhir.convertors.loaders.loaderR5.R2016MayToR5Loader;
import org.hl7.fhir.convertors.loaders.R2ToR5Loader; import org.hl7.fhir.convertors.loaders.loaderR5.R2ToR5Loader;
import org.hl7.fhir.convertors.loaders.R3ToR5Loader; import org.hl7.fhir.convertors.loaders.loaderR5.R3ToR5Loader;
import org.hl7.fhir.convertors.loaders.R4ToR5Loader; import org.hl7.fhir.convertors.loaders.loaderR5.R4ToR5Loader;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader;
import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.context.SimpleWorkerContext;
@ -101,13 +101,13 @@ public class UtilitiesXTests {
if (Utilities.noString(version)) if (Utilities.noString(version))
return null; return null;
if (version.startsWith("1.0")) if (version.startsWith("1.0"))
return new R2ToR5Loader(new String[] { "Conformance", "StructureDefinition", "ValueSet", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProvider()); return new R2ToR5Loader(new String[] { "Conformance", "StructureDefinition", "ValueSet", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5());
if (version.startsWith("1.4")) if (version.startsWith("1.4"))
return new R2016MayToR5Loader(new String[] { "Conformance", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProvider()); // special case return new R2016MayToR5Loader(new String[] { "Conformance", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5()); // special case
if (version.startsWith("3.0")) if (version.startsWith("3.0"))
return new R3ToR5Loader(new String[] { "CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProvider()); return new R3ToR5Loader(new String[] { "CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5());
if (version.startsWith("4.0")) if (version.startsWith("4.0"))
return new R4ToR5Loader(new String[] { "CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProvider()); return new R4ToR5Loader(new String[] { "CapabilityStatement", "StructureDefinition", "ValueSet", "CodeSystem", "SearchParameter", "OperationDefinition", "Questionnaire","ConceptMap","StructureMap", "NamingSystem"}, new NullLoaderKnowledgeProviderR5());
return null; return null;
} }