Starfish API Documentation

Importing Eyeglass Prescriptions

Importing eyeglass prescriptions requires both the customer and the member of staff to have an account in Starfish. Staff accounts must be added through the Starfish application, but customer accounts can be created via the API. The steps below walk through fetching all the required data before importing the eyeglass prescription.

Unlike contact lens prescriptions, eyeglass prescriptions are not tied to a product — they carry the measurements directly.

1. Fetch the staff member from Starfish

Query the staffMember endpoint to get the staff member's Starfish ID. We use this ID when the member of staff imports prescriptions via the API.

Query

query($externalStaffUserIdentifier: String) {
  staffMember(externalStaffUserIdentifier: $externalStaffUserIdentifier) {
    id
  }
}

Variables

{
  "externalStaffUserIdentifier": "pms-claudia"
}

Response

{
  "data": {
    "staffMember": {
      "id": "StaffMember-WVNFD3KPVRD"
    }
  }
}

2. Fetch the customer from Starfish

If there is not already an account holder for this customer, follow the documentation here to create one.

Query the AccountHolder endpoint to get the customer's Starfish ID.

Query

query SearchAccountHolders($pmsPatientIdentifier: StringQueryInput) {
  accountHolders(pmsPatientIdentifier: $pmsPatientIdentifier) {
    nodes {
      id
      pmsPatientIdentifier
    }
  }
}

Variables

{
  "pmsPatientIdentifier": {
    "is": "123456"
  }
}

Response

{
  "data": {
    "accountHolders": {
      "nodes": [
        {
          "id": "AccountHolder-MZVF2MBN8GR",
          "pmsPatientIdentifier": "123456"
        }
      ]
    }
  }
}

3. Resolve the patient

Prescriptions are created against a patient — you pass patientId, not the account holder's ID. Query the account holder's patients and pick the one the prescription is for — the account_holder patient for the customer themselves, or a dependant matched on pmsPatientIdentifier.

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"
      }
    ]
  }
}

If the prescription is for a dependant who does not exist yet, create them first. See Patients and Account Holders for the full explanation of how patients relate to account holders.

4. Fetch the location from Starfish

If the prescription is an in-house prescription, you can pass this ID up when importing the customer's prescription. If you don't have this location's Starfish ID, you can fetch it from the API:

Query

query SearchLocations($name: StringQueryInput) {
  locations(name: $name) {
    nodes {
      id
      name
      city
      countryCode
    }
  }
}

Variables

{
  "name": {
    "contains": "James "
  }
}

Response

{
  "data": {
    "locations": {
      "nodes": [
        {
          "id": "Location-G9LT2699KD6",
          "name": "James Road",
          "city": "New York",
          "countryCode": "US"
        }
      ]
    }
  }
}

5. Import the eyeglass prescription

Now we have the patient's ID, the staff member's ID, and the location ID, we can import the prescription via the API following the documentation here.

The formType argument controls which measurements apply:

  • simple forms carry a single set of measurements (simpleRightEye… / simpleLeftEye…).

Query

mutation($input: CreateEyeGlassPrescriptionMutationInput!) {
  createEyeGlassPrescription(input: $input) {
    prescription {
      id
      name
      formType
      patient {
        id
      }
      status
      validityPeriod {
        expiryDate
        startDate
      }
      prescribingLocation {
        id
      }
      simpleRightEyeSphere
      simpleRightEyeCyl
      simpleRightEyeAxis
      simpleRightEyeAdd
      simpleLeftEyeSphere
      simpleLeftEyeCyl
      simpleLeftEyeAxis
      simpleLeftEyeAdd
      pupillaryDistance
      doctor {
        addressLine1
        addressLine2
        city
        countryCode
        postalCode
        region
        locationName
        doctorsName
        phoneNumber
        isThirdPartyLocation
      }
    }
  }
}

Variables

