40.15.1Composition 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.

40.15.2Method: 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);

40.15.3Method: 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');

40.15.4Method: 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');

40.15.5Method: addSection()

 

This method can be used to create a subsection within a section. The following C-CDA sections use subsections to cluster resources. Please refer to the documentation for each section for the details on how clustering will affect the generated document.

Inputs:

  • This method does not take any arguments.
var composition = ResourceBuilder.build('Composition');
var vitalSignsSection = composition.addSection('vitalsign');
var vitalSignsCluster = vitalSignsSection.addSection();

Outputs:

  • Returns a CompositionSectionBuilder resource to work with.