On this page:

20.1Converter API

 

The Converter object can be used to convert object types from one format to another.

20.1.1Method: hl7v2TsToFhirDate(dt);

 

This method converts an HL7 v2.x DT or TS datatype value into an equivalent FHIR Date (ISO 8601) string.

Inputs:

  • ts – An HL7 v2.x datetime string (e.g. 20110101 or 201512010005). Note that any precision beyond the day of the month will be ignored.

Outputs:

  • Returns a FHIR Date string (e.g. 2011-01-01).

Example:

var dt = '20110202123000-0400'; // this would likely come from an HL7 v2.x message
var authoredOn = Converter.hl7v2TsToFhirDate(dt);
Log.info(authoredOn); // 2011-02-02

20.1.2Method: hl7v2TsToFhirDateTime(ts);

 

This method converts an HL7 v2.x DT or TS datatype value into an equivalent FHIR DateTime (ISO 8601) string.

Inputs:

  • ts – An HL7 v2.x datetime string (e.g. 20110101 or 201512010005).

Outputs:

  • Returns a FHIR DateTime string (e.g. 2011-01-01T12:30:00-04:00).

Example:

var ts = '20110202123000-0400'; // this would likely come from an HL7 v2.x message
var authoredOn = Converter.hl7v2TsToFhirDateTime(ts);
Log.info(authoredOn); // 2011-02-02T12:30:00-04:00

20.1.3Method: hl7v2TsToFhirDateTime(ts, impliedTimeZone);

 

This method converts an HL7 v2.x DT or TS datatype value into an equivalent FHIR DateTime (ISO 8601) string. This method is useful for processing messages originating in an HL7 v2.x system that does not include timezone offset information in messages, and is known to be located in a specific timezone.

Inputs:

  • ts – An HL7 v2.x datetime string (e.g. 20110101 or 201512010005).
  • impliedTimeZone – A timezone string to use for the resulting FHIR DateTime string (e.g. America/New_York).

Outputs:

  • Returns a FHIR DateTime string (e.g. 2011-01-01T12:30:00-04:00).

Example:

var ts = '20110202123000'; // this would likely come from an HL7 v2.x message
var authoredOn = Converter.hl7v2TsToFhirDateTime(ts, 'America/New_York');

20.1.4Method: urlDecode(string);

 

This method decodes a URL Encoded string.

Inputs:

  • string – A URL encoded string

Outputs:

  • Returns the corresponding URL decoded string (if the supplied string was null, this method returns null)

Example:

var input = 'help%20i%20%C3%A4m%20a%20b%C3%BBg';
var output = Converter.urlDecodeString(input); // returns "help i äm a bûg"

20.1.5Method: urlEncode(string);

 

This method decodes a URL Encoded string.

Inputs:

  • string – A string

Outputs:

  • Returns the corresponding URL encoded string (if the supplied string was null, this method returns null)

Example:

var input = 'help i äm a bûg';
var output = Converter.urlEncodeString(input); // returns help%20i%20%C3%A4m%20a%20b%C3%BBg