{
  "input": {
    "name": "Britneys Computer Glasses",
    "formType": "simple",
    "validityPeriod": {
      "startDate": "2021-05-19",
      "expiryDate": "2023-05-19"
    },
    "patientId": "PrescriptionPatient-2L3CVY4QL4M",
    "simpleRightEyeSphere": "+2.00",
    "simpleRightEyeCyl": "-1.00",
    "simpleRightEyeAxis": "90",
    "simpleRightEyeAdd": "+1.00",
    "simpleLeftEyeSphere": "+1.75",
    "simpleLeftEyeCyl": "-0.75",
    "simpleLeftEyeAxis": "85",
    "simpleLeftEyeAdd": "+0.75",
    "pupillaryDistance": "65",
    "doctor": {
      "doctorsName": "Gerald Fields",
      "phoneNumber": "01234",
      "locationName": "Dr Hype",
      "addressLine1": "Humphries Rd",
      "city": "Utah City",
      "countryCode": "US",
      "postalCode": "84101",
      "region": "UT",
      "isThirdPartyLocation": true
    },
    "prescribingLocationId": "Location-9R3TMR8XMV4",
    "createdById": "StaffMember-WVNFD3KPVRD"
  }
}

Response

{
  "data": {
    "createEyeGlassPrescription": {
      "prescription": {
        "id": "EyeGlassPrescription-6B8IJBPKG6G",
        "name": "Britneys Computer Glasses",
        "formType": "simple",
        "patient": {
          "id": "PrescriptionPatient-2L3CVY4QL4M"
        },
        "status": "approved",
        "validityPeriod": {
          "expiryDate": "2023-05-19",
          "startDate": "2021-05-19"
        },
        "prescribingLocation": {
          "id": "Location-9R3TMR8XMV4"
        },
        "simpleRightEyeSphere": "+2.00",
        "simpleRightEyeCyl": "-1.00",
        "simpleRightEyeAxis": "90",
        "simpleRightEyeAdd": "+1.00",
        "simpleLeftEyeSphere": "+1.75",
        "simpleLeftEyeCyl": "-0.75",
        "simpleLeftEyeAxis": "85",
        "simpleLeftEyeAdd": "+0.75",
        "pupillaryDistance": "65",
        "doctor": {
          "addressLine1": "(4000) Alamaro Street",
          "addressLine2": null,
          "city": "Los Angeles",
          "countryCode": "US",
          "postalCode": "90210",
          "region": "CA",
          "locationName": "Dr Hype",
          "doctorsName": "Gerald Fields",
          "phoneNumber": "01234",
          "isThirdPartyLocation": true
        }
      }
    }
  }
}
  • advanced forms carry separate distance, intermediate and near measurements. An add value is supported on the simple, intermediate and near sets (distance has none).

Query

mutation($input: CreateEyeGlassPrescriptionMutationInput!) {
  createEyeGlassPrescription(input: $input) {
    prescription {
      id
      name
      formType
      patient {
        id
      }
      status
      validityPeriod {
        expiryDate
        startDate
      }
      prescribingLocation {
        id
      }
      distanceRightEyeSphere
      distanceRightEyeCyl
      distanceRightEyeAxis
      distanceLeftEyeSphere
      distanceLeftEyeCyl
      distanceLeftEyeAxis
      intermediateRightEyeSphere
      intermediateRightEyeCyl
      intermediateRightEyeAxis
      intermediateRightEyeAdd
      intermediateLeftEyeSphere
      intermediateLeftEyeCyl
      intermediateLeftEyeAxis
      intermediateLeftEyeAdd
      nearRightEyeSphere
      nearRightEyeCyl
      nearRightEyeAxis
      nearRightEyeAdd
      nearLeftEyeSphere
      nearLeftEyeCyl
      nearLeftEyeAxis
      nearLeftEyeAdd
      pupillaryDistance
      doctor {
        addressLine1
        addressLine2
        city
        countryCode
        postalCode
        region
        locationName
        doctorsName
        phoneNumber
        isThirdPartyLocation
      }
    }
  }
}

Variables

