func (x *MessageHeader) UnmarshalJSON(data []byte) (err error) {
	x2 := messageHeader{}
	if err = json.Unmarshal(data, &x2); err == nil {
		if x2.Contained != nil {
			for i := range x2.Contained {
				x2.Contained[i] = MapToResource(x2.Contained[i], true)
			}
		}
		*x = MessageHeader(x2)
		return x.checkResourceType()
	}
	return
}
Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
package models
import (
	"encoding/json"
	"errors"
	"fmt"
)
type MessageHeader struct {
	DomainResource `bson:",inline"`
	Timestamp      *FHIRDateTime                              `bson:"timestamp,omitempty" json:"timestamp,omitempty"`
	Event          *Coding                                    `bson:"event,omitempty" json:"event,omitempty"`
	Response       *MessageHeaderResponseComponent            `bson:"response,omitempty" json:"response,omitempty"`
	Source         *MessageHeaderMessageSourceComponent       `bson:"source,omitempty" json:"source,omitempty"`
	Destination    []MessageHeaderMessageDestinationComponent `bson:"destination,omitempty" json:"destination,omitempty"`
	Enterer        *Reference                                 `bson:"enterer,omitempty" json:"enterer,omitempty"`
	Author         *Reference                                 `bson:"author,omitempty" json:"author,omitempty"`
	Receiver       *Reference                                 `bson:"receiver,omitempty" json:"receiver,omitempty"`
	Responsible    *Reference                                 `bson:"responsible,omitempty" json:"responsible,omitempty"`
	Reason         *CodeableConcept                           `bson:"reason,omitempty" json:"reason,omitempty"`
	Data           []Reference                                `bson:"data,omitempty" json:"data,omitempty"`
}
func (resource *MessageHeader) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "MessageHeader"
	return json.Marshal(*resource)
}
func (x *MessageHeader) GetBSON() (interface{}, error) {
	x.ResourceType = "MessageHeader"
	return *x, nil
}
type messageHeader MessageHeader