Java Code Examples for org.hl7.fhir.r4.model.ValueSet#hasExpansion()

The following examples show how to use org.hl7.fhir.r4.model.ValueSet#hasExpansion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueSetExpansionCache.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void loadCache() throws FHIRFormatError, IOException {
  File[] files = new File(cacheFolder).listFiles();
  for (File f : files) {
    if (f.getName().endsWith(".xml")) {
      final FileInputStream is = new FileInputStream(f);
      try {	   
        Resource r = context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).parse(is);
        if (r instanceof OperationOutcome) {
          OperationOutcome oo = (OperationOutcome) r;
          expansions.put(ToolingExtensions.getExtension(oo,VS_ID_EXT).getValue().toString(),
              new ValueSetExpansionOutcome(new XhtmlComposer(XhtmlComposer.XML, false).composePlainText(oo.getText().getDiv()), TerminologyServiceErrorClass.UNKNOWN));
        } else if (r instanceof ValueSet) {
          ValueSet vs = (ValueSet) r;
          if (vs.hasExpansion())
            expansions.put(vs.getUrl(), new ValueSetExpansionOutcome(vs));
          else {
            canonicals.put(vs.getUrl(), vs);
            if (vs.hasVersion())
              canonicals.put(vs.getUrl()+"|"+vs.getVersion(), vs);
          }
        } else if (r instanceof MetadataResource) {
          MetadataResource md = (MetadataResource) r;
          canonicals.put(md.getUrl(), md);
          if (md.hasVersion())
            canonicals.put(md.getUrl()+"|"+md.getVersion(), md);
        }
      } finally {
        IOUtils.closeQuietly(is);
      }
    }
  }
}
 
Example 2
Source File: TerminologyCache.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public ValueSet getVSEssense(ValueSet vs) {
  if (vs == null)
    return null;
  ValueSet vsc = new ValueSet();
  vsc.setCompose(vs.getCompose());
  if (vs.hasExpansion()) {
    vsc.getExpansion().getParameter().addAll(vs.getExpansion().getParameter());
    vsc.getExpansion().getContains().addAll(vs.getExpansion().getContains());
  }
  return vsc;
}
 
Example 3
Source File: ValidationSupportR4.java    From synthea with Apache License 2.0 5 votes vote down vote up
private void handleResource(IBaseResource resource) {
  if (resource instanceof Bundle) {
    Bundle bundle = (Bundle) resource;
    for (BundleEntryComponent entry : bundle.getEntry()) {
      if (entry.hasResource()) {
        handleResource(entry.getResource());
      }
    }
  } else {
    resources.add(resource);
    if (resource instanceof CodeSystem) {
      CodeSystem cs = (CodeSystem) resource;
      resourcesMap.put(cs.getUrl(), cs);
      codeSystemMap.put(cs.getUrl(), cs);
    } else if (resource instanceof ValueSet) {
      ValueSet vs = (ValueSet) resource;
      resourcesMap.put(vs.getUrl(), vs);

      if (vs.hasExpansion() && vs.getExpansion().hasContains()) {
        processExpansion(vs.getExpansion().getContains());
      }
    } else if (resource instanceof StructureDefinition) {
      StructureDefinition sd = (StructureDefinition) resource;
      resourcesMap.put(sd.getUrl(), sd);
      definitions.add(sd);
      definitionsMap.put(sd.getUrl(), sd);
    }
  }
}