안 용태

안 용태

1603334400

[왕초보 무료 프로그래밍 언어 강의] [Dart] #19 - Class [#3] Inheritance

Flutter 에서 사용되는 Dart 언어 프로그래밍 왕초보용 강의입니다.

Dart 언어의 Class Inheritance (상속) 에 대해 배워보는 강의입니다.

#dart #flutter #mobile-apps

What is GEEK

Buddha Community

[왕초보 무료 프로그래밍 언어 강의] [Dart] #19 - Class [#3] Inheritance

A Wrapper for Sembast and SQFlite to Enable Easy

FHIR_DB

This is really just a wrapper around Sembast_SQFLite - so all of the heavy lifting was done by Alex Tekartik. I highly recommend that if you have any questions about working with this package that you take a look at Sembast. He's also just a super nice guy, and even answered a question for me when I was deciding which sembast version to use. As usual, ResoCoder also has a good tutorial.

I have an interest in low-resource settings and thus a specific reason to be able to store data offline. To encourage this use, there are a number of other packages I have created based around the data format FHIR. FHIR® is the registered trademark of HL7 and is used with the permission of HL7. Use of the FHIR trademark does not constitute endorsement of this product by HL7.

Using the Db

So, while not absolutely necessary, I highly recommend that you use some sort of interface class. This adds the benefit of more easily handling errors, plus if you change to a different database in the future, you don't have to change the rest of your app, just the interface.

I've used something like this in my projects:

class IFhirDb {
  IFhirDb();
  final ResourceDao resourceDao = ResourceDao();

  Future<Either<DbFailure, Resource>> save(Resource resource) async {
    Resource resultResource;
    try {
      resultResource = await resourceDao.save(resource);
    } catch (error) {
      return left(DbFailure.unableToSave(error: error.toString()));
    }
    return right(resultResource);
  }

  Future<Either<DbFailure, List<Resource>>> returnListOfSingleResourceType(
      String resourceType) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.getAllSortedById(resourceType: resourceType);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }

  Future<Either<DbFailure, List<Resource>>> searchFunction(
      String resourceType, String searchString, String reference) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.searchFor(resourceType, searchString, reference);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }
}

I like this because in case there's an i/o error or something, it won't crash your app. Then, you can call this interface in your app like the following:

final patient = Patient(
    resourceType: 'Patient',
    name: [HumanName(text: 'New Patient Name')],
    birthDate: Date(DateTime.now()),
);

final saveResult = await IFhirDb().save(patient);

This will save your newly created patient to the locally embedded database.

IMPORTANT: this database will expect that all previously created resources have an id. When you save a resource, it will check to see if that resource type has already been stored. (Each resource type is saved in it's own store in the database). It will then check if there is an ID. If there's no ID, it will create a new one for that resource (along with metadata on version number and creation time). It will save it, and return the resource. If it already has an ID, it will copy the the old version of the resource into a _history store. It will then update the metadata of the new resource and save that version into the appropriate store for that resource. If, for instance, we have a previously created patient:

{
    "resourceType": "Patient",
    "id": "fhirfli-294057507-6811107",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2020-10-16T19:41:28.054369Z"
    },
    "name": [
        {
            "given": ["New"],
            "family": "Patient"
        }
    ],
    "birthDate": "2020-10-16"
}

And we update the last name to 'Provider'. The above version of the patient will be kept in _history, while in the 'Patient' store in the db, we will have the updated version:

{
    "resourceType": "Patient",
    "id": "fhirfli-294057507-6811107",
    "meta": {
        "versionId": "2",
        "lastUpdated": "2020-10-16T19:45:07.316698Z"
    },
    "name": [
        {
            "given": ["New"],
            "family": "Provider"
        }
    ],
    "birthDate": "2020-10-16"
}

This way we can keep track of all previous version of all resources (which is obviously important in medicine).

For most of the interactions (saving, deleting, etc), they work the way you'd expect. The only difference is search. Because Sembast is NoSQL, we can search on any of the fields in a resource. If in our interface class, we have the following function:

  Future<Either<DbFailure, List<Resource>>> searchFunction(
      String resourceType, String searchString, String reference) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.searchFor(resourceType, searchString, reference);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }

You can search for all immunizations of a certain patient:

searchFunction(
        'Immunization', 'patient.reference', 'Patient/$patientId');

This function will search through all entries in the 'Immunization' store. It will look at all 'patient.reference' fields, and return any that match 'Patient/$patientId'.

The last thing I'll mention is that this is a password protected db, using AES-256 encryption (although it can also use Salsa20). Anytime you use the db, you have the option of using a password for encryption/decryption. Remember, if you setup the database using encryption, you will only be able to access it using that same password. When you're ready to change the password, you will need to call the update password function. If we again assume we created a change password method in our interface, it might look something like this:

class IFhirDb {
  IFhirDb();
  final ResourceDao resourceDao = ResourceDao();
  ...
    Future<Either<DbFailure, Unit>> updatePassword(String oldPassword, String newPassword) async {
    try {
      await resourceDao.updatePw(oldPassword, newPassword);
    } catch (error) {
      return left(DbFailure.unableToUpdatePassword(error: error.toString()));
    }
    return right(Unit);
  }

You don't have to use a password, and in that case, it will save the db file as plain text. If you want to add a password later, it will encrypt it at that time.

General Store

After using this for a while in an app, I've realized that it needs to be able to store data apart from just FHIR resources, at least on occasion. For this, I've added a second class for all versions of the database called GeneralDao. This is similar to the ResourceDao, but fewer options. So, in order to save something, it would look like this:

await GeneralDao().save('password', {'new':'map'});
await GeneralDao().save('password', {'new':'map'}, 'key');

The difference between these two options is that the first one will generate a key for the map being stored, while the second will store the map using the key provided. Both will return the key after successfully storing the map.

Other functions available include:

// deletes everything in the general store
await GeneralDao().deleteAllGeneral('password'); 

// delete specific entry
await GeneralDao().delete('password','key'); 

// returns map with that key
await GeneralDao().find('password', 'key'); 

FHIR® is a registered trademark of Health Level Seven International (HL7) and its use does not constitute an endorsement of products by HL7®

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add fhir_db

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  fhir_db: ^0.4.3

Alternatively, your editor might support or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:fhir_db/dstu2.dart';
import 'package:fhir_db/dstu2/fhir_db.dart';
import 'package:fhir_db/dstu2/general_dao.dart';
import 'package:fhir_db/dstu2/resource_dao.dart';
import 'package:fhir_db/encrypt/aes.dart';
import 'package:fhir_db/encrypt/salsa.dart';
import 'package:fhir_db/r4.dart';
import 'package:fhir_db/r4/fhir_db.dart';
import 'package:fhir_db/r4/general_dao.dart';
import 'package:fhir_db/r4/resource_dao.dart';
import 'package:fhir_db/r5.dart';
import 'package:fhir_db/r5/fhir_db.dart';
import 'package:fhir_db/r5/general_dao.dart';
import 'package:fhir_db/r5/resource_dao.dart';
import 'package:fhir_db/stu3.dart';
import 'package:fhir_db/stu3/fhir_db.dart';
import 'package:fhir_db/stu3/general_dao.dart';
import 'package:fhir_db/stu3/resource_dao.dart'; 

example/lib/main.dart

import 'package:fhir/r4.dart';
import 'package:fhir_db/r4.dart';
import 'package:flutter/material.dart';
import 'package:test/test.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final resourceDao = ResourceDao();

  // await resourceDao.updatePw('newPw', null);
  await resourceDao.deleteAllResources(null);

