func (x *MedicationDispense) UnmarshalJSON(data []byte) (err error) {
	x2 := medicationDispense{}
	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 = MedicationDispense(x2)
		return x.checkResourceType()
	}
	return
}
Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
package models
import (
	"encoding/json"
	"errors"
	"fmt"
)
type MedicationDispense struct {
	DomainResource            `bson:",inline"`
	Identifier                *Identifier                                    `bson:"identifier,omitempty" json:"identifier,omitempty"`
	Status                    string                                         `bson:"status,omitempty" json:"status,omitempty"`
	MedicationCodeableConcept *CodeableConcept                               `bson:"medicationCodeableConcept,omitempty" json:"medicationCodeableConcept,omitempty"`
	MedicationReference       *Reference                                     `bson:"medicationReference,omitempty" json:"medicationReference,omitempty"`
	Patient                   *Reference                                     `bson:"patient,omitempty" json:"patient,omitempty"`
	Dispenser                 *Reference                                     `bson:"dispenser,omitempty" json:"dispenser,omitempty"`
	DispensingOrganization    *Reference                                     `bson:"dispensingOrganization,omitempty" json:"dispensingOrganization,omitempty"`
	AuthorizingPrescription   []Reference                                    `bson:"authorizingPrescription,omitempty" json:"authorizingPrescription,omitempty"`
	Type                      *CodeableConcept                               `bson:"type,omitempty" json:"type,omitempty"`
	Quantity                  *Quantity                                      `bson:"quantity,omitempty" json:"quantity,omitempty"`
	DaysSupply                *Quantity                                      `bson:"daysSupply,omitempty" json:"daysSupply,omitempty"`
	WhenPrepared              *FHIRDateTime                                  `bson:"whenPrepared,omitempty" json:"whenPrepared,omitempty"`
	WhenHandedOver            *FHIRDateTime                                  `bson:"whenHandedOver,omitempty" json:"whenHandedOver,omitempty"`
	Destination               *Reference                                     `bson:"destination,omitempty" json:"destination,omitempty"`
	Receiver                  []Reference                                    `bson:"receiver,omitempty" json:"receiver,omitempty"`
	Note                      []Annotation                                   `bson:"note,omitempty" json:"note,omitempty"`
	DosageInstruction         []MedicationDispenseDosageInstructionComponent `bson:"dosageInstruction,omitempty" json:"dosageInstruction,omitempty"`
	Substitution              *MedicationDispenseSubstitutionComponent       `bson:"substitution,omitempty" json:"substitution,omitempty"`
	EventHistory              []MedicationDispenseEventHistoryComponent      `bson:"eventHistory,omitempty" json:"eventHistory,omitempty"`
}
func (resource *MedicationDispense) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "MedicationDispense"
	return json.Marshal(*resource)
}
func (x *MedicationDispense) GetBSON() (interface{}, error) {
	x.ResourceType = "MedicationDispense"
	return *x, nil
}
type medicationDispense MedicationDispense