Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

akido_lib

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akido_lib

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

AkidoLib

Short description and motivation.

Usage

How to use my plugin.

Installation

Add this line to your application's Gemfile:

gem 'akido_lib'

And then execute:

$ bundle

Or install it yourself as:

$ gem install akido_lib

Extra Classes/Methods

AkidoLib::Bundle

We're liable to add some utility methods to AkidoLib::Bundle, since it's the main entry point into what comes back from the server.

Methods
  • #to_a

    Bundle#to_a works exactly as you'd expect: the full bundle is read from the server, and then turned into an array. Useful for when you want to call #map or #select on what gets returned in a bundle.

AkidoLib::Query

Query exists to bridge the gap between FHIR::Client and ActiveRecord-y syntax, which most Rails developers seem to think in. Its syntax should be familiar to those familiar with ActiveRecord::Relation, specifically #all and #where.

Methods
Class Methods
  • .set_base_url!(base_url)

    Ordinarily, new Queries reach back to FHIR::Model.client to get their base URL, but if it isn't set, or if you just want to overwrite it, you can do so.

  • .new(resource, base_url)

    You probably won't call this method — most Queries will be created using methods on FHIR::Model.

    When a Query is created, it needs two things to be meaningful: a base URL to hit, and the name of a FHIR resource. This method takes both as arguments. The resource name is required, but base_url is optional — if base_url is set on AkidoLib::Query, that will be used, otherwise it will default to the base URL set on AkidoLib::Model.client.

Instance Methods
  • #where(conditions)

    The where method is the main entry point for adding constraints to the query. It accepts all of the parameters for FHIR searching, with the caveat that parameter names should be written as Ruby-style symbols, without the leading underscore and in snake_case instead of camelCase — e.g. _lastUpdated becomes :last_updated.

  • #last_updated(date)

    #where has the advantage of being able to set more than one property at a time, but the disadvantage that it doesn't cast any of the values to be more palatable to the server. Because of how precise FHIR servers can be about their date requirements, #last_updated is a convenience method that lets you pass a date, then sets _lastUpdated to the XML-encoded version of that date.

  • #include(relation)

    Shorthand for adding _include=[Relation] to your query. Takes a sting, e.g. 'Encounter:Patient'. Can take option after the name of the relation to include. There is currenlty one option implemented: passing :rev => true will insert the relation as a _revinclude instead of an _include.

    AkidoLib::Encounter.where(:last_updated =>2.weeks.ago).include("Encounter:Patient")
    
  • #custom(key, value)

    #where is prescriptive — it has opinions about how query keys should looks (i.e. they should be preceded with an underscore, they should be camelCase, etc.). #custom has no such prescriptions: whatever you pass in will be assigned to the query as a key and a value.

  • #fetch!

    Intended to be the last method called on a chain of queries. Will execute the query to which it is attached, and return the AkidoLib::Bundle that comes back from the server.

    Note: one of two Query methods that doesn't itself return a Query (returns an AkidoLab::Bundle).

  • #url

    Sometimes you just need to peer into the inner workings of Query and see what it's doing, maybe to paste a URL into Postman or curl. This is precisely that utility method.

    Note: the second of two Query methods that doesn't return a Query (returns a string).

AkidoLib::Model

AkidoLib::Model is another one of those classes that we'll periodically open up to add new functionality. For now, the main thing is adding methods that return AkidoLib::Query objects.

Methods
  • #all

    When called on a FHIR model, #all will return an AkidoLib::Query object pointed at the base level of that resource — e.g. FHIR::Encounter.all will return a Query with a URL of <BaseURL>/Encounter

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 19 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc