HDR Factories

This section contains the following topics:

Factories

Classes in this package provide factory methods for creating instances of the following data types and classes:

A reference to ServiceLocator is required to get an instance of each factory. Factories are thus tied to a specific HDR session, and should not be cached and reused across different login sessions.

Note:

Do not use Java's new operator to construct instances of HDR classes. Use factories instead— to ensure that RIM objects or data types that require a service locator for their operation will have access to one.

Data Type Factory

Because the Code System UID is mandatory on coded datatypes (CD, CE, CV), factory methods that do not include the code system UID (Example: methods that take the code system name instead) incur a performance penalty while the factory method requests the UID from ETS.

To achieve optimal performance, provide the code system UID explicitly. You can retrieve the complete mapping of code system names to UIDs by querying the corresponding ETS coding system.

Note:

You can also retrieve the complete mapping of code system names to UIDs in the following way:
  • For coding systems registered with HL7, an online OID Registry is provided as a free service by the HL7 website.

RIM Object Factories

You can create RIM objects through one of the three available factories: ActFactory, EntityFactory, or RoleFactory.

Each factory contains one generic factory method, for creating Act, Entity, and Role objects respectively:

  • ActFactory.newAct
  • EntityFactory.newEntity
  • RoleFactory.newRole

In addition, there are numerous convenience methods within each class for creating various subtypes of Acts, Entities and Roles.

Examples:

  • Create RIM Observations Using the Generic Factory Method (see Example 7-4).
  • Create RIM Observations Using the Convenience Factory Method (see Example 7-5).

Example 7-4 Create RIM Observations Using the Generic Factory Method

DataTypeFactory dtf = DataTypeFactory.getInstance();
ActFactory af = ActFactory.getInstance(serviceLocator);
Observation observation = (Observation) af.newAct(ActClass.OBS, 
ActMood.EVN, dtf.nullCD(NullFlavor.NI), dtf.nullSET_II(NullFlavor.NI));

Example 7-5 Create RIM Observations Using the Convenience Factory Method

The following example illustrates the preferred method for creating RIM objects:

DataTypeFactory dtf = DataTypeFactory.getInstance();
ActFactory af = ActFactory.getInstance(serviceLocator);
Observation observation = af.newObservation(ActMood.EVN, dtf.nullCD(NullFlavor.NI),
dtf.nullSET_II(NullFlavor.NI));

Query Component Factory

See also:

  • HDR Query for information about creating criteria and fetch objects using this factory, submitting them to RIM Service, and interpreting results returned.

Reference Modifiers

In addition to factory classes, the oracle.hsgbu.hdr.hl7.rim.factories package contains the ReferenceModifier class, a typed enumeration of all possible values for RIM class reference modifiers.

See also:

  • Use RIM Services for information about how RIM service persistence uses ReferenceModifier values.