py fhir

Solutions on MaxInterview for py fhir by the best coders in the world

showing results for - "py fhir"
Erica
12 Nov 2020
1# Import the relevant classes from fhir.model
2from fhir.model import Patient, HumanName, Identifier, CodeableConcept, Coding, uri
3
4# Create a new Patient object. Resource attributes can be passed in the constructor. Note
5# that 'id' is the logical id of the Resource and has no relation to the Medical Record
6# Number (MRN)
7p = Patient(id='patient1')
8
9# Give the patient an MRN
10identifier = Identifier(
11    type=CodeableConcept(coding=[Coding(system="http://hl7.org/fhir/v2/0203", code="MR")]),
12    system='urn:oid:1.2.36.146.595.217.0.1',
13    value='123456789'
14)
15
16# Lists can be assigned to attributes.
17# Alternatively p.identifier.append(identifier) could have been used.
18p.identifier = [identifier]
19
20# Native python values are automatically coerced to FHIR classes
21p.active = True
22print(type(p.active))
23# output: <class 'fhir.model._boolean.boolean'>
24
25name = HumanName()
26name.use = 'official'
27name.given = ['Melle', 'Sjoerd']
28name.family = 'Sieswerda'
29p.name = [name]
30
31# Serialize to JSON and print the result. To serialize to XML use 'p.toXML()'.
32print(p.dumps('json'))
33
similar questions
queries leading to this page
py fhir