more package maintenance, and more work on mapping generator

This commit is contained in:
Grahame Grieve 2019-07-04 10:26:57 +10:00
parent ee0a32b6ab
commit 0357e58203
13 changed files with 1454 additions and 60 deletions

View File

@ -0,0 +1,80 @@
package org.hl7.fhir.convertors.misc;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.json.JsonTrackingParser;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
public class PackageMaintainer {
private static final String PATH = "C:\\work\\org.hl7.fhir\\packages\\core";
public static void main(String[] args) throws IOException {
new PackageMaintainer().check("r4");
new PackageMaintainer().check("r2");
new PackageMaintainer().check("r3");
new PackageMaintainer().check("r2b");
}
private void check(String ver) throws IOException {
System.out.println("Check "+ver);
List<String> allIds = listResources(Utilities.path(PATH, "hl7.fhir."+ver+".examples", "package"));
List<String> coreIds = listResources(Utilities.path(PATH, "hl7.fhir."+ver+".core", "package"));
for (String s : coreIds) {
if (!allIds.contains(s)) {
System.out.println("Core contains "+s+" but allIds doesn't");
}
}
for (String s : allIds) {
if (!coreIds.contains(s)) {
String c = s.substring(0, s.indexOf("-"));
if (Utilities.existsInList(c, "CodeSystem", "ValueSet", "ConceptMap", "StructureDefinition", "StructureMap", "NamingSystem", "SearchParameter", "OperationDefinition", "CapabilityStatement", "Conformance"))
System.out.println("Examples contains "+s+" but core doesn't");
}
}
strip(new File(Utilities.path(PATH, "hl7.fhir."+ver+".core", "package")));
strip(new File(Utilities.path(PATH, "hl7.fhir."+ver+".expansions", "package")));
if (!ver.equals("r2b"))
strip(new File(Utilities.path(PATH, "hl7.fhir."+ver+".elements", "package")));
}
private List<String> listResources(String dir) {
File folder = new File(dir);
List<String> res = new ArrayList<>();
for (String fn : folder.list()) {
if (fn.endsWith(".json") && fn.contains("-")) {
String s = fn;
s = s.substring(0, s.indexOf("."));
res.add(s);
}
}
return res;
}
private void strip(File folder) throws IOException {
for (File f : folder.listFiles()) {
if (f.isDirectory())
strip(f);
else if (f.getName().endsWith(".json")) {
JsonObject json = JsonTrackingParser.parseJson(f);
if (json.has("resourceType") && json.has("text")) {
json.remove("text");
Gson gson = new GsonBuilder().create();
String src = gson.toJson(json);
TextFile.stringToFile(src, f.getAbsolutePath());
}
}
}
}
}

View File

@ -0,0 +1,45 @@
package org.hl7.fhir.dstu2.utils;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu2.formats.JsonParser;
import org.hl7.fhir.dstu2.model.Bundle;
import org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu2.model.Resource;
import org.hl7.fhir.dstu2.model.ValueSet;
import org.hl7.fhir.utilities.Utilities;
public class Unbundler {
public static void main(String[] args) throws Exception {
unbundle(args[0]);
}
private static void unbundle(String src) throws FHIRFormatError, FileNotFoundException, IOException {
String folder = Utilities.getDirectoryForFile(src);
Bundle bnd = (Bundle) new JsonParser().parse(new FileInputStream(src));
for (BundleEntryComponent be : bnd.getEntry()) {
Resource r = be.getResource();
if (r != null) {
if (StringUtils.isBlank(r.getId())) {
if (r instanceof ValueSet)
r.setId(tail((ValueSet) r));
}
if (!StringUtils.isBlank(r.getId())) {
String tgt = Utilities.path(folder, r.fhirType()+"-"+r.getId()+".json");
new JsonParser().compose(new FileOutputStream(tgt), r);
}
}
}
}
private static String tail(ValueSet r) {
return r.getUrl().contains("/") ? r.getUrl().substring(r.getUrl().lastIndexOf("/")+1) : null;
}
}

View File

@ -0,0 +1,45 @@
package org.hl7.fhir.dstu2016may.utils;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu2016may.model.ValueSet;
import org.hl7.fhir.dstu2016may.formats.JsonParser;
import org.hl7.fhir.dstu2016may.model.Bundle;
import org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu2016may.model.Resource;
import org.hl7.fhir.utilities.Utilities;
public class Unbundler {
public static void main(String[] args) throws Exception {
unbundle(args[0]);
}
private static void unbundle(String src) throws FHIRFormatError, FileNotFoundException, IOException {
String folder = Utilities.getDirectoryForFile(src);
Bundle bnd = (Bundle) new JsonParser().parse(new FileInputStream(src));
for (BundleEntryComponent be : bnd.getEntry()) {
Resource r = be.getResource();
if (r != null) {
if (StringUtils.isBlank(r.getId())) {
if (r instanceof ValueSet)
r.setId(tail((ValueSet) r));
}
if (!StringUtils.isBlank(r.getId())) {
String tgt = Utilities.path(folder, r.fhirType()+"-"+r.getId()+".json");
new JsonParser().compose(new FileOutputStream(tgt), r);
}
}
}
}
private static String tail(ValueSet r) {
return r.getUrl().contains("/") ? r.getUrl().substring(r.getUrl().lastIndexOf("/")+1) : null;
}
}

View File

@ -0,0 +1,33 @@
package org.hl7.fhir.dstu3.utils;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.dstu3.formats.JsonParser;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.utilities.Utilities;
public class Unbundler {
public static void main(String[] args) throws Exception {
unbundle(args[0]);
}
private static void unbundle(String src) throws FHIRFormatError, FileNotFoundException, IOException {
String folder = Utilities.getDirectoryForFile(src);
Bundle bnd = (Bundle) new JsonParser().parse(new FileInputStream(src));
for (BundleEntryComponent be : bnd.getEntry()) {
Resource r = be.getResource();
if (r != null) {
String tgt = Utilities.path(folder, r.fhirType()+"-"+r.getId()+".json");
new JsonParser().compose(new FileOutputStream(tgt), r);
}
}
}
}

View File

@ -0,0 +1,48 @@
package org.hl7.fhir.r4.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r4.formats.JsonParser;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r4.model.MetadataResource;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.utilities.Utilities;
public class Unbundler {
public static void main(String[] args) throws Exception {
unbundle(args[0]);
}
private static void unbundle(String src) throws FHIRFormatError, FileNotFoundException, IOException {
String folder = Utilities.getDirectoryForFile(src);
Bundle bnd = (Bundle) new JsonParser().parse(new FileInputStream(src));
for (BundleEntryComponent be : bnd.getEntry()) {
Resource r = be.getResource();
if (r != null) {
if (StringUtils.isBlank(r.getId())) {
if (r instanceof MetadataResource)
r.setId(tail((MetadataResource) r));
}
if (!StringUtils.isBlank(r.getId())) {
String tgt = Utilities.path(folder, r.fhirType()+"-"+r.getId()+".json");
if (!new File(tgt).exists())
new JsonParser().compose(new FileOutputStream(tgt), r);
}
}
}
}
private static String tail(MetadataResource r) {
return r.getUrl().contains("/") ? r.getUrl().substring(r.getUrl().lastIndexOf("/")+1) : null;
}
}

View File

@ -0,0 +1,880 @@
package org.hl7.fhir.r5.patterns;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Wed, May 8, 2019 10:40+1000 for FHIR v4.1.0
import java.util.*;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.r5.model.Enumerations.*;
import org.hl7.fhir.r5.model.*;
import org.hl7.fhir.r5.model.Enumeration;
import org.hl7.fhir.exceptions.FHIRException;
public class ActivityDefinitionDefinitionImpl extends PatternBaseImpl implements Definition {
private ActivityDefinition wrapped;
public ActivityDefinitionDefinitionImpl(ActivityDefinition wrapped) {
super(wrapped);
this.wrapped = wrapped;
}
public int getUrlMin() {
return 0;
}
public int getUrlMax() {
return 1;
}
public UriType getUrlElement() throws FHIRException {
return wrapped.getUrlElement();
}
public boolean hasUrlElement() {
return wrapped.hasUrlElement();
}
public boolean hasUrl() {
return wrapped.hasUrl();
}
public Definition setUrlElement(UriType value) throws FHIRException {
wrapped.setUrlElement(value);
return this;
}
public String getUrl() throws FHIRException {
return wrapped.getUrl();
}
public Definition setUrl(String value) throws FHIRException {
wrapped.setUrl(value);
return this;
}
public int getIdentifierMin() {
return 0;
}
public int getIdentifierMax() {
return 2147483647;
}
public Identifier getIdentifier() throws FHIRException {
return wrapped.getIdentifierFirstRep();
}
public boolean hasIdentifier() {
return wrapped.hasIdentifier();
}
public Definition setIdentifier(Identifier value) throws FHIRException {
wrapped.getIdentifier().clear();
if (value != null)
wrapped.getIdentifier().add(value);
return this;
}
public int getVersionMin() {
return 0;
}
public int getVersionMax() {
return 1;
}
public StringType getVersionElement() throws FHIRException {
return wrapped.getVersionElement();
}
public boolean hasVersionElement() {
return wrapped.hasVersionElement();
}
public boolean hasVersion() {
return wrapped.hasVersion();
}
public Definition setVersionElement(StringType value) throws FHIRException {
wrapped.setVersionElement(value);
return this;
}
public String getVersion() throws FHIRException {
return wrapped.getVersion();
}
public Definition setVersion(String value) throws FHIRException {
wrapped.setVersion(value);
return this;
}
public int getTitleMin() {
return 0;
}
public int getTitleMax() {
return 1;
}
public StringType getTitleElement() throws FHIRException {
return wrapped.getTitleElement();
}
public boolean hasTitleElement() {
return wrapped.hasTitleElement();
}
public boolean hasTitle() {
return wrapped.hasTitle();
}
public Definition setTitleElement(StringType value) throws FHIRException {
wrapped.setTitleElement(value);
return this;
}
public String getTitle() throws FHIRException {
return wrapped.getTitle();
}
public Definition setTitle(String value) throws FHIRException {
wrapped.setTitle(value);
return this;
}
public int getDerivedFromCanonicalMin() {
return 0;
}
public int getDerivedFromCanonicalMax() {
return 0;
}
public List<CanonicalType> getDerivedFromCanonical() throws FHIRException {
throw new FHIRException("The pattern property 'derivedFromCanonical' is not supported in 'ActivityDefinition'");
}
public Definition setDerivedFromCanonical(List<CanonicalType> theDerivedFromCanonical) throws FHIRException {
throw new FHIRException("The pattern property 'derivedFromCanonical' is not supported in 'ActivityDefinition'");
}
public boolean hasDerivedFromCanonical() {
return false;
}
public CanonicalType addDerivedFromCanonicalElement() throws FHIRException {
throw new FHIRException("The pattern property 'derivedFromCanonical' is not supported in 'ActivityDefinition'");
}
public Definition addDerivedFromCanonical(String value) throws FHIRException {
throw new FHIRException("The pattern property 'derivedFromCanonical' is not supported in 'ActivityDefinition'");
}
public boolean hasDerivedFromCanonical(String value) {
return false;
}
public int getDerivedFromUriMin() {
return 0;
}
public int getDerivedFromUriMax() {
return 0;
}
public List<UriType> getDerivedFromUri() throws FHIRException {
throw new FHIRException("The pattern property 'derivedFromUri' is not supported in 'ActivityDefinition'");
}
public Definition setDerivedFromUri(List<UriType> theDerivedFromUri) throws FHIRException {
throw new FHIRException("The pattern property 'derivedFromUri' is not supported in 'ActivityDefinition'");
}
public boolean hasDerivedFromUri() {
return false;
}
public UriType addDerivedFromUriElement() throws FHIRException {
throw new FHIRException("The pattern property 'derivedFromUri' is not supported in 'ActivityDefinition'");
}
public Definition addDerivedFromUri(String value) throws FHIRException {
throw new FHIRException("The pattern property 'derivedFromUri' is not supported in 'ActivityDefinition'");
}
public boolean hasDerivedFromUri(String value) {
return false;
}
public int getPartOfMin() {
return 0;
}
public int getPartOfMax() {
return 0;
}
public List<CanonicalType> getPartOf() throws FHIRException {
throw new FHIRException("The pattern property 'partOf' is not supported in 'ActivityDefinition'");
}
public Definition setPartOf(List<CanonicalType> thePartOf) throws FHIRException {
throw new FHIRException("The pattern property 'partOf' is not supported in 'ActivityDefinition'");
}
public boolean hasPartOf() {
return false;
}
public CanonicalType addPartOfElement() throws FHIRException {
throw new FHIRException("The pattern property 'partOf' is not supported in 'ActivityDefinition'");
}
public Definition addPartOf(String value) throws FHIRException {
throw new FHIRException("The pattern property 'partOf' is not supported in 'ActivityDefinition'");
}
public boolean hasPartOf(String value) {
return false;
}
public int getReplacesMin() {
return 0;
}
public int getReplacesMax() {
return 0;
}
public List<CanonicalType> getReplaces() throws FHIRException {
throw new FHIRException("The pattern property 'replaces' is not supported in 'ActivityDefinition'");
}
public Definition setReplaces(List<CanonicalType> theReplaces) throws FHIRException {
throw new FHIRException("The pattern property 'replaces' is not supported in 'ActivityDefinition'");
}
public boolean hasReplaces() {
return false;
}
public CanonicalType addReplacesElement() throws FHIRException {
throw new FHIRException("The pattern property 'replaces' is not supported in 'ActivityDefinition'");
}
public Definition addReplaces(String value) throws FHIRException {
throw new FHIRException("The pattern property 'replaces' is not supported in 'ActivityDefinition'");
}
public boolean hasReplaces(String value) {
return false;
}
public int getStatusMin() {
return 0;
}
public int getStatusMax() {
return 0;
}
public Enumeration<PublicationStatus> getStatusElement() throws FHIRException {
throw new FHIRException("The pattern property 'status' is not supported in 'ActivityDefinition'");
}
public boolean hasStatusElement() {
return false;
}
public boolean hasStatus() {
return false;
}
public Definition setStatusElement(Enumeration<PublicationStatus> value) throws FHIRException {
throw new FHIRException("The pattern property 'status' is not supported in 'ActivityDefinition'");
}
public PublicationStatus getStatus() throws FHIRException {
throw new FHIRException("The pattern property 'status' is not supported in 'ActivityDefinition'");
}
public Definition setStatus(PublicationStatus value) throws FHIRException {
throw new FHIRException("The pattern property 'status' is not supported in 'ActivityDefinition'");
}
public int getExperimentalMin() {
return 0;
}
public int getExperimentalMax() {
return 1;
}
public BooleanType getExperimentalElement() throws FHIRException {
return wrapped.getExperimentalElement();
}
public boolean hasExperimentalElement() {
return wrapped.hasExperimentalElement();
}
public boolean hasExperimental() {
return wrapped.hasExperimental();
}
public Definition setExperimentalElement(BooleanType value) throws FHIRException {
wrapped.setExperimentalElement(value);
return this;
}
public boolean getExperimental() throws FHIRException {
return wrapped.getExperimental();
}
public Definition setExperimental(boolean value) throws FHIRException {
wrapped.setExperimental(value);
return this;
}
public int getSubjectMin() {
return 0;
}
public int getSubjectMax() {
return 0;
}
public Type getSubject() throws FHIRException {
throw new FHIRException("The pattern property 'subject[x]' is not supported in 'ActivityDefinition'");
}
public CodeableConcept getSubjectCodeableConcept() throws FHIRException {
throw new FHIRException("The pattern property 'subject[x]' is not supported in 'ActivityDefinition'");
}
public boolean hasSubjectCodeableConcept() {
return false;
}
public Reference getSubjectReference() throws FHIRException {
throw new FHIRException("The pattern property 'subject[x]' is not supported in 'ActivityDefinition'");
}
public boolean hasSubjectReference() {
return false;
}
public boolean hasSubject() {
return false;
}
public Definition setSubject(Type value) throws FHIRException {
throw new FHIRException("The pattern property 'subject[x]' is not supported in 'ActivityDefinition'");
}
public int getDateMin() {
return 0;
}
public int getDateMax() {
return 1;
}
public DateTimeType getDateElement() throws FHIRException {
return wrapped.getDateElement();
}
public boolean hasDateElement() {
return wrapped.hasDateElement();
}
public boolean hasDate() {
return wrapped.hasDate();
}
public Definition setDateElement(DateTimeType value) throws FHIRException {
wrapped.setDateElement(value);
return this;
}
public Date getDate() throws FHIRException {
return wrapped.getDate();
}
public Definition setDate(Date value) throws FHIRException {
wrapped.setDate(value);
return this;
}
public int getPublisherMin() {
return 0;
}
public int getPublisherMax() {
return 0;
}
public Reference getPublisher() throws FHIRException {
throw new FHIRException("The pattern property 'publisher' is not supported in 'ActivityDefinition'");
}
public boolean hasPublisher() {
return false;
}
public Definition setPublisher(Reference value) throws FHIRException {
throw new FHIRException("The pattern property 'publisher' is not supported in 'ActivityDefinition'");
}
public int getContactMin() {
return 0;
}
public int getContactMax() {
return 2147483647;
}
public List<ContactDetail> getContact() throws FHIRException {
return wrapped.getContact();
}
public Definition setContact(List<ContactDetail> theContact) throws FHIRException {
wrapped.setContact(theContact);
return this;
}
public boolean hasContact() {
return wrapped.hasContact();
}
public ContactDetail addContact() throws FHIRException {
throw new FHIRException("The pattern property 'contact' is not supported in 'ActivityDefinition'");
}
public Definition addContact(ContactDetail t) throws FHIRException {
throw new FHIRException("The pattern property 'contact' is not supported in 'ActivityDefinition'");
}
public ContactDetail getContactFirstRep() throws FHIRException {
return wrapped.getContactFirstRep();
}
public int getDescriptionMin() {
return 0;
}
public int getDescriptionMax() {
return 1;
}
public MarkdownType getDescriptionElement() throws FHIRException {
return wrapped.getDescriptionElement();
}
public boolean hasDescriptionElement() {
return wrapped.hasDescriptionElement();
}
public boolean hasDescription() {
return wrapped.hasDescription();
}
public Definition setDescriptionElement(MarkdownType value) throws FHIRException {
wrapped.setDescriptionElement(value);
return this;
}
public String getDescription() throws FHIRException {
return wrapped.getDescription();
}
public Definition setDescription(String value) throws FHIRException {
wrapped.setDescription(value);
return this;
}
public int getUseContextMin() {
return 0;
}
public int getUseContextMax() {
return 2147483647;
}
public List<UsageContext> getUseContext() throws FHIRException {
return wrapped.getUseContext();
}
public Definition setUseContext(List<UsageContext> theUseContext) throws FHIRException {
wrapped.setUseContext(theUseContext);
return this;
}
public boolean hasUseContext() {
return wrapped.hasUseContext();
}
public UsageContext addUseContext() throws FHIRException {
throw new FHIRException("The pattern property 'useContext' is not supported in 'ActivityDefinition'");
}
public Definition addUseContext(UsageContext t) throws FHIRException {
throw new FHIRException("The pattern property 'useContext' is not supported in 'ActivityDefinition'");
}
public UsageContext getUseContextFirstRep() throws FHIRException {
return wrapped.getUseContextFirstRep();
}
public int getJurisdictionMin() {
return 0;
}
public int getJurisdictionMax() {
return 2147483647;
}
public List<CodeableConcept> getJurisdiction() throws FHIRException {
return wrapped.getJurisdiction();
}
public Definition setJurisdiction(List<CodeableConcept> theJurisdiction) throws FHIRException {
wrapped.setJurisdiction(theJurisdiction);
return this;
}
public boolean hasJurisdiction() {
return wrapped.hasJurisdiction();
}
public CodeableConcept addJurisdiction() throws FHIRException {
throw new FHIRException("The pattern property 'jurisdiction' is not supported in 'ActivityDefinition'");
}
public Definition addJurisdiction(CodeableConcept t) throws FHIRException {
throw new FHIRException("The pattern property 'jurisdiction' is not supported in 'ActivityDefinition'");
}
public CodeableConcept getJurisdictionFirstRep() throws FHIRException {
return wrapped.getJurisdictionFirstRep();
}
public int getPurposeMin() {
return 0;
}
public int getPurposeMax() {
return 1;
}
public MarkdownType getPurposeElement() throws FHIRException {
return wrapped.getPurposeElement();
}
public boolean hasPurposeElement() {
return wrapped.hasPurposeElement();
}
public boolean hasPurpose() {
return wrapped.hasPurpose();
}
public Definition setPurposeElement(MarkdownType value) throws FHIRException {
wrapped.setPurposeElement(value);
return this;
}
public String getPurpose() throws FHIRException {
return wrapped.getPurpose();
}
public Definition setPurpose(String value) throws FHIRException {
wrapped.setPurpose(value);
return this;
}
public int getCopyrightMin() {
return 0;
}
public int getCopyrightMax() {
return 1;
}
public MarkdownType getCopyrightElement() throws FHIRException {
return wrapped.getCopyrightElement();
}
public boolean hasCopyrightElement() {
return wrapped.hasCopyrightElement();
}
public boolean hasCopyright() {
return wrapped.hasCopyright();
}
public Definition setCopyrightElement(MarkdownType value) throws FHIRException {
wrapped.setCopyrightElement(value);
return this;
}
public String getCopyright() throws FHIRException {
return wrapped.getCopyright();
}
public Definition setCopyright(String value) throws FHIRException {
wrapped.setCopyright(value);
return this;
}
public int getApprovalDateMin() {
return 0;
}
public int getApprovalDateMax() {
return 1;
}
public DateType getApprovalDateElement() throws FHIRException {
return wrapped.getApprovalDateElement();
}
public boolean hasApprovalDateElement() {
return wrapped.hasApprovalDateElement();
}
public boolean hasApprovalDate() {
return wrapped.hasApprovalDate();
}
public Definition setApprovalDateElement(DateType value) throws FHIRException {
wrapped.setApprovalDateElement(value);
return this;
}
public Date getApprovalDate() throws FHIRException {
return wrapped.getApprovalDate();
}
public Definition setApprovalDate(Date value) throws FHIRException {
wrapped.setApprovalDate(value);
return this;
}
public int getLastReviewDateMin() {
return 0;
}
public int getLastReviewDateMax() {
return 1;
}
public DateType getLastReviewDateElement() throws FHIRException {
return wrapped.getLastReviewDateElement();
}
public boolean hasLastReviewDateElement() {
return wrapped.hasLastReviewDateElement();
}
public boolean hasLastReviewDate() {
return wrapped.hasLastReviewDate();
}
public Definition setLastReviewDateElement(DateType value) throws FHIRException {
wrapped.setLastReviewDateElement(value);
return this;
}
public Date getLastReviewDate() throws FHIRException {
return wrapped.getLastReviewDate();
}
public Definition setLastReviewDate(Date value) throws FHIRException {
wrapped.setLastReviewDate(value);
return this;
}
public int getEffectivePeriodMin() {
return 0;
}
public int getEffectivePeriodMax() {
return 1;
}
public Period getEffectivePeriod() throws FHIRException {
return wrapped.getEffectivePeriod();
}
public boolean hasEffectivePeriod() {
return wrapped.hasEffectivePeriod();
}
public Definition setEffectivePeriod(Period value) throws FHIRException {
wrapped.setEffectivePeriod(value);
return this;
}
public int getPerformerTypeMin() {
return 0;
}
public int getPerformerTypeMax() {
return 0;
}
public CodeableConcept getPerformerType() throws FHIRException {
throw new FHIRException("The pattern property 'performerType' is not supported in 'ActivityDefinition'");
}
public boolean hasPerformerType() {
return false;
}
public Definition setPerformerType(CodeableConcept value) throws FHIRException {
throw new FHIRException("The pattern property 'performerType' is not supported in 'ActivityDefinition'");
}
public String fhirType() {
return "ActivityDefinition";
}
}

View File

@ -27,8 +27,10 @@ public class IGHelper {
public static final String EXT_SPREADSHEET = ToolingExtensions.EXT_IGP_SPREADSHEET; public static final String EXT_SPREADSHEET = ToolingExtensions.EXT_IGP_SPREADSHEET;
public static final String EXT_MAPPING_CSV = ToolingExtensions.EXT_IGP_MAPPING_CSV;
public static final String EXT_BUNDLE = ToolingExtensions.EXT_IGP_BUNDLE; public static final String EXT_BUNDLE = ToolingExtensions.EXT_IGP_BUNDLE;
public static final String EXT_RESOURCE_INFO = ToolingExtensions.EXT_IGP_RESOURCE_INFO; public static final String EXT_RESOURCE_INFO = ToolingExtensions.EXT_IGP_RESOURCE_INFO;
public static final String EXT_PRIVATE_BASE = ToolingExtensions.EXT_PRIVATE_BASE;
public static String readStringParameter(ImplementationGuideDefinitionComponent ig, String name) { public static String readStringParameter(ImplementationGuideDefinitionComponent ig, String name) {
for (ImplementationGuideDefinitionParameterComponent p : ig.getParameter()) { for (ImplementationGuideDefinitionParameterComponent p : ig.getParameter()) {

View File

@ -3,6 +3,7 @@ package org.hl7.fhir.r5.utils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,15 +11,33 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.fhir.ucum.Utilities;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.model.ConceptMap; import org.hl7.fhir.r5.model.ConceptMap;
import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent;
import org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent;
import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent; import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent;
import org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent;
import org.hl7.fhir.r5.model.DateTimeType; import org.hl7.fhir.r5.model.DateTimeType;
import org.hl7.fhir.r5.model.Enumerations.ConceptMapEquivalence;
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
import org.hl7.fhir.r5.model.IdType;
import org.hl7.fhir.r5.model.MetadataResource; import org.hl7.fhir.r5.model.MetadataResource;
import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.StructureMap;
import org.hl7.fhir.r5.model.StructureMap.StructureMapContextType;
import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent;
import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent;
import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent;
import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent;
import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent;
import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupTypeMode;
import org.hl7.fhir.r5.model.StructureMap.StructureMapTransform;
import org.hl7.fhir.r5.model.UrlType; import org.hl7.fhir.r5.model.UrlType;
import org.hl7.fhir.utilities.CSVReader; import org.hl7.fhir.utilities.CSVReader;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
public class MappingSheetParser { public class MappingSheetParser {
@ -52,6 +71,12 @@ public class MappingSheetParser {
public String getCardinality() { public String getCardinality() {
return cardinality; return cardinality;
} }
public int getCardinalityMin() {
return Integer.parseInt(cardinality.split("\\.")[0]);
}
public String getCardinalityMax() {
return cardinality.split("\\.")[2];
}
public String getCondition() { public String getCondition() {
return condition; return condition;
} }
@ -82,21 +107,24 @@ public class MappingSheetParser {
} }
private CSVReader csv;
private List<MappingRow> rows = new ArrayList<>(); private List<MappingRow> rows = new ArrayList<>();
private Map<String, String> metadata = new HashMap<>(); private Map<String, String> metadata = new HashMap<>();
public MappingSheetParser(InputStream stream, String name) throws FHIRException, IOException { public MappingSheetParser() {
super(); super();
this.csv = new CSVReader(stream); }
checkHeaders1(name);
checkHeaders2(name); public void parse(InputStream stream, String name) throws FHIRException, IOException {
CSVReader csv = new CSVReader(stream);
checkHeaders1(csv, name);
checkHeaders2(csv, name);
while (csv.line()) { while (csv.line()) {
processRow(); processRow(csv);
} }
} }
private void checkHeaders1(String name) throws FHIRException, IOException { private void checkHeaders1(CSVReader csv, String name) throws FHIRException, IOException {
csv.readHeaders(); csv.readHeaders();
csv.checkColumn(1, "HL7 v2", "Mapping Sheet "+name); csv.checkColumn(1, "HL7 v2", "Mapping Sheet "+name);
csv.checkColumn(6, "Condition (IF True)", "Mapping Sheet "+name); csv.checkColumn(6, "Condition (IF True)", "Mapping Sheet "+name);
@ -106,7 +134,7 @@ public class MappingSheetParser {
csv.checkColumn(17, "Value", "Mapping Sheet "+name); csv.checkColumn(17, "Value", "Mapping Sheet "+name);
} }
private void checkHeaders2(String name) throws FHIRException, IOException { private void checkHeaders2(CSVReader csv, String name) throws FHIRException, IOException {
csv.readHeaders(); csv.readHeaders();
csv.checkColumn(1, "Display Sequence", "Mapping Sheet "+name); csv.checkColumn(1, "Display Sequence", "Mapping Sheet "+name);
csv.checkColumn(2, "Identifier", "Mapping Sheet "+name); csv.checkColumn(2, "Identifier", "Mapping Sheet "+name);
@ -121,7 +149,7 @@ public class MappingSheetParser {
csv.checkColumn(12, "Derived Mapping", "Mapping Sheet "+name); csv.checkColumn(12, "Derived Mapping", "Mapping Sheet "+name);
} }
private void processRow() { private void processRow(CSVReader csv) {
MappingRow mr = new MappingRow(); MappingRow mr = new MappingRow();
mr.sequence = csv.value(1); mr.sequence = csv.value(1);
mr.identifier = csv.value(2); mr.identifier = csv.value(2);
@ -160,27 +188,37 @@ public class MappingSheetParser {
element.setCode(row.getIdentifier()); element.setCode(row.getIdentifier());
element.setId(row.getSequence()); element.setId(row.getSequence());
element.setDisplay(row.getName()+" : "+row.getDataType()+" ["+row.getCardinality()+"]"); element.setDisplay(row.getName()+" : "+row.getDataType()+" ["+row.getCardinality()+"]");
element.addExtension(ToolingExtensions.EXT_MAPPING_NAME, new StringType(row.getName()));
element.addExtension(ToolingExtensions.EXT_MAPPING_TYPE, new StringType(row.getDataType()));
element.addExtension(ToolingExtensions.EXT_MAPPING_CARD, new StringType(row.getCardinality()));
if ("N/A".equals(row.getAttribute()))
element.getTargetFirstRep().setEquivalence(ConceptMapEquivalence.UNMATCHED);
else {
element.getTargetFirstRep().setEquivalence(ConceptMapEquivalence.RELATEDTO);
if (row.getCondition() != null) if (row.getCondition() != null)
element.getTargetFirstRep().addDependsOn().setProperty("http://hl7.org/fhirpath").setValue(processCondition(row.getCondition())); element.getTargetFirstRep().addDependsOn().setProperty("http://hl7.org/fhirpath").setValue(processCondition(row.getCondition()));
element.getTargetFirstRep().setCode(row.getAttribute()); element.getTargetFirstRep().setCode(row.getAttribute());
element.getTargetFirstRep().setDisplay(row.getType()+" : ["+row.getMinMax()+"]"); element.getTargetFirstRep().setDisplay(row.getType()+" : ["+row.getMinMax()+"]");
element.getTargetFirstRep().addExtension(ToolingExtensions.EXT_MAPPING_TGTTYPE, new StringType(row.getType()));
element.getTargetFirstRep().addExtension(ToolingExtensions.EXT_MAPPING_TGTCARD, new StringType(row.getMinMax()));
if (row.getDerived() != null) if (row.getDerived() != null)
element.getTargetFirstRep().getProductFirstRep().setProperty(row.getDerived()).setValue(row.getDerivedMapping()); element.getTargetFirstRep().getProductFirstRep().setProperty(row.getDerived()).setValue(row.getDerivedMapping());
if (row.getComments() != null) if (row.getComments() != null)
element.getTargetFirstRep().setComment(row.getComments()); element.getTargetFirstRep().setComment(row.getComments());
if (row.getDtMapping() != null) if (row.getDtMapping() != null)
element.getTargetFirstRep().addExtension("htp://hl7.org/fhir/StructureDefinition/ConceptMap-type-mapping", new UrlType("todo#"+row.getDtMapping())); element.getTargetFirstRep().addExtension("http://hl7.org/fhir/StructureDefinition/ConceptMap-type-mapping", new UrlType("todo#"+row.getDtMapping()));
if (row.getVocabMapping() != null) if (row.getVocabMapping() != null)
element.getTargetFirstRep().addExtension("htp://hl7.org/fhir/StructureDefinition/ConceptMap-vocab-mapping", new UrlType("todo#"+row.getVocabMapping())); element.getTargetFirstRep().addExtension("http://hl7.org/fhir/StructureDefinition/ConceptMap-vocab-mapping", new UrlType("todo#"+row.getVocabMapping()));
}
} }
return map; return map;
} }
private String processCondition(String condition) { private String processCondition(String condition) {
if (condition.startsWith("IF ") && condition.endsWith(" IS VALUED")) if (condition.startsWith("IF ") && condition.endsWith(" IS VALUED"))
return "`"+condition.substring(4, condition.length()-10)+".exists()"; return "`"+condition.substring(4, condition.length()-10)+"`.exists()";
if (condition.startsWith("IF ") && condition.endsWith(" DOES NOT EXIST")) if (condition.startsWith("IF ") && condition.endsWith(" DOES NOT EXIST"))
return "`"+condition.substring(4, condition.length()-15)+".exists()"; return "`"+condition.substring(4, condition.length()-15)+"`.exists()";
throw new Error("not processed yet: "+condition); throw new Error("not processed yet: "+condition);
} }
@ -205,9 +243,190 @@ public class MappingSheetParser {
mr.setDescription(metadata.get("description")); mr.setDescription(metadata.get("description"));
} }
public static void main(String[] args) throws FileNotFoundException, IOException, FHIRException { public StructureMap getStructureMap() throws FHIRException {
MappingSheetParser parser = new MappingSheetParser(new FileInputStream("c:\\temp\\v2-pid.csv"), "v2-pid.csv"); StructureMap map = new StructureMap();
ConceptMap cm = parser.getConceptMap(); loadMetadata(map);
if (metadata.containsKey("copyright"))
map.setCopyright(metadata.get("copyright"));
StructureMapGroupComponent grp = map.addGroup();
grp.setTypeMode(StructureMapGroupTypeMode.NONE);
for (MappingRow row : rows) {
StructureMapGroupRuleComponent rule = grp.addRule();
rule.setName(row.getSequence());
StructureMapGroupRuleSourceComponent src = rule.getSourceFirstRep();
src.setContext("src");
src.setElement(row.getIdentifier());
src.setMin(row.getCardinalityMin());
src.setMax(row.getCardinalityMax());
src.setType(row.getDataType());
src.addExtension(ToolingExtensions.EXT_MAPPING_NAME, new StringType(row.getName()));
if (row.getCondition() != null) {
src.setCheck(processCondition(row.getCondition()));
}
StructureMapGroupRuleTargetComponent tgt = rule.getTargetFirstRep();
tgt.setContext("tgt");
tgt.setContextType(StructureMapContextType.VARIABLE);
tgt.setElement(row.getAttribute());
tgt.addExtension(ToolingExtensions.EXT_MAPPING_TGTTYPE, new StringType(row.getType()));
tgt.addExtension(ToolingExtensions.EXT_MAPPING_TGTCARD, new StringType(row.getMinMax()));
if (row.getDtMapping() != null) {
src.setVariable("s");
tgt.setVariable("t");
tgt.setTransform(StructureMapTransform.CREATE);
StructureMapGroupRuleDependentComponent dep = rule.addDependent();
dep.setName(row.getDtMapping());
dep.addVariable("s");
dep.addVariable("t");
} else if (row.getVocabMapping() != null) {
tgt.setTransform(StructureMapTransform.TRANSLATE);
tgt.addParameter().setValue(new StringType(row.getVocabMapping()));
tgt.addParameter().setValue(new IdType("src"));
} else {
tgt.setTransform(StructureMapTransform.COPY);
}
rule.setDocumentation(row.getComments());
if (row.getDerived() != null) {
tgt = rule.addTarget();
tgt.setContext("tgt");
tgt.setContextType(StructureMapContextType.VARIABLE);
tgt.setElement(row.getDerived());
tgt.setTransform(StructureMapTransform.COPY);
tgt.addParameter().setValue(new StringType(row.getDerivedMapping()));
}
}
return map;
}
public boolean isSheet(ConceptMap cm) {
if (cm.getGroup().size() != 1)
return false;
ConceptMapGroupComponent grp = cm.getGroupFirstRep();
for (SourceElementComponent e : grp.getElement()) {
if (!e.hasExtension(ToolingExtensions.EXT_MAPPING_TYPE))
return false;
}
return true;
}
public String genSheet(ConceptMap cm) throws FHIRException {
StringBuilder b = new StringBuilder();
readConceptMap(cm);
b.append("<table class=\"grid\">\r\n");
addHeaderRow1(b);
addHeaderRow2(b);
for (MappingRow row : rows)
addRow(b, row);
b.append("</table>\r\n");
return b.toString();
}
private void addRow(StringBuilder b, MappingRow row) {
b.append(" <tr>");
b.append("<td>"+Utilities.escapeXml(nn(row.sequence))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.identifier))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.name))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.dataType))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.cardinality))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.condition))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.attribute))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.type))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.minMax))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.dtMapping))+"</td>");
b.append("<td>"+Utilities.escapeXml(nn(row.vocabMapping))+"</td>");
if (row.derived != null)
b.append("<td>"+Utilities.escapeXml(nn(row.derived+"="+row.derivedMapping))+"</td>");
else
b.append("<td></td>");
b.append("<td>"+Utilities.escapeXml(nn(row.comments))+"</td>");
b.append("</tr>\r\n");
} }
private String nn(String s) {
return s == null ? "" : s;
}
private void addHeaderRow1(StringBuilder b) {
b.append(" <tr>");
b.append("<td colspan=\"5\" style=\"background-color: lightgreen\"><b>v2</b></td>");
b.append("<td colspan=\"1\"><b>Condition</b></td>");
b.append("<td colspan=\"6\" style=\"background-color: orange\"><b>FHIR</b></td>");
b.append("<td colspan=\"1\"><b>Comments</b></td>");
b.append("</tr>\r\n");
}
private void addHeaderRow2(StringBuilder b) {
b.append(" <tr>");
b.append("<td style=\"background-color: lightgreen\"><b>Display Sequence</b></td>");
b.append("<td style=\"background-color: lightgreen\"><b>Identifier</b></td>");
b.append("<td style=\"background-color: lightgreen\"><b>Name</b></td>");
b.append("<td style=\"background-color: lightgreen\"><b>Data Type</b></td>");
b.append("<td style=\"background-color: lightgreen\"><b>Cardinality</b></td>");
b.append("<td><b></b></td>");
b.append("<td style=\"background-color: orange\"><b>FHIR Attribute</b></td>");
b.append("<td style=\"background-color: orange\"><b>Data Type</b></td>");
b.append("<td style=\"background-color: orange\"><b>Cardinality</b></td>");
b.append("<td style=\"background-color: orange\"><b>Data Type Mapping</b></td>");
b.append("<td style=\"background-color: orange\"><b>Vocabulary Mapping</b></td>");
b.append("<td style=\"background-color: orange\"><b>Derived Mapping</b></td>");
b.append("<td><b></b></td>");
b.append("</tr>\r\n");
}
private void readConceptMap(ConceptMap cm) throws FHIRException {
for (ConceptMapGroupComponent g : cm.getGroup()) {
for (SourceElementComponent e : g.getElement()) {
if (e.hasId() && e.getTarget().size() == 1 && e.hasExtension(ToolingExtensions.EXT_MAPPING_TYPE)) {
TargetElementComponent t = e.getTargetFirstRep();
MappingRow row = new MappingRow();
row.sequence = e.getId();
row.identifier = e.getCode();
row.name = e.getExtensionString(ToolingExtensions.EXT_MAPPING_NAME);
row.dataType = e.getExtensionString(ToolingExtensions.EXT_MAPPING_TYPE);
row.cardinality = e.getExtensionString(ToolingExtensions.EXT_MAPPING_CARD);
if (t.getEquivalence() == ConceptMapEquivalence.UNMATCHED) {
row.attribute = "N/A";
} else {
OtherElementComponent dep = getDependency(t, "http://hl7.org/fhirpath");
if (dep != null)
row.condition = dep.getValue();
row.attribute = t.getCode();
row.type = t.getExtensionString(ToolingExtensions.EXT_MAPPING_TGTTYPE);
row.minMax = t.getExtensionString(ToolingExtensions.EXT_MAPPING_TGTCARD);
row.dtMapping = t.getExtensionString("http://hl7.org/fhir/StructureDefinition/ConceptMap-type-mapping");
row.vocabMapping = t.getExtensionString("http://hl7.org/fhir/StructureDefinition/ConceptMap-vocab-mapping");
if (t.getProduct().size() > 0) {
row.derived = t.getProductFirstRep().getProperty();
row.derivedMapping = t.getProductFirstRep().getValue();
}
}
row.comments = t.getComment();
rows.add(row);
}
}
}
}
private OtherElementComponent getDependency(TargetElementComponent t, String prop) {
for (OtherElementComponent dep : t.getDependsOn()) {
if (prop.equals(dep.getProperty()))
return dep;
}
return null;
}
private static final String PFX = "<html><link rel=\"stylesheet\" href=\"file:c:\\work\\org.hl7.fhir\\build\\publish\\fhir.css\"/></head><body>\r\n";
private static final String SFX = "<body></html>";
public static void main(String[] args) throws FileNotFoundException, IOException, FHIRException {
MappingSheetParser parser = new MappingSheetParser();
parser.parse(new FileInputStream("c:\\temp\\v2-pid.csv"), "v2-pid.csv");
ConceptMap cm = parser.getConceptMap();
StructureMap sm = parser.getStructureMap();
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\sm.json"), sm);
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\cm.json"), cm);
TextFile.stringToFile(StructureMapUtilities.render(sm), "c:\\temp\\sm.txt");
TextFile.stringToFile(PFX+parser.genSheet(cm)+SFX, "c:\\temp\\map.html");
}
} }

