use of io.github.linuxforhealth.hl7.message.HL7MessageEngine in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7ToFHIRConverter method convertToBundle.
/**
* Converts the input HL7 message (String data) into FHIR bundle resource.
*
* @param hl7MessageData Message to convert
* @param options Options for conversion
* @param engine Hl7Message engine
* @return Bundle {@link Bundle} resource.
* @throws UnsupportedOperationException - if message type is not supported
*/
public Bundle convertToBundle(String hl7MessageData, ConverterOptions options, HL7MessageEngine engine) {
Preconditions.checkArgument(StringUtils.isNotBlank(hl7MessageData), "Input HL7 message cannot be blank");
if (engine == null) {
engine = getMessageEngine(options);
}
Message hl7message = getHl7Message(hl7MessageData);
if (hl7message != null) {
String messageType = HL7DataExtractor.getMessageType(hl7message);
HL7MessageModel hl7MessageTemplateModel = messagetemplates.get(messageType);
if (hl7MessageTemplateModel != null) {
return hl7MessageTemplateModel.convert(hl7message, engine);
} else {
throw new UnsupportedOperationException("Message type not yet supported " + messageType);
}
} else {
throw new IllegalArgumentException("Parsed HL7 message was null.");
}
}
use of io.github.linuxforhealth.hl7.message.HL7MessageEngine in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7ToFHIRConverter method convert.
/**
* Converts the input HL7 message (String data) into FHIR bundle resource.
*
* @param hl7MessageData Message to convert
* @param options Options for conversion
*
* @return JSON representation of FHIR {@link Bundle} resource.
* @throws UnsupportedOperationException - if message type is not supported
*/
public String convert(String hl7MessageData, ConverterOptions options) {
HL7MessageEngine engine = getMessageEngine(options);
Bundle bundle = convertToBundle(hl7MessageData, options, engine);
return engine.getFHIRContext().encodeResourceToString(bundle);
}
use of io.github.linuxforhealth.hl7.message.HL7MessageEngine in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7ToFHIRConverter method getMessageEngine.
private HL7MessageEngine getMessageEngine(ConverterOptions options) {
Preconditions.checkArgument(options != null, "options cannot be null.");
FHIRContext context = new FHIRContext(options.isPrettyPrint(), options.isValidateResource(), options.getProperties(), options.getZoneIdText());
return new HL7MessageEngine(context, options.getBundleType());
}
Aggregations