Willie  Beier

Willie Beier

1595652300

3 Language Constructs From Dart That You Are Missing Out on in JS

With the recent Flutter hype, Dart has gained quite a bit of attention. Dart was originally designed and implemented by Google to be used as a language that can be transpiled into JavaScript and vice versa. However, it didn’t pick up all too much on that front and TypeScript definitely became the industry standard — probably also due to the fact that it’s a superset of JavaScript and not a completely new language.

However, Dart is now on the rise again with Flutter. Here are three very cool language constructs you can use in Dart that are not possible in TypeScript or JavaScript.


Conditional Spread Operator

This is definitely my favorite and super elegant, although it is only available in Dart ≥2.90 at the time of writing. You use the conditional spread operator when you want to spread an iterable that could be undefined. It’s basically optional chaining for an iterable that you wish to spread.

#javascript #nodejs #programming #dart #flutter

What is GEEK

Buddha Community

3 Language Constructs From Dart That You Are Missing Out on in JS

NBB: Ad-hoc CLJS Scripting on Node.js

Nbb

Not babashka. Node.js babashka!?

Ad-hoc CLJS scripting on Node.js.

Status

Experimental. Please report issues here.

Goals and features

Nbb's main goal is to make it easy to get started with ad hoc CLJS scripting on Node.js.

Additional goals and features are:

  • Fast startup without relying on a custom version of Node.js.
  • Small artifact (current size is around 1.2MB).
  • First class macros.
  • Support building small TUI apps using Reagent.
  • Complement babashka with libraries from the Node.js ecosystem.

Requirements

Nbb requires Node.js v12 or newer.

How does this tool work?

CLJS code is evaluated through SCI, the same interpreter that powers babashka. Because SCI works with advanced compilation, the bundle size, especially when combined with other dependencies, is smaller than what you get with self-hosted CLJS. That makes startup faster. The trade-off is that execution is less performant and that only a subset of CLJS is available (e.g. no deftype, yet).

Usage

Install nbb from NPM:

$ npm install nbb -g

Omit -g for a local install.

Try out an expression:

$ nbb -e '(+ 1 2 3)'
6

And then install some other NPM libraries to use in the script. E.g.:

$ npm install csv-parse shelljs zx

Create a script which uses the NPM libraries:

(ns script
  (:require ["csv-parse/lib/sync$default" :as csv-parse]
            ["fs" :as fs]
            ["path" :as path]
            ["shelljs$default" :as sh]
            ["term-size$default" :as term-size]
            ["zx$default" :as zx]
            ["zx$fs" :as zxfs]
            [nbb.core :refer [*file*]]))

(prn (path/resolve "."))

(prn (term-size))

(println (count (str (fs/readFileSync *file*))))

(prn (sh/ls "."))

(prn (csv-parse "foo,bar"))

(prn (zxfs/existsSync *file*))

