Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valueDecimal won't accept long values #33

Closed
danqrodney opened this issue Apr 21, 2017 · 2 comments
Closed

valueDecimal won't accept long values #33

danqrodney opened this issue Apr 21, 2017 · 2 comments

Comments

@danqrodney
Copy link

Questionnaire responses can have an answer of type integer, limited to 32 bits; or they can use valueDecimal for bigger numbers.

However, if the client doesn't put a decimal point, and instead sets valueDecimal to a number that won't fit into an int (e.g. 10000000000000000000), it gets parsed as a long, and the parser gives a validation error:

FHIRValidationError: {root}: group: question: answer: valueDecimal: Wrong type <type 'long'> for property "valueDecimal" on $lt;class 'fhirclient.models.questionnaireresponse.QuestionnaireResponseGroupQuestionAnswer'>, expecting <type 'float'>

Long values without decimal points should be accepted here (even if it means having to convert to a float).

@p2
Copy link
Member

p2 commented Apr 25, 2017

This is a current limitation since we map native Python types to many FHIR primitives, in this case we use float for Decimal.

In an update we want to also use custom classes for FHIR primitives, at which point we can address this issue as well. See #30 .

@mikix
Copy link
Contributor

mikix commented Jul 30, 2024

These days, the provided example works (we use float like p2 says):

from fhirclient.models.questionnaireresponse import QuestionnaireResponseItemAnswer

QuestionnaireResponseItemAnswer({"valueDecimal": 10000000000000000000}).as_json()
# {'valueDecimal': 10000000000000000000}

QuestionnaireResponseItemAnswer({"valueDecimal": 10000000000000000000.00}).as_json()
# {'valueDecimal': 1e+19}

@mikix mikix closed this as completed Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants