Converter API
The Converter
object can be used to convert object types from one format to another.
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:
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
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:
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
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:
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');
This method decodes a URL Encoded string.
Inputs:
string
– A URL encoded stringOutputs:
Example:
var input = 'help%20i%20%C3%A4m%20a%20b%C3%BBg';
var output = Converter.urlDecodeString(input); // returns "help i äm a bûg"
This method decodes a URL Encoded string.
Inputs:
string
– A stringOutputs:
Example:
var input = 'help i äm a bûg';
var output = Converter.urlEncodeString(input); // returns help%20i%20%C3%A4m%20a%20b%C3%BBg
This method encodes a string to base64.
Inputs:
string
– A stringOutputs:
Example:
var input = 'help i äm a bûg';
var output = Converter.base64Encode(input); // returns aGVscCBpIMOkbSBhIGLDu2c=
This method decodes a base64 encoded string.
Inputs:
string
– A stringOutputs:
Example:
var input = 'aGVscCBpIMOkbSBhIGLDu2c=';
var output = Converter.base64Decode(input); // returns "help i äm a bûg"