func (resource *CompartmentDefinition) MarshalJSON() ([]byte, error) {
	resource.ResourceType = "CompartmentDefinition"
	return json.Marshal(*resource)
}
Custom marshaller to add the resourceType property, as required by the specification
package models
import (
	"encoding/json"
	"errors"
	"fmt"
)
type CompartmentDefinition struct {
	DomainResource `bson:",inline"`
	Url            string                                   `bson:"url,omitempty" json:"url,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        []CompartmentDefinitionContactComponent  `bson:"contact,omitempty" json:"contact,omitempty"`
	Date           *FHIRDateTime                            `bson:"date,omitempty" json:"date,omitempty"`
	Description    string                                   `bson:"description,omitempty" json:"description,omitempty"`
	Requirements   string                                   `bson:"requirements,omitempty" json:"requirements,omitempty"`
	Code           string                                   `bson:"code,omitempty" json:"code,omitempty"`
	Search         *bool                                    `bson:"search,omitempty" json:"search,omitempty"`
	Resource       []CompartmentDefinitionResourceComponent `bson:"resource,omitempty" json:"resource,omitempty"`
}