Skip to content

Commit

Permalink
Merge pull request #987 from HL7/custom-resource
Browse files Browse the repository at this point in the history
Custom resource
  • Loading branch information
grahamegrieve authored Nov 18, 2024
2 parents 3471359 + b89e5b1 commit 4bfb8bf
Show file tree
Hide file tree
Showing 20 changed files with 509 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r5.utils.XVerExtensionManager;
import org.hl7.fhir.r5.utils.validation.ValidatorSession;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.validation.BaseValidator;
Expand All @@ -52,8 +53,8 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
*/
public class CodeSystemValidator extends BaseValidator {

public CodeSystemValidator(IWorkerContext context, XVerExtensionManager xverManager) {
super(context, xverManager, false);
public CodeSystemValidator(IWorkerContext context, XVerExtensionManager xverManager, ValidatorSession session) {
super(context, xverManager, false, session);
}

public List<ValidationMessage> validate(CodeSystem cs, boolean forBuild) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent;
import org.hl7.fhir.r5.utils.UserDataNames;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.utilities.json.model.JsonObject;
import org.hl7.fhir.utilities.validation.ValidationMessage;
Expand Down Expand Up @@ -60,6 +61,7 @@ public class FetchedResource {
private boolean hasTranslations;
private String resourceName;
private String resourceDescription;
private boolean regenAfterValidation;

public FetchedResource(String nameForErrors) {
super();
Expand Down Expand Up @@ -352,5 +354,22 @@ public String getBestName() {
return resourceDescription;
}
}

public boolean isRegenAfterValidation() {
return regenAfterValidation;
}

public void setRegenAfterValidation(boolean regenAfterValidation) {
this.regenAfterValidation = regenAfterValidation;
}

public boolean isCustomResource() {
if (getResource() != null) {
return getResource().hasUserData(UserDataNames.loader_custom_resource);
} else {
return getElement().getProperty().getStructure().hasUserData(UserDataNames.loader_custom_resource);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.utils.UserDataNames;
import org.hl7.fhir.r5.utils.XVerExtensionManager;
import org.hl7.fhir.utilities.LoincLinker;
import org.hl7.fhir.utilities.Utilities;
Expand Down Expand Up @@ -426,7 +427,7 @@ else if ((bc.getUrl().startsWith(canonical) || (altCanonical != null && bc.getUr
if (r.getConfig() == null)
findConfiguration(f, r);
JsonObject e = r.getConfig();
bc.setUserData("config", e);
bc.setUserData(UserDataNames.pub_resource_config, e);
String base = getProperty(r, "base");
if (base != null)
bc.setWebPath(doReplacements(base, r, null, null));
Expand All @@ -449,7 +450,7 @@ public void checkForPath(FetchedFile f, FetchedResource r, Element res) throws F
if (r.getConfig() == null)
findConfiguration(f, r);
JsonObject e = r.getConfig();
res.setUserData("config", e);
res.setUserData(UserDataNames.pub_resource_config, e);
String base = getProperty(r, "base");
if (base != null)
res.setWebPath(doReplacements(base, r, null, null));
Expand Down Expand Up @@ -586,7 +587,7 @@ else if (ref.equals("http://www.iso.org/iso/country_codes.htm"))
br.url = vs.getWebPath();
br.display = vs.getName();
br.uri = vs.getVersionedUrl();
br.external = vs.hasUserData("External.Link");
br.external = vs.hasUserData(UserDataNames.render_external_link);
}
} else {
if (ref.startsWith("http://hl7.org/fhir/ValueSet/")) {
Expand All @@ -595,7 +596,7 @@ else if (ref.equals("http://www.iso.org/iso/country_codes.htm"))
br.url = vs.getWebPath();
br.display = vs.getName();
br.uri = vs.getUrl();
br.external = vs.hasUserData("External.Link");
br.external = vs.hasUserData(UserDataNames.render_external_link);
} else {
String nvref = ref;
if (nvref.contains("|")) {
Expand Down Expand Up @@ -641,7 +642,7 @@ else if (ref.equals("http://www.iso.org/iso/country_codes.htm"))
br.display = vs.getName();
}
br.uri = vs.getUrl();
br.external = vs.hasUserData("External.Link");
br.external = vs.hasUserData(UserDataNames.render_external_link);
} else if (ref.startsWith("http://cts.nlm.nih.gov/fhir/ValueSet/")) {
String oid = ref.substring("http://cts.nlm.nih.gov/fhir/ValueSet/".length());
br.url = "https://vsac.nlm.nih.gov/valueset/"+oid+"/expansion";
Expand Down
Loading

0 comments on commit 4bfb8bf

Please sign in to comment.