Z.MIS (Portico/Z v0.1.0)

Context module for Medical Information System. As of 2022: CampDoc

See also Library.Campdoc for API-specific implementation functions.

OAuth, Tokens, Authentication, Oh My!

CampDoc uses OAuth for their V2 API - meaning that you need to use a browser-based workflow for a specific logged-in user to get a base OAuth authorization code for all following API requests. Once this authorization code has been obtained, it can be re-used indefinitely through "refresh tokens" (see the CampDoc API OAuth notes for more details of how this works).

For the purposes of EXPLO's API needs, this means that the system needs to be "primed" by having an EXPLO admin login to CampDoc and pass that token into Z - see ZWeb.Admin.CampdocOauthController for the relevant endpoint to hit to perform this login magic. This will cause the access + refresh token information to be stored as Z.Configurations (encrypted-at-rest) runtime configuration, and will be re-used and refreshed automatically by Z for all CampDoc API requests.

Link to this section Summary

Functions

Create or update a profile in the MIS.

Create a registration for a given profile_id into a given group_id.

Create a user in the MIS, associated with a profile

Deactivate a registration for a given profile_id

Get a group from the MIS

Get a profile from the MIS

Get profile registrations from the MIS

Get profile reviews from the MIS

List all groups in the MIS

List all profiles in the MIS

Generate an SSO (Single Sign-On) URL for a MIS user, by email

Given an OAauth code, retrieve (+ store) MIS access info for all future MIS API calls

Link to this section Functions

Link to this function

create_or_update_profile(identifier, params)

Create or update a profile in the MIS.

Attempts to find an existing profile (matching on identifier) - and will update if one is found. If none is found, will attempt profile creation.

Returns nil if everything fails.

Link to this function

create_registration(profile_id, group_id, type \\ "patient")

Create a registration for a given profile_id into a given group_id.

Will attempt to convert Portico contact ID into CampDoc profile_id.

Note that type will default to "patient" unless otherwise specified.

Link to this function

create_user(identifier, params)

Create a user in the MIS, associated with a profile

Parameters

A User object in the MIS has the following shape:

  • email [REQUIRED] The user's email address
  • givenName [REQUIRED] The user's given name
  • familyName [REQUIRED] The user's family name

Examples

Z.MIS.create_user("abc", %{"email" => "test@explo.org", "givenName" => "test", "familyName" => "test"})
Link to this function

deactivate_registration(profile_id, registration_id)

Deactivate a registration for a given profile_id

Will attempt to convert Portico contact ID into CampDoc profile_id.

Link to this function

get_group(group_id)

Get a group from the MIS

Link to this function

get_profile(identifier)

Get a profile from the MIS

Link to this function

get_profile_registrations(profile_id)

Get profile registrations from the MIS

Link to this function

get_profile_reviews(profile_id)

Get profile reviews from the MIS

List all groups in the MIS

Link to this function

list_profiles()

List all profiles in the MIS

Generate an SSO (Single Sign-On) URL for a MIS user, by email

Link to this function

store_access_information(oauth_code, redirect_uri)

Given an OAauth code, retrieve (+ store) MIS access info for all future MIS API calls

Will also schedule token refreshes using Z.MIS.TokenRefreshWorker.