001/*-
002 * #%L
003 * Smile CDR - CDR
004 * %%
005 * Copyright (C) 2016 - 2024 Smile CDR, Inc.
006 * %%
007 * All rights reserved.
008 * #L%
009 */
010package ca.cdr.api.camel;
011
012import ca.cdr.api.model.enm.TransactionLogEventTypeEnum;
013import ca.cdr.api.model.json.TransactionLogStepJson;
014import ca.cdr.api.pub.hl7v2.model.Hl7v2ToFhirConversionResultJson;
015import ca.uhn.hl7v2.HL7Exception;
016import ca.uhn.hl7v2.model.Message;
017import org.apache.camel.Exchange;
018
019import java.util.List;
020
021/**
022 * Transaction log helper to be used by for HL7V2 Camel procedures
023 */
024public interface IHl7V2CamelProcessorTxLogHelper {
025
026        /**
027         * Adds a transaction log step If a transaction log is present or a new transaction log otherwise
028         * @param theProcedureName the calling procedure name
029         * @param theExchange      the camel exchange
030         * @param theMessage       the HL7V2 message
031         * @throws HL7Exception on message encoding failure
032         */
033        void logHl7RawMsg(String theProcedureName, Exchange theExchange, Message theMessage) throws HL7Exception;
034
035        /**
036         * If transaction logging is active, logs a step if transaction log is present or a new transaction log otherwise
037         * @param theExchange            the camel exchange
038         * @param theConversionResult    the input Hl7v2ToFhirConversionResultJson
039         * @param theIntermediateProcess boolean indicating if caller is intermediate HL7V2 process
040         * @param theLogType             the TransactionLogEventTypeEnum
041         * @param theStepsProvider       the HL7V2TransactionLogStepsProvider
042         * @throws HL7Exception when original message can't be extracted from exchange
043         */
044        void addHl7LogStepOrNewLog(
045                        Exchange theExchange,
046                        Hl7v2ToFhirConversionResultJson theConversionResult,
047                        boolean theIntermediateProcess,
048                        TransactionLogEventTypeEnum theLogType,
049                        IHL7V2TxLogStepsProvider theStepsProvider)
050                        throws HL7Exception;
051
052        /**
053         * Builds a list of bundles corresponding to the received conversionResult
054         * @param theExchange                   the camel exchange
055         * @param theConversionResult   the ongoing process {@code Hl7v2ToFhirConversionResultJson}
056         * @param theProcedureName              the current procedure name
057         * @return the list of transaction log steps corresponding to the bundles contained in received theConversionResult
058         * @throws HL7Exception                 if HL7V2 message can't be extracted from {@code Hl7v2ToFhirConversionResultJson}
059         */
060        List<TransactionLogStepJson> getHl7LogStepsForBundles(
061                        Exchange theExchange, Hl7v2ToFhirConversionResultJson theConversionResult, String theProcedureName)
062                        throws HL7Exception;
063}