update extension extractor
This commit is contained in:
parent
f9b386d5b2
commit
107fa0e3a2
|
@ -17,7 +17,6 @@ import org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult;
|
|||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.json.model.JsonArray;
|
||||
import org.hl7.fhir.utilities.json.model.JsonElement;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Bool
|
|||
import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Date30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.DateTime30_40;
|
||||
import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4.model.Extension;
|
||||
import org.hl7.fhir.r4.model.Immunization;
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.hl7.fhir.convertors.conv30_50.resources30_50;
|
|||
import org.hl7.fhir.convertors.context.ConversionContext30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Code30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
|
||||
|
|
|
@ -5,9 +5,7 @@ import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50;
|
|||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Code30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Integer30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.MarkDown30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
|
||||
import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50;
|
||||
|
||||
import org.hl7.fhir.convertors.context.ConversionContext40_50;
|
||||
import org.hl7.fhir.convertors.context.ConversionContext43_50;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
||||
public class DateTime40_50 {
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50;
|
||||
|
||||
import org.hl7.fhir.convertors.context.ConversionContext30_50;
|
||||
import org.hl7.fhir.convertors.context.ConversionContext40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.hl7.fhir.r5.model.CanonicalType;
|
||||
import org.hl7.fhir.r5.model.CodeableReference;
|
||||
|
||||
public class Reference40_50 {
|
||||
|
|
|
@ -5,10 +5,7 @@ import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableCon
|
|||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Code40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Integer40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
|
||||
import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50;
|
||||
|
||||
import org.hl7.fhir.convertors.context.ConversionContext40_50;
|
||||
import org.hl7.fhir.convertors.context.ConversionContext43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
|
||||
|
|
|
@ -5,10 +5,7 @@ import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableCon
|
|||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.ContactDetail43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.UsageContext43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Canonical43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Code43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Integer43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
|
||||
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50;
|
||||
|
|
|
@ -47,12 +47,10 @@ import org.hl7.fhir.r5.model.CanonicalType;
|
|||
import org.hl7.fhir.r5.model.CodeSystem;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.r5.model.Enumerations.BindingStrength;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||
import org.hl7.fhir.r5.model.UriType;
|
||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||
|
||||
public class R5ToR5Loader extends BaseLoaderR5 {
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.hl7.fhir.convertors.misc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -7,8 +8,10 @@ import java.util.ArrayList;
|
|||
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.context.CanonicalResourceManager;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||
import org.hl7.fhir.r5.model.CodeSystem;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingAdditionalComponent;
|
||||
|
@ -21,8 +24,6 @@ import org.hl7.fhir.utilities.Utilities;
|
|||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
|
||||
import ca.uhn.fhir.model.api.IStreamingDatatype;
|
||||
|
||||
public class ExtensionExtractor {
|
||||
|
||||
public static void main(String[] args) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
|
@ -57,9 +58,16 @@ public class ExtensionExtractor {
|
|||
for (String r : r5.listResources("StructureDefinition")) {
|
||||
StructureDefinition sd = (StructureDefinition) new JsonParser().parse(r5.load(r));
|
||||
if (sd.getType().equals("Extension") && sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
|
||||
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
seeBinding(ed.getBinding().getValueSet(), vslist, "ext", sd);
|
||||
for (ElementDefinitionBindingAdditionalComponent ab : ed.getBinding().getAdditional()) {
|
||||
seeBinding(ab.getValueSet(), vslist, "ext", sd);
|
||||
}
|
||||
}
|
||||
sd.setSnapshot(null);
|
||||
String fn;
|
||||
if (sd.getContext().size() == 0) {
|
||||
fn = Utilities.path(dst, "null", sd.getId()+".json");
|
||||
save(sd, dst,"none");
|
||||
} else if (sd.getContext().size() > 1) {
|
||||
boolean dt = true;
|
||||
for (StructureDefinitionContextComponent x : sd.getContext()) {
|
||||
|
@ -67,24 +75,16 @@ public class ExtensionExtractor {
|
|||
dt = dt && isDataType(s);
|
||||
}
|
||||
if (dt) {
|
||||
fn = Utilities.path(dst, "datatypes", "multiple", sd.getId()+".xml");
|
||||
save(sd, dst,"datatypes");
|
||||
} else {
|
||||
fn = Utilities.path(dst, "multiple", sd.getId()+".xml");
|
||||
save(sd, dst,"multiple");
|
||||
}
|
||||
} else {
|
||||
String s = extractType(sd.getContextFirstRep().getExpression());
|
||||
if (isDataType(s)) {
|
||||
fn = Utilities.path(dst, "datatypes", s, sd.getId()+".xml");
|
||||
save(sd, dst,"datatypes");
|
||||
} else {
|
||||
fn = Utilities.path(dst, s, sd.getId()+".xml");
|
||||
}
|
||||
Utilities.createDirectory(Utilities.getDirectoryForFile(fn));
|
||||
new XmlParser().compose(new FileOutputStream(fn), sd);
|
||||
}
|
||||
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
seeBinding(ed.getBinding().getValueSet(), vslist, "ext", sd);
|
||||
for (ElementDefinitionBindingAdditionalComponent ab : ed.getBinding().getAdditional()) {
|
||||
seeBinding(ab.getValueSet(), vslist, "ext", sd);
|
||||
save(sd, dst,s);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -97,13 +97,13 @@ public class ExtensionExtractor {
|
|||
}
|
||||
}
|
||||
for (ValueSet vs : vslist.getList()) {
|
||||
if (vs.hasUserData("core") || !vs.hasUserData("ext")) {
|
||||
if (vs.hasUserData("core") || !vs.hasUserData("ext") || vs.getUrl().startsWith("http://terminology.")) {
|
||||
vslist.drop(vs.getId());
|
||||
}
|
||||
}
|
||||
for (CodeSystem cs : cslist.getList()) {
|
||||
boolean keep = false;
|
||||
if (cs.hasUserData("vsl" )) {
|
||||
if (cs.hasUserData("vsl") && !cs.getUrl().startsWith("http://terminology.")) {
|
||||
keep = true;
|
||||
for (ValueSet vs : (ArrayList<ValueSet>) cs.getUserData("vsl")) {
|
||||
if (!vslist.has(vs.getUrl())) {
|
||||
|
@ -116,10 +116,28 @@ public class ExtensionExtractor {
|
|||
}
|
||||
}
|
||||
for (ValueSet vs : vslist.getList()) {
|
||||
System.out.println(vs.getUrl());
|
||||
StructureDefinition sd = (StructureDefinition) vs.getUserData("ext");
|
||||
String s = sd.getUserString("folder");
|
||||
save(vs, dst, s);
|
||||
}
|
||||
for (CodeSystem cs : cslist.getList()) {
|
||||
System.out.println(cs.getUrl());
|
||||
ValueSet vs = ((ArrayList<ValueSet>) cs.getUserData("vsl")).get(0);
|
||||
String s = vs.getUserString("folder");
|
||||
save(cs, dst,s);
|
||||
}
|
||||
}
|
||||
|
||||
private void save(CanonicalResource cr, String dst, String folder) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
cr.setText(null);
|
||||
if (!cr.hasTitle()) {
|
||||
cr.setTitle(Utilities.unCamelCase(cr.getName()));
|
||||
}
|
||||
String fn = Utilities.path(dst, folder, cr.fhirType()+"-"+cr.getId()+".xml");
|
||||
cr.setUserData("folder", folder);
|
||||
if (!new File(fn).exists()) {
|
||||
Utilities.createDirectory(Utilities.getDirectoryForFile(fn));
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), cr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.convertors.misc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package org.hl7.fhir.convertors.misc;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -8,6 +12,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
|
@ -35,9 +41,6 @@ import org.hl7.fhir.utilities.json.model.JsonObject;
|
|||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackageIndexBuilder;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class NpmPackageVersionConverter {
|
||||
|
||||
private static final int BUFFER_SIZE = 1024;
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.hl7.fhir.convertors.misc;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.model.JsonProperty;
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.hl7.fhir.convertors.misc.xver;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
|
||||
|
@ -14,7 +13,6 @@ import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50;
|
|||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.convertors.misc.xver.CorePackageVersionConvertor.BaseConvertor;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.json.model.JsonArray;
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package org.hl7.fhir.convertors.conv30_40;
|
||||
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
public class Immunization30_40Test {
|
||||
|
||||
private org.hl7.fhir.r4.formats.JsonParser r4Parser = new org.hl7.fhir.r4.formats.JsonParser();
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
package org.hl7.fhir.convertors.conv40_50;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import javax.annotation.Nullable;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package org.hl7.fhir.convertors.misc;
|
||||
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.tests.ResourceLoaderTests;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import org.hl7.fhir.utilities.tests.ResourceLoaderTests;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class NpmPackageVersionConverterTests implements ResourceLoaderTests {
|
||||
@org.junit.jupiter.api.Test
|
||||
|
|
Loading…
Reference in New Issue