-
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
add YAML support #47
Comments
This seems is a very good idea 💡 and also I think this will open up to support for XML. For me, I could try after the holiday season ends (after the new year) but anyone welcomes to try now. |
@Healthedata1 what should be the proper mime type for YAML? some folk suggest |
I don't have an opinion. It seems from the pydantic CRs that just using the yaml dump and load methods is the preferred choice. e.g. Testing out fhir.resourcesstart with fhirstring class...from fhir.resources.patient import Patient as P
from yaml import dump as y_dump, load as y_load
import datetime p = P()
p.json()
print(y_dump(p.dict()))
my_patient = {'id': 'subject1',
'meta': {'profile': ['http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient|4.0.0']},
'active': True,
'address': [{'city': 'Anytown',
'country': 'USA',
'line': ['100 Main St'],
'postalCode': '99999',
'state': 'CA',
'text': '100 Main St\nAnytown, CA 99999\nUSA'}],
'birthDate': datetime.date(1964, 6, 19),
'communication': [{'language': {'coding': [{'code': 'en',
'display': 'English',
'system': 'urn:ietf:bcp:47'}],
'text': 'English'}}],
'gender': 'male',
'identifier': [{'system': 'http://example.org/pids', 'value': '1234'}],
'name': [{'family': 'Doe', 'given': ['John', 'M']}],
'resourceType': 'Patient'} p = P(**my_patient)
print(y_dump(p.dict()))
p_yaml = '''
active: true
address:
- city: Anytown
country: USA
line:
- 100 Main St
postalCode: '99999'
state: CA
text: '100 Main St
Anytown, CA 99999
USA'
birthDate: 1964-06-19
communication:
- language:
coding:
- code: en
display: English
system: urn:ietf:bcp:47
text: English
gender: male
id: subject1
identifier:
- system: http://example.org/pids
value: '1234'
meta:
profile:
- http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient|4.0.0
name:
- family: Doe
given:
- John
- M
resourceType: Patient
''' y = y_load(p_yaml)
y
p = P(**y)
print(y_dump(p.dict()))
|
@Healthedata1 did you try the latest beta release yet? |
not yet, but I will. I am going through the FastAPI spec hoping to generate
swagger docs using the models but I see that there are some issues with
that.
Eric
Eric M Haas, DVM, MS
Health eData Inc
35 Crescent Avenue, Sausalito, CA 94965
707.227.2608|Skype: haas.eric1
***@***.***
…On Thu, Apr 1, 2021 at 9:57 AM Md Nazrul Islam ***@***.***> wrote:
@Healthedata1 <https://github.com/Healthedata1> did you try the latest
beta release yet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#47 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYRJ2VSJTKHAZEHSAKVTYDTGSQYTANCNFSM4VAAFBLA>
.
|
used it and it works great. many thanks |
Description
would like to add native YAML support so that a Resource object can be created from YAML object or file and serialize as a YAML string.
e.g:
and
and
The text was updated successfully, but these errors were encountered: