func NewHL7V2Client(ctx context.Context, cred string, metrics *monitoring.Client, projectID, locationID, datasetID, hl7V2StoreID string, logNACKedMsg bool) (*HL7V2Client, error) {
	if err := validatesComponents(projectID, locationID, datasetID, hl7V2StoreID); err != nil {
		return nil, err
	}
	storeService, err := initHL7v2StoreService(ctx, cred)
	if err != nil {
		return nil, err
	}
	c := &HL7V2Client{
		metrics:      metrics,
		storeService: storeService,
		projectID:    projectID,
		locationID:   locationID,
		datasetID:    datasetID,
		hl7V2StoreID: hl7V2StoreID,
		logNACKedMsg: logNACKedMsg,
	}
	c.initMetrics()
	return c, nil
}
NewHL7V2Client creates a properly authenticated client that talks to an HL7v2 backend.
package healthapiclient
import (
	"context"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"unicode/utf8"
	log "github.com/golang/glog"
	"google.golang.org/api/googleapi"
	"google.golang.org/api/option"
	"github.com/GoogleCloudPlatform/mllp/shared/monitoring"
	"github.com/GoogleCloudPlatform/mllp/shared/util"
	healthcare "google.golang.org/api/healthcare/v1"
)
const (
	scope               = "https://www.googleapis.com/auth/cloud-healthcare"
	contentType         = "application/json"
	fhirJSONContentType = "application/fhir+json;charset=utf-8"
	sendSuffix          = "messages:ingest"
	sentMetric               = "apiclient-sent"
	sendErrorMetric          = "apiclient-send-error"
	fetchedMetric            = "apiclient-fetched"
	fetchErrorMetric         = "apiclient-fetch-error"
	fetchErrorInternalMetric = "apiclient-fetch-error-internal"
)
type HL7V2Client struct {
	metrics      *monitoring.Client
	storeService *healthcare.ProjectsLocationsDatasetsHl7V2StoresService
	projectID    string
	locationID   string
	datasetID    string
	hl7V2StoreID string
	logNACKedMsg bool
}
type sendMessageErrorResp struct {
	Error struct {
		Details []struct {
			Hl7Nack []byte `json:"hl7Nack"`
		} `json:"details"`
	} `json:"error"`
}