Skip to content

Commit

Permalink
Fix Decimal Types
Browse files Browse the repository at this point in the history
I use json.Number for a maximum of flexibility.
  • Loading branch information
alexanderkiel committed Dec 3, 2022
1 parent 53e78f9 commit 8c800ff
Show file tree
Hide file tree
Showing 50 changed files with 200 additions and 160 deletions.
4 changes: 2 additions & 2 deletions fhir-models-gen/cmd/genResources.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ func addFieldStatement(
return 0, err
}
elementIndex--
} else if typeIdentifier == "decimal" {
statement.Qual("encoding/json", "Number")
} else {
if unicode.IsUpper(rune(typeIdentifier[0])) {
requiredTypes[typeIdentifier] = true
Expand Down Expand Up @@ -502,8 +504,6 @@ func typeCodeToTypeIdentifier(typeCode string) string {
return "string"
case "dateTime":
return "string"
case "decimal":
return "string"
case "id":
return "string"
case "instant":
Expand Down
2 changes: 1 addition & 1 deletion fhir-models-gen/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "fhir-gen",
Version: "0.3.0",
Version: "0.3.2",
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
4 changes: 3 additions & 1 deletion fhir-models-gen/fhir/age.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

package fhir

import "encoding/json"

// 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
type Age struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Value *string `bson:"value,omitempty" json:"value,omitempty"`
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
System *string `bson:"system,omitempty" json:"system,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion fhir-models-gen/fhir/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type BundleEntrySearch struct {
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"`
Mode *SearchEntryMode `bson:"mode,omitempty" json:"mode,omitempty"`
Score *string `bson:"score,omitempty" json:"score,omitempty"`
Score *json.Number `bson:"score,omitempty" json:"score,omitempty"`
}
type BundleEntryRequest struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion fhir-models-gen/fhir/codeSystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type CodeSystemConceptProperty struct {
ValueInteger int `bson:"valueInteger" json:"valueInteger"`
ValueBoolean bool `bson:"valueBoolean" json:"valueBoolean"`
ValueDateTime string `bson:"valueDateTime" json:"valueDateTime"`
ValueDecimal string `bson:"valueDecimal" json:"valueDecimal"`
ValueDecimal json.Number `bson:"valueDecimal" json:"valueDecimal"`
}
type OtherCodeSystem CodeSystem

Expand Down
4 changes: 3 additions & 1 deletion fhir-models-gen/fhir/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

package fhir

import "encoding/json"

// 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
type Count struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Value *string `bson:"value,omitempty" json:"value,omitempty"`
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
System *string `bson:"system,omitempty" json:"system,omitempty"`
Expand Down
4 changes: 3 additions & 1 deletion fhir-models-gen/fhir/distance.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

package fhir

import "encoding/json"

// 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
type Distance struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Value *string `bson:"value,omitempty" json:"value,omitempty"`
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
System *string `bson:"system,omitempty" json:"system,omitempty"`
Expand Down
4 changes: 3 additions & 1 deletion fhir-models-gen/fhir/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

package fhir

import "encoding/json"

// 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
type Duration struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Value *string `bson:"value,omitempty" json:"value,omitempty"`
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
System *string `bson:"system,omitempty" json:"system,omitempty"`
Expand Down
14 changes: 8 additions & 6 deletions fhir-models-gen/fhir/elementDefinition.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package fhir

import "encoding/json"

// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
// PLEASE DO NOT EDIT BY HAND

Expand Down Expand Up @@ -45,7 +47,7 @@ type ElementDefinition struct {
DefaultValueCode *string `bson:"defaultValueCode,omitempty" json:"defaultValueCode,omitempty"`
DefaultValueDate *string `bson:"defaultValueDate,omitempty" json:"defaultValueDate,omitempty"`
DefaultValueDateTime *string `bson:"defaultValueDateTime,omitempty" json:"defaultValueDateTime,omitempty"`
DefaultValueDecimal *string `bson:"defaultValueDecimal,omitempty" json:"defaultValueDecimal,omitempty"`
DefaultValueDecimal *json.Number `bson:"defaultValueDecimal,omitempty" json:"defaultValueDecimal,omitempty"`
DefaultValueId *string `bson:"defaultValueId,omitempty" json:"defaultValueId,omitempty"`
DefaultValueInstant *string `bson:"defaultValueInstant,omitempty" json:"defaultValueInstant,omitempty"`
DefaultValueInteger *int `bson:"defaultValueInteger,omitempty" json:"defaultValueInteger,omitempty"`
Expand Down Expand Up @@ -97,7 +99,7 @@ type ElementDefinition struct {
FixedCode *string `bson:"fixedCode,omitempty" json:"fixedCode,omitempty"`
FixedDate *string `bson:"fixedDate,omitempty" json:"fixedDate,omitempty"`
FixedDateTime *string `bson:"fixedDateTime,omitempty" json:"fixedDateTime,omitempty"`
FixedDecimal *string `bson:"fixedDecimal,omitempty" json:"fixedDecimal,omitempty"`
FixedDecimal *json.Number `bson:"fixedDecimal,omitempty" json:"fixedDecimal,omitempty"`
FixedId *string `bson:"fixedId,omitempty" json:"fixedId,omitempty"`
FixedInstant *string `bson:"fixedInstant,omitempty" json:"fixedInstant,omitempty"`
FixedInteger *int `bson:"fixedInteger,omitempty" json:"fixedInteger,omitempty"`
Expand Down Expand Up @@ -147,7 +149,7 @@ type ElementDefinition struct {
PatternCode *string `bson:"patternCode,omitempty" json:"patternCode,omitempty"`
PatternDate *string `bson:"patternDate,omitempty" json:"patternDate,omitempty"`
PatternDateTime *string `bson:"patternDateTime,omitempty" json:"patternDateTime,omitempty"`
PatternDecimal *string `bson:"patternDecimal,omitempty" json:"patternDecimal,omitempty"`
PatternDecimal *json.Number `bson:"patternDecimal,omitempty" json:"patternDecimal,omitempty"`
PatternId *string `bson:"patternId,omitempty" json:"patternId,omitempty"`
PatternInstant *string `bson:"patternInstant,omitempty" json:"patternInstant,omitempty"`
PatternInteger *int `bson:"patternInteger,omitempty" json:"patternInteger,omitempty"`
Expand Down Expand Up @@ -196,7 +198,7 @@ type ElementDefinition struct {
MinValueDateTime *string `bson:"minValueDateTime,omitempty" json:"minValueDateTime,omitempty"`
MinValueInstant *string `bson:"minValueInstant,omitempty" json:"minValueInstant,omitempty"`
MinValueTime *string `bson:"minValueTime,omitempty" json:"minValueTime,omitempty"`
MinValueDecimal *string `bson:"minValueDecimal,omitempty" json:"minValueDecimal,omitempty"`
MinValueDecimal *json.Number `bson:"minValueDecimal,omitempty" json:"minValueDecimal,omitempty"`
MinValueInteger *int `bson:"minValueInteger,omitempty" json:"minValueInteger,omitempty"`
MinValuePositiveInt *int `bson:"minValuePositiveInt,omitempty" json:"minValuePositiveInt,omitempty"`
MinValueUnsignedInt *int `bson:"minValueUnsignedInt,omitempty" json:"minValueUnsignedInt,omitempty"`
Expand All @@ -205,7 +207,7 @@ type ElementDefinition struct {
MaxValueDateTime *string `bson:"maxValueDateTime,omitempty" json:"maxValueDateTime,omitempty"`
MaxValueInstant *string `bson:"maxValueInstant,omitempty" json:"maxValueInstant,omitempty"`
MaxValueTime *string `bson:"maxValueTime,omitempty" json:"maxValueTime,omitempty"`
MaxValueDecimal *string `bson:"maxValueDecimal,omitempty" json:"maxValueDecimal,omitempty"`
MaxValueDecimal *json.Number `bson:"maxValueDecimal,omitempty" json:"maxValueDecimal,omitempty"`
MaxValueInteger *int `bson:"maxValueInteger,omitempty" json:"maxValueInteger,omitempty"`
MaxValuePositiveInt *int `bson:"maxValuePositiveInt,omitempty" json:"maxValuePositiveInt,omitempty"`
MaxValueUnsignedInt *int `bson:"maxValueUnsignedInt,omitempty" json:"maxValueUnsignedInt,omitempty"`
Expand Down Expand Up @@ -260,7 +262,7 @@ type ElementDefinitionExample struct {
ValueCode string `bson:"valueCode" json:"valueCode"`
ValueDate string `bson:"valueDate" json:"valueDate"`
ValueDateTime string `bson:"valueDateTime" json:"valueDateTime"`
ValueDecimal string `bson:"valueDecimal" json:"valueDecimal"`
ValueDecimal json.Number `bson:"valueDecimal" json:"valueDecimal"`
ValueId string `bson:"valueId" json:"valueId"`
ValueInstant string `bson:"valueInstant" json:"valueInstant"`
ValueInteger int `bson:"valueInteger" json:"valueInteger"`
Expand Down
4 changes: 3 additions & 1 deletion fhir-models-gen/fhir/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package fhir

import "encoding/json"

// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
// PLEASE DO NOT EDIT BY HAND

Expand All @@ -28,7 +30,7 @@ type Extension struct {
ValueCode *string `bson:"valueCode,omitempty" json:"valueCode,omitempty"`
ValueDate *string `bson:"valueDate,omitempty" json:"valueDate,omitempty"`
ValueDateTime *string `bson:"valueDateTime,omitempty" json:"valueDateTime,omitempty"`
ValueDecimal *string `bson:"valueDecimal,omitempty" json:"valueDecimal,omitempty"`
ValueDecimal *json.Number `bson:"valueDecimal,omitempty" json:"valueDecimal,omitempty"`
ValueId *string `bson:"valueId,omitempty" json:"valueId,omitempty"`
ValueInstant *string `bson:"valueInstant,omitempty" json:"valueInstant,omitempty"`
ValueInteger *int `bson:"valueInteger,omitempty" json:"valueInteger,omitempty"`
Expand Down
10 changes: 6 additions & 4 deletions fhir-models-gen/fhir/money.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

package fhir

import "encoding/json"

// 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
type Money struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Value *string `bson:"value,omitempty" json:"value,omitempty"`
Currency *string `bson:"currency,omitempty" json:"currency,omitempty"`
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
Currency *string `bson:"currency,omitempty" json:"currency,omitempty"`
}
4 changes: 3 additions & 1 deletion fhir-models-gen/fhir/quantity.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

package fhir

import "encoding/json"

// 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
type Quantity struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Value *string `bson:"value,omitempty" json:"value,omitempty"`
Value *json.Number `bson:"value,omitempty" json:"value,omitempty"`
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
System *string `bson:"system,omitempty" json:"system,omitempty"`
Expand Down
20 changes: 11 additions & 9 deletions fhir-models-gen/fhir/sampledData.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@

package fhir

import "encoding/json"

// 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
type SampledData struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Origin Quantity `bson:"origin" json:"origin"`
Period string `bson:"period" json:"period"`
Factor *string `bson:"factor,omitempty" json:"factor,omitempty"`
LowerLimit *string `bson:"lowerLimit,omitempty" json:"lowerLimit,omitempty"`
UpperLimit *string `bson:"upperLimit,omitempty" json:"upperLimit,omitempty"`
Dimensions int `bson:"dimensions" json:"dimensions"`
Data *string `bson:"data,omitempty" json:"data,omitempty"`
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Origin Quantity `bson:"origin" json:"origin"`
Period json.Number `bson:"period" json:"period"`
Factor *json.Number `bson:"factor,omitempty" json:"factor,omitempty"`
LowerLimit *json.Number `bson:"lowerLimit,omitempty" json:"lowerLimit,omitempty"`
UpperLimit *json.Number `bson:"upperLimit,omitempty" json:"upperLimit,omitempty"`
Dimensions int `bson:"dimensions" json:"dimensions"`
Data *string `bson:"data,omitempty" json:"data,omitempty"`
}
10 changes: 6 additions & 4 deletions fhir-models-gen/fhir/timing.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package fhir

import "encoding/json"

// THIS FILE IS GENERATED BY https://github.com/samply/golang-fhir-models
// PLEASE DO NOT EDIT BY HAND

Expand All @@ -34,13 +36,13 @@ type TimingRepeat struct {
BoundsPeriod *Period `bson:"boundsPeriod,omitempty" json:"boundsPeriod,omitempty"`
Count *int `bson:"count,omitempty" json:"count,omitempty"`
CountMax *int `bson:"countMax,omitempty" json:"countMax,omitempty"`
Duration *string `bson:"duration,omitempty" json:"duration,omitempty"`
DurationMax *string `bson:"durationMax,omitempty" json:"durationMax,omitempty"`
Duration *json.Number `bson:"duration,omitempty" json:"duration,omitempty"`
DurationMax *json.Number `bson:"durationMax,omitempty" json:"durationMax,omitempty"`
DurationUnit *string `bson:"durationUnit,omitempty" json:"durationUnit,omitempty"`
Frequency *int `bson:"frequency,omitempty" json:"frequency,omitempty"`
FrequencyMax *int `bson:"frequencyMax,omitempty" json:"frequencyMax,omitempty"`
Period *string `bson:"period,omitempty" json:"period,omitempty"`
PeriodMax *string `bson:"periodMax,omitempty" json:"periodMax,omitempty"`
Period *json.Number `bson:"period,omitempty" json:"period,omitempty"`
PeriodMax *json.Number `bson:"periodMax,omitempty" json:"periodMax,omitempty"`
PeriodUnit *string `bson:"periodUnit,omitempty" json:"periodUnit,omitempty"`
DayOfWeek []DaysOfWeek `bson:"dayOfWeek,omitempty" json:"dayOfWeek,omitempty"`
TimeOfDay []string `bson:"timeOfDay,omitempty" json:"timeOfDay,omitempty"`
Expand Down
22 changes: 11 additions & 11 deletions fhir-models-gen/fhir/valueSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ type ValueSetExpansion struct {
Contains []ValueSetExpansionContains `bson:"contains,omitempty" json:"contains,omitempty"`
}
type ValueSetExpansionParameter struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"`
Name string `bson:"name" json:"name"`
ValueString *string `bson:"valueString,omitempty" json:"valueString,omitempty"`
ValueBoolean *bool `bson:"valueBoolean,omitempty" json:"valueBoolean,omitempty"`
ValueInteger *int `bson:"valueInteger,omitempty" json:"valueInteger,omitempty"`
ValueDecimal *string `bson:"valueDecimal,omitempty" json:"valueDecimal,omitempty"`
ValueUri *string `bson:"valueUri,omitempty" json:"valueUri,omitempty"`
ValueCode *string `bson:"valueCode,omitempty" json:"valueCode,omitempty"`
ValueDateTime *string `bson:"valueDateTime,omitempty" json:"valueDateTime,omitempty"`
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"`
Name string `bson:"name" json:"name"`
ValueString *string `bson:"valueString,omitempty" json:"valueString,omitempty"`
ValueBoolean *bool `bson:"valueBoolean,omitempty" json:"valueBoolean,omitempty"`
ValueInteger *int `bson:"valueInteger,omitempty" json:"valueInteger,omitempty"`
ValueDecimal *json.Number `bson:"valueDecimal,omitempty" json:"valueDecimal,omitempty"`
ValueUri *string `bson:"valueUri,omitempty" json:"valueUri,omitempty"`
ValueCode *string `bson:"valueCode,omitempty" json:"valueCode,omitempty"`
ValueDateTime *string `bson:"valueDateTime,omitempty" json:"valueDateTime,omitempty"`
}
type ValueSetExpansionContains struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Expand Down
Loading

0 comments on commit 8c800ff

Please sign in to comment.