-
Notifications
You must be signed in to change notification settings - Fork 109
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
Dates are not converted when using construct_fhir_element
#29
Comments
@ItayGoren you got right, as python |
isn't this case in contradiction to the purpose of
|
Fully agree with you about the contradiction of By Default
I think currently it is possible to make a custom root validator and achieve your approach, it's depended on project-specific requirements. But I have got another idea, maybe we can make some option so that it is possible to inject custom validator into Primitive types, that would give a developer a lot of flexibility (like your implement your approach). |
As a developer, I expect the field to be a date. And that the code |
I've been thinking about this issue a lot recently. I think what I would like to do is create a customized @nazrulworld, what do you think about this? I'm going to start some of the initial work today and let you know where you can check out my progress once there's something to share. |
Okay, so I have a lot of the work done on a new data type for FHIR date/datetime values. One thing I could use some feedback on is what makes the most sense when comparing two objects that have different granularity. For example, would you expect the following to return DateTime(2021, 4) < DateTime(2021) # Does the existence of months in 2021 before April make it less than?
DateTime(2021, 4) > DateTime(2021) # Does the existence of months in 2021 after April make it greater than?
DateTime(2021, 4) == DateTime(2021) # Does it make sense to only consider the values we have when testing equality? What I've been leaning toward is making the first two examples above return |
@mmabey great works! We can do some tests here http://hapi.fhir.org/resource . To see how they manage this situation. For example create the same resources with different dateTime, after then search with eq,lt,gt |
@nazrulworld you're right about the comparisons. I'm not sure why my intuition was off on that, but I confirmed with the HAPI FHIR sandbox that only the populated fields are compared, so the above examples should return I've packaged everything up and pushed to GitHub: https://github.com/mmabey/fhirdatetime and I would love your feedback, especially on the the comparison test cases. Next week, I'll work on hooking in some CI/auto testing, getting it up on PyPI, and working on a custom root validator for my own uses. If things go well, @nazrulworld I could see how to hook that work into this project as the default parser for |
First of all, congratulation on the nice work. |
I'm not very concerned with that name collision because from DateTime import DateTime And with mine you do: from fhirdatetime import DateTime |
Description
When creating a resource with
construct_fhir_element
and specifying a date as a string, the date is not converted toDate
but rather stay as string. Yet, the regex pattern is verified.I tried multiple resources and it happens for all of them.
What I Did
The same happen when using
Patient.parse_obj
.Edit:
The following
Patient.parse_obj({'birthDate': '2012-01-01'}).birthDate
indeed returnsdatetime.date
.The text was updated successfully, but these errors were encountered: