diff --git a/fhir-models-gen/cmd/valueSet.go b/fhir-models-gen/cmd/valueSet.go index 0e7b9c2a..11fcc6d9 100644 --- a/fhir-models-gen/cmd/valueSet.go +++ b/fhir-models-gen/cmd/valueSet.go @@ -3,9 +3,10 @@ package cmd import ( "errors" "fmt" + "strings" + "github.com/dave/jennifer/jen" "github.com/samply/golang-fhir-models/fhir-models-gen/fhir" - "strings" ) func generateValueSet(resources ResourceMap, valueSet fhir.ValueSet) (*jen.File, error) { @@ -50,9 +51,42 @@ func generateValueSet(resources ResourceMap, valueSet fhir.ValueSet) (*jen.File, file.Type().Id(*valueSet.Name).Int() file.Const().DefsFunc(constsRoot(*valueSet.Name, codeSystem.Concept)) + file.Func(). + Params(jen.Id("code").Op("*").Id(*valueSet.Name)). + Id("MarshalBSONValue"). + Params(). + Params(jen.Id("bsontype.Type"), jen.Op("[]").Byte(), jen.Error()). + Block( + jen.Return(jen.Qual("go.mongodb.org/mongo-driver/bson", "MarshalValue").Call(jen.Id("code").Op(".").Id("Code").Call())), + ) + + file.Func(). + Params(jen.Id("code").Op("*").Id(*valueSet.Name)). + Id("UnmarshalBSONValue"). + Params(jen.Id("t").Qual("go.mongodb.org/mongo-driver/bson/bsontype", "Type"), jen.Id("bytes").Op("[]").Byte()). + Params(jen.Error()). + Block( + jen.If(jen.Id("t").Op("!=").Id("bsontype.String")).Block( + jen.Id("err").Op(":=").Qual("fmt", "Errorf").Call(jen.Lit("UnmarshalBSONValue error: cannot unmarshal non string value")), + jen.Return(jen.Id("err")), + ), + jen.Id("reader").Op(":=").Qual("go.mongodb.org/mongo-driver/bson/bsonrw", "NewBSONValueReader").Call(jen.Id("t"), jen.Id("bytes")), + jen.Id("decoder").Op(",").Id("err").Op(":=").Qual("go.mongodb.org/mongo-driver/bson", "NewDecoder").Call(jen.Id("reader")), + jen.If(jen.Id("err").Op("!=").Nil()).Block( + jen.Return(jen.Id("err")), + ), + jen.Var().Id("s").String(), + jen.Id("err").Op("=").Id("decoder").Op(".").Id("Decode").Call(jen.Op("&").Id("s")), + jen.If(jen.Id("err").Op("!=").Nil()).Block( + jen.Return(jen.Id("err")), + ), + jen.Switch(jen.Id("s")).BlockFunc(unmarshalRoot(*valueSet.Name, codeSystem.Concept)), + jen.Return(jen.Id("nil")), + ) + // MarshalJSON function file.Func(). - Params(jen.Id("code").Id(*valueSet.Name)). + Params(jen.Id("code").Op("*").Id(*valueSet.Name)). Id("MarshalJSON"). Params(). Params(jen.Op("[]").Byte(), jen.Error()). diff --git a/fhir-models/fhir/address.go b/fhir-models/fhir/address.go index 582cac38..2d268c90 100644 --- a/fhir-models/fhir/address.go +++ b/fhir-models/fhir/address.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Address is documented here http://hl7.org/fhir/StructureDefinition/Address diff --git a/fhir-models/fhir/addressType.go b/fhir-models/fhir/addressType.go index bb224be1..42bbb24f 100644 --- a/fhir-models/fhir/addressType.go +++ b/fhir-models/fhir/addressType.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // AddressType is documented here http://hl7.org/fhir/ValueSet/address-type @@ -32,7 +35,37 @@ const ( AddressTypeBoth ) - func (code *AddressType)MarshalJSON() ([]byte, error) { +func (code *AddressType) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *AddressType) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "postal": + *code = AddressTypePostal + case "physical": + *code = AddressTypePhysical + case "both": + *code = AddressTypeBoth + default: + return fmt.Errorf("unknown AddressType code `%s`", s) + } + return nil +} +func (code *AddressType) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *AddressType) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/addressUse.go b/fhir-models/fhir/addressUse.go index 9e335eb5..f38fc88b 100644 --- a/fhir-models/fhir/addressUse.go +++ b/fhir-models/fhir/addressUse.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // AddressUse is documented here http://hl7.org/fhir/ValueSet/address-use @@ -34,7 +37,41 @@ const ( AddressUseBilling ) - func (code *AddressUse)MarshalJSON() ([]byte, error) { +func (code *AddressUse) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *AddressUse) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "home": + *code = AddressUseHome + case "work": + *code = AddressUseWork + case "temp": + *code = AddressUseTemp + case "old": + *code = AddressUseOld + case "billing": + *code = AddressUseBilling + default: + return fmt.Errorf("unknown AddressUse code `%s`", s) + } + return nil +} +func (code *AddressUse) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *AddressUse) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/age.go b/fhir-models/fhir/age.go index 6b9cd851..18473f57 100644 --- a/fhir-models/fhir/age.go +++ b/fhir-models/fhir/age.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Age is documented here http://hl7.org/fhir/StructureDefinition/Age diff --git a/fhir-models/fhir/aggregationMode.go b/fhir-models/fhir/aggregationMode.go index ce3bd84f..3fef29b3 100644 --- a/fhir-models/fhir/aggregationMode.go +++ b/fhir-models/fhir/aggregationMode.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // AggregationMode is documented here http://hl7.org/fhir/ValueSet/resource-aggregation-mode @@ -32,7 +35,37 @@ const ( AggregationModeBundled ) - func (code *AggregationMode)MarshalJSON() ([]byte, error) { +func (code *AggregationMode) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *AggregationMode) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "contained": + *code = AggregationModeContained + case "referenced": + *code = AggregationModeReferenced + case "bundled": + *code = AggregationModeBundled + default: + return fmt.Errorf("unknown AggregationMode code `%s`", s) + } + return nil +} +func (code *AggregationMode) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *AggregationMode) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/annotation.go b/fhir-models/fhir/annotation.go index d575aa88..6531e24a 100644 --- a/fhir-models/fhir/annotation.go +++ b/fhir-models/fhir/annotation.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Annotation is documented here http://hl7.org/fhir/StructureDefinition/Annotation diff --git a/fhir-models/fhir/attachment.go b/fhir-models/fhir/attachment.go index 514247a7..9ebe67e1 100644 --- a/fhir-models/fhir/attachment.go +++ b/fhir-models/fhir/attachment.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Attachment is documented here http://hl7.org/fhir/StructureDefinition/Attachment diff --git a/fhir-models/fhir/bindingStrength.go b/fhir-models/fhir/bindingStrength.go index d481cac1..6f639909 100644 --- a/fhir-models/fhir/bindingStrength.go +++ b/fhir-models/fhir/bindingStrength.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // BindingStrength is documented here http://hl7.org/fhir/ValueSet/binding-strength @@ -33,7 +36,39 @@ const ( BindingStrengthExample ) - func (code *BindingStrength)MarshalJSON() ([]byte, error) { +func (code *BindingStrength) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *BindingStrength) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "required": + *code = BindingStrengthRequired + case "extensible": + *code = BindingStrengthExtensible + case "preferred": + *code = BindingStrengthPreferred + case "example": + *code = BindingStrengthExample + default: + return fmt.Errorf("unknown BindingStrength code `%s`", s) + } + return nil +} +func (code *BindingStrength) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *BindingStrength) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/bundle.go b/fhir-models/fhir/bundle.go index ae3c351b..bfbd480e 100644 --- a/fhir-models/fhir/bundle.go +++ b/fhir-models/fhir/bundle.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Bundle is documented here http://hl7.org/fhir/StructureDefinition/Bundle @@ -82,12 +82,12 @@ type BundleEntryResponse struct { type OtherBundle Bundle // MarshalJSON marshals the given Bundle as JSON into a byte slice - func (r *Bundle)MarshalJSON() ([]byte, error) { +func (r Bundle) MarshalJSON() ([]byte, error) { return json.Marshal(struct { OtherBundle ResourceType string `json:"resourceType"` }{ - OtherBundle: OtherBundle(*r), + OtherBundle: OtherBundle(r), ResourceType: "Bundle", }) } diff --git a/fhir-models/fhir/bundleType.go b/fhir-models/fhir/bundleType.go index fcfb0f7b..531efac0 100644 --- a/fhir-models/fhir/bundleType.go +++ b/fhir-models/fhir/bundleType.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // BundleType is documented here http://hl7.org/fhir/ValueSet/bundle-type @@ -38,7 +41,49 @@ const ( BundleTypeCollection ) - func (code *BundleType)MarshalJSON() ([]byte, error) { +func (code *BundleType) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *BundleType) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "document": + *code = BundleTypeDocument + case "message": + *code = BundleTypeMessage + case "transaction": + *code = BundleTypeTransaction + case "transaction-response": + *code = BundleTypeTransactionResponse + case "batch": + *code = BundleTypeBatch + case "batch-response": + *code = BundleTypeBatchResponse + case "history": + *code = BundleTypeHistory + case "searchset": + *code = BundleTypeSearchset + case "collection": + *code = BundleTypeCollection + default: + return fmt.Errorf("unknown BundleType code `%s`", s) + } + return nil +} +func (code *BundleType) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *BundleType) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/codeSystem.go b/fhir-models/fhir/codeSystem.go index e6e20ab5..3e9cd3c2 100644 --- a/fhir-models/fhir/codeSystem.go +++ b/fhir-models/fhir/codeSystem.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // CodeSystem is documented here http://hl7.org/fhir/StructureDefinition/CodeSystem @@ -108,12 +108,12 @@ type CodeSystemConceptProperty struct { type OtherCodeSystem CodeSystem // MarshalJSON marshals the given CodeSystem as JSON into a byte slice - func (r *CodeSystem)MarshalJSON() ([]byte, error) { +func (r CodeSystem) MarshalJSON() ([]byte, error) { return json.Marshal(struct { OtherCodeSystem ResourceType string `json:"resourceType"` }{ - OtherCodeSystem: OtherCodeSystem(*r), + OtherCodeSystem: OtherCodeSystem(r), ResourceType: "CodeSystem", }) } diff --git a/fhir-models/fhir/codeSystemContentMode.go b/fhir-models/fhir/codeSystemContentMode.go index cd4762e7..8fd9d497 100644 --- a/fhir-models/fhir/codeSystemContentMode.go +++ b/fhir-models/fhir/codeSystemContentMode.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // CodeSystemContentMode is documented here http://hl7.org/fhir/ValueSet/codesystem-content-mode @@ -34,7 +37,41 @@ const ( CodeSystemContentModeSupplement ) - func (code *CodeSystemContentMode)MarshalJSON() ([]byte, error) { +func (code *CodeSystemContentMode) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *CodeSystemContentMode) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "not-present": + *code = CodeSystemContentModeNotPresent + case "example": + *code = CodeSystemContentModeExample + case "fragment": + *code = CodeSystemContentModeFragment + case "complete": + *code = CodeSystemContentModeComplete + case "supplement": + *code = CodeSystemContentModeSupplement + default: + return fmt.Errorf("unknown CodeSystemContentMode code `%s`", s) + } + return nil +} +func (code *CodeSystemContentMode) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *CodeSystemContentMode) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/codeSystemHierarchyMeaning.go b/fhir-models/fhir/codeSystemHierarchyMeaning.go index e52f7797..5689cd3d 100644 --- a/fhir-models/fhir/codeSystemHierarchyMeaning.go +++ b/fhir-models/fhir/codeSystemHierarchyMeaning.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // CodeSystemHierarchyMeaning is documented here http://hl7.org/fhir/ValueSet/codesystem-hierarchy-meaning @@ -33,7 +36,39 @@ const ( CodeSystemHierarchyMeaningClassifiedWith ) - func (code *CodeSystemHierarchyMeaning)MarshalJSON() ([]byte, error) { +func (code *CodeSystemHierarchyMeaning) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *CodeSystemHierarchyMeaning) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "grouped-by": + *code = CodeSystemHierarchyMeaningGroupedBy + case "is-a": + *code = CodeSystemHierarchyMeaningIsA + case "part-of": + *code = CodeSystemHierarchyMeaningPartOf + case "classified-with": + *code = CodeSystemHierarchyMeaningClassifiedWith + default: + return fmt.Errorf("unknown CodeSystemHierarchyMeaning code `%s`", s) + } + return nil +} +func (code *CodeSystemHierarchyMeaning) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *CodeSystemHierarchyMeaning) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/codeableConcept.go b/fhir-models/fhir/codeableConcept.go index ec80144c..5eb57b5a 100644 --- a/fhir-models/fhir/codeableConcept.go +++ b/fhir-models/fhir/codeableConcept.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // CodeableConcept is documented here http://hl7.org/fhir/StructureDefinition/CodeableConcept diff --git a/fhir-models/fhir/coding.go b/fhir-models/fhir/coding.go index 331f3a8e..20d8cda9 100644 --- a/fhir-models/fhir/coding.go +++ b/fhir-models/fhir/coding.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Coding is documented here http://hl7.org/fhir/StructureDefinition/Coding diff --git a/fhir-models/fhir/constraintSeverity.go b/fhir-models/fhir/constraintSeverity.go index 99d8eabe..c94954f4 100644 --- a/fhir-models/fhir/constraintSeverity.go +++ b/fhir-models/fhir/constraintSeverity.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ConstraintSeverity is documented here http://hl7.org/fhir/ValueSet/constraint-severity @@ -31,7 +34,35 @@ const ( ConstraintSeverityWarning ) - func (code *ConstraintSeverity)MarshalJSON() ([]byte, error) { +func (code *ConstraintSeverity) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *ConstraintSeverity) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "error": + *code = ConstraintSeverityError + case "warning": + *code = ConstraintSeverityWarning + default: + return fmt.Errorf("unknown ConstraintSeverity code `%s`", s) + } + return nil +} +func (code *ConstraintSeverity) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *ConstraintSeverity) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/contactDetail.go b/fhir-models/fhir/contactDetail.go index 27a84b6f..a352bbda 100644 --- a/fhir-models/fhir/contactDetail.go +++ b/fhir-models/fhir/contactDetail.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ContactDetail is documented here http://hl7.org/fhir/StructureDefinition/ContactDetail diff --git a/fhir-models/fhir/contactPoint.go b/fhir-models/fhir/contactPoint.go index cabf96a3..be465518 100644 --- a/fhir-models/fhir/contactPoint.go +++ b/fhir-models/fhir/contactPoint.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ContactPoint is documented here http://hl7.org/fhir/StructureDefinition/ContactPoint diff --git a/fhir-models/fhir/contactPointSystem.go b/fhir-models/fhir/contactPointSystem.go index 693722b0..eafa95c8 100644 --- a/fhir-models/fhir/contactPointSystem.go +++ b/fhir-models/fhir/contactPointSystem.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ContactPointSystem is documented here http://hl7.org/fhir/ValueSet/contact-point-system @@ -36,7 +39,45 @@ const ( ContactPointSystemOther ) - func (code *ContactPointSystem)MarshalJSON() ([]byte, error) { +func (code *ContactPointSystem) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *ContactPointSystem) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "phone": + *code = ContactPointSystemPhone + case "fax": + *code = ContactPointSystemFax + case "email": + *code = ContactPointSystemEmail + case "pager": + *code = ContactPointSystemPager + case "url": + *code = ContactPointSystemUrl + case "sms": + *code = ContactPointSystemSms + case "other": + *code = ContactPointSystemOther + default: + return fmt.Errorf("unknown ContactPointSystem code `%s`", s) + } + return nil +} +func (code *ContactPointSystem) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *ContactPointSystem) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/contactPointUse.go b/fhir-models/fhir/contactPointUse.go index c9a00253..a9c3bcf1 100644 --- a/fhir-models/fhir/contactPointUse.go +++ b/fhir-models/fhir/contactPointUse.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ContactPointUse is documented here http://hl7.org/fhir/ValueSet/contact-point-use @@ -34,7 +37,41 @@ const ( ContactPointUseMobile ) - func (code *ContactPointUse)MarshalJSON() ([]byte, error) { +func (code *ContactPointUse) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *ContactPointUse) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "home": + *code = ContactPointUseHome + case "work": + *code = ContactPointUseWork + case "temp": + *code = ContactPointUseTemp + case "old": + *code = ContactPointUseOld + case "mobile": + *code = ContactPointUseMobile + default: + return fmt.Errorf("unknown ContactPointUse code `%s`", s) + } + return nil +} +func (code *ContactPointUse) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *ContactPointUse) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/contributor.go b/fhir-models/fhir/contributor.go index 6b9978df..a405ec9d 100644 --- a/fhir-models/fhir/contributor.go +++ b/fhir-models/fhir/contributor.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Contributor is documented here http://hl7.org/fhir/StructureDefinition/Contributor diff --git a/fhir-models/fhir/contributorType.go b/fhir-models/fhir/contributorType.go index 006eec0e..ae0082c0 100644 --- a/fhir-models/fhir/contributorType.go +++ b/fhir-models/fhir/contributorType.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ContributorType is documented here http://hl7.org/fhir/ValueSet/contributor-type @@ -33,7 +36,39 @@ const ( ContributorTypeEndorser ) - func (code *ContributorType)MarshalJSON() ([]byte, error) { +func (code *ContributorType) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *ContributorType) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "author": + *code = ContributorTypeAuthor + case "editor": + *code = ContributorTypeEditor + case "reviewer": + *code = ContributorTypeReviewer + case "endorser": + *code = ContributorTypeEndorser + default: + return fmt.Errorf("unknown ContributorType code `%s`", s) + } + return nil +} +func (code *ContributorType) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *ContributorType) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/count.go b/fhir-models/fhir/count.go index 80508d28..ac9624fc 100644 --- a/fhir-models/fhir/count.go +++ b/fhir-models/fhir/count.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Count is documented here http://hl7.org/fhir/StructureDefinition/Count diff --git a/fhir-models/fhir/dataRequirement.go b/fhir-models/fhir/dataRequirement.go index 39de4dcd..90dea4d3 100644 --- a/fhir-models/fhir/dataRequirement.go +++ b/fhir-models/fhir/dataRequirement.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // DataRequirement is documented here http://hl7.org/fhir/StructureDefinition/DataRequirement diff --git a/fhir-models/fhir/daysOfWeek.go b/fhir-models/fhir/daysOfWeek.go index b3fbcdfc..8530a4df 100644 --- a/fhir-models/fhir/daysOfWeek.go +++ b/fhir-models/fhir/daysOfWeek.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // DaysOfWeek is documented here http://hl7.org/fhir/ValueSet/days-of-week @@ -36,7 +39,45 @@ const ( DaysOfWeekSun ) - func (code *DaysOfWeek)MarshalJSON() ([]byte, error) { +func (code *DaysOfWeek) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *DaysOfWeek) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "mon": + *code = DaysOfWeekMon + case "tue": + *code = DaysOfWeekTue + case "wed": + *code = DaysOfWeekWed + case "thu": + *code = DaysOfWeekThu + case "fri": + *code = DaysOfWeekFri + case "sat": + *code = DaysOfWeekSat + case "sun": + *code = DaysOfWeekSun + default: + return fmt.Errorf("unknown DaysOfWeek code `%s`", s) + } + return nil +} +func (code *DaysOfWeek) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *DaysOfWeek) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/discriminatorType.go b/fhir-models/fhir/discriminatorType.go index 7119cd07..07c53bdf 100644 --- a/fhir-models/fhir/discriminatorType.go +++ b/fhir-models/fhir/discriminatorType.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // DiscriminatorType is documented here http://hl7.org/fhir/ValueSet/discriminator-type @@ -34,7 +37,41 @@ const ( DiscriminatorTypeProfile ) - func (code *DiscriminatorType)MarshalJSON() ([]byte, error) { +func (code *DiscriminatorType) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *DiscriminatorType) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "value": + *code = DiscriminatorTypeValue + case "exists": + *code = DiscriminatorTypeExists + case "pattern": + *code = DiscriminatorTypePattern + case "type": + *code = DiscriminatorTypeType + case "profile": + *code = DiscriminatorTypeProfile + default: + return fmt.Errorf("unknown DiscriminatorType code `%s`", s) + } + return nil +} +func (code *DiscriminatorType) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *DiscriminatorType) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/distance.go b/fhir-models/fhir/distance.go index 4a907d3b..7c5331d5 100644 --- a/fhir-models/fhir/distance.go +++ b/fhir-models/fhir/distance.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Distance is documented here http://hl7.org/fhir/StructureDefinition/Distance diff --git a/fhir-models/fhir/dosage.go b/fhir-models/fhir/dosage.go index dd1d5947..a29628ce 100644 --- a/fhir-models/fhir/dosage.go +++ b/fhir-models/fhir/dosage.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Dosage is documented here http://hl7.org/fhir/StructureDefinition/Dosage diff --git a/fhir-models/fhir/duration.go b/fhir-models/fhir/duration.go index 6ab09eec..f6e94026 100644 --- a/fhir-models/fhir/duration.go +++ b/fhir-models/fhir/duration.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Duration is documented here http://hl7.org/fhir/StructureDefinition/Duration diff --git a/fhir-models/fhir/elementDefinition.go b/fhir-models/fhir/elementDefinition.go index f64b511e..66ca13b2 100644 --- a/fhir-models/fhir/elementDefinition.go +++ b/fhir-models/fhir/elementDefinition.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ElementDefinition is documented here http://hl7.org/fhir/StructureDefinition/ElementDefinition diff --git a/fhir-models/fhir/expression.go b/fhir-models/fhir/expression.go index 2ab1b253..d6867635 100644 --- a/fhir-models/fhir/expression.go +++ b/fhir-models/fhir/expression.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Expression is documented here http://hl7.org/fhir/StructureDefinition/Expression diff --git a/fhir-models/fhir/extension.go b/fhir-models/fhir/extension.go index f88158d9..d55cd999 100644 --- a/fhir-models/fhir/extension.go +++ b/fhir-models/fhir/extension.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Extension is documented here http://hl7.org/fhir/StructureDefinition/Extension diff --git a/fhir-models/fhir/extensionContextType.go b/fhir-models/fhir/extensionContextType.go index 441ec657..6fe93508 100644 --- a/fhir-models/fhir/extensionContextType.go +++ b/fhir-models/fhir/extensionContextType.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ExtensionContextType is documented here http://hl7.org/fhir/ValueSet/extension-context-type @@ -32,7 +35,37 @@ const ( ExtensionContextTypeExtension ) - func (code *ExtensionContextType)MarshalJSON() ([]byte, error) { +func (code *ExtensionContextType) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *ExtensionContextType) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "fhirpath": + *code = ExtensionContextTypeFhirpath + case "element": + *code = ExtensionContextTypeElement + case "extension": + *code = ExtensionContextTypeExtension + default: + return fmt.Errorf("unknown ExtensionContextType code `%s`", s) + } + return nil +} +func (code *ExtensionContextType) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *ExtensionContextType) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/fHIRVersion.go b/fhir-models/fhir/fHIRVersion.go index 88be622b..f7e295ad 100644 --- a/fhir-models/fhir/fHIRVersion.go +++ b/fhir-models/fhir/fHIRVersion.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // FHIRVersion is documented here http://hl7.org/fhir/ValueSet/FHIR-version @@ -51,7 +54,75 @@ const ( FHIRVersion4_0_1 ) - func (code *FHIRVersion)MarshalJSON() ([]byte, error) { +func (code *FHIRVersion) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *FHIRVersion) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "0.01": + *code = FHIRVersion0_01 + case "0.05": + *code = FHIRVersion0_05 + case "0.06": + *code = FHIRVersion0_06 + case "0.11": + *code = FHIRVersion0_11 + case "0.0.80": + *code = FHIRVersion0_0_80 + case "0.0.81": + *code = FHIRVersion0_0_81 + case "0.0.82": + *code = FHIRVersion0_0_82 + case "0.4.0": + *code = FHIRVersion0_4_0 + case "0.5.0": + *code = FHIRVersion0_5_0 + case "1.0.0": + *code = FHIRVersion1_0_0 + case "1.0.1": + *code = FHIRVersion1_0_1 + case "1.0.2": + *code = FHIRVersion1_0_2 + case "1.1.0": + *code = FHIRVersion1_1_0 + case "1.4.0": + *code = FHIRVersion1_4_0 + case "1.6.0": + *code = FHIRVersion1_6_0 + case "1.8.0": + *code = FHIRVersion1_8_0 + case "3.0.0": + *code = FHIRVersion3_0_0 + case "3.0.1": + *code = FHIRVersion3_0_1 + case "3.3.0": + *code = FHIRVersion3_3_0 + case "3.5.0": + *code = FHIRVersion3_5_0 + case "4.0.0": + *code = FHIRVersion4_0_0 + case "4.0.1": + *code = FHIRVersion4_0_1 + default: + return fmt.Errorf("unknown FHIRVersion code `%s`", s) + } + return nil +} +func (code *FHIRVersion) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *FHIRVersion) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/filterOperator.go b/fhir-models/fhir/filterOperator.go index 4e2ac8fb..e7723913 100644 --- a/fhir-models/fhir/filterOperator.go +++ b/fhir-models/fhir/filterOperator.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // FilterOperator is documented here http://hl7.org/fhir/ValueSet/filter-operator @@ -38,7 +41,49 @@ const ( FilterOperatorExists ) - func (code *FilterOperator)MarshalJSON() ([]byte, error) { +func (code *FilterOperator) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *FilterOperator) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "=": + *code = FilterOperatorEquals + case "is-a": + *code = FilterOperatorIsA + case "descendent-of": + *code = FilterOperatorDescendentOf + case "is-not-a": + *code = FilterOperatorIsNotA + case "regex": + *code = FilterOperatorRegex + case "in": + *code = FilterOperatorIn + case "not-in": + *code = FilterOperatorNotIn + case "generalizes": + *code = FilterOperatorGeneralizes + case "exists": + *code = FilterOperatorExists + default: + return fmt.Errorf("unknown FilterOperator code `%s`", s) + } + return nil +} +func (code *FilterOperator) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *FilterOperator) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/hTTPVerb.go b/fhir-models/fhir/hTTPVerb.go index 07beeb27..99f507aa 100644 --- a/fhir-models/fhir/hTTPVerb.go +++ b/fhir-models/fhir/hTTPVerb.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // HTTPVerb is documented here http://hl7.org/fhir/ValueSet/http-verb @@ -35,7 +38,43 @@ const ( HTTPVerbPATCH ) - func (code *HTTPVerb)MarshalJSON() ([]byte, error) { +func (code *HTTPVerb) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *HTTPVerb) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "GET": + *code = HTTPVerbGET + case "HEAD": + *code = HTTPVerbHEAD + case "POST": + *code = HTTPVerbPOST + case "PUT": + *code = HTTPVerbPUT + case "DELETE": + *code = HTTPVerbDELETE + case "PATCH": + *code = HTTPVerbPATCH + default: + return fmt.Errorf("unknown HTTPVerb code `%s`", s) + } + return nil +} +func (code *HTTPVerb) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *HTTPVerb) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/humanName.go b/fhir-models/fhir/humanName.go index 2ea45154..63d990bb 100644 --- a/fhir-models/fhir/humanName.go +++ b/fhir-models/fhir/humanName.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // HumanName is documented here http://hl7.org/fhir/StructureDefinition/HumanName diff --git a/fhir-models/fhir/identifier.go b/fhir-models/fhir/identifier.go index b708c04f..5a66ed60 100644 --- a/fhir-models/fhir/identifier.go +++ b/fhir-models/fhir/identifier.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Identifier is documented here http://hl7.org/fhir/StructureDefinition/Identifier diff --git a/fhir-models/fhir/identifierUse.go b/fhir-models/fhir/identifierUse.go index 40a5b35d..27b9a70b 100644 --- a/fhir-models/fhir/identifierUse.go +++ b/fhir-models/fhir/identifierUse.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // IdentifierUse is documented here http://hl7.org/fhir/ValueSet/identifier-use @@ -34,7 +37,41 @@ const ( IdentifierUseOld ) - func (code *IdentifierUse)MarshalJSON() ([]byte, error) { +func (code *IdentifierUse) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *IdentifierUse) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "usual": + *code = IdentifierUseUsual + case "official": + *code = IdentifierUseOfficial + case "temp": + *code = IdentifierUseTemp + case "secondary": + *code = IdentifierUseSecondary + case "old": + *code = IdentifierUseOld + default: + return fmt.Errorf("unknown IdentifierUse code `%s`", s) + } + return nil +} +func (code *IdentifierUse) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *IdentifierUse) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/meta.go b/fhir-models/fhir/meta.go index f554ee6c..dde2377c 100644 --- a/fhir-models/fhir/meta.go +++ b/fhir-models/fhir/meta.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Meta is documented here http://hl7.org/fhir/StructureDefinition/Meta diff --git a/fhir-models/fhir/money.go b/fhir-models/fhir/money.go index 8e3878e6..5f089d3d 100644 --- a/fhir-models/fhir/money.go +++ b/fhir-models/fhir/money.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Money is documented here http://hl7.org/fhir/StructureDefinition/Money diff --git a/fhir-models/fhir/nameUse.go b/fhir-models/fhir/nameUse.go index bf6a6f9e..63433426 100644 --- a/fhir-models/fhir/nameUse.go +++ b/fhir-models/fhir/nameUse.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // NameUse is documented here http://hl7.org/fhir/ValueSet/name-use @@ -36,7 +39,45 @@ const ( NameUseMaiden ) - func (code *NameUse)MarshalJSON() ([]byte, error) { +func (code *NameUse) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *NameUse) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "usual": + *code = NameUseUsual + case "official": + *code = NameUseOfficial + case "temp": + *code = NameUseTemp + case "nickname": + *code = NameUseNickname + case "anonymous": + *code = NameUseAnonymous + case "old": + *code = NameUseOld + case "maiden": + *code = NameUseMaiden + default: + return fmt.Errorf("unknown NameUse code `%s`", s) + } + return nil +} +func (code *NameUse) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *NameUse) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/narrative.go b/fhir-models/fhir/narrative.go index 1f7447ec..86e4ff99 100644 --- a/fhir-models/fhir/narrative.go +++ b/fhir-models/fhir/narrative.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Narrative is documented here http://hl7.org/fhir/StructureDefinition/Narrative diff --git a/fhir-models/fhir/narrativeStatus.go b/fhir-models/fhir/narrativeStatus.go index 0a191942..dc70ffd1 100644 --- a/fhir-models/fhir/narrativeStatus.go +++ b/fhir-models/fhir/narrativeStatus.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // NarrativeStatus is documented here http://hl7.org/fhir/ValueSet/narrative-status @@ -33,7 +36,39 @@ const ( NarrativeStatusEmpty ) - func (code *NarrativeStatus)MarshalJSON() ([]byte, error) { +func (code *NarrativeStatus) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *NarrativeStatus) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "generated": + *code = NarrativeStatusGenerated + case "extensions": + *code = NarrativeStatusExtensions + case "additional": + *code = NarrativeStatusAdditional + case "empty": + *code = NarrativeStatusEmpty + default: + return fmt.Errorf("unknown NarrativeStatus code `%s`", s) + } + return nil +} +func (code *NarrativeStatus) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *NarrativeStatus) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/operationParameterUse.go b/fhir-models/fhir/operationParameterUse.go index bcb65db2..16c638f9 100644 --- a/fhir-models/fhir/operationParameterUse.go +++ b/fhir-models/fhir/operationParameterUse.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // OperationParameterUse is documented here http://hl7.org/fhir/ValueSet/operation-parameter-use @@ -31,7 +34,35 @@ const ( OperationParameterUseOut ) - func (code *OperationParameterUse)MarshalJSON() ([]byte, error) { +func (code *OperationParameterUse) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *OperationParameterUse) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "in": + *code = OperationParameterUseIn + case "out": + *code = OperationParameterUseOut + default: + return fmt.Errorf("unknown OperationParameterUse code `%s`", s) + } + return nil +} +func (code *OperationParameterUse) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *OperationParameterUse) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/parameterDefinition.go b/fhir-models/fhir/parameterDefinition.go index f46cb5ed..f10a9cf6 100644 --- a/fhir-models/fhir/parameterDefinition.go +++ b/fhir-models/fhir/parameterDefinition.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ParameterDefinition is documented here http://hl7.org/fhir/StructureDefinition/ParameterDefinition diff --git a/fhir-models/fhir/period.go b/fhir-models/fhir/period.go index 8997c6d4..2925b9c9 100644 --- a/fhir-models/fhir/period.go +++ b/fhir-models/fhir/period.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Period is documented here http://hl7.org/fhir/StructureDefinition/Period diff --git a/fhir-models/fhir/propertyRepresentation.go b/fhir-models/fhir/propertyRepresentation.go index 7a0d5f0f..f0a2c569 100644 --- a/fhir-models/fhir/propertyRepresentation.go +++ b/fhir-models/fhir/propertyRepresentation.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // PropertyRepresentation is documented here http://hl7.org/fhir/ValueSet/property-representation @@ -34,7 +37,41 @@ const ( PropertyRepresentationXhtml ) - func (code *PropertyRepresentation)MarshalJSON() ([]byte, error) { +func (code *PropertyRepresentation) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *PropertyRepresentation) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "xmlAttr": + *code = PropertyRepresentationXmlAttr + case "xmlText": + *code = PropertyRepresentationXmlText + case "typeAttr": + *code = PropertyRepresentationTypeAttr + case "cdaText": + *code = PropertyRepresentationCdaText + case "xhtml": + *code = PropertyRepresentationXhtml + default: + return fmt.Errorf("unknown PropertyRepresentation code `%s`", s) + } + return nil +} +func (code *PropertyRepresentation) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *PropertyRepresentation) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/propertyType.go b/fhir-models/fhir/propertyType.go index 146da5e2..874574de 100644 --- a/fhir-models/fhir/propertyType.go +++ b/fhir-models/fhir/propertyType.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // PropertyType is documented here http://hl7.org/fhir/ValueSet/concept-property-type @@ -36,7 +39,45 @@ const ( PropertyTypeDecimal ) - func (code *PropertyType)MarshalJSON() ([]byte, error) { +func (code *PropertyType) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *PropertyType) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "code": + *code = PropertyTypeCode + case "Coding": + *code = PropertyTypeCoding + case "string": + *code = PropertyTypeString + case "integer": + *code = PropertyTypeInteger + case "boolean": + *code = PropertyTypeBoolean + case "dateTime": + *code = PropertyTypeDateTime + case "decimal": + *code = PropertyTypeDecimal + default: + return fmt.Errorf("unknown PropertyType code `%s`", s) + } + return nil +} +func (code *PropertyType) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *PropertyType) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/publicationStatus.go b/fhir-models/fhir/publicationStatus.go index ee6fc0fc..9b29bc37 100644 --- a/fhir-models/fhir/publicationStatus.go +++ b/fhir-models/fhir/publicationStatus.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // PublicationStatus is documented here http://hl7.org/fhir/ValueSet/publication-status @@ -33,7 +36,39 @@ const ( PublicationStatusUnknown ) - func (code *PublicationStatus)MarshalJSON() ([]byte, error) { +func (code *PublicationStatus) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *PublicationStatus) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "draft": + *code = PublicationStatusDraft + case "active": + *code = PublicationStatusActive + case "retired": + *code = PublicationStatusRetired + case "unknown": + *code = PublicationStatusUnknown + default: + return fmt.Errorf("unknown PublicationStatus code `%s`", s) + } + return nil +} +func (code *PublicationStatus) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *PublicationStatus) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/quantity.go b/fhir-models/fhir/quantity.go index d352f6d4..84a04f0a 100644 --- a/fhir-models/fhir/quantity.go +++ b/fhir-models/fhir/quantity.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Quantity is documented here http://hl7.org/fhir/StructureDefinition/Quantity diff --git a/fhir-models/fhir/quantityComparator.go b/fhir-models/fhir/quantityComparator.go index bd7254a8..22d40666 100644 --- a/fhir-models/fhir/quantityComparator.go +++ b/fhir-models/fhir/quantityComparator.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // QuantityComparator is documented here http://hl7.org/fhir/ValueSet/quantity-comparator @@ -33,7 +36,39 @@ const ( QuantityComparatorGreaterThan ) - func (code *QuantityComparator)MarshalJSON() ([]byte, error) { +func (code *QuantityComparator) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *QuantityComparator) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "<": + *code = QuantityComparatorLessThan + case "<=": + *code = QuantityComparatorLessOrEquals + case ">=": + *code = QuantityComparatorGreaterOrEquals + case ">": + *code = QuantityComparatorGreaterThan + default: + return fmt.Errorf("unknown QuantityComparator code `%s`", s) + } + return nil +} +func (code *QuantityComparator) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *QuantityComparator) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/range.go b/fhir-models/fhir/range.go index 6ac3faea..d71ddf70 100644 --- a/fhir-models/fhir/range.go +++ b/fhir-models/fhir/range.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Range is documented here http://hl7.org/fhir/StructureDefinition/Range diff --git a/fhir-models/fhir/ratio.go b/fhir-models/fhir/ratio.go index 03adf3f7..6d96da6b 100644 --- a/fhir-models/fhir/ratio.go +++ b/fhir-models/fhir/ratio.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Ratio is documented here http://hl7.org/fhir/StructureDefinition/Ratio diff --git a/fhir-models/fhir/reference.go b/fhir-models/fhir/reference.go index 0ae4e3a6..867247b9 100644 --- a/fhir-models/fhir/reference.go +++ b/fhir-models/fhir/reference.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Reference is documented here http://hl7.org/fhir/StructureDefinition/Reference diff --git a/fhir-models/fhir/referenceVersionRules.go b/fhir-models/fhir/referenceVersionRules.go index ae12c9e0..083e4b28 100644 --- a/fhir-models/fhir/referenceVersionRules.go +++ b/fhir-models/fhir/referenceVersionRules.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ReferenceVersionRules is documented here http://hl7.org/fhir/ValueSet/reference-version-rules @@ -32,7 +35,37 @@ const ( ReferenceVersionRulesSpecific ) - func (code *ReferenceVersionRules)MarshalJSON() ([]byte, error) { +func (code *ReferenceVersionRules) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *ReferenceVersionRules) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "either": + *code = ReferenceVersionRulesEither + case "independent": + *code = ReferenceVersionRulesIndependent + case "specific": + *code = ReferenceVersionRulesSpecific + default: + return fmt.Errorf("unknown ReferenceVersionRules code `%s`", s) + } + return nil +} +func (code *ReferenceVersionRules) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *ReferenceVersionRules) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/relatedArtifact.go b/fhir-models/fhir/relatedArtifact.go index e2e51207..25814515 100644 --- a/fhir-models/fhir/relatedArtifact.go +++ b/fhir-models/fhir/relatedArtifact.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // RelatedArtifact is documented here http://hl7.org/fhir/StructureDefinition/RelatedArtifact diff --git a/fhir-models/fhir/relatedArtifactType.go b/fhir-models/fhir/relatedArtifactType.go index 1d7d8f4f..619d4086 100644 --- a/fhir-models/fhir/relatedArtifactType.go +++ b/fhir-models/fhir/relatedArtifactType.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // RelatedArtifactType is documented here http://hl7.org/fhir/ValueSet/related-artifact-type @@ -37,7 +40,47 @@ const ( RelatedArtifactTypeComposedOf ) - func (code *RelatedArtifactType)MarshalJSON() ([]byte, error) { +func (code *RelatedArtifactType) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *RelatedArtifactType) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "documentation": + *code = RelatedArtifactTypeDocumentation + case "justification": + *code = RelatedArtifactTypeJustification + case "citation": + *code = RelatedArtifactTypeCitation + case "predecessor": + *code = RelatedArtifactTypePredecessor + case "successor": + *code = RelatedArtifactTypeSuccessor + case "derived-from": + *code = RelatedArtifactTypeDerivedFrom + case "depends-on": + *code = RelatedArtifactTypeDependsOn + case "composed-of": + *code = RelatedArtifactTypeComposedOf + default: + return fmt.Errorf("unknown RelatedArtifactType code `%s`", s) + } + return nil +} +func (code *RelatedArtifactType) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *RelatedArtifactType) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/sampledData.go b/fhir-models/fhir/sampledData.go index 8eb773b5..8d3972f3 100644 --- a/fhir-models/fhir/sampledData.go +++ b/fhir-models/fhir/sampledData.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // SampledData is documented here http://hl7.org/fhir/StructureDefinition/SampledData diff --git a/fhir-models/fhir/searchEntryMode.go b/fhir-models/fhir/searchEntryMode.go index a2f63971..84748b1a 100644 --- a/fhir-models/fhir/searchEntryMode.go +++ b/fhir-models/fhir/searchEntryMode.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // SearchEntryMode is documented here http://hl7.org/fhir/ValueSet/search-entry-mode @@ -32,7 +35,37 @@ const ( SearchEntryModeOutcome ) - func (code *SearchEntryMode)MarshalJSON() ([]byte, error) { +func (code *SearchEntryMode) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *SearchEntryMode) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "match": + *code = SearchEntryModeMatch + case "include": + *code = SearchEntryModeInclude + case "outcome": + *code = SearchEntryModeOutcome + default: + return fmt.Errorf("unknown SearchEntryMode code `%s`", s) + } + return nil +} +func (code *SearchEntryMode) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *SearchEntryMode) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/signature.go b/fhir-models/fhir/signature.go index 176f6d7d..c8ce03e1 100644 --- a/fhir-models/fhir/signature.go +++ b/fhir-models/fhir/signature.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Signature is documented here http://hl7.org/fhir/StructureDefinition/Signature diff --git a/fhir-models/fhir/slicingRules.go b/fhir-models/fhir/slicingRules.go index 37415784..31c93045 100644 --- a/fhir-models/fhir/slicingRules.go +++ b/fhir-models/fhir/slicingRules.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // SlicingRules is documented here http://hl7.org/fhir/ValueSet/resource-slicing-rules @@ -32,7 +35,37 @@ const ( SlicingRulesOpenAtEnd ) - func (code *SlicingRules)MarshalJSON() ([]byte, error) { +func (code *SlicingRules) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *SlicingRules) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "closed": + *code = SlicingRulesClosed + case "open": + *code = SlicingRulesOpen + case "openAtEnd": + *code = SlicingRulesOpenAtEnd + default: + return fmt.Errorf("unknown SlicingRules code `%s`", s) + } + return nil +} +func (code *SlicingRules) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *SlicingRules) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/sortDirection.go b/fhir-models/fhir/sortDirection.go index 272241b9..b9d8066e 100644 --- a/fhir-models/fhir/sortDirection.go +++ b/fhir-models/fhir/sortDirection.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // SortDirection is documented here http://hl7.org/fhir/ValueSet/sort-direction @@ -31,7 +34,35 @@ const ( SortDirectionDescending ) - func (code *SortDirection)MarshalJSON() ([]byte, error) { +func (code *SortDirection) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *SortDirection) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "ascending": + *code = SortDirectionAscending + case "descending": + *code = SortDirectionDescending + default: + return fmt.Errorf("unknown SortDirection code `%s`", s) + } + return nil +} +func (code *SortDirection) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *SortDirection) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/structureDefinition.go b/fhir-models/fhir/structureDefinition.go index 31935f58..a4f42373 100644 --- a/fhir-models/fhir/structureDefinition.go +++ b/fhir-models/fhir/structureDefinition.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // StructureDefinition is documented here http://hl7.org/fhir/StructureDefinition/StructureDefinition @@ -87,12 +87,12 @@ type StructureDefinitionDifferential struct { type OtherStructureDefinition StructureDefinition // MarshalJSON marshals the given StructureDefinition as JSON into a byte slice - func (r *StructureDefinition)MarshalJSON() ([]byte, error) { +func (r StructureDefinition) MarshalJSON() ([]byte, error) { return json.Marshal(struct { OtherStructureDefinition ResourceType string `json:"resourceType"` }{ - OtherStructureDefinition: OtherStructureDefinition(*r), + OtherStructureDefinition: OtherStructureDefinition(r), ResourceType: "StructureDefinition", }) } diff --git a/fhir-models/fhir/structureDefinitionKind.go b/fhir-models/fhir/structureDefinitionKind.go index c6fc6c5e..a6e5c5ca 100644 --- a/fhir-models/fhir/structureDefinitionKind.go +++ b/fhir-models/fhir/structureDefinitionKind.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // StructureDefinitionKind is documented here http://hl7.org/fhir/ValueSet/structure-definition-kind @@ -33,7 +36,39 @@ const ( StructureDefinitionKindLogical ) - func (code *StructureDefinitionKind)MarshalJSON() ([]byte, error) { +func (code *StructureDefinitionKind) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *StructureDefinitionKind) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "primitive-type": + *code = StructureDefinitionKindPrimitiveType + case "complex-type": + *code = StructureDefinitionKindComplexType + case "resource": + *code = StructureDefinitionKindResource + case "logical": + *code = StructureDefinitionKindLogical + default: + return fmt.Errorf("unknown StructureDefinitionKind code `%s`", s) + } + return nil +} +func (code *StructureDefinitionKind) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *StructureDefinitionKind) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/timing.go b/fhir-models/fhir/timing.go index c816fa1a..5dbaf9b0 100644 --- a/fhir-models/fhir/timing.go +++ b/fhir-models/fhir/timing.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // Timing is documented here http://hl7.org/fhir/StructureDefinition/Timing diff --git a/fhir-models/fhir/triggerDefinition.go b/fhir-models/fhir/triggerDefinition.go index ce91fb50..bca75426 100644 --- a/fhir-models/fhir/triggerDefinition.go +++ b/fhir-models/fhir/triggerDefinition.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // TriggerDefinition is documented here http://hl7.org/fhir/StructureDefinition/TriggerDefinition diff --git a/fhir-models/fhir/triggerType.go b/fhir-models/fhir/triggerType.go index 25f0e075..79ad81a4 100644 --- a/fhir-models/fhir/triggerType.go +++ b/fhir-models/fhir/triggerType.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // TriggerType is documented here http://hl7.org/fhir/ValueSet/trigger-type @@ -37,7 +40,47 @@ const ( TriggerTypeDataAccessEnded ) - func (code *TriggerType)MarshalJSON() ([]byte, error) { +func (code *TriggerType) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *TriggerType) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "named-event": + *code = TriggerTypeNamedEvent + case "periodic": + *code = TriggerTypePeriodic + case "data-changed": + *code = TriggerTypeDataChanged + case "data-added": + *code = TriggerTypeDataAdded + case "data-modified": + *code = TriggerTypeDataModified + case "data-removed": + *code = TriggerTypeDataRemoved + case "data-accessed": + *code = TriggerTypeDataAccessed + case "data-access-ended": + *code = TriggerTypeDataAccessEnded + default: + return fmt.Errorf("unknown TriggerType code `%s`", s) + } + return nil +} +func (code *TriggerType) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *TriggerType) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/typeDerivationRule.go b/fhir-models/fhir/typeDerivationRule.go index 9b61439c..a7978cd2 100644 --- a/fhir-models/fhir/typeDerivationRule.go +++ b/fhir-models/fhir/typeDerivationRule.go @@ -17,10 +17,13 @@ package fhir import ( "encoding/json" "fmt" + bson "go.mongodb.org/mongo-driver/bson" + bsonrw "go.mongodb.org/mongo-driver/bson/bsonrw" + bsontype "go.mongodb.org/mongo-driver/bson/bsontype" "strings" ) -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // TypeDerivationRule is documented here http://hl7.org/fhir/ValueSet/type-derivation-rule @@ -31,7 +34,35 @@ const ( TypeDerivationRuleConstraint ) - func (code *TypeDerivationRule)MarshalJSON() ([]byte, error) { +func (code *TypeDerivationRule) MarshalBSONValue() (bsontype.Type, []byte, error) { + return bson.MarshalValue(code.Code()) +} +func (code *TypeDerivationRule) UnmarshalBSONValue(t bsontype.Type, bytes []byte) error { + if t != bsontype.String { + err := fmt.Errorf("UnmarshalBSONValue error: cannot unmarshal non string value") + return err + } + reader := bsonrw.NewBSONValueReader(t, bytes) + decoder, err := bson.NewDecoder(reader) + if err != nil { + return err + } + var s string + err = decoder.Decode(&s) + if err != nil { + return err + } + switch s { + case "specialization": + *code = TypeDerivationRuleSpecialization + case "constraint": + *code = TypeDerivationRuleConstraint + default: + return fmt.Errorf("unknown TypeDerivationRule code `%s`", s) + } + return nil +} +func (code *TypeDerivationRule) MarshalJSON() ([]byte, error) { return json.Marshal(code.Code()) } func (code *TypeDerivationRule) UnmarshalJSON(json []byte) error { diff --git a/fhir-models/fhir/usageContext.go b/fhir-models/fhir/usageContext.go index 8d8d2cb9..81156dd5 100644 --- a/fhir-models/fhir/usageContext.go +++ b/fhir-models/fhir/usageContext.go @@ -14,7 +14,7 @@ package fhir -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // UsageContext is documented here http://hl7.org/fhir/StructureDefinition/UsageContext diff --git a/fhir-models/fhir/valueSet.go b/fhir-models/fhir/valueSet.go index 3437f224..cb6792d2 100644 --- a/fhir-models/fhir/valueSet.go +++ b/fhir-models/fhir/valueSet.go @@ -16,7 +16,7 @@ package fhir import "encoding/json" -// THIS FILE IS GENERATED BY https://github.com/stat/golang-fhir-models +// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models // PLEASE DO NOT EDIT BY HAND // ValueSet is documented here http://hl7.org/fhir/StructureDefinition/ValueSet @@ -130,12 +130,12 @@ type ValueSetExpansionContains struct { type OtherValueSet ValueSet // MarshalJSON marshals the given ValueSet as JSON into a byte slice - func (r *ValueSet)MarshalJSON() ([]byte, error) { +func (r ValueSet) MarshalJSON() ([]byte, error) { return json.Marshal(struct { OtherValueSet ResourceType string `json:"resourceType"` }{ - OtherValueSet: OtherValueSet(*r), + OtherValueSet: OtherValueSet(r), ResourceType: "ValueSet", }) }