py fhir

# Import the relevant classes from fhir.model
from fhir.model import Patient, HumanName, Identifier, CodeableConcept, Coding, uri

# Create a new Patient object. Resource attributes can be passed in the constructor. Note
# that 'id' is the logical id of the Resource and has no relation to the Medical Record
# Number (MRN)
p = Patient(id='patient1')

# Give the patient an MRN
identifier = Identifier(
    type=CodeableConcept(coding=[Coding(system="http://hl7.org/fhir/v2/0203", code="MR")]),
    system='urn:oid:1.2.36.146.595.217.0.1',
    value='123456789'
)

# Lists can be assigned to attributes.
# Alternatively p.identifier.append(identifier) could have been used.
p.identifier = [identifier]

# Native python values are automatically coerced to FHIR classes
p.active = True
print(type(p.active))
# output: <class 'fhir.model._boolean.boolean'>

name = HumanName()
name.use = 'official'
name.given = ['Melle', 'Sjoerd']
name.family = 'Sieswerda'
p.name = [name]

# Serialize to JSON and print the result. To serialize to XML use 'p.toXML()'.
print(p.dumps('json'))

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source