use of org.hl7.fhir.r5.model.UriType in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method importValueSet.
private void importValueSet(String value, List<ValueSetExpansionParameterComponent> params) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException {
if (value == null)
throw new TerminologyServiceException("unable to find value set with no identity");
ValueSet vs = context.fetchResource(ValueSet.class, value);
if (vs == null)
throw new TerminologyServiceException("Unable to find imported value set " + value);
ValueSetExpansionOutcome vso = factory.getExpander().expand(vs);
if (vso.getService() != null)
throw new TerminologyServiceException("Unable to expand imported value set " + value);
if (vs.hasVersion())
if (!existsInParams(params, "version", new UriType(vs.getUrl() + "?version=" + vs.getVersion())))
params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "?version=" + vs.getVersion())));
for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
if (!existsInParams(params, p.getName(), p.getValue()))
params.add(p);
}
for (ValueSetExpansionContainsComponent c : vso.getValueset().getExpansion().getContains()) {
addCode(c.getSystem(), c.getCode(), c.getDisplay());
}
}
use of org.hl7.fhir.r5.model.UriType in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method includeCodes.
private void includeCodes(ConceptSetComponent inc, List<ValueSetExpansionParameterComponent> params) throws TerminologyServiceException, ETooCostly {
if (context.supportsSystem(inc.getSystem())) {
try {
int i = codes.size();
addCodes(context.expandVS(inc), params);
if (codes.size() > i)
return;
} catch (Exception e) {
// ok, we'll try locally
}
}
CodeSystem cs = context.fetchCodeSystem(inc.getSystem());
if (cs == null)
throw new TerminologyServiceException("unable to find code system " + inc.getSystem().toString());
if (cs.hasVersion())
if (!existsInParams(params, "version", new UriType(cs.getUrl() + "?version=" + cs.getVersion())))
params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(cs.getUrl() + "?version=" + cs.getVersion())));
if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
// special case - add all the code system
for (ConceptDefinitionComponent def : cs.getConcept()) {
addCodeAndDescendents(cs, inc.getSystem(), def);
}
}
for (ConceptReferenceComponent c : inc.getConcept()) {
addCode(inc.getSystem(), c.getCode(), Utilities.noString(c.getDisplay()) ? getCodeDisplay(cs, c.getCode()) : c.getDisplay());
}
if (inc.getFilter().size() > 1)
// need to and them, and this isn't done yet. But this shouldn't arise in non loinc and snomed value sets
throw new TerminologyServiceException("Multiple filters not handled yet");
if (inc.getFilter().size() == 1) {
ConceptSetFilterComponent fc = inc.getFilter().get(0);
if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISA) {
// special: all non-abstract codes in the target code system under the value
ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue());
if (def == null)
throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
addCodeAndDescendents(cs, inc.getSystem(), def);
} else
throw new NotImplementedException("not done yet");
}
}
use of org.hl7.fhir.r5.model.UriType in project org.hl7.fhir.core by hapifhir.
the class ValueSet method setProperty.
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("url"))
// UriType
this.url = castToUri(value);
else if (name.equals("identifier"))
// Identifier
this.identifier = castToIdentifier(value);
else if (name.equals("version"))
// StringType
this.version = castToString(value);
else if (name.equals("name"))
// StringType
this.name = castToString(value);
else if (name.equals("status"))
// Enumeration<ConformanceResourceStatus>
this.status = new ConformanceResourceStatusEnumFactory().fromType(value);
else if (name.equals("experimental"))
// BooleanType
this.experimental = castToBoolean(value);
else if (name.equals("publisher"))
// StringType
this.publisher = castToString(value);
else if (name.equals("contact"))
this.getContact().add((ValueSetContactComponent) value);
else if (name.equals("date"))
// DateTimeType
this.date = castToDateTime(value);
else if (name.equals("lockedDate"))
// DateType
this.lockedDate = castToDate(value);
else if (name.equals("description"))
// StringType
this.description = castToString(value);
else if (name.equals("useContext"))
this.getUseContext().add(castToCodeableConcept(value));
else if (name.equals("immutable"))
// BooleanType
this.immutable = castToBoolean(value);
else if (name.equals("requirements"))
// StringType
this.requirements = castToString(value);
else if (name.equals("copyright"))
// StringType
this.copyright = castToString(value);
else if (name.equals("extensible"))
// BooleanType
this.extensible = castToBoolean(value);
else if (name.equals("compose"))
// ValueSetComposeComponent
this.compose = (ValueSetComposeComponent) value;
else if (name.equals("expansion"))
// ValueSetExpansionComponent
this.expansion = (ValueSetExpansionComponent) value;
else
super.setProperty(name, value);
}
use of org.hl7.fhir.r5.model.UriType in project org.hl7.fhir.core by hapifhir.
the class R2016MayToR5Loader method loadResource.
@Override
public org.hl7.fhir.r5.model.Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException {
Resource r2016may = null;
if (isJson)
r2016may = new JsonParser().parse(stream);
else
r2016may = new XmlParser().parse(stream);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertorFactory_14_50.convertResource(r2016may);
setPath(r5);
if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems");
}
if (killPrimitives) {
throw new FHIRException("Cannot kill primitives when using deferred loading");
}
if (patchUrls) {
if (r5 instanceof StructureDefinition) {
StructureDefinition sd = (StructureDefinition) r5;
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_R4));
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE));
for (ElementDefinition ed : sd.getSnapshot().getElement()) patchUrl(ed);
for (ElementDefinition ed : sd.getDifferential().getElement()) patchUrl(ed);
}
}
return r5;
}
use of org.hl7.fhir.r5.model.UriType in project org.hl7.fhir.core by hapifhir.
the class R2ToR5Loader method loadResource.
@Override
public org.hl7.fhir.r5.model.Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException {
Resource r2 = null;
if (isJson)
r2 = new JsonParser().parse(stream);
else
r2 = new XmlParser().parse(stream);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertorFactory_10_50.convertResource(r2, advisor);
setPath(r5);
if (!advisor.getCslist().isEmpty()) {
throw new FHIRException("Error: Cannot have included code systems");
}
if (killPrimitives) {
throw new FHIRException("Cannot kill primitives when using deferred loading");
}
if (patchUrls) {
if (r5 instanceof StructureDefinition) {
StructureDefinition sd = (StructureDefinition) r5;
sd.setUrl(sd.getUrl().replace(URL_BASE, URL_R4));
sd.addExtension().setUrl(URL_ELEMENT_DEF_NAMESPACE).setValue(new UriType(URL_BASE));
for (ElementDefinition ed : sd.getSnapshot().getElement()) patchUrl(ed);
for (ElementDefinition ed : sd.getDifferential().getElement()) patchUrl(ed);
}
}
return r5;
}
Aggregations