Java Code Examples for org.hl7.fhir.dstu3.model.ValueSet#copy()

The following examples show how to use org.hl7.fhir.dstu3.model.ValueSet#copy() . 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: ISO21090Importer.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void generateValueSet(EnumValueSet evs) throws Exception {
  ValueSet bvs = ctxt.fetchResource(ValueSet.class, evs.template);
  if (bvs == null)
    throw new Exception("Did not find template value set "+evs.template);
  ValueSet vs = bvs.copy();
  vs.getCompose().getInclude().clear();
  vs.getIdentifier().clear();
  vs.setName("ISO 20190 "+evs.name+" Enumeration");
  vs.setId(evs.name);
  vs.setUrl("http://hl7.org/fhir/iso21090/ValueSet/"+vs.getId());
  vs.setDate(new Date());
  vs.setExperimental(false);
  ConceptSetComponent inc = vs.getCompose().addInclude().setSystem(evs.system);
  for (String code : evs.codes) {
    inc.addConcept().setCode(code);
  }
  new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\iso21090\\ValueSet-"+evs.name+".xml"), vs);
}
 
Example 2
Source File: ValueSets.java    From bunsen with Apache License 2.0 4 votes vote down vote up
@Override
public Row call(Row valueSetRow) throws Exception {

  ValueSet valueSet = (ValueSet) converter.rowToResource(valueSetRow);

  ValueSet valueSetWithoutConcepts = valueSet.copy();

  List<ConceptSetComponent> updatedInclusions = new ArrayList<>();

  for (ConceptSetComponent inclusion: valueSet.getCompose().getInclude()) {

    ConceptSetComponent inclusionWithoutConcepts = inclusion.copy();

    inclusionWithoutConcepts.setConcept(new ArrayList<>());
    updatedInclusions.add(inclusionWithoutConcepts);
  }

  valueSetWithoutConcepts.getCompose().setInclude(updatedInclusions);

  return converter.resourceToRow(valueSetWithoutConcepts);
}