Oystehr
eRx
Patient Sync
🚧

The eRx Service is currently in beta.

Patient Sync

Patient information stored in the FHIR Service must be explicitly synced with the eRx service in order to enable ePrescribing for individual patients.

Access Policy

To sync patients, your user needs to have the following minimum access policy:

{
  "rule": [
    {
      "action": "eRx:SyncPatient",
      "resource": "eRx:Patient",
      "effect": "Allow"
    },
  ]
}

Data that is Synced

The following patient information is sent to the upstream eRx provider:

  • name (first and last)
  • date of birth
  • gender
  • email
  • phone number
  • address
  • allergies
  • medication history

How to Sync

When you trigger a patient sync (opens in a new tab), information is collected from the referenced FHIR Patient record. The required fields for patient sync are:

  • name (first and last)
  • date of birth
  • gender
  • phone number

Here is an example of a patient creation followed by a sync:

create-patient.ts
import Oystehr from '@oystehr/sdk';
import { Patient } from 'fhir/r4b';
 
const patient: Patient = {
  resourceType: 'Patient',
  name: [
    {
      family: 'Shaw',
      given: ['Amy', 'V.'],
    },
  ],
  telecom: [
    {
      system: 'phone',
      value: '+14231112222',
      use: 'home',
      extension: [
        {
          url: 'https://extensions.fhir.oystehr.com/contact-point/telecom-phone-erx',
        },
      ],          
    },
    {
      system: 'email',
      value: '[email protected]',
    },
  ],
  gender: 'female',
  birthDate: '1987-02-20',
  address: [
    {
      line: ['49 Meadow St', 'Apt 2'],
      city: 'Mounds',
      state: 'OK',
      postalCode: '74047',
      country: 'US',
    },
  ],
};
 
const oystehr = new Oystehr({ accessToken: '<your_access_token>' });
const createdResource = await oystehr.fhir.create<Patient>(patient);
const syncPatientResult = await oystehr.erx.syncPatient({ patientId: createdResource.id });

When synchronizing patient phone numbers for eRx purposes, phone numbers with extension URL of https://extensions.fhir.oystehr.com/contact-point/telecom-phone-erx will be preferred. Phone number search is conducted in the following order:

  1. Patient Resource, telecom tagged for eRx
  2. Patient Resource's contacts, telecoms tagged for eRx
  3. Patient Resource, telecom, untagged
  4. Patient Resource's contacts, untagged

Phone Number Validation

While FHIR supports any format for phone numbers in the patient's telecom field, the eRx service is more restrictive. Phone numbers are validated with AWS (opens in a new tab), and patient sync will return a validation error if the phone number is not valid. For example, the 999 area code is unassigned so a number with this area code would cause a sync failure. It's strongly encouraged to validate phone numbers for patients when collecting them.

{
  "statusCode": 400,
  "body": {
    "message": "Patient property was invalid: phone",
    "code": "4006"
  }
}

eRx Patient ID

When a patient is synced, a unique patient ID is returned. This ID is stored in the FHIR Patient record as an identifier. Changing or deleting this identifier will result in errors when next syncing the patient with the eRx service. Here is an example identifier:

{
  "identifier": [
    {
      "use":"official",
      "value":"7814134",
      "system":"https://identifiers.fhir.oystehr.com/erx-patient-id"
    }
  ]
}

Patient Allergies

In order to sync allergies with the eRx service (which enables drug-allergy interaction checks), you must add a valid code when you create the AllergyIntolerance (opens in a new tab) resource in the FHIR service. Code values are retrieved using Allergen Search. Here is an example of creating an AllergyIntolerance with a code that will sync with the eRx service:

create-allergy.ts
import Oystehr from '@oystehr/sdk';
import { AllergyIntolerance } from 'fhir/r4b';
 
const allergy: AllergyIntolerance = {
  resourceType: 'AllergyIntolerance',
  patient: {
    reference: `Patient/${your-fhir-patient-id}`,
  },
  code: {
    coding: [
      {
        system: 'https://identifiers.fhir.oystehr.com/erx-allergen-id',
        code: '949182',
        display: 'peanut allergenic extract',
      }
    ],
  },
  onsetDateTime: '2021-08-01',
  note: [
    {
      text: 'Patient has had allergy since 10 yo.',
    },
  ],
};
 
const oystehr = new Oystehr({ accessToken: '<your_access_token>' });
const createdResource = await oystehr.fhir.create<AllergyIntolerance>(allergy);

The following allergy information is synced:

  • allergen id
  • onset date
  • comment

Of these, only the allergen id is required. The other fields are optional.

After sync, the AllergyIntolerance resource will be updated with an eRx patient allergy ID. This ID is stored in the identifier field of the AllergyIntolerance resource. The identifier will look like this:

{
  "identifier": [
    {
      "use":"official",
      "value":"112301",
      "system":"https://identifiers.fhir.oystehr.com/erx-patient-allergy-id"
    }
  ]
}

Medication History

In order to sync medication history with the eRx service (which enables drug-drug interaction checks), you must add a valid medicationCodeableConcept when you create the MedicationStatement (opens in a new tab) resource in the FHIR service. Code values are retrieved using Medication Search. Here is an example of creating a MedicationStatement with a code that will sync with the eRx service:

create-medication.ts
import Oystehr from '@oystehr/sdk';
import { MedicationStatement } from 'fhir/r4b';
 
const medication: MedicationStatement = {
  resourceType: 'MedicationStatement',
  status: 'active',
  subject: {
    reference: `Patient/${your-fhir-patient-id}`,
  },
  medicationCodeableConcept: {
    coding: [
      {
        system: 'https://identifiers.fhir.oystehr.com/erx-medication-id',
        code: '49210',
        display: 'Amoxil (Amoxicillin 400 mg /5mL) Oral powder, for suspension',
      }
    ],
  },
  note: [
    {
      text: 'Patient has been taking this medication since 10 yo.',
    },
  ],
};
 
const oystehr = new Oystehr({ accessToken: '<your_access_token>' });
const createdResource = await oystehr.fhir.create<MedicationStatement>(medication);

The following medication information is synced:

  • medication id
  • active status
  • comment

Of these, medication id and active status are required.

After sync, the MedicationStatement resource will be updated with an eRx patient medication ID. This ID is stored in the identifier field of the MedicationStatement resource. The identifier will look like this:

{
  "identifier": [
    {
      "use":"official",
      "value":"112301",
      "system":"https://identifiers.fhir.oystehr.com/erx-patient-medication-id"
    }
  ]
}