{
  "input": {
    "name": "Britneys Computer Glasses",
    "formType": "advanced",
    "validityPeriod": {
      "startDate": "2021-05-19",
      "expiryDate": "2023-05-19"
    },
    "patientId": "PrescriptionPatient-2L3CVY4QL4M",
    "distanceRightEyeSphere": "+2.00",
    "distanceRightEyeCyl": "-1.00",
    "distanceRightEyeAxis": "90",
    "distanceLeftEyeSphere": "+1.75",
    "distanceLeftEyeCyl": "-0.75",
    "distanceLeftEyeAxis": "85",
    "intermediateRightEyeSphere": "+2.25",
    "intermediateRightEyeCyl": "-1.25",
    "intermediateRightEyeAxis": "90",
    "intermediateRightEyeAdd": "+1.25",
    "intermediateLeftEyeSphere": "+2.00",
    "intermediateLeftEyeCyl": "-1.00",
    "intermediateLeftEyeAxis": "85",
    "intermediateLeftEyeAdd": "+1.00",
    "nearRightEyeSphere": "+2.50",
    "nearRightEyeCyl": "-1.50",
    "nearRightEyeAxis": "90",
    "nearRightEyeAdd": "+2.00",
    "nearLeftEyeSphere": "+2.25",
    "nearLeftEyeCyl": "-1.25",
    "nearLeftEyeAxis": "85",
    "nearLeftEyeAdd": "+1.75",
    "pupillaryDistance": "65",
    "doctor": {
      "doctorsName": "Gerald Fields",
      "phoneNumber": "01234",
      "locationName": "Dr Hype",
      "addressLine1": "Humphries Rd",
      "city": "Utah City",
      "countryCode": "US",
      "postalCode": "84101",
      "region": "UT",
      "isThirdPartyLocation": true
    },
    "prescribingLocationId": "Location-9R3TMR8XMV4",
    "createdById": "StaffMember-WVNFD3KPVRD"
  }
}

Response

{
  "data": {
    "createEyeGlassPrescription": {
      "prescription": {
        "id": "EyeGlassPrescription-2QMIG3NVZ66",
        "name": "Britneys Computer Glasses",
        "formType": "advanced",
        "patient": {
          "id": "PrescriptionPatient-2L3CVY4QL4M"
        },
        "status": "approved",
        "validityPeriod": {
          "expiryDate": "2023-05-19",
          "startDate": "2021-05-19"
        },
        "prescribingLocation": {
          "id": "Location-9R3TMR8XMV4"
        },
        "distanceRightEyeSphere": "+2.00",
        "distanceRightEyeCyl": "-1.00",
        "distanceRightEyeAxis": "90",
        "distanceLeftEyeSphere": "+1.75",
        "distanceLeftEyeCyl": "-0.75",
        "distanceLeftEyeAxis": "85",
        "intermediateRightEyeSphere": "+2.25",
        "intermediateRightEyeCyl": "-1.25",
        "intermediateRightEyeAxis": "90",
        "intermediateRightEyeAdd": "+1.25",
        "intermediateLeftEyeSphere": "+2.00",
        "intermediateLeftEyeCyl": "-1.00",
        "intermediateLeftEyeAxis": "85",
        "intermediateLeftEyeAdd": "+1.00",
        "nearRightEyeSphere": "+2.50",
        "nearRightEyeCyl": "-1.50",
        "nearRightEyeAxis": "90",
        "nearRightEyeAdd": "+2.00",
        "nearLeftEyeSphere": "+2.25",
        "nearLeftEyeCyl": "-1.25",
        "nearLeftEyeAxis": "85",
        "nearLeftEyeAdd": "+1.75",
        "pupillaryDistance": "65",
        "doctor": {
          "addressLine1": "(4000) Alamaro Street",
          "addressLine2": null,
          "city": "Los Angeles",
          "countryCode": "US",
          "postalCode": "90210",
          "region": "CA",
          "locationName": "Dr Hype",
          "doctorsName": "Gerald Fields",
          "phoneNumber": "01234",
          "isThirdPartyLocation": true
        }
      }
    }
  }
}