  group('Playing with passwords', () {
    test('Playing with Passwords', () async {
      final patient = Patient(id: Id('1'));

      final saved = await resourceDao.save(null, patient);

      await resourceDao.updatePw(null, 'newPw');
      final search1 = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search1[0]);

      await resourceDao.updatePw('newPw', 'newerPw');
      final search2 = await resourceDao.find('newerPw',
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search2[0]);

      await resourceDao.updatePw('newerPw', null);
      final search3 = await resourceDao.find(null,
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search3[0]);

      await resourceDao.deleteAllResources(null);
    });
  });

  final id = Id('12345');
  group('Saving Things:', () {
    test('Save Patient', () async {
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);
      final patient = Patient(id: id, name: [humanName]);
      final saved = await resourceDao.save(null, patient);

      expect(saved.id, id);

      expect((saved as Patient).name?[0], humanName);
    });

    test('Save Organization', () async {
      final organization = Organization(id: id, name: 'FhirFli');
      final saved = await resourceDao.save(null, organization);

      expect(saved.id, id);

      expect((saved as Organization).name, 'FhirFli');
    });

    test('Save Observation1', () async {
      final observation1 = Observation(
        id: Id('obs1'),
        code: CodeableConcept(text: 'Observation #1'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1');
    });

    test('Save Observation1 Again', () async {
      final observation1 = Observation(
          id: Id('obs1'),
          code: CodeableConcept(text: 'Observation #1 - Updated'));
      final saved = await resourceDao.save(null, observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1 - Updated');

      expect(saved.meta?.versionId, Id('2'));
    });

    test('Save Observation2', () async {
      final observation2 = Observation(
        id: Id('obs2'),
        code: CodeableConcept(text: 'Observation #2'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation2);

      expect(saved.id, Id('obs2'));

      expect((saved as Observation).code.text, 'Observation #2');
    });

    test('Save Observation3', () async {
      final observation3 = Observation(
        id: Id('obs3'),
        code: CodeableConcept(text: 'Observation #3'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation3);

      expect(saved.id, Id('obs3'));

      expect((saved as Observation).code.text, 'Observation #3');
    });
  });

  group('Finding Things:', () {
    test('Find 1st Patient', () async {
      final search = await resourceDao.find(null,
          resourceType: R4ResourceType.Patient, id: id);
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);

      expect(search.length, 1);

      expect((search[0] as Patient).name?[0], humanName);
    });

    test('Find 3rd Observation', () async {
      final search = await resourceDao.find(null,
          resourceType: R4ResourceType.Observation, id: Id('obs3'));

      expect(search.length, 1);

      expect(search[0].id, Id('obs3'));

      expect((search[0] as Observation).code.text, 'Observation #3');
    });

    test('Find All Observations', () async {
      final search = await resourceDao.getResourceType(
        null,
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 3);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), true);

      expect(idList.contains('obs3'), true);
    });

    test('Find All (non-historical) Resources', () async {
      final search = await resourceDao.getAll(null);

      expect(search.length, 5);
      final patList = search.toList();
      final orgList = search.toList();
      final obsList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);
      obsList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Observation);

      expect(patList.length, 1);

      expect(orgList.length, 1);

      expect(obsList.length, 3);
    });
  });

  group('Deleting Things:', () {
    test('Delete 2nd Observation', () async {
      await resourceDao.delete(
          null, null, R4ResourceType.Observation, Id('obs2'), null, null);

      final search = await resourceDao.getResourceType(
        null,
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 2);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), false);

      expect(idList.contains('obs3'), true);
    });

    test('Delete All Observations', () async {
      await resourceDao.deleteSingleType(null,
          resourceType: R4ResourceType.Observation);

      final search = await resourceDao.getAll(null);

      expect(search.length, 2);

      final patList = search.toList();
      final orgList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);

      expect(patList.length, 1);

      expect(patList.length, 1);
    });

    test('Delete All Resources', () async {
      await resourceDao.deleteAllResources(null);

      final search = await resourceDao.getAll(null);

      expect(search.length, 0);
    });
  });

  group('Password - Saving Things:', () {
    test('Save Patient', () async {
      await resourceDao.updatePw(null, 'newPw');
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);
      final patient = Patient(id: id, name: [humanName]);
      final saved = await resourceDao.save('newPw', patient);

      expect(saved.id, id);

      expect((saved as Patient).name?[0], humanName);
    });

    test('Save Organization', () async {
      final organization = Organization(id: id, name: 'FhirFli');
      final saved = await resourceDao.save('newPw', organization);

      expect(saved.id, id);

      expect((saved as Organization).name, 'FhirFli');
    });

    test('Save Observation1', () async {
      final observation1 = Observation(
        id: Id('obs1'),
        code: CodeableConcept(text: 'Observation #1'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1');
    });

    test('Save Observation1 Again', () async {
      final observation1 = Observation(
          id: Id('obs1'),
          code: CodeableConcept(text: 'Observation #1 - Updated'));
      final saved = await resourceDao.save('newPw', observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1 - Updated');

      expect(saved.meta?.versionId, Id('2'));
    });

    test('Save Observation2', () async {
      final observation2 = Observation(
        id: Id('obs2'),
        code: CodeableConcept(text: 'Observation #2'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation2);

      expect(saved.id, Id('obs2'));

      expect((saved as Observation).code.text, 'Observation #2');
    });

    test('Save Observation3', () async {
      final observation3 = Observation(
        id: Id('obs3'),
        code: CodeableConcept(text: 'Observation #3'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation3);

      expect(saved.id, Id('obs3'));

      expect((saved as Observation).code.text, 'Observation #3');
    });
  });

  group('Password - Finding Things:', () {
    test('Find 1st Patient', () async {
      final search = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Patient, id: id);
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);

      expect(search.length, 1);

      expect((search[0] as Patient).name?[0], humanName);
    });

    test('Find 3rd Observation', () async {
      final search = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Observation, id: Id('obs3'));

      expect(search.length, 1);

      expect(search[0].id, Id('obs3'));

      expect((search[0] as Observation).code.text, 'Observation #3');
    });

    test('Find All Observations', () async {
      final search = await resourceDao.getResourceType(
        'newPw',
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 3);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), true);

      expect(idList.contains('obs3'), true);
    });

    test('Find All (non-historical) Resources', () async {
      final search = await resourceDao.getAll('newPw');

      expect(search.length, 5);
      final patList = search.toList();
      final orgList = search.toList();
      final obsList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);
      obsList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Observation);

      expect(patList.length, 1);

      expect(orgList.length, 1);

      expect(obsList.length, 3);
    });
  });

  group('Password - Deleting Things:', () {
    test('Delete 2nd Observation', () async {
      await resourceDao.delete(
          'newPw', null, R4ResourceType.Observation, Id('obs2'), null, null);

      final search = await resourceDao.getResourceType(
        'newPw',
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 2);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), false);

      expect(idList.contains('obs3'), true);
    });

    test('Delete All Observations', () async {
      await resourceDao.deleteSingleType('newPw',
          resourceType: R4ResourceType.Observation);

      final search = await resourceDao.getAll('newPw');

      expect(search.length, 2);

      final patList = search.toList();
      final orgList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);

      expect(patList.length, 1);

      expect(patList.length, 1);
    });

    test('Delete All Resources', () async {
      await resourceDao.deleteAllResources('newPw');

      final search = await resourceDao.getAll('newPw');

      expect(search.length, 0);

      await resourceDao.updatePw('newPw', null);
    });
  });
} 

Download Details:

Author: MayJuun

Source Code: https://github.com/MayJuun/fhir/tree/main/fhir_db

#sqflite  #dart  #flutter 

안 용태

안 용태

1603334400

[왕초보 무료 프로그래밍 언어 강의] [Dart] #19 - Class [#3] Inheritance

Flutter 에서 사용되는 Dart 언어 프로그래밍 왕초보용 강의입니다.

Dart 언어의 Class Inheritance (상속) 에 대해 배워보는 강의입니다.

#dart #flutter #mobile-apps

안 용태

안 용태

1604544000

[왕초보 무료 프로그래밍 언어 강의] [Dart] #21 - Class [#5] Class Static Keyword

Flutter 에서 사용되는 Dart 언어 프로그래밍 왕초보용 강의입니다.

Dart 언어의 Static Keyword 에 대해 배워보는 강의입니다.

#flutter #dart #mobile-apps

안 용태

안 용태

1598236800

[왕초보 무료 프로그래밍 언어 강의] [Dart] #3 Numbers

Flutter 에서 사용되는 Dart 언어 프로그래밍 왕초보용 강의입니다.

Dart 언어에서 사용되는 숫자 변수에 대한 강의입니다.

#dart #flutter #mobile-apps

A Dart/Flutter package for working with FHIR® resources

FHIR

A Dart/Flutter package for working with FHIR® resources. FHIR® is the registered trademark of HL7 and is used with the permission of HL7. Use of the FHIR trademark does not constitute endorsement of this product by HL7.

It contains packages for the 3 released FHIR versions:

As well as the R5 Preview #3:

Say Hello!

  • As all parts of this are new (FHIR, Flutter, using the two together), I'd love to hear from you if you're working in this space. Open to PR, suggestions or requests. You can email me at grey@fhirfli.dev. Or, feel free to join our Slack!.

Tilo

Has made a bunch of contributions to these packages so far

Has also created his own awesome Flutter package, faiadashu (pub.dev, github), so check it out!

How To Use

In order to use this package in your app, you must include the following in your pubspec.yaml file under dependencies:

dependencies:
  fhir: ^0.2.4

Or if you want to include the most recent unreleased version from Github

fhir:
  git:
    url: git://github.com/MayJuun/fhir/tree/dev/fhir