(zx/$ #js ["ls"])

Call the script:

$ nbb script.cljs
"/private/tmp/test-script"
#js {:columns 216, :rows 47}
510
#js ["node_modules" "package-lock.json" "package.json" "script.cljs"]
#js [#js ["foo" "bar"]]
true
$ ls
node_modules
package-lock.json
package.json
script.cljs

Macros

Nbb has first class support for macros: you can define them right inside your .cljs file, like you are used to from JVM Clojure. Consider the plet macro to make working with promises more palatable:

(defmacro plet
  [bindings & body]
  (let [binding-pairs (reverse (partition 2 bindings))
        body (cons 'do body)]
    (reduce (fn [body [sym expr]]
              (let [expr (list '.resolve 'js/Promise expr)]
                (list '.then expr (list 'clojure.core/fn (vector sym)
                                        body))))
            body
            binding-pairs)))

Using this macro we can look async code more like sync code. Consider this puppeteer example:

(-> (.launch puppeteer)
      (.then (fn [browser]
               (-> (.newPage browser)
                   (.then (fn [page]
                            (-> (.goto page "https://clojure.org")
                                (.then #(.screenshot page #js{:path "screenshot.png"}))
                                (.catch #(js/console.log %))
                                (.then #(.close browser)))))))))

Using plet this becomes:

(plet [browser (.launch puppeteer)
       page (.newPage browser)
       _ (.goto page "https://clojure.org")
       _ (-> (.screenshot page #js{:path "screenshot.png"})
             (.catch #(js/console.log %)))]
      (.close browser))

See the puppeteer example for the full code.

Since v0.0.36, nbb includes promesa which is a library to deal with promises. The above plet macro is similar to promesa.core/let.

Startup time

$ time nbb -e '(+ 1 2 3)'
6
nbb -e '(+ 1 2 3)'   0.17s  user 0.02s system 109% cpu 0.168 total

The baseline startup time for a script is about 170ms seconds on my laptop. When invoked via npx this adds another 300ms or so, so for faster startup, either use a globally installed nbb or use $(npm bin)/nbb script.cljs to bypass npx.

Dependencies

NPM dependencies

Nbb does not depend on any NPM dependencies. All NPM libraries loaded by a script are resolved relative to that script. When using the Reagent module, React is resolved in the same way as any other NPM library.

Classpath

To load .cljs files from local paths or dependencies, you can use the --classpath argument. The current dir is added to the classpath automatically. So if there is a file foo/bar.cljs relative to your current dir, then you can load it via (:require [foo.bar :as fb]). Note that nbb uses the same naming conventions for namespaces and directories as other Clojure tools: foo-bar in the namespace name becomes foo_bar in the directory name.

To load dependencies from the Clojure ecosystem, you can use the Clojure CLI or babashka to download them and produce a classpath:

$ classpath="$(clojure -A:nbb -Spath -Sdeps '{:aliases {:nbb {:replace-deps {com.github.seancorfield/honeysql {:git/tag "v2.0.0-rc5" :git/sha "01c3a55"}}}}}')"

and then feed it to the --classpath argument:

$ nbb --classpath "$classpath" -e "(require '[honey.sql :as sql]) (sql/format {:select :foo :from :bar :where [:= :baz 2]})"
["SELECT foo FROM bar WHERE baz = ?" 2]

Currently nbb only reads from directories, not jar files, so you are encouraged to use git libs. Support for .jar files will be added later.

Current file

The name of the file that is currently being executed is available via nbb.core/*file* or on the metadata of vars:

(ns foo
  (:require [nbb.core :refer [*file*]]))

(prn *file*) ;; "/private/tmp/foo.cljs"

(defn f [])
(prn (:file (meta #'f))) ;; "/private/tmp/foo.cljs"

Reagent

Nbb includes reagent.core which will be lazily loaded when required. You can use this together with ink to create a TUI application:

$ npm install ink

ink-demo.cljs:

(ns ink-demo
  (:require ["ink" :refer [render Text]]
            [reagent.core :as r]))

(defonce state (r/atom 0))

(doseq [n (range 1 11)]
  (js/setTimeout #(swap! state inc) (* n 500)))

(defn hello []
  [:> Text {:color "green"} "Hello, world! " @state])

(render (r/as-element [hello]))

Promesa

Working with callbacks and promises can become tedious. Since nbb v0.0.36 the promesa.core namespace is included with the let and do! macros. An example:

(ns prom
  (:require [promesa.core :as p]))

(defn sleep [ms]
  (js/Promise.
   (fn [resolve _]
     (js/setTimeout resolve ms))))

(defn do-stuff
  []
  (p/do!
   (println "Doing stuff which takes a while")
   (sleep 1000)
   1))

(p/let [a (do-stuff)
        b (inc a)
        c (do-stuff)
        d (+ b c)]
  (prn d))
$ nbb prom.cljs
Doing stuff which takes a while
Doing stuff which takes a while
3

Also see API docs.

Js-interop

Since nbb v0.0.75 applied-science/js-interop is available:

(ns example
  (:require [applied-science.js-interop :as j]))

(def o (j/lit {:a 1 :b 2 :c {:d 1}}))

(prn (j/select-keys o [:a :b])) ;; #js {:a 1, :b 2}
(prn (j/get-in o [:c :d])) ;; 1

Most of this library is supported in nbb, except the following:

  • destructuring using :syms
  • property access using .-x notation. In nbb, you must use keywords.

See the example of what is currently supported.

Examples

See the examples directory for small examples.

Also check out these projects built with nbb:

API

See API documentation.

Migrating to shadow-cljs

See this gist on how to convert an nbb script or project to shadow-cljs.

Build

Prequisites:

  • babashka >= 0.4.0
  • Clojure CLI >= 1.10.3.933
  • Node.js 16.5.0 (lower version may work, but this is the one I used to build)

To build:

  • Clone and cd into this repo
  • bb release

Run bb tasks for more project-related tasks.

Download Details:
Author: borkdude
Download Link: Download The Source Code
Official Website: https://github.com/borkdude/nbb 
License: EPL-1.0

#node #javascript

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 

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 

Quinten  Boehm

Quinten Boehm

1626965402

2021 Dart Programming Language Tutorial for Beginners #3 Operators

Welcome to my Dart programming language tutorial#3. In this series you will
be introduced to operators and learn how to use them in Dart.

Source Code: https://github.com/Rea2er/dart-tutorial

#dart programming #dart #dart programming language

Willie  Beier

Willie Beier

1595652300

3 Language Constructs From Dart That You Are Missing Out on in JS

With the recent Flutter hype, Dart has gained quite a bit of attention. Dart was originally designed and implemented by Google to be used as a language that can be transpiled into JavaScript and vice versa. However, it didn’t pick up all too much on that front and TypeScript definitely became the industry standard — probably also due to the fact that it’s a superset of JavaScript and not a completely new language.

However, Dart is now on the rise again with Flutter. Here are three very cool language constructs you can use in Dart that are not possible in TypeScript or JavaScript.


Conditional Spread Operator

This is definitely my favorite and super elegant, although it is only available in Dart ≥2.90 at the time of writing. You use the conditional spread operator when you want to spread an iterable that could be undefined. It’s basically optional chaining for an iterable that you wish to spread.

#javascript #nodejs #programming #dart #flutter