View File

@ -2833,7 +2833,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
} }
private boolean isSource(ValueSet vs, Type source) { private boolean isSource(ValueSet vs, Type source) {
return vs.hasUrl() && vs.getUrl().equals(source.primitiveValue()); return vs.hasUrl() && source != null && vs.getUrl().equals(source.primitiveValue());
} }
private Integer countMembership(ValueSet vs) { private Integer countMembership(ValueSet vs) {
@ -4076,6 +4076,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
inject(ig, x, NarrativeStatus.GENERATED); inject(ig, x, NarrativeStatus.GENERATED);
return true; return true;
} }
public boolean generate(ResourceContext rcontext, OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException { public boolean generate(ResourceContext rcontext, OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException {
XhtmlNode x = new XhtmlNode(NodeType.Element, "div"); XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
x.h2().addText(opd.getName()); x.h2().addText(opd.getName());

View File

@ -416,6 +416,7 @@ public class StructureMapUtilities {
b.append(g.getExtends()); b.append(g.getExtends());
} }
if (g.hasTypeMode()) {
switch (g.getTypeMode()) { switch (g.getTypeMode()) {
case TYPES: case TYPES:
b.append(" <<types>>"); b.append(" <<types>>");
@ -425,6 +426,7 @@ public class StructureMapUtilities {
break; break;
default: // NONE, NULL default: // NONE, NULL
} }
}
b.append(" {\r\n"); b.append(" {\r\n");
for (StructureMapGroupRuleComponent r : g.getRule()) { for (StructureMapGroupRuleComponent r : g.getRule()) {
renderRule(b, r, 2); renderRule(b, r, 2);

View File

@ -148,14 +148,20 @@ public class ToolingExtensions {
public static final String EXT_IGP_RESOURCES = "http://hl7.org/fhir/StructureDefinition/igpublisher-folder-resource"; public static final String EXT_IGP_RESOURCES = "http://hl7.org/fhir/StructureDefinition/igpublisher-folder-resource";
public static final String EXT_IGP_PAGES = "http://hl7.org/fhir/StructureDefinition/igpublisher-folder-pages"; public static final String EXT_IGP_PAGES = "http://hl7.org/fhir/StructureDefinition/igpublisher-folder-pages";
public static final String EXT_IGP_SPREADSHEET = "http://hl7.org/fhir/StructureDefinition/igpublisher-spreadsheet"; public static final String EXT_IGP_SPREADSHEET = "http://hl7.org/fhir/StructureDefinition/igpublisher-spreadsheet";
public static final String EXT_IGP_MAPPING_CSV = "http://hl7.org/fhir/StructureDefinition/igpublisher-mapping-csv";
public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle"; public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle";
public static final String EXT_IGP_RESOURCE_INFO = "http://tools.fhir.org/StructureDefinition/resource-information"; public static final String EXT_IGP_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/resource-information";
public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion"; public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion";
public static final String EXT_MAX_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"; public static final String EXT_MAX_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet";
public static final String EXT_MIN_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"; public static final String EXT_MIN_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet";
public static final String EXT_PROFILE_ELEMENT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element"; public static final String EXT_PROFILE_ELEMENT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element";
public static final String EXT_LIST_PACKAGE = "http://hl7.org/fhir/StructureDefinition/list-packageId"; public static final String EXT_LIST_PACKAGE = "http://hl7.org/fhir/StructureDefinition/list-packageId";
public static final String EXT_MAPPING_NAME = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-source-name";
public static final String EXT_MAPPING_TYPE = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-source-type";
public static final String EXT_MAPPING_CARD = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-source-cardinality";
public static final String EXT_MAPPING_TGTTYPE = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-target-type";
public static final String EXT_MAPPING_TGTCARD = "http://hl7.org/fhir/tools/StructureDefinition/conceptmap-target-cardinality";
public static final String EXT_PRIVATE_BASE = "http://hl7.org/fhir/tools/";
// specific extension helpers // specific extension helpers

View File

@ -0,0 +1,33 @@
package org.hl7.fhir.r5.utils;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.utilities.Utilities;
public class Unbundler {
public static void main(String[] args) throws Exception {
unbundle(args[0]);
}
private static void unbundle(String src) throws FHIRFormatError, FileNotFoundException, IOException {
String folder = Utilities.getDirectoryForFile(src);
Bundle bnd = (Bundle) new JsonParser().parse(new FileInputStream(src));
for (BundleEntryComponent be : bnd.getEntry()) {
Resource r = be.getResource();
if (r != null) {
String tgt = Utilities.path(folder, r.fhirType()+"-"+r.getId()+".json");
new JsonParser().compose(new FileOutputStream(tgt), r);
}
}
}
}

View File

@ -47,8 +47,8 @@
42. Choice Types: constrain list of choices to 1 42. Choice Types: constrain list of choices to 1
43. Choice Types: constrain list of choices to 1 and constrain the type (slicing) 43. Choice Types: constrain list of choices to 1 and constrain the type (slicing)
44. Choice Types: constrain list of choices to 1 and constrain the type (shortcut) 44. Choice Types: constrain list of choices to 1 and constrain the type (shortcut)
43. Choice Types: constrain list of choices to 2 and constrain the types (slicing) 45. Choice Types: constrain list of choices to 2 and constrain the types (slicing)
44. Choice Types: constrain list of choices to 2 and constrain the types (shortcut) 46. Choice Types: constrain list of choices to 2 and constrain the types (shortcut)
--> -->
<contained> <contained>
<StructureDefinition> <StructureDefinition>
@ -1948,7 +1948,7 @@
<contained> <contained>
<StructureDefinition> <StructureDefinition>
<id value="t39"/> <id value="t39"/>
<url value="urn:uuid:"/> <url value="urn:uuid:9756f0c4-6818-4549-ad46-dfad96c371b1"/>
<name value="t39"/> <name value="t39"/>
<status value="draft"/> <status value="draft"/>
<description value="fixture for #39: Choice types: no constraint"/> <description value="fixture for #39: Choice types: no constraint"/>
@ -1973,7 +1973,7 @@
<contained> <contained>
<StructureDefinition> <StructureDefinition>
<id value="t40"/> <id value="t40"/>
<url value="urn:uuid:"/> <url value="urn:uuid:9"/>
<name value="t40"/> <name value="t40"/>
<status value="draft"/> <status value="draft"/>
<description value="fixture for #40: Choice Types: constrain minimum cardinality"/> <description value="fixture for #40: Choice Types: constrain minimum cardinality"/>
@ -1999,7 +1999,7 @@
<contained> <contained>
<StructureDefinition> <StructureDefinition>
<id value="t41"/> <id value="t41"/>
<url value="urn:uuid:"/> <url value="urn:uuid:4485cada-4667-4460-937d-f2dbe6e73f1d"/>
<name value="t41"/> <name value="t41"/>
<status value="draft"/> <status value="draft"/>
<description value="fixture for #41: Choice Types: constrain list of choices to 2"/> <description value="fixture for #41: Choice Types: constrain list of choices to 2"/>
@ -2030,7 +2030,7 @@
<contained> <contained>
<StructureDefinition> <StructureDefinition>
<id value="t42"/> <id value="t42"/>
<url value="urn:uuid:"/> <url value="urn:uuid:5eb149bd-b2f3-4d63-80d2-4d7fccbd76db"/>
<name value="t42"/> <name value="t42"/>
<status value="draft"/> <status value="draft"/>
<description value="fixture for #42: Choice Types: constrain list of choices to 1"/> <description value="fixture for #42: Choice Types: constrain list of choices to 1"/>
@ -2058,7 +2058,7 @@
<contained> <contained>
<StructureDefinition> <StructureDefinition>
<id value="t43"/> <id value="t43"/>
<url value="urn:uuid:"/> <url value="urn:uuid:4caab1de-9278-4783-810c-472c3071f7fd"/>
<name value="t43"/> <name value="t43"/>
<status value="draft"/> <status value="draft"/>
<description value="fixture for #43: Choice Types: constrain list of choices to 1 and constrain the type (slicing)"/> <description value="fixture for #43: Choice Types: constrain list of choices to 1 and constrain the type (slicing)"/>
@ -2104,7 +2104,7 @@
<contained> <contained>
<StructureDefinition> <StructureDefinition>
<id value="t44"/> <id value="t44"/>
<url value="urn:uuid:"/> <url value="urn:uuid:ecb6f563-2957-4da8-832e-cb6d94329a93"/>
<name value="t44"/> <name value="t44"/>
<status value="draft"/> <status value="draft"/>
<description value="fixture for #44: Choice Types: constrain list of choices to 1 and constrain the type (shortcut)"/> <description value="fixture for #44: Choice Types: constrain list of choices to 1 and constrain the type (shortcut)"/>
@ -2136,14 +2136,14 @@
</StructureDefinition> </StructureDefinition>
</contained> </contained>
<!-- 43. Choice Types: constrain list of choices to 2 and constrain the types (slicing) --> <!-- 45. Choice Types: constrain list of choices to 2 and constrain the types (slicing) -->
<contained> <contained>
<StructureDefinition> <StructureDefinition>
<id value="t43"/> <id value="t45"/>
<url value="urn:uuid:"/> <url value="urn:uuid:48b311a6-060c-44f8-8c62-d0abdf39ccb5"/>
<name value="t43"/> <name value="t45"/>
<status value="draft"/> <status value="draft"/>
<description value="fixture for #43: Choice Types: constrain list of choices to 2 and constrain the types (slicing)"/> <description value="fixture for #45: Choice Types: constrain list of choices to 2 and constrain the types (slicing)"/>
<kind value="resource"/> <kind value="resource"/>
<abstract value="false"/> <abstract value="false"/>
<type value="Observation"/> <type value="Observation"/>
@ -2194,14 +2194,14 @@
</StructureDefinition> </StructureDefinition>
</contained> </contained>
<!-- 44. Choice Types: constrain list of choices to 2 and constrain the types (shortcut) --> <!-- 46. Choice Types: constrain list of choices to 2 and constrain the types (shortcut) -->
<contained> <contained>
<StructureDefinition> <StructureDefinition>
<id value="t44"/> <id value="t46"/>
<url value="urn:uuid:"/> <url value="urn:uuid:1fd72ec3-baa8-4cc9-b8d4-13f4f5fdb2af"/>
<name value="t44"/> <name value="t46"/>
<status value="draft"/> <status value="draft"/>
<description value="fixture for #44: Choice Types: constrain list of choices to 2 and constrain the types (shortcut)"/> <description value="fixture for #46: Choice Types: constrain list of choices to 2 and constrain the types (shortcut)"/>
<kind value="resource"/> <kind value="resource"/>
<abstract value="false"/> <abstract value="false"/>
<type value="Observation"/> <type value="Observation"/>