Then, in any file where you're going to be using it, simply import it like this:

import 'package:fhir/r4.dart';

Or, you may need to rename the package, for instance, there are some variables FHIR uses that overlap with dart:core, or if you're going to be using more than oen version of FHIR in the same file:

import 'package:fhir/r4.dart' as r4;
import 'package:fhir/stu3.dart' as stu3;

And then just remember to append r4 or stu3 to any variables you use from the library.

Currently this package is really just for serializing/deserializing FHIR data, and being able to create FHIR resources.

To do something like create a patient, you can do the following::

var newPatient = Patient(
  resourceType: 'Patient',
  name: [
    HumanName(family: 'LastName', given: ['FirstName'])
  ],
  birthDate: Date('2020-01-01'),
  gender: PatientGender.female,
);

If you're instead trying to get data from a server (currently I haven't implemented SMART on FHIR so it would need to be an open server, HAPI for instance - make sure you choose the right version you're interested in), a very simple example of querying and then printing the result:

Future main() async {
  var server = 'https://hapi.fhir.org/baseR4';
  var headers = {'Content-type': 'application/json'};
  var desiredResource = 'Patient';
  var response = await get('$server/$desiredResource', headers: headers);
  var searchSetBundle = Bundle.fromJson(json.decode(response.body));
  print(searchSetBundle.toJson());
}

All of the FHIR resources are immutable classes using the freezed package, which means you can take advantage of it's functionality for things like copying/updating:

  var changePatientName = newPatient.copyWith(name: [
    HumanName(family: 'NewLastName', given: ['SameFirstName'])
  ]);

Primitive Values

Primitive values are these, things like instant, string, integer, etc. Howevever, because FHIR has some definitions of how they define some of these values that differ from Dart, I've made all of them (except String) and primitiveObject. This has a couple of useful things (and one or two annoying ones). In order to make something like an integer, you have to write it like this: Integer(128) or Integer('128). Yes, a little annoying, but it prevents inappropriate formatting, especially for things like dates that are a lot trickier. You can, however, check equality without this. For instance, Integer(128) == 128 will evaluate to true.

As I was saying, dates are tricker. For Date or DateTime you're allowed to use values of 2020, 2020-06, or 2020-06-01 (written of course Date('2020-06-01')). For Instant and DateTime you're also allowed to specify hours, minutes, seconds, milliseconds. For Instant at least hour, minute and second is required. So, the way I've decided to deal with dates is to first turn them into Strings. I then see if they are a Date with the isDate function. If they are, I check if they're more or less than 10 characters. If they're less than 10 characters, I store however many characters they are, and return this number when I print it out. If they're more than 10 characters, I check if there's a space in the 10 position and replaces it with a "T" (because FHIR doesn't allow 2017-01-01 00:00:00.000Z but will allow 2017-01-01T00:00:00.000Z.) I then parse it to a DateTime and then I change it to UTC. This is also how I return the value. THIS IS IMPORTANT because it means that if you specify anything with an hour, minute, second or millisecond, whether or not you assign it a timezone, this package will still change it and output it in UTC. This is mostly because I think that makes it easier to do any calculations with, because all times are going to be in UTC. Then, all you have to do is change it to the local timezone when you display it (if you want to).

Thus
input: FhirDateTime('2015-02-07T13:28:17-05:00'), output: 2015-02-07T18:28:17.000Z
input: FhirDateTime('2015-02-07T13:28:17'), output: 2015-02-07T13:28:17.000 - you're technically supposed to have a time zone when you specify more than a simple date
input: FhirDateTime('2017-01-01T00:00:00.000Z'), output: 2017-01-01T00:00:00.000Z

UPDATE: Hooray for user input!. Working with primitives has been nagging at me for a while now, and this gave me the impetus to try and fix it. It MOSTLY shouldn't effect anyone's code. It's still going to serialize/deserialize in the same way. The difference is that now you can get the value from the field without having to fold it (I love Dartz, but I don't think I was using it the best way for these). Now, however, you can do this:

final obs = Observation(
      code: CodeableConcept(), effectiveDateTime: FhirDateTime('2020-01-01'));
print(obs.effectiveDateTime == DateTime(2020, 1, 1)); // true

Note that this only works in one direction because the classes override the == operator. This means that if you try

print(DateTime(2020, 1, 1) == obs.effectiveDateTime); // false

It will be false, because it will use the DateTime == instead.

Validation

  • For validation testing, I run all of the sample files from hl7 through a tester. There is an errors.txt file in the test folder where all of the errors are reported (the file name and then the specific field). Currently the only errors involve Codes and IDs. The Codes have to due with the fact that code is not supposed to have leading or trailing white space. The issues with the IDs are that IDs are not supposed to be more than 64 characters, and these are 65. However, if it turns out that no one wants to enforce these as strictly as I do, I may relax them. Also, for r5, there are some fields that I'm not sure if they're supposed to be lists or not, and there are a number of reference I'm not sure if I have the correct name (because the names differe on the website vs. the downloadable schema). I've kept whichever one seemed to be present in the examples.
  • For validating the toYaml() functions, I first read the map into a Resource, convert it into Yaml, convert it back into a Resource, and then use that in the validation function above.
  • There are two files that seem to have random nulls in the middle, I'm not sure why, they don't seem to serve any purpose, and they don't currently transfer into Yaml at this point.

First Package

This is the first time I've ever created a package, feedback and pull requests are welcome. I've also been started to implement type checking using Freezed. But if you run into any issues with this, either incorrect validation, or frustrating to work with returned failures, please let me know.

Code Generation

