func (x *PractitionerRole) UnmarshalJSON(data []byte) (err error) {
	x2 := practitionerRole{}
	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 = PractitionerRole(x2)
		return x.checkResourceType()
	}
	return
}
Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
package models
import (
	"encoding/json"
	"errors"
	"fmt"
)
type PractitionerRole struct {
	DomainResource         `bson:",inline"`
	Identifier             []Identifier                             `bson:"identifier,omitempty" json:"identifier,omitempty"`
	Active                 *bool                                    `bson:"active,omitempty" json:"active,omitempty"`
	Practitioner           *Reference                               `bson:"practitioner,omitempty" json:"practitioner,omitempty"`
	Organization           *Reference                               `bson:"organization,omitempty" json:"organization,omitempty"`
	Code                   []CodeableConcept                        `bson:"code,omitempty" json:"code,omitempty"`
	Specialty              []CodeableConcept                        `bson:"specialty,omitempty" json:"specialty,omitempty"`
	Location               []Reference                              `bson:"location,omitempty" json:"location,omitempty"`
	HealthcareService      []Reference                              `bson:"healthcareService,omitempty" json:"healthcareService,omitempty"`
	Telecom                []ContactPoint                           `bson:"telecom,omitempty" json:"telecom,omitempty"`
	Period                 *Period                                  `bson:"period,omitempty" json:"period,omitempty"`
	AvailableTime          []PractitionerRoleAvailableTimeComponent `bson:"availableTime,omitempty" json:"availableTime,omitempty"`
	NotAvailable           []PractitionerRoleNotAvailableComponent  `bson:"notAvailable,omitempty" json:"notAvailable,omitempty"`
	AvailabilityExceptions string                                   `bson:"availabilityExceptions,omitempty" json:"availabilityExceptions,omitempty"`
	Endpoint               []Reference                              `bson:"endpoint,omitempty" json:"endpoint,omitempty"`
}
func (resource *PractitionerRole) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "PractitionerRole"
	return json.Marshal(*resource)
}
func (x *PractitionerRole) GetBSON() (interface{}, error) {
	x.ResourceType = "PractitionerRole"
	return *x, nil
}
type practitionerRole PractitionerRole