On this page:

20.10Composition Section API

 

The CompositionSection object represents a section of a composition. This object is not an extension of ResourceBuilder and as such, you cannot use dot notation to set its fields.

To create a CompositionSection, use the ResourceBuilder.build('Composition').addSection(sectionType) method as described in the Composition Resource section of this documentation.

20.10.1Method: populate(List<Resource> resources)

 

Add resource references to this section.

Note that any Fhir.search().forResource(resource)... .asList() call will return a List<Resource> that this method can use for input.

You can view the available options for Fhir.search() here.

Inputs:

  • resources – the list of Resources from which to add references

Outputs:

  • Populates Composition.section.entry with references to the provided resources.
  • Returns the same CompositionSection object for chaining.

Example:

var composition = ResourceBuilder.build('Composition');
var section = composition.addSection();
var observations = Fhir
  .search()
  .forResource('Observation')
  .asList();

section.populate(observations);

20.10.2Method: setTitle(title)

 

Note that if you used a supported value for section type when creating this object, the title will already be set for you. In case you are manually setting the section type or would prefer your own title, you can use this method.

Inputs:

  • title – the value to set the title to.

Outputs:

  • Populates the field with the requested value
  • Returns the same CompositionSection object for chaining.

Example:

var composition = ResourceBuilder.build('Composition');
var section = composition.addSection('problems');
section.setTitle('I got 99 problems');

20.10.3Method: setCode(system, code, display)

 

Note that if you used a supported value for section type when creating this object, the code will be properly populated for you. If you would like to override manually setting the section type or would prefer your own title, you can use this method.

Inputs:

  • system – the desired system
  • code – the desired code
  • system – the desired display name

Outputs:

  • Populates the fields with the requested values
  • Returns the same CompositionSection object for chaining.

Example:

var composition = ResourceBuilder.build('Composition');
var section = composition.addSection();
section.setCode('mySystem', 'myCode', 'myDisplay');