I think it's the new compiling. It's actually great though, json_serializable and freezed are used extensively throughout. In order to allow a field to contain any resource, it is passed to the resource class and is passed to a switch case statement (which feels a little clunky, but I haven't managed a better way yet). I've removed the resource.g.dart files for all versions. It didn't appear to ever be used, but did lose me points on pub.dev. But if it changes your functionality, please let me know. It will state that there's an error when you run code generation however.

[WARNING] json_serializable:json_serializable on lib/dstu2/basic_types/resource.dart:
Missing "part 'resource.g.dart';".

Formatting Notes

  • Class names: upper camel case.
  • Variables: lower camel case.
  • File names: snake case.
  • FHIR nested classes (including enums) listed under the primary class
  • There are a number of FHIR fields that are reserved words in Dart. For these, I have added a '_' to the end of the field. (note that this does not change the json format, as when that happens the @JsonKey has been added to the field like so:
@JsonKey(name: 'extension') List<FhirExtension> extension_,

A couple special notes about DSTU2

  • Because Dstu2 is not formatted as well as the newer versions, a number of the names end up being extremely long. What I have decided to do is the following:
    • If the field/class id in the schema is a single word("id": "integer" or "id": "ValueSet"), that word is used as the field or class name.
    • If the id is more than a single word AND it is a primitive type ("id": "ValueSet.expansion.contains.display" which is a string), the last word is used as the type, in this case the field would be: String display
    • If the id is 2 words and is NOT a primitive type ("id": "ValueSet.expansion"), the type is the two words combined with upper camel case, and the field is the last word: ValueSetExpansion expansion
    • if the id is more than 2 words and NOT a primitive type ("id": "TestScript.setup.action.operation.requestHeader"), the type is the first, next to last and last word combined with upper camel case, and the field is the last word: TestScriptOperationRequestHeader requestHeader
  • Many of the element fields I have included because they are included as part of the test resources. I could not find a full list online, so there may still be some element fields that I have missed.

FHIR datatypes (these are R4 (which is what everyone should be using, but since EHR vendors are doing everything they can to not share data, I am also working on stu3 and dstu2 as well)

The full resource lists I've decided it's not worth upkeeping since HL7 does that already.

Resource Index Dstu2

Resource Index Stu3

Resource Index R4

Resource Index R5 Preview #3

FHIR® is a registered trademark of Health Level Seven International (HL7) and its use does not constitute an endorsement of products by HL7®

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add fhir

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):


dependencies:
  fhir: ^0.4.7

Alternatively, your editor might support dart pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:fhir/dstu2.dart';
import 'package:fhir/dstu2/basic_types/basic_types.dart';
import 'package:fhir/dstu2/basic_types/element.dart';
import 'package:fhir/dstu2/basic_types/element.freezed.dart';
import 'package:fhir/dstu2/basic_types/element.g.dart';
import 'package:fhir/dstu2/basic_types/fhir_extension.dart';
import 'package:fhir/dstu2/basic_types/fhir_extension.freezed.dart';
import 'package:fhir/dstu2/basic_types/fhir_extension.g.dart';
import 'package:fhir/dstu2/dstu2.dart';
import 'package:fhir/dstu2/general_types/general_types.dart';
import 'package:fhir/dstu2/general_types/general_types.enums.dart';
import 'package:fhir/dstu2/general_types/general_types.freezed.dart';
import 'package:fhir/dstu2/general_types/general_types.g.dart';
import 'package:fhir/dstu2/resource/resource.dart';
import 'package:fhir/dstu2/resource/resource.g.dart';
import 'package:fhir/dstu2/resource/resource_from_json.dart';
import 'package:fhir/dstu2/resource/resource_new_version.dart';
import 'package:fhir/dstu2/resource/resource_type_enum.dart';
import 'package:fhir/dstu2/resource/resource_utils.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/care_provision/care_provision.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/care_provision/care_provision.enums.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/care_provision/care_provision.freezed.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/care_provision/care_provision.g.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/clinical_types.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/diagnostics/diagnostics.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/diagnostics/diagnostics.enums.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/diagnostics/diagnostics.freezed.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/diagnostics/diagnostics.g.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/general/general.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/general/general.enums.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/general/general.freezed.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/general/general.g.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/medication_and_immunization/medication_and_immunization.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/medication_and_immunization/medication_and_immunization.enums.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/medication_and_immunization/medication_and_immunization.freezed.dart';
import 'package:fhir/dstu2/resource_types/clinical_types/medication_and_immunization/medication_and_immunization.g.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/conformance_types.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/content/content.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/content/content.enums.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/content/content.freezed.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/content/content.g.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/misc/misc.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/misc/misc.enums.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/misc/misc.freezed.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/misc/misc.g.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/operations_control/operations_control.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/operations_control/operations_control.enums.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/operations_control/operations_control.freezed.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/operations_control/operations_control.g.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/terminology/terminology.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/terminology/terminology.enums.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/terminology/terminology.freezed.dart';
import 'package:fhir/dstu2/resource_types/conformance_types/terminology/terminology.g.dart';
import 'package:fhir/dstu2/resource_types/financial_types/billing/billing.dart';
import 'package:fhir/dstu2/resource_types/financial_types/billing/billing.enums.dart';
import 'package:fhir/dstu2/resource_types/financial_types/billing/billing.freezed.dart';
import 'package:fhir/dstu2/resource_types/financial_types/billing/billing.g.dart';
import 'package:fhir/dstu2/resource_types/financial_types/financial_types.dart';
import 'package:fhir/dstu2/resource_types/financial_types/other/other.dart';
import 'package:fhir/dstu2/resource_types/financial_types/other/other.enums.dart';
import 'package:fhir/dstu2/resource_types/financial_types/other/other.freezed.dart';
import 'package:fhir/dstu2/resource_types/financial_types/other/other.g.dart';
import 'package:fhir/dstu2/resource_types/financial_types/payment/payment.dart';
import 'package:fhir/dstu2/resource_types/financial_types/payment/payment.enums.dart';
import 'package:fhir/dstu2/resource_types/financial_types/payment/payment.freezed.dart';
import 'package:fhir/dstu2/resource_types/financial_types/payment/payment.g.dart';
import 'package:fhir/dstu2/resource_types/financial_types/support/support.dart';
import 'package:fhir/dstu2/resource_types/financial_types/support/support.enums.dart';
import 'package:fhir/dstu2/resource_types/financial_types/support/support.freezed.dart';
import 'package:fhir/dstu2/resource_types/financial_types/support/support.g.dart';
import 'package:fhir/dstu2/resource_types/identification_types/devices/devices.dart';
import 'package:fhir/dstu2/resource_types/identification_types/devices/devices.enums.dart';
import 'package:fhir/dstu2/resource_types/identification_types/devices/devices.freezed.dart';
import 'package:fhir/dstu2/resource_types/identification_types/devices/devices.g.dart';
import 'package:fhir/dstu2/resource_types/identification_types/entities/entities.dart';
import 'package:fhir/dstu2/resource_types/identification_types/entities/entities.enums.dart';
import 'package:fhir/dstu2/resource_types/identification_types/entities/entities.freezed.dart';
import 'package:fhir/dstu2/resource_types/identification_types/entities/entities.g.dart';
import 'package:fhir/dstu2/resource_types/identification_types/groups/groups.dart';
import 'package:fhir/dstu2/resource_types/identification_types/groups/groups.enums.dart';
import 'package:fhir/dstu2/resource_types/identification_types/groups/groups.freezed.dart';
import 'package:fhir/dstu2/resource_types/identification_types/groups/groups.g.dart';
import 'package:fhir/dstu2/resource_types/identification_types/identification_types.dart';
import 'package:fhir/dstu2/resource_types/identification_types/individuals/individuals.dart';
import 'package:fhir/dstu2/resource_types/identification_types/individuals/individuals.enums.dart';
import 'package:fhir/dstu2/resource_types/identification_types/individuals/individuals.freezed.dart';
import 'package:fhir/dstu2/resource_types/identification_types/individuals/individuals.g.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/documents_and_lists/documents_and_lists.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/documents_and_lists/documents_and_lists.enums.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/documents_and_lists/documents_and_lists.freezed.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/documents_and_lists/documents_and_lists.g.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/exchange/exchange.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/exchange/exchange.enums.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/exchange/exchange.freezed.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/exchange/exchange.g.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/information_tracking/information_tracking.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/information_tracking/information_tracking.enums.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/information_tracking/information_tracking.freezed.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/information_tracking/information_tracking.g.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/infrastructure_types.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/structure/structure.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/structure/structure.enums.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/structure/structure.freezed.dart';
import 'package:fhir/dstu2/resource_types/infrastructure_types/structure/structure.g.dart';
import 'package:fhir/dstu2/resource_types/resource_types.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/patient_management/patient_management.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/patient_management/patient_management.enums.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/patient_management/patient_management.freezed.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/patient_management/patient_management.g.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/scheduling/scheduling.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/scheduling/scheduling.enums.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/scheduling/scheduling.freezed.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/scheduling/scheduling.g.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow1/workflow1.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow1/workflow1.enums.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow1/workflow1.freezed.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow1/workflow1.g.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow2/workflow2.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow2/workflow2.enums.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow2/workflow2.freezed.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow2/workflow2.g.dart';
import 'package:fhir/dstu2/resource_types/workflow_types/workflow_types.dart';
import 'package:fhir/dstu2/special_types/special_types.dart';
import 'package:fhir/dstu2/special_types/special_types.enums.dart';
import 'package:fhir/dstu2/special_types/special_types.freezed.dart';
import 'package:fhir/dstu2/special_types/special_types.g.dart';
import 'package:fhir/primitive_types/base64binary.dart';
import 'package:fhir/primitive_types/boolean.dart';
import 'package:fhir/primitive_types/canonical.dart';
import 'package:fhir/primitive_types/code.dart';
import 'package:fhir/primitive_types/date.dart';
import 'package:fhir/primitive_types/decimal.dart';
import 'package:fhir/primitive_types/fhir_date_time.dart';
import 'package:fhir/primitive_types/fhir_uri.dart';
import 'package:fhir/primitive_types/fhir_url.dart';
import 'package:fhir/primitive_types/id.dart';
import 'package:fhir/primitive_types/instant.dart';
import 'package:fhir/primitive_types/integer.dart';
import 'package:fhir/primitive_types/integer64.dart';
import 'package:fhir/primitive_types/markdown.dart';
import 'package:fhir/primitive_types/oid.dart';
import 'package:fhir/primitive_types/positive_int.dart';
import 'package:fhir/primitive_types/primitive_types.dart';
import 'package:fhir/primitive_types/time.dart';
import 'package:fhir/primitive_types/unsigned_int.dart';
import 'package:fhir/primitive_types/uuid.dart';
import 'package:fhir/r4.dart';
import 'package:fhir/r4/basic_types/basic_types.dart';
import 'package:fhir/r4/basic_types/element.dart';
import 'package:fhir/r4/basic_types/element.freezed.dart';
import 'package:fhir/r4/basic_types/element.g.dart';
import 'package:fhir/r4/basic_types/fhir_extension.dart';
import 'package:fhir/r4/basic_types/fhir_extension.freezed.dart';
import 'package:fhir/r4/basic_types/fhir_extension.g.dart';
import 'package:fhir/r4/draft_types/draft_types.dart';
import 'package:fhir/r4/draft_types/draft_types.freezed.dart';
import 'package:fhir/r4/draft_types/draft_types.g.dart';
import 'package:fhir/r4/general_types/general_types.dart';
import 'package:fhir/r4/general_types/general_types.enums.dart';
import 'package:fhir/r4/general_types/general_types.freezed.dart';
import 'package:fhir/r4/general_types/general_types.g.dart';
import 'package:fhir/r4/metadata_types/metadata_types.dart';
import 'package:fhir/r4/metadata_types/metadata_types.enums.dart';
import 'package:fhir/r4/metadata_types/metadata_types.freezed.dart';
import 'package:fhir/r4/metadata_types/metadata_types.g.dart';
import 'package:fhir/r4/r4.dart';
import 'package:fhir/r4/resource/resource.dart';
import 'package:fhir/r4/resource/resource.g.dart';
import 'package:fhir/r4/resource/resource_from_json.dart';
import 'package:fhir/r4/resource/resource_new_version.dart';
import 'package:fhir/r4/resource/resource_types_enum.dart';
import 'package:fhir/r4/resource/resource_utils.dart';
import 'package:fhir/r4/resource_types/base/base.dart';
import 'package:fhir/r4/resource_types/base/entities1/entities1.dart';
import 'package:fhir/r4/resource_types/base/entities1/entities1.enums.dart';
import 'package:fhir/r4/resource_types/base/entities1/entities1.freezed.dart';
import 'package:fhir/r4/resource_types/base/entities1/entities1.g.dart';
import 'package:fhir/r4/resource_types/base/entities2/entities2.dart';
import 'package:fhir/r4/resource_types/base/entities2/entities2.enums.dart';
import 'package:fhir/r4/resource_types/base/entities2/entities2.freezed.dart';
import 'package:fhir/r4/resource_types/base/entities2/entities2.g.dart';
import 'package:fhir/r4/resource_types/base/individuals/individuals.dart';
import 'package:fhir/r4/resource_types/base/individuals/individuals.enums.dart';
import 'package:fhir/r4/resource_types/base/individuals/individuals.freezed.dart';
import 'package:fhir/r4/resource_types/base/individuals/individuals.g.dart';
import 'package:fhir/r4/resource_types/base/management/management.dart';
import 'package:fhir/r4/resource_types/base/management/management.enums.dart';
import 'package:fhir/r4/resource_types/base/management/management.freezed.dart';
import 'package:fhir/r4/resource_types/base/management/management.g.dart';
import 'package:fhir/r4/resource_types/base/workflow/workflow.dart';
import 'package:fhir/r4/resource_types/base/workflow/workflow.enums.dart';
import 'package:fhir/r4/resource_types/base/workflow/workflow.freezed.dart';
import 'package:fhir/r4/resource_types/base/workflow/workflow.g.dart';
import 'package:fhir/r4/resource_types/clinical/care_provision/care_provision.dart';
import 'package:fhir/r4/resource_types/clinical/care_provision/care_provision.enums.dart';
import 'package:fhir/r4/resource_types/clinical/care_provision/care_provision.freezed.dart';
import 'package:fhir/r4/resource_types/clinical/care_provision/care_provision.g.dart';
import 'package:fhir/r4/resource_types/clinical/clinical.dart';
import 'package:fhir/r4/resource_types/clinical/diagnostics/diagnostics.dart';
import 'package:fhir/r4/resource_types/clinical/diagnostics/diagnostics.enums.dart';
import 'package:fhir/r4/resource_types/clinical/diagnostics/diagnostics.freezed.dart';
import 'package:fhir/r4/resource_types/clinical/diagnostics/diagnostics.g.dart';
import 'package:fhir/r4/resource_types/clinical/medications/medications.dart';
import 'package:fhir/r4/resource_types/clinical/medications/medications.freezed.dart';
import 'package:fhir/r4/resource_types/clinical/medications/medications.g.dart';
import 'package:fhir/r4/resource_types/clinical/request_and_response/request_and_response.dart';
import 'package:fhir/r4/resource_types/clinical/request_and_response/request_and_response.enums.dart';
import 'package:fhir/r4/resource_types/clinical/request_and_response/request_and_response.freezed.dart';
import 'package:fhir/r4/resource_types/clinical/request_and_response/request_and_response.g.dart';
import 'package:fhir/r4/resource_types/clinical/summary/summary.dart';
import 'package:fhir/r4/resource_types/clinical/summary/summary.enums.dart';
import 'package:fhir/r4/resource_types/clinical/summary/summary.freezed.dart';
import 'package:fhir/r4/resource_types/clinical/summary/summary.g.dart';
import 'package:fhir/r4/resource_types/financial/billing/billing.dart';
import 'package:fhir/r4/resource_types/financial/billing/billing.enums.dart';
import 'package:fhir/r4/resource_types/financial/billing/billing.freezed.dart';
import 'package:fhir/r4/resource_types/financial/billing/billing.g.dart';
import 'package:fhir/r4/resource_types/financial/financial.dart';
import 'package:fhir/r4/resource_types/financial/general/general.dart';
import 'package:fhir/r4/resource_types/financial/general/general.enums.dart';
import 'package:fhir/r4/resource_types/financial/general/general.freezed.dart';
import 'package:fhir/r4/resource_types/financial/general/general.g.dart';
import 'package:fhir/r4/resource_types/financial/payment/payment.dart';
import 'package:fhir/r4/resource_types/financial/payment/payment.enums.dart';
import 'package:fhir/r4/resource_types/financial/payment/payment.freezed.dart';
import 'package:fhir/r4/resource_types/financial/payment/payment.g.dart';
import 'package:fhir/r4/resource_types/financial/support/support.dart';
import 'package:fhir/r4/resource_types/financial/support/support.enums.dart';
import 'package:fhir/r4/resource_types/financial/support/support.freezed.dart';
import 'package:fhir/r4/resource_types/financial/support/support.g.dart';
import 'package:fhir/r4/resource_types/foundation/conformance/conformance.dart';
import 'package:fhir/r4/resource_types/foundation/conformance/conformance.enums.dart';
import 'package:fhir/r4/resource_types/foundation/conformance/conformance.freezed.dart';
import 'package:fhir/r4/resource_types/foundation/conformance/conformance.g.dart';
import 'package:fhir/r4/resource_types/foundation/documents/documents.dart';
import 'package:fhir/r4/resource_types/foundation/documents/documents.enums.dart';
import 'package:fhir/r4/resource_types/foundation/documents/documents.freezed.dart';
import 'package:fhir/r4/resource_types/foundation/documents/documents.g.dart';
import 'package:fhir/r4/resource_types/foundation/foundation.dart';
import 'package:fhir/r4/resource_types/foundation/other/other.dart';
import 'package:fhir/r4/resource_types/foundation/other/other.enums.dart';
import 'package:fhir/r4/resource_types/foundation/other/other.freezed.dart';
import 'package:fhir/r4/resource_types/foundation/other/other.g.dart';
import 'package:fhir/r4/resource_types/foundation/security/security.dart';
import 'package:fhir/r4/resource_types/foundation/security/security.enums.dart';
import 'package:fhir/r4/resource_types/foundation/security/security.freezed.dart';
import 'package:fhir/r4/resource_types/foundation/security/security.g.dart';
import 'package:fhir/r4/resource_types/foundation/terminology/terminology.dart';
import 'package:fhir/r4/resource_types/foundation/terminology/terminology.enums.dart';
import 'package:fhir/r4/resource_types/foundation/terminology/terminology.freezed.dart';
import 'package:fhir/r4/resource_types/foundation/terminology/terminology.g.dart';
import 'package:fhir/r4/resource_types/resource_types.dart';
import 'package:fhir/r4/resource_types/specialized/definitional_artifacts/definitional_artifacts.dart';
import 'package:fhir/r4/resource_types/specialized/definitional_artifacts/definitional_artifacts.enums.dart';
import 'package:fhir/r4/resource_types/specialized/definitional_artifacts/definitional_artifacts.freezed.dart';
import 'package:fhir/r4/resource_types/specialized/definitional_artifacts/definitional_artifacts.g.dart';
import 'package:fhir/r4/resource_types/specialized/evidence_based_medicine/evidence_based_medicine.dart';
import 'package:fhir/r4/resource_types/specialized/evidence_based_medicine/evidence_based_medicine.enums.dart';
import 'package:fhir/r4/resource_types/specialized/evidence_based_medicine/evidence_based_medicine.freezed.dart';
import 'package:fhir/r4/resource_types/specialized/evidence_based_medicine/evidence_based_medicine.g.dart';
import 'package:fhir/r4/resource_types/specialized/medication_definition/medication_definition.dart';
import 'package:fhir/r4/resource_types/specialized/medication_definition/medication_definition.freezed.dart';
import 'package:fhir/r4/resource_types/specialized/medication_definition/medication_definition.g.dart';
import 'package:fhir/r4/resource_types/specialized/public_health_and_research/public_health_and_research.dart';
import 'package:fhir/r4/resource_types/specialized/public_health_and_research/public_health_and_research.enums.dart';
import 'package:fhir/r4/resource_types/specialized/public_health_and_research/public_health_and_research.freezed.dart';
import 'package:fhir/r4/resource_types/specialized/public_health_and_research/public_health_and_research.g.dart';
import 'package:fhir/r4/resource_types/specialized/quality_reporting_and_testing/quality_reporting_and_testing.dart';
import 'package:fhir/r4/resource_types/specialized/quality_reporting_and_testing/quality_reporting_and_testing.enums.dart';
import 'package:fhir/r4/resource_types/specialized/quality_reporting_and_testing/quality_reporting_and_testing.freezed.dart';
import 'package:fhir/r4/resource_types/specialized/quality_reporting_and_testing/quality_reporting_and_testing.g.dart';
import 'package:fhir/r4/resource_types/specialized/specialized.dart';
import 'package:fhir/r4/special_types/special_types.dart';
import 'package:fhir/r4/special_types/special_types.enums.dart';
import 'package:fhir/r4/special_types/special_types.freezed.dart';
import 'package:fhir/r4/special_types/special_types.g.dart';
import 'package:fhir/r5.dart';
import 'package:fhir/r5/basic_types/basic_types.dart';
import 'package:fhir/r5/basic_types/element.dart';
import 'package:fhir/r5/basic_types/element.freezed.dart';
import 'package:fhir/r5/basic_types/element.g.dart';
import 'package:fhir/r5/basic_types/fhir_extension.dart';
import 'package:fhir/r5/basic_types/fhir_extension.freezed.dart';
import 'package:fhir/r5/basic_types/fhir_extension.g.dart';
import 'package:fhir/r5/draft_types/draft_types.dart';
import 'package:fhir/r5/draft_types/draft_types.enums.dart';
import 'package:fhir/r5/draft_types/draft_types.freezed.dart';
import 'package:fhir/r5/draft_types/draft_types.g.dart';
import 'package:fhir/r5/general_types/general_types.dart';
import 'package:fhir/r5/general_types/general_types.enums.dart';
import 'package:fhir/r5/general_types/general_types.freezed.dart';
import 'package:fhir/r5/general_types/general_types.g.dart';
import 'package:fhir/r5/metadata_types/metadata_types.dart';
import 'package:fhir/r5/metadata_types/metadata_types.enums.dart';
import 'package:fhir/r5/metadata_types/metadata_types.freezed.dart';
import 'package:fhir/r5/metadata_types/metadata_types.g.dart';
import 'package:fhir/r5/r5.dart';
import 'package:fhir/r5/resource/resource.dart';
import 'package:fhir/r5/resource/resource.g.dart';
import 'package:fhir/r5/resource/resource_from_json.dart';
import 'package:fhir/r5/resource/resource_new_version.dart';
import 'package:fhir/r5/resource/resource_types_enum.dart';
import 'package:fhir/r5/resource/resource_utils.dart';
import 'package:fhir/r5/resource_types/base/base.dart';
import 'package:fhir/r5/resource_types/base/entities1/entities1.dart';
import 'package:fhir/r5/resource_types/base/entities1/entities1.enums.dart';
import 'package:fhir/r5/resource_types/base/entities1/entities1.freezed.dart';
import 'package:fhir/r5/resource_types/base/entities1/entities1.g.dart';
import 'package:fhir/r5/resource_types/base/entities2/entities2.dart';
import 'package:fhir/r5/resource_types/base/entities2/entities2.enums.dart';
import 'package:fhir/r5/resource_types/base/entities2/entities2.freezed.dart';
import 'package:fhir/r5/resource_types/base/entities2/entities2.g.dart';
import 'package:fhir/r5/resource_types/base/individuals/individuals.dart';
import 'package:fhir/r5/resource_types/base/individuals/individuals.enums.dart';
import 'package:fhir/r5/resource_types/base/individuals/individuals.freezed.dart';
import 'package:fhir/r5/resource_types/base/individuals/individuals.g.dart';
import 'package:fhir/r5/resource_types/base/management/management.dart';
import 'package:fhir/r5/resource_types/base/management/management.enums.dart';
import 'package:fhir/r5/resource_types/base/management/management.freezed.dart';
import 'package:fhir/r5/resource_types/base/management/management.g.dart';
import 'package:fhir/r5/resource_types/base/workflow/workflow.dart';
import 'package:fhir/r5/resource_types/base/workflow/workflow.enums.dart';
import 'package:fhir/r5/resource_types/base/workflow/workflow.freezed.dart';
import 'package:fhir/r5/resource_types/base/workflow/workflow.g.dart';
import 'package:fhir/r5/resource_types/clinical/care_provision/care_provision.dart';
import 'package:fhir/r5/resource_types/clinical/care_provision/care_provision.enums.dart';
import 'package:fhir/r5/resource_types/clinical/care_provision/care_provision.freezed.dart';
import 'package:fhir/r5/resource_types/clinical/care_provision/care_provision.g.dart';
import 'package:fhir/r5/resource_types/clinical/clinical.dart';
import 'package:fhir/r5/resource_types/clinical/diagnostics/diagnostics.dart';
import 'package:fhir/r5/resource_types/clinical/diagnostics/diagnostics.enums.dart';
import 'package:fhir/r5/resource_types/clinical/diagnostics/diagnostics.freezed.dart';
import 'package:fhir/r5/resource_types/clinical/diagnostics/diagnostics.g.dart';
import 'package:fhir/r5/resource_types/clinical/medications/medications.dart';
import 'package:fhir/r5/resource_types/clinical/medications/medications.freezed.dart';
import 'package:fhir/r5/resource_types/clinical/medications/medications.g.dart';
import 'package:fhir/r5/resource_types/clinical/request_and_response/request_and_response.dart';
import 'package:fhir/r5/resource_types/clinical/request_and_response/request_and_response.enums.dart';
import 'package:fhir/r5/resource_types/clinical/request_and_response/request_and_response.freezed.dart';
import 'package:fhir/r5/resource_types/clinical/request_and_response/request_and_response.g.dart';
import 'package:fhir/r5/resource_types/clinical/summary/summary.dart';
import 'package:fhir/r5/resource_types/clinical/summary/summary.enums.dart';
import 'package:fhir/r5/resource_types/clinical/summary/summary.freezed.dart';
import 'package:fhir/r5/resource_types/clinical/summary/summary.g.dart';
import 'package:fhir/r5/resource_types/financial/billing/billing.dart';
import 'package:fhir/r5/resource_types/financial/billing/billing.enums.dart';
import 'package:fhir/r5/resource_types/financial/billing/billing.freezed.dart';
import 'package:fhir/r5/resource_types/financial/billing/billing.g.dart';
import 'package:fhir/r5/resource_types/financial/financial.dart';
import 'package:fhir/r5/resource_types/financial/general/general.dart';
import 'package:fhir/r5/resource_types/financial/general/general.enums.dart';
import 'package:fhir/r5/resource_types/financial/general/general.freezed.dart';
import 'package:fhir/r5/resource_types/financial/general/general.g.dart';
import 'package:fhir/r5/resource_types/financial/payment/payment.dart';
import 'package:fhir/r5/resource_types/financial/payment/payment.enums.dart';
import 'package:fhir/r5/resource_types/financial/payment/payment.freezed.dart';
import 'package:fhir/r5/resource_types/financial/payment/payment.g.dart';
import 'package:fhir/r5/resource_types/financial/support/support.dart';
import 'package:fhir/r5/resource_types/financial/support/support.enums.dart';
import 'package:fhir/r5/resource_types/financial/support/support.freezed.dart';
import 'package:fhir/r5/resource_types/financial/support/support.g.dart';
import 'package:fhir/r5/resource_types/foundation/conformance/conformance.dart';
import 'package:fhir/r5/resource_types/foundation/conformance/conformance.enums.dart';
import 'package:fhir/r5/resource_types/foundation/conformance/conformance.freezed.dart';
import 'package:fhir/r5/resource_types/foundation/conformance/conformance.g.dart';
import 'package:fhir/r5/resource_types/foundation/documents/documents.dart';
import 'package:fhir/r5/resource_types/foundation/documents/documents.enums.dart';
import 'package:fhir/r5/resource_types/foundation/documents/documents.freezed.dart';
import 'package:fhir/r5/resource_types/foundation/documents/documents.g.dart';
import 'package:fhir/r5/resource_types/foundation/foundation.dart';
import 'package:fhir/r5/resource_types/foundation/other/other.dart';
import 'package:fhir/r5/resource_types/foundation/other/other.enums.dart';
import 'package:fhir/r5/resource_types/foundation/other/other.freezed.dart';
import 'package:fhir/r5/resource_types/foundation/other/other.g.dart';
import 'package:fhir/r5/resource_types/foundation/security/security.dart';
import 'package:fhir/r5/resource_types/foundation/security/security.enums.dart';
import 'package:fhir/r5/resource_types/foundation/security/security.freezed.dart';
import 'package:fhir/r5/resource_types/foundation/security/security.g.dart';
import 'package:fhir/r5/resource_types/foundation/terminology/terminology.dart';
import 'package:fhir/r5/resource_types/foundation/terminology/terminology.enums.dart';
import 'package:fhir/r5/resource_types/foundation/terminology/terminology.freezed.dart';
import 'package:fhir/r5/resource_types/foundation/terminology/terminology.g.dart';
import 'package:fhir/r5/resource_types/resource_types.dart';
import 'package:fhir/r5/resource_types/specialized/definitional_artifacts/definitional_artifacts.dart';
import 'package:fhir/r5/resource_types/specialized/definitional_artifacts/definitional_artifacts.enums.dart';
import 'package:fhir/r5/resource_types/specialized/definitional_artifacts/definitional_artifacts.freezed.dart';
import 'package:fhir/r5/resource_types/specialized/definitional_artifacts/definitional_artifacts.g.dart';
import 'package:fhir/r5/resource_types/specialized/evidence_based_medicine/evidence_based_medicine.dart';
import 'package:fhir/r5/resource_types/specialized/evidence_based_medicine/evidence_based_medicine.enums.dart';
import 'package:fhir/r5/resource_types/specialized/evidence_based_medicine/evidence_based_medicine.freezed.dart';
import 'package:fhir/r5/resource_types/specialized/evidence_based_medicine/evidence_based_medicine.g.dart';
import 'package:fhir/r5/resource_types/specialized/medication_definition/medication_definition.dart';
import 'package:fhir/r5/resource_types/specialized/medication_definition/medication_definition.enums.dart';
import 'package:fhir/r5/resource_types/specialized/medication_definition/medication_definition.freezed.dart';
import 'package:fhir/r5/resource_types/specialized/medication_definition/medication_definition.g.dart';
import 'package:fhir/r5/resource_types/specialized/public_health_and_research/public_health_and_research.dart';
import 'package:fhir/r5/resource_types/specialized/public_health_and_research/public_health_and_research.enums.dart';
import 'package:fhir/r5/resource_types/specialized/public_health_and_research/public_health_and_research.freezed.dart';
import 'package:fhir/r5/resource_types/specialized/public_health_and_research/public_health_and_research.g.dart';
import 'package:fhir/r5/resource_types/specialized/quality_reporting_and_testing/quality_reporting_and_testing.dart';
import 'package:fhir/r5/resource_types/specialized/quality_reporting_and_testing/quality_reporting_and_testing.enums.dart';
import 'package:fhir/r5/resource_types/specialized/quality_reporting_and_testing/quality_reporting_and_testing.freezed.dart';
import 'package:fhir/r5/resource_types/specialized/quality_reporting_and_testing/quality_reporting_and_testing.g.dart';
import 'package:fhir/r5/resource_types/specialized/specialized.dart';
import 'package:fhir/r5/special_types/special_types.dart';
import 'package:fhir/r5/special_types/special_types.enums.dart';
import 'package:fhir/r5/special_types/special_types.freezed.dart';
import 'package:fhir/r5/special_types/special_types.g.dart';
import 'package:fhir/stu3.dart';
import 'package:fhir/stu3/basic_types/basic_types.dart';
import 'package:fhir/stu3/basic_types/element.dart';
import 'package:fhir/stu3/basic_types/element.freezed.dart';
import 'package:fhir/stu3/basic_types/element.g.dart';
import 'package:fhir/stu3/basic_types/fhir_extension.dart';
import 'package:fhir/stu3/basic_types/fhir_extension.freezed.dart';
import 'package:fhir/stu3/basic_types/fhir_extension.g.dart';
import 'package:fhir/stu3/general_types/general_types.dart';
import 'package:fhir/stu3/general_types/general_types.enums.dart';
import 'package:fhir/stu3/general_types/general_types.freezed.dart';
import 'package:fhir/stu3/general_types/general_types.g.dart';
import 'package:fhir/stu3/metadata_types/metadata_types.dart';
import 'package:fhir/stu3/metadata_types/metadata_types.enums.dart';
import 'package:fhir/stu3/metadata_types/metadata_types.freezed.dart';
import 'package:fhir/stu3/metadata_types/metadata_types.g.dart';
import 'package:fhir/stu3/resource/resource.dart';
import 'package:fhir/stu3/resource/resource.g.dart';
import 'package:fhir/stu3/resource/resource_from_json.dart';
import 'package:fhir/stu3/resource/resource_new_version.dart';
import 'package:fhir/stu3/resource/resource_types_enum.dart';
import 'package:fhir/stu3/resource/resource_utils.dart';
import 'package:fhir/stu3/resource_types/base/base.dart';
import 'package:fhir/stu3/resource_types/base/entities/entities.dart';
import 'package:fhir/stu3/resource_types/base/entities/entities.enums.dart';
import 'package:fhir/stu3/resource_types/base/entities/entities.freezed.dart';
import 'package:fhir/stu3/resource_types/base/entities/entities.g.dart';
import 'package:fhir/stu3/resource_types/base/individuals/individuals.dart';
import 'package:fhir/stu3/resource_types/base/individuals/individuals.enums.dart';
import 'package:fhir/stu3/resource_types/base/individuals/individuals.freezed.dart';
import 'package:fhir/stu3/resource_types/base/individuals/individuals.g.dart';
import 'package:fhir/stu3/resource_types/base/management/management.dart';
import 'package:fhir/stu3/resource_types/base/management/management.enums.dart';
import 'package:fhir/stu3/resource_types/base/management/management.freezed.dart';
import 'package:fhir/stu3/resource_types/base/management/management.g.dart';
import 'package:fhir/stu3/resource_types/base/workflow/workflow.dart';
import 'package:fhir/stu3/resource_types/base/workflow/workflow.enums.dart';
import 'package:fhir/stu3/resource_types/base/workflow/workflow.freezed.dart';
import 'package:fhir/stu3/resource_types/base/workflow/workflow.g.dart';
import 'package:fhir/stu3/resource_types/clinical/care_provision/care_provision.dart';
import 'package:fhir/stu3/resource_types/clinical/care_provision/care_provision.enums.dart';
import 'package:fhir/stu3/resource_types/clinical/care_provision/care_provision.freezed.dart';
import 'package:fhir/stu3/resource_types/clinical/care_provision/care_provision.g.dart';
import 'package:fhir/stu3/resource_types/clinical/clinical.dart';
import 'package:fhir/stu3/resource_types/clinical/diagnostics/diagnostics.dart';
import 'package:fhir/stu3/resource_types/clinical/diagnostics/diagnostics.enums.dart';
import 'package:fhir/stu3/resource_types/clinical/diagnostics/diagnostics.freezed.dart';
import 'package:fhir/stu3/resource_types/clinical/diagnostics/diagnostics.g.dart';
import 'package:fhir/stu3/resource_types/clinical/medications/medications.dart';
import 'package:fhir/stu3/resource_types/clinical/medications/medications.enums.dart';
import 'package:fhir/stu3/resource_types/clinical/medications/medications.freezed.dart';
import 'package:fhir/stu3/resource_types/clinical/medications/medications.g.dart';
import 'package:fhir/stu3/resource_types/clinical/request_and_response/request_and_response.dart';
import 'package:fhir/stu3/resource_types/clinical/request_and_response/request_and_response.enums.dart';
import 'package:fhir/stu3/resource_types/clinical/request_and_response/request_and_response.freezed.dart';
import 'package:fhir/stu3/resource_types/clinical/request_and_response/request_and_response.g.dart';
import 'package:fhir/stu3/resource_types/clinical/summary/summary.dart';
import 'package:fhir/stu3/resource_types/clinical/summary/summary.enums.dart';
import 'package:fhir/stu3/resource_types/clinical/summary/summary.freezed.dart';
import 'package:fhir/stu3/resource_types/clinical/summary/summary.g.dart';
import 'package:fhir/stu3/resource_types/financial/billing/billing.dart';
import 'package:fhir/stu3/resource_types/financial/billing/billing.enums.dart';
import 'package:fhir/stu3/resource_types/financial/billing/billing.freezed.dart';
import 'package:fhir/stu3/resource_types/financial/billing/billing.g.dart';
import 'package:fhir/stu3/resource_types/financial/financial.dart';
import 'package:fhir/stu3/resource_types/financial/general/general.dart';
import 'package:fhir/stu3/resource_types/financial/general/general.enums.dart';
import 'package:fhir/stu3/resource_types/financial/general/general.freezed.dart';
import 'package:fhir/stu3/resource_types/financial/general/general.g.dart';
import 'package:fhir/stu3/resource_types/financial/payment/payment.dart';
import 'package:fhir/stu3/resource_types/financial/payment/payment.enums.dart';
import 'package:fhir/stu3/resource_types/financial/payment/payment.freezed.dart';
import 'package:fhir/stu3/resource_types/financial/payment/payment.g.dart';
import 'package:fhir/stu3/resource_types/financial/support/support.dart';
import 'package:fhir/stu3/resource_types/financial/support/support.enums.dart';
import 'package:fhir/stu3/resource_types/financial/support/support.freezed.dart';
import 'package:fhir/stu3/resource_types/financial/support/support.g.dart';
import 'package:fhir/stu3/resource_types/foundation/conformance/conformance.dart';
import 'package:fhir/stu3/resource_types/foundation/conformance/conformance.enums.dart';
import 'package:fhir/stu3/resource_types/foundation/conformance/conformance.freezed.dart';
import 'package:fhir/stu3/resource_types/foundation/conformance/conformance.g.dart';
import 'package:fhir/stu3/resource_types/foundation/documents/documents.dart';
import 'package:fhir/stu3/resource_types/foundation/documents/documents.enums.dart';
import 'package:fhir/stu3/resource_types/foundation/documents/documents.freezed.dart';
import 'package:fhir/stu3/resource_types/foundation/documents/documents.g.dart';
import 'package:fhir/stu3/resource_types/foundation/foundation.dart';
import 'package:fhir/stu3/resource_types/foundation/other/other.dart';
import 'package:fhir/stu3/resource_types/foundation/other/other.enums.dart';
import 'package:fhir/stu3/resource_types/foundation/other/other.freezed.dart';
import 'package:fhir/stu3/resource_types/foundation/other/other.g.dart';
import 'package:fhir/stu3/resource_types/foundation/security/security.dart';
import 'package:fhir/stu3/resource_types/foundation/security/security.enums.dart';
import 'package:fhir/stu3/resource_types/foundation/security/security.freezed.dart';
import 'package:fhir/stu3/resource_types/foundation/security/security.g.dart';
import 'package:fhir/stu3/resource_types/foundation/terminology/terminology.dart';
import 'package:fhir/stu3/resource_types/foundation/terminology/terminology.enums.dart';
import 'package:fhir/stu3/resource_types/foundation/terminology/terminology.freezed.dart';
import 'package:fhir/stu3/resource_types/foundation/terminology/terminology.g.dart';
import 'package:fhir/stu3/resource_types/resource_types.dart';
import 'package:fhir/stu3/resource_types/resource_types.enums.dart';
import 'package:fhir/stu3/resource_types/specialized/clinical_decision_support/clinical_decision_support.dart';
import 'package:fhir/stu3/resource_types/specialized/clinical_decision_support/clinical_decision_support.enums.dart';
import 'package:fhir/stu3/resource_types/specialized/clinical_decision_support/clinical_decision_support.freezed.dart';
import 'package:fhir/stu3/resource_types/specialized/clinical_decision_support/clinical_decision_support.g.dart';
import 'package:fhir/stu3/resource_types/specialized/definitional_artifacts/definitional_artifacts.dart';
import 'package:fhir/stu3/resource_types/specialized/definitional_artifacts/definitional_artifacts.enums.dart';
import 'package:fhir/stu3/resource_types/specialized/definitional_artifacts/definitional_artifacts.freezed.dart';
import 'package:fhir/stu3/resource_types/specialized/definitional_artifacts/definitional_artifacts.g.dart';
import 'package:fhir/stu3/resource_types/specialized/public_health_and_research/public_health_and_research.dart';
import 'package:fhir/stu3/resource_types/specialized/public_health_and_research/public_health_and_research.enums.dart';
import 'package:fhir/stu3/resource_types/specialized/public_health_and_research/public_health_and_research.freezed.dart';
import 'package:fhir/stu3/resource_types/specialized/public_health_and_research/public_health_and_research.g.dart';
import 'package:fhir/stu3/resource_types/specialized/quality_reporting/quality_reporting.dart';
import 'package:fhir/stu3/resource_types/specialized/quality_reporting/quality_reporting.enums.dart';
import 'package:fhir/stu3/resource_types/specialized/quality_reporting/quality_reporting.freezed.dart';
import 'package:fhir/stu3/resource_types/specialized/quality_reporting/quality_reporting.g.dart';
import 'package:fhir/stu3/resource_types/specialized/specialized.dart';
import 'package:fhir/stu3/resource_types/specialized/testing/testing.dart';
import 'package:fhir/stu3/resource_types/specialized/testing/testing.enums.dart';
import 'package:fhir/stu3/resource_types/specialized/testing/testing.freezed.dart';
import 'package:fhir/stu3/resource_types/specialized/testing/testing.g.dart';
import 'package:fhir/stu3/special_types/special_types.dart';
import 'package:fhir/stu3/special_types/special_types.enums.dart';
import 'package:fhir/stu3/special_types/special_types.freezed.dart';
import 'package:fhir/stu3/special_types/special_types.g.dart';
import 'package:fhir/stu3/stu3.dart';

example/lib/main.dart

import 'package:fhir/r4.dart';

void main() {
  final patient = Patient(
    id: Id('12345'),
    active: Boolean(true),
    name: <HumanName>[
      HumanName(
        family: 'Atreides',
        given: ['Paul'],
      ),
    ],
    address: <Address>[Address(postalCode: '12345')],
    gender: PatientGender.male,
    birthDate: Date(DateTime(3071, 04, 25)),
  );

  print(patient.toYaml());

  final condition = Condition(
    subject: Reference(reference: 'Patient/12345'),
    clinicalStatus: CodeableConcept(
      coding: [
        Coding(
          system: FhirUri(
              'http://terminology.hl7.org/CodeSystem/condition-clinical'),
          code: Code('active'),
          display: 'Active',
        ),
      ],
    ),
    verificationStatus: CodeableConcept(
      coding: [
        Coding(
            system: FhirUri(
                'http://terminology.hl7.org/CodeSystem/condition-ver-status'),
            code: Code('confirmed'),
            display: 'Confirmed')
      ],
    ),
    category: [
      CodeableConcept(
        coding: [
          Coding(
            system: FhirUri(
                'http://hl7.org/fhir/us/core/CodeSystem/condition-category'),
            code: Code('health-concern'),
          )
        ],
      )
    ],
    code: CodeableConcept(
      coding: [
        Coding(
          system: FhirUri('http://factor.info/sct'),
          code: Code('32911000'),
          display: 'Homeless',
        ),
      ],
      text: 'Homeless (finding)',
    ),
    onsetPeriod: Period(
      start: FhirDateTime(
        DateTime(
          DateTime.now().year - 1,
          DateTime.now().month,
          DateTime.now().day,
        ),
      ),
    ),
  );

  print(condition.toYaml());

  final observation = Observation(
    subject: Reference(reference: 'Patient/12345'),
    status: ObservationStatus.final_,
    category: [
      CodeableConcept(
        coding: [
          Coding(
            system: FhirUri(
                'http://hl7.org/fhir/us/core/CodeSystem/condition-category'),
            code: Code('social-history'),
            display: 'Social History',
          )
        ],
      ),
      CodeableConcept(
        coding: [
          Coding(
            system: FhirUri(
                'http://hl7.org/fhir/us/core/CodeSystem/condition-category'),
            code: Code('survey'),
            display: 'Survey',
          )
        ],
      ),
    ],
    code: CodeableConcept(
      coding: [
        Coding(
          system: FhirUri('http://loinc.org'),
          code: Code('LA19952-3'),
          display: 'At risk',
        ),
      ],
      text: 'Food insecurity risk [HVS]',
    ),
    effectivePeriod: Period(
      start: FhirDateTime(
        DateTime(
          DateTime.now().year - 1,
          DateTime.now().month,
          DateTime.now().day,
        ),
      ),
    ),
    valueCodeableConcept: CodeableConcept(
      coding: [
        Coding(
          system: FhirUri('http://loinc.org'),
          code: Code('LA17956-6'),
          display: 'Unemployed',
        ),
      ],
      text: 'Unemployed',
    ),
  );

  print(observation.toYaml());
} 

Download Details:

Author: MayJuun

Source Code: https://github.com/MayJuun/fhir/tree/main/fhir

#dart  #flutter