diff --git a/mllp_adapter/mllp_adapter.go b/mllp_adapter/mllp_adapter.go index cc9df92..b6d0948 100644 --- a/mllp_adapter/mllp_adapter.go +++ b/mllp_adapter/mllp_adapter.go @@ -45,6 +45,7 @@ var ( hl7V2LocationID = flag.String("hl7_v2_location_id", "", "ID of Cloud Location where the healthcare dataset is stored") hl7V2DatasetID = flag.String("hl7_v2_dataset_id", "", "ID of the healthcare dataset") hl7V2StoreID = flag.String("hl7_v2_store_id", "", "ID of the HL7v2 store inside the healthcare dataset") + logACK = flag.Bool("log_ack", false, "[Optional] Whether to log the ACK received from the API. These info logs will contain sensitive data.") logNACKedMsg = flag.Bool("log_nacked_msg", false, "[Optional] Whether to log the contents of messages that receive NACK from the API. These error logs will contain sensitive data.") logErrorMsg = flag.Bool("log_error_msg", false, "[Optional] Whether to log the error message when NACK is received from the API. These error logs will contain sensitive data.") exportStats = flag.Bool("export_stats", true, "[Optional] Whether to export stackdriver stats") @@ -79,7 +80,7 @@ func run() error { log.Warningf("Flag --api_addr_prefix deprecated, API calls will be made to healthcare.googleapis.com/v1.") } si := healthapiclient.StoreInfo{*hl7V2ProjectID, *hl7V2LocationID, *hl7V2DatasetID, *hl7V2StoreID} - opt := healthapiclient.Option{*logNACKedMsg, *logErrorMsg} + opt := healthapiclient.Option{*logNACKedMsg, *logErrorMsg, *logACK} apiClient, err := healthapiclient.NewHL7V2Client(ctx, *credentials, mon, si, opt) if err != nil { return fmt.Errorf("failed to connect to HL7v2 API: %v", err) diff --git a/shared/healthapiclient/healthapiclient.go b/shared/healthapiclient/healthapiclient.go index 52e888b..796ce68 100644 --- a/shared/healthapiclient/healthapiclient.go +++ b/shared/healthapiclient/healthapiclient.go @@ -54,6 +54,7 @@ type HL7V2Client struct { hl7V2StoreID string logNACKedMsg bool logErrMsg bool + logACK bool } type sendMessageErrorResp struct { @@ -77,6 +78,7 @@ type StoreInfo struct { type Option struct { LogNACKedMessage bool LogErrorMessage bool + LogACK bool } // NewHL7V2Client creates a properly authenticated client that talks to an HL7v2 backend. @@ -99,6 +101,7 @@ func NewHL7V2Client(ctx context.Context, cred string, metrics monitoring.Client, hl7V2StoreID: si.HL7V2StoreID, logNACKedMsg: opt.LogNACKedMessage, logErrMsg: opt.LogErrorMessage, + logACK: opt.LogACK, } c.initMetrics() return c, nil @@ -188,6 +191,9 @@ func (c *HL7V2Client) Send(data []byte) ([]byte, error) { c.metrics.IncCounter(sendErrorMetric) return nil, fmt.Errorf("unable to parse ACK response: %v", err) } + if c.logACK { + log.Infof("Received ACK from HL7V2 Store: %s", sanitizeMessageForPrintout(ack)) + } log.Infof("Message was successfully sent to the Cloud Healthcare API HL7V2 Store.") return ack, nil }