Starfish API Documentation

Patients and Account Holders

Every prescription in Starfish is created against a patient, who in turn belongs to an account holder (the customer). The prescription is linked to both, but you supply the patientId when creating it — so you need to resolve the right patient first. Understanding how patients relate to account holders avoids creating duplicate records when importing prescriptions.

An account holder always has a patient

When you create an account holder with createAccountHolder, Starfish automatically creates a matching patient for them with the relationship account_holder. Its name, date of birth and gender are kept in sync with the account holder.

This means that for the account holder's own prescription you do not create a patient — you look up the one that already exists.

Listing an account holder's patients

Query patients with the account holder's ID to get every patient they manage. The response includes the auto-created account_holder patient alongside any dependants. Use the relationship field to tell them apart, and pmsPatientIdentifier to match a patient back to your PMS record.

Query

query($userId: ID!) {
  patients(userId: $userId) {
    id
    firstName
    lastName
    middleName
    relationship
    dateOfBirth
    gender
  }
}

Variables

{
  "userId": "AccountHolder-XL3FBMGL86"
}

Response

{
  "data": {
    "patients": [
      {
        "id": "PrescriptionPatient-2L3CVY4QL4M",
        "firstName": "Bizzney",
        "lastName": "Johnson",
        "middleName": null,
        "relationship": "dependent",
        "dateOfBirth": "2010-06-15",
        "gender": "female"
      },
      {
        "id": "PrescriptionPatient-4RYCMOD63GM",
        "firstName": "Britney",
        "lastName": "Johnson",
        "middleName": null,
        "relationship": "account_holder",
        "dateOfBirth": "1981-12-02",
        "gender": "female"
      }
    ]
  }
}

Choosing the right patient

  • Prescription for the account holder themselves — pick the patient whose relationship is account_holder. It already exists; never create another one.
  • Prescription for a dependant that already exists — match on pmsPatientIdentifier and use that patient's id.
  • Prescription for a new dependant — create it (see below).

Creating a dependant

When a prescription is for a dependant that does not yet exist, create them with createPatient, passing the account holder's ID as userId and a relationship of dependent, minor or other.

Query

mutation($input: CreatePatientMutationInput!) {
  createPatient(input: $input) {
    patient {
      id
      firstName
      lastName
      middleName
      relationship
      dateOfBirth
      gender
    }
  }
}

Variables

{
  "input": {
    "userId": "AccountHolder-XL3FBMGL86",
    "firstName": "John",
    "lastName": "Doe",
    "middleName": "Robert",
    "relationship": "dependent",
    "dateOfBirth": "2010-05-15",
    "gender": "male"
  }
}

Response

{
  "data": {
    "createPatient": {
      "patient": {
        "id": "PrescriptionPatient-6PGCYE9RVD4",
        "firstName": "John",
        "lastName": "Doe",
        "middleName": "Robert",
        "relationship": "dependent",
        "dateOfBirth": "2010-05-15",
        "gender": "male"
      }
    }
  }
}

Do not call createPatient with relationship: account_holder — that patient already exists and a second one would be a duplicate.