func (x *CodeSystem) UnmarshalJSON(data []byte) (err error) {
	x2 := codeSystem{}
	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 = CodeSystem(x2)
		return x.checkResourceType()
	}
	return
}
Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
package models
import (
	"encoding/json"
	"errors"
	"fmt"
)
type CodeSystem struct {
	DomainResource   `bson:",inline"`
	Url              string                                 `bson:"url,omitempty" json:"url,omitempty"`
	Identifier       *Identifier                            `bson:"identifier,omitempty" json:"identifier,omitempty"`
	Version          string                                 `bson:"version,omitempty" json:"version,omitempty"`
	Name             string                                 `bson:"name,omitempty" json:"name,omitempty"`
	Status           string                                 `bson:"status,omitempty" json:"status,omitempty"`
	Experimental     *bool                                  `bson:"experimental,omitempty" json:"experimental,omitempty"`
	Publisher        string                                 `bson:"publisher,omitempty" json:"publisher,omitempty"`
	Contact          []CodeSystemContactComponent           `bson:"contact,omitempty" json:"contact,omitempty"`
	Date             *FHIRDateTime                          `bson:"date,omitempty" json:"date,omitempty"`
	Description      string                                 `bson:"description,omitempty" json:"description,omitempty"`
	UseContext       []CodeableConcept                      `bson:"useContext,omitempty" json:"useContext,omitempty"`
	Requirements     string                                 `bson:"requirements,omitempty" json:"requirements,omitempty"`
	Copyright        string                                 `bson:"copyright,omitempty" json:"copyright,omitempty"`
	CaseSensitive    *bool                                  `bson:"caseSensitive,omitempty" json:"caseSensitive,omitempty"`
	ValueSet         string                                 `bson:"valueSet,omitempty" json:"valueSet,omitempty"`
	HierarchyMeaning string                                 `bson:"hierarchyMeaning,omitempty" json:"hierarchyMeaning,omitempty"`
	Compositional    *bool                                  `bson:"compositional,omitempty" json:"compositional,omitempty"`
	VersionNeeded    *bool                                  `bson:"versionNeeded,omitempty" json:"versionNeeded,omitempty"`
	Content          string                                 `bson:"content,omitempty" json:"content,omitempty"`
	Count            *uint32                                `bson:"count,omitempty" json:"count,omitempty"`
	Filter           []CodeSystemFilterComponent            `bson:"filter,omitempty" json:"filter,omitempty"`
	Property         []CodeSystemPropertyComponent          `bson:"property,omitempty" json:"property,omitempty"`
	Concept          []CodeSystemConceptDefinitionComponent `bson:"concept,omitempty" json:"concept,omitempty"`
}
func (resource *CodeSystem) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "CodeSystem"
	return json.Marshal(*resource)
}
func (x *CodeSystem) GetBSON() (interface{}, error) {
	x.ResourceType = "CodeSystem"
	return *x, nil
}
type codeSystem CodeSystem