-
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
YAML datetime is not serialized to the propor iso format #96
Comments
https://yaml.org/type/timestamp.html although without T (space only) is a valid format according to YAML specification. But I fully agree with you, DateTime should represent according to FHIR specification and fortunately, that will comply with YAML specification as well. |
Yes FHIR specifies the iso8601 format with a capital 'T' and I
unexpectedly get a yaml to json error when converting using the standard
modules.
import sys, yaml, json; json.dump(yaml.full_load(sys.stdin), sys.stdout,
indent=4)' < $yaml_file > $json_file
but I think that is because it is not encased in quotes.
Eric
Eric M Haas, DVM, MS
Health eData Inc
35 Crescent Avenue, Sausalito, CA 94965
707.227.2608|Skype: haas.eric1
***@***.***
…On Wed, Mar 30, 2022 at 12:58 AM Md Nazrul Islam ***@***.***> wrote:
https://yaml.org/type/timestamp.html although without T (space only) is a
valid format according to YAML specification. But I fully agree with you,
DateTime should represent according to FHIR specification and fortunately,
that will comply with YAML specification as well.
—
Reply to this email directly, view it on GitHub
<#96 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYRJ2WVC4KHPDPLTYPAXKLVCQCRJANCNFSM5R7LRVOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
… created. * tests coverages are added. * changes log updated.
@Healthedata1 check out the new release https://pypi.org/project/fhir.resources/6.2.2/ |
Thanks, I'll check it out.
Eric M Haas, DVM, MS
Health eData Inc
35 Crescent Avenue, Sausalito, CA 94965
707.227.2608|Skype: haas.eric1
***@***.***
…On Sat, Apr 2, 2022 at 2:14 AM Md Nazrul Islam ***@***.***> wrote:
@Healthedata1 <https://github.com/Healthedata1> check out the new release
https://pypi.org/project/fhir.resources/6.2.2/
—
Reply to this email directly, view it on GitHub
<#96 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYRJ2UYB4G5U5UI7Y6MKB3VDAFYPANCNFSM5R7LRVOA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
this fixes the main issue but one more is that the YAML serialized datetime/time is not wrapped in quotes and caused issues when try to convert yaml to json. So you cannot round trip from fhir.resource model to yaml to json to fhir.resource. see below: from pathlib import Path
from fhir.resources import construct_fhir_element
from datetime import datetime, timedelta
import yaml, json
delta = timedelta(hours = 12)
pd = construct_fhir_element('Period', {})
pd.start = datetime.now() - delta
pd.end = datetime.now()
pd
pd_json=pd.json()
pd_json
pd_dict = json.loads(pd_json)
yaml.dump(pd_dict)
pd_yaml=pd.yaml()
pd_yaml
pd_dict = yaml.safe_load(pd_yaml)
json.dumps(pd_dict)
|
After reviewing the PyYaml documentation I realize there is no issue here and it lies with my usage of the yaml package. |
Description
The datetime is not serialized to the proper iso format when using the yaml() method. This leads to errors when converting to json and with FHIR validation.
What I Did
The text was updated successfully, but these errors were encountered: