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

+2-2
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

+1-1
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

+3-1
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

+1-1
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

+1-1
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

+3-1
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

+3-1
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

+3-1
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

+8-6
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

+3-1
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"`

fhir-models-gen/fhir/money.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
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
// Money is documented here http://hl7.org/fhir/StructureDefinition/Money
2123
type Money struct {
22-
Id *string `bson:"id,omitempty" json:"id,omitempty"`
23-
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
24-
Value *string `bson:"value,omitempty" json:"value,omitempty"`
25-
Currency *string `bson:"currency,omitempty" json:"currency,omitempty"`
24+
Id *string `bson:"id,omitempty" json:"id,omitempty"`
25+
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
26+
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
27+
Currency *string `bson:"currency,omitempty" json:"currency,omitempty"`
2628
}

fhir-models-gen/fhir/quantity.go

+3-1
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
// Quantity is documented here http://hl7.org/fhir/StructureDefinition/Quantity
2123
type Quantity 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/sampledData.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@
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
// SampledData is documented here http://hl7.org/fhir/StructureDefinition/SampledData
2123
type SampledData struct {
22-
Id *string `bson:"id,omitempty" json:"id,omitempty"`
23-
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
24-
Origin Quantity `bson:"origin" json:"origin"`
25-
Period string `bson:"period" json:"period"`
26-
Factor *string `bson:"factor,omitempty" json:"factor,omitempty"`
27-
LowerLimit *string `bson:"lowerLimit,omitempty" json:"lowerLimit,omitempty"`
28-
UpperLimit *string `bson:"upperLimit,omitempty" json:"upperLimit,omitempty"`
29-
Dimensions int `bson:"dimensions" json:"dimensions"`
30-
Data *string `bson:"data,omitempty" json:"data,omitempty"`
24+
Id *string `bson:"id,omitempty" json:"id,omitempty"`
25+
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
26+
Origin Quantity `bson:"origin" json:"origin"`
27+
Period json.Number `bson:"period" json:"period"`
28+
Factor *json.Number `bson:"factor,omitempty" json:"factor,omitempty"`
29+
LowerLimit *json.Number `bson:"lowerLimit,omitempty" json:"lowerLimit,omitempty"`
30+
UpperLimit *json.Number `bson:"upperLimit,omitempty" json:"upperLimit,omitempty"`
31+
Dimensions int `bson:"dimensions" json:"dimensions"`
32+
Data *string `bson:"data,omitempty" json:"data,omitempty"`
3133
}

fhir-models-gen/fhir/timing.go

+6-4
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

@@ -34,13 +36,13 @@ type TimingRepeat struct {
3436
BoundsPeriod *Period `bson:"boundsPeriod,omitempty" json:"boundsPeriod,omitempty"`
3537
Count *int `bson:"count,omitempty" json:"count,omitempty"`
3638
CountMax *int `bson:"countMax,omitempty" json:"countMax,omitempty"`
37-
Duration *string `bson:"duration,omitempty" json:"duration,omitempty"`
38-
DurationMax *string `bson:"durationMax,omitempty" json:"durationMax,omitempty"`
39+
Duration *json.Number `bson:"duration,omitempty" json:"duration,omitempty"`
40+
DurationMax *json.Number `bson:"durationMax,omitempty" json:"durationMax,omitempty"`
3941
DurationUnit *string `bson:"durationUnit,omitempty" json:"durationUnit,omitempty"`
4042
Frequency *int `bson:"frequency,omitempty" json:"frequency,omitempty"`
4143
FrequencyMax *int `bson:"frequencyMax,omitempty" json:"frequencyMax,omitempty"`
42-
Period *string `bson:"period,omitempty" json:"period,omitempty"`
43-
PeriodMax *string `bson:"periodMax,omitempty" json:"periodMax,omitempty"`
44+
Period *json.Number `bson:"period,omitempty" json:"period,omitempty"`
45+
PeriodMax *json.Number `bson:"periodMax,omitempty" json:"periodMax,omitempty"`
4446
PeriodUnit *string `bson:"periodUnit,omitempty" json:"periodUnit,omitempty"`
4547
DayOfWeek []DaysOfWeek `bson:"dayOfWeek,omitempty" json:"dayOfWeek,omitempty"`
4648
TimeOfDay []string `bson:"timeOfDay,omitempty" json:"timeOfDay,omitempty"`

fhir-models-gen/fhir/valueSet.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ type ValueSetExpansion struct {
102102
Contains []ValueSetExpansionContains `bson:"contains,omitempty" json:"contains,omitempty"`
103103
}
104104
type ValueSetExpansionParameter struct {
105-
Id *string `bson:"id,omitempty" json:"id,omitempty"`
106-
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
107-
ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"`
108-
Name string `bson:"name" json:"name"`
109-
ValueString *string `bson:"valueString,omitempty" json:"valueString,omitempty"`
110-
ValueBoolean *bool `bson:"valueBoolean,omitempty" json:"valueBoolean,omitempty"`
111-
ValueInteger *int `bson:"valueInteger,omitempty" json:"valueInteger,omitempty"`
112-
ValueDecimal *string `bson:"valueDecimal,omitempty" json:"valueDecimal,omitempty"`
113-
ValueUri *string `bson:"valueUri,omitempty" json:"valueUri,omitempty"`
114-
ValueCode *string `bson:"valueCode,omitempty" json:"valueCode,omitempty"`
115-
ValueDateTime *string `bson:"valueDateTime,omitempty" json:"valueDateTime,omitempty"`
105+
Id *string `bson:"id,omitempty" json:"id,omitempty"`
106+
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
107+
ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"`
108+
Name string `bson:"name" json:"name"`
109+
ValueString *string `bson:"valueString,omitempty" json:"valueString,omitempty"`
110+
ValueBoolean *bool `bson:"valueBoolean,omitempty" json:"valueBoolean,omitempty"`
111+
ValueInteger *int `bson:"valueInteger,omitempty" json:"valueInteger,omitempty"`
112+
ValueDecimal *json.Number `bson:"valueDecimal,omitempty" json:"valueDecimal,omitempty"`
113+
ValueUri *string `bson:"valueUri,omitempty" json:"valueUri,omitempty"`
114+
ValueCode *string `bson:"valueCode,omitempty" json:"valueCode,omitempty"`
115+
ValueDateTime *string `bson:"valueDateTime,omitempty" json:"valueDateTime,omitempty"`
116116
}
117117
type ValueSetExpansionContains struct {
118118
Id *string `bson:"id,omitempty" json:"id,omitempty"`

0 commit comments

Comments
 (0)