Skip to content

Commit 8c800ff

Browse files
committed
Fix Decimal Types
I use json.Number for a maximum of flexibility.
1 parent 53e78f9 commit 8c800ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+200
-160
lines changed

fhir-models-gen/cmd/genResources.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ func addFieldStatement(
461461
return 0, err
462462
}
463463
elementIndex--
464+
} else if typeIdentifier == "decimal" {
465+
statement.Qual("encoding/json", "Number")
464466
} else {
465467
if unicode.IsUpper(rune(typeIdentifier[0])) {
466468
requiredTypes[typeIdentifier] = true
@@ -502,8 +504,6 @@ func typeCodeToTypeIdentifier(typeCode string) string {
502504
return "string"
503505
case "dateTime":
504506
return "string"
505-
case "decimal":
506-
return "string"
507507
case "id":
508508
return "string"
509509
case "instant":

fhir-models-gen/cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
// rootCmd represents the base command when called without any subcommands
2424
var rootCmd = &cobra.Command{
2525
Use: "fhir-gen",
26-
Version: "0.3.0",
26+
Version: "0.3.2",
2727
}
2828

2929
// Execute adds all child commands to the root command and sets flags appropriately.

fhir-models-gen/fhir/age.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414

1515
package fhir
1616

17+
import "encoding/json"
18+
1719
// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
1820
// PLEASE DO NOT EDIT BY HAND
1921

2022
// Age is documented here http://hl7.org/fhir/StructureDefinition/Age
2123
type Age struct {
2224
Id *string `bson:"id,omitempty" json:"id,omitempty"`
2325
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
24-
Value *string `bson:"value,omitempty" json:"value,omitempty"`
26+
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
2527
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
2628
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
2729
System *string `bson:"system,omitempty" json:"system,omitempty"`

fhir-models-gen/fhir/bundle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type BundleEntrySearch struct {
5656
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
5757
ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"`
5858
Mode *SearchEntryMode `bson:"mode,omitempty" json:"mode,omitempty"`
59-
Score *string `bson:"score,omitempty" json:"score,omitempty"`
59+
Score *json.Number `bson:"score,omitempty" json:"score,omitempty"`
6060
}
6161
type BundleEntryRequest struct {
6262
Id *string `bson:"id,omitempty" json:"id,omitempty"`

fhir-models-gen/fhir/codeSystem.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ type CodeSystemConceptProperty struct {
103103
ValueInteger int `bson:"valueInteger" json:"valueInteger"`
104104
ValueBoolean bool `bson:"valueBoolean" json:"valueBoolean"`
105105
ValueDateTime string `bson:"valueDateTime" json:"valueDateTime"`
106-
ValueDecimal string `bson:"valueDecimal" json:"valueDecimal"`
106+
ValueDecimal json.Number `bson:"valueDecimal" json:"valueDecimal"`
107107
}
108108
type OtherCodeSystem CodeSystem
109109

fhir-models-gen/fhir/count.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414

1515
package fhir
1616

17+
import "encoding/json"
18+
1719
// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
1820
// PLEASE DO NOT EDIT BY HAND
1921

2022
// Count is documented here http://hl7.org/fhir/StructureDefinition/Count
2123
type Count struct {
2224
Id *string `bson:"id,omitempty" json:"id,omitempty"`
2325
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
24-
Value *string `bson:"value,omitempty" json:"value,omitempty"`
26+
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
2527
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
2628
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
2729
System *string `bson:"system,omitempty" json:"system,omitempty"`

fhir-models-gen/fhir/distance.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414

1515
package fhir
1616

17+
import "encoding/json"
18+
1719
// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
1820
// PLEASE DO NOT EDIT BY HAND
1921

2022
// Distance is documented here http://hl7.org/fhir/StructureDefinition/Distance
2123
type Distance struct {
2224
Id *string `bson:"id,omitempty" json:"id,omitempty"`
2325
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
24-
Value *string `bson:"value,omitempty" json:"value,omitempty"`
26+
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
2527
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
2628
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
2729
System *string `bson:"system,omitempty" json:"system,omitempty"`

fhir-models-gen/fhir/duration.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414

1515
package fhir
1616

17+
import "encoding/json"
18+
1719
// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
1820
// PLEASE DO NOT EDIT BY HAND
1921

2022
// Duration is documented here http://hl7.org/fhir/StructureDefinition/Duration
2123
type Duration struct {
2224
Id *string `bson:"id,omitempty" json:"id,omitempty"`
2325
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
24-
Value *string `bson:"value,omitempty" json:"value,omitempty"`
26+
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
2527
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
2628
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
2729
System *string `bson:"system,omitempty" json:"system,omitempty"`

fhir-models-gen/fhir/elementDefinition.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package fhir
1616

17+
import "encoding/json"
18+
1719
// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
1820
// PLEASE DO NOT EDIT BY HAND
1921

@@ -45,7 +47,7 @@ type ElementDefinition struct {
4547
DefaultValueCode *string `bson:"defaultValueCode,omitempty" json:"defaultValueCode,omitempty"`
4648
DefaultValueDate *string `bson:"defaultValueDate,omitempty" json:"defaultValueDate,omitempty"`
4749
DefaultValueDateTime *string `bson:"defaultValueDateTime,omitempty" json:"defaultValueDateTime,omitempty"`
48-
DefaultValueDecimal *string `bson:"defaultValueDecimal,omitempty" json:"defaultValueDecimal,omitempty"`
50+
DefaultValueDecimal *json.Number `bson:"defaultValueDecimal,omitempty" json:"defaultValueDecimal,omitempty"`
4951
DefaultValueId *string `bson:"defaultValueId,omitempty" json:"defaultValueId,omitempty"`
5052
DefaultValueInstant *string `bson:"defaultValueInstant,omitempty" json:"defaultValueInstant,omitempty"`
5153
DefaultValueInteger *int `bson:"defaultValueInteger,omitempty" json:"defaultValueInteger,omitempty"`
@@ -97,7 +99,7 @@ type ElementDefinition struct {
9799
FixedCode *string `bson:"fixedCode,omitempty" json:"fixedCode,omitempty"`
98100
FixedDate *string `bson:"fixedDate,omitempty" json:"fixedDate,omitempty"`
99101
FixedDateTime *string `bson:"fixedDateTime,omitempty" json:"fixedDateTime,omitempty"`
100-
FixedDecimal *string `bson:"fixedDecimal,omitempty" json:"fixedDecimal,omitempty"`
102+
FixedDecimal *json.Number `bson:"fixedDecimal,omitempty" json:"fixedDecimal,omitempty"`
101103
FixedId *string `bson:"fixedId,omitempty" json:"fixedId,omitempty"`
102104
FixedInstant *string `bson:"fixedInstant,omitempty" json:"fixedInstant,omitempty"`
103105
FixedInteger *int `bson:"fixedInteger,omitempty" json:"fixedInteger,omitempty"`
@@ -147,7 +149,7 @@ type ElementDefinition struct {
147149
PatternCode *string `bson:"patternCode,omitempty" json:"patternCode,omitempty"`
148150
PatternDate *string `bson:"patternDate,omitempty" json:"patternDate,omitempty"`
149151
PatternDateTime *string `bson:"patternDateTime,omitempty" json:"patternDateTime,omitempty"`
150-
PatternDecimal *string `bson:"patternDecimal,omitempty" json:"patternDecimal,omitempty"`
152+
PatternDecimal *json.Number `bson:"patternDecimal,omitempty" json:"patternDecimal,omitempty"`
151153
PatternId *string `bson:"patternId,omitempty" json:"patternId,omitempty"`
152154
PatternInstant *string `bson:"patternInstant,omitempty" json:"patternInstant,omitempty"`
153155
PatternInteger *int `bson:"patternInteger,omitempty" json:"patternInteger,omitempty"`
@@ -196,7 +198,7 @@ type ElementDefinition struct {
196198
MinValueDateTime *string `bson:"minValueDateTime,omitempty" json:"minValueDateTime,omitempty"`
197199
MinValueInstant *string `bson:"minValueInstant,omitempty" json:"minValueInstant,omitempty"`
198200
MinValueTime *string `bson:"minValueTime,omitempty" json:"minValueTime,omitempty"`
199-
MinValueDecimal *string `bson:"minValueDecimal,omitempty" json:"minValueDecimal,omitempty"`
201+
MinValueDecimal *json.Number `bson:"minValueDecimal,omitempty" json:"minValueDecimal,omitempty"`
200202
MinValueInteger *int `bson:"minValueInteger,omitempty" json:"minValueInteger,omitempty"`
201203
MinValuePositiveInt *int `bson:"minValuePositiveInt,omitempty" json:"minValuePositiveInt,omitempty"`
202204
MinValueUnsignedInt *int `bson:"minValueUnsignedInt,omitempty" json:"minValueUnsignedInt,omitempty"`
@@ -205,7 +207,7 @@ type ElementDefinition struct {
205207
MaxValueDateTime *string `bson:"maxValueDateTime,omitempty" json:"maxValueDateTime,omitempty"`
206208
MaxValueInstant *string `bson:"maxValueInstant,omitempty" json:"maxValueInstant,omitempty"`
207209
MaxValueTime *string `bson:"maxValueTime,omitempty" json:"maxValueTime,omitempty"`
208-
MaxValueDecimal *string `bson:"maxValueDecimal,omitempty" json:"maxValueDecimal,omitempty"`
210+
MaxValueDecimal *json.Number `bson:"maxValueDecimal,omitempty" json:"maxValueDecimal,omitempty"`
209211
MaxValueInteger *int `bson:"maxValueInteger,omitempty" json:"maxValueInteger,omitempty"`
210212
MaxValuePositiveInt *int `bson:"maxValuePositiveInt,omitempty" json:"maxValuePositiveInt,omitempty"`
211213
MaxValueUnsignedInt *int `bson:"maxValueUnsignedInt,omitempty" json:"maxValueUnsignedInt,omitempty"`
@@ -260,7 +262,7 @@ type ElementDefinitionExample struct {
260262
ValueCode string `bson:"valueCode" json:"valueCode"`
261263
ValueDate string `bson:"valueDate" json:"valueDate"`
262264
ValueDateTime string `bson:"valueDateTime" json:"valueDateTime"`
263-
ValueDecimal string `bson:"valueDecimal" json:"valueDecimal"`
265+
ValueDecimal json.Number `bson:"valueDecimal" json:"valueDecimal"`
264266
ValueId string `bson:"valueId" json:"valueId"`
265267
ValueInstant string `bson:"valueInstant" json:"valueInstant"`
266268
ValueInteger int `bson:"valueInteger" json:"valueInteger"`

fhir-models-gen/fhir/extension.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package fhir
1616

17+
import "encoding/json"
18+
1719
// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
1820
// PLEASE DO NOT EDIT BY HAND
1921

@@ -28,7 +30,7 @@ type Extension struct {
2830
ValueCode *string `bson:"valueCode,omitempty" json:"valueCode,omitempty"`
2931
ValueDate *string `bson:"valueDate,omitempty" json:"valueDate,omitempty"`
3032
ValueDateTime *string `bson:"valueDateTime,omitempty" json:"valueDateTime,omitempty"`
31-
ValueDecimal *string `bson:"valueDecimal,omitempty" json:"valueDecimal,omitempty"`
33+
ValueDecimal *json.Number `bson:"valueDecimal,omitempty" json:"valueDecimal,omitempty"`
3234
ValueId *string `bson:"valueId,omitempty" json:"valueId,omitempty"`
3335
ValueInstant *string `bson:"valueInstant,omitempty" json:"valueInstant,omitempty"`
3436
ValueInteger *int `bson:"valueInteger,omitempty" json:"valueInteger,omitempty"`

0 commit comments

Comments
 (0)