func (x *EpisodeOfCare) UnmarshalJSON(data []byte) (err error) {
	x2 := episodeOfCare{}
	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 = EpisodeOfCare(x2)
		return x.checkResourceType()
	}
	return
}
Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
package models
import (
	"encoding/json"
	"errors"
	"fmt"
)
type EpisodeOfCare struct {
	DomainResource       `bson:",inline"`
	Identifier           []Identifier                          `bson:"identifier,omitempty" json:"identifier,omitempty"`
	Status               string                                `bson:"status,omitempty" json:"status,omitempty"`
	StatusHistory        []EpisodeOfCareStatusHistoryComponent `bson:"statusHistory,omitempty" json:"statusHistory,omitempty"`
	Type                 []CodeableConcept                     `bson:"type,omitempty" json:"type,omitempty"`
	Condition            []Reference                           `bson:"condition,omitempty" json:"condition,omitempty"`
	Patient              *Reference                            `bson:"patient,omitempty" json:"patient,omitempty"`
	ManagingOrganization *Reference                            `bson:"managingOrganization,omitempty" json:"managingOrganization,omitempty"`
	Period               *Period                               `bson:"period,omitempty" json:"period,omitempty"`
	ReferralRequest      []Reference                           `bson:"referralRequest,omitempty" json:"referralRequest,omitempty"`
	CareManager          *Reference                            `bson:"careManager,omitempty" json:"careManager,omitempty"`
	Team                 []Reference                           `bson:"team,omitempty" json:"team,omitempty"`
	Account              []Reference                           `bson:"account,omitempty" json:"account,omitempty"`
}
func (resource *EpisodeOfCare) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "EpisodeOfCare"
	return json.Marshal(*resource)
}
func (x *EpisodeOfCare) GetBSON() (interface{}, error) {
	x.ResourceType = "EpisodeOfCare"
	return *x, nil
}
type episodeOfCare EpisodeOfCare