// Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
428730
func (x *Parameters) UnmarshalJSON(data []byte) (err error) {
	x2 := parameters{}
	if err = json.Unmarshal(data, &x2); err == nil {
		*x = Parameters(x2)
		return x.checkResourceType()
	}
	return
}
1191830
func (x *DocumentManifest) UnmarshalJSON(data []byte) (err error) {
	x2 := documentManifest{}
	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 = DocumentManifest(x2)
		return x.checkResourceType()
	}
	return
}
395218
func (x *RiskAssessment) UnmarshalJSON(data []byte) (err error) {
	x2 := riskAssessment{}
	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 = RiskAssessment(x2)
		return x.checkResourceType()
	}
	return
}
793771
func (x *ConceptMap) UnmarshalJSON(data []byte) (err error) {
	x2 := conceptMap{}
	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 = ConceptMap(x2)
		return x.checkResourceType()
	}
	return
}
334799
func (x *RelatedPerson) UnmarshalJSON(data []byte) (err error) {
	x2 := relatedPerson{}
	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 = RelatedPerson(x2)
		return x.checkResourceType()
	}
	return
}
1044571
func (self *ResourceAuth) UnmarshalJSON(b []byte) error {
	var m rawResourceAuth
	err := json.Unmarshal(b, &m)
	if err == nil {
		o := ResourceAuth(m)
		*self = o
		err = self.Validate()
	}
	return err
}
341285
func (r *Resource) UnmarshalJSON(buf []byte) error {
	m := map[string]interface{}{}
	if err := json.Unmarshal(buf, &m); err != nil {
		return err
	}

	typeName := m["Type"].(string)
	r.DependsOn, _ = m["DependsOn"].([]string)
	r.Metadata, _ = m["Metadata"].(map[string]interface{})
	r.DeletionPolicy, _ = m["DeletionPolicy"].(string)
	r.Properties = NewResourceByType(typeName)
	if r.Properties == nil {
		return fmt.Errorf("unknown resource type: %s", typeName)
	}

	propertiesBuf, err := json.Marshal(m["Properties"])
	if err != nil {
		return err
	}
	return json.Unmarshal(propertiesBuf, r.Properties)
}
1145393
func (x *OrderResponse) UnmarshalJSON(data []byte) (err error) {
	x2 := orderResponse{}
	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 = OrderResponse(x2)
		return x.checkResourceType()
	}
	return
}
450092
func (self *ResourceOutput) UnmarshalJSON(b []byte) error {
	var m rawResourceOutput
	err := json.Unmarshal(b, &m)
	if err == nil {
		o := ResourceOutput(m)
		*self = o
		err = self.Validate()
	}
	return err
}
1218436
func (x *Questionnaire) UnmarshalJSON(data []byte) (err error) {
	x2 := questionnaire{}
	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 = Questionnaire(x2)
		return x.checkResourceType()
	}
	return
}
723845
func (x *AuditEvent) UnmarshalJSON(data []byte) (err error) {
	x2 := auditEvent{}
	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 = AuditEvent(x2)
		return x.checkResourceType()
	}
	return
}
639769
func (x *ProcessResponse) UnmarshalJSON(data []byte) (err error) {
	x2 := processResponse{}
	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 = ProcessResponse(x2)
		return x.checkResourceType()
	}
	return
}
1223590
func (x *FamilyMemberHistory) UnmarshalJSON(data []byte) (err error) {
	x2 := familyMemberHistory{}
	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 = FamilyMemberHistory(x2)
		return x.checkResourceType()
	}
	return
}
429494
func (x *Person) UnmarshalJSON(data []byte) (err error) {
	x2 := person{}
	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 = Person(x2)
		return x.checkResourceType()
	}
	return
}
61647
func (x *PaymentNotice) UnmarshalJSON(data []byte) (err error) {
	x2 := paymentNotice{}
	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 = PaymentNotice(x2)
		return x.checkResourceType()
	}
	return
}
314155
func (x *AllergyIntolerance) UnmarshalJSON(data []byte) (err error) {
	x2 := allergyIntolerance{}
	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 = AllergyIntolerance(x2)
		return x.checkResourceType()
	}
	return
}
278278
func (x *QuestionnaireResponse) UnmarshalJSON(data []byte) (err error) {
	x2 := questionnaireResponse{}
	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 = QuestionnaireResponse(x2)
		return x.checkResourceType()
	}
	return
}