Public/Get-SfPatientPreferences.ps1

<#
    .SYNOPSIS
    Queries salesforce for patient preferences.

    .DESCRIPTION
    Used to query for patient preferences for a single patient or all patients.

    .INPUTS
    None. You cannot pipe objects to Get-SfPatientPreferences.

    .OUTPUTS
    An array of PSCustomObject with the properties:
        Id
        Name
        phecc__Patient__c ( sfdc patient object id)

    .PARAMETER Patient
    The patient object from Get-Patients. If not supplied then all patient preferences are queries.

    .EXAMPLE
    PS> $ptPrefs = Get-SfPatientPreferences

    .LINK
    Set-FileConfig
    Get-Patients

    .NOTES
    Assumes config is initialized for org access.
#>

function Get-SfPatientPreferences {
    param($Patient)
    if ($Patient) {
        Invoke-SfQuery "SELECT Id,Name,phecc__Patient__c FROM phecc__Patient_Preference__c WHERE phecc__Patient__c='$($Patient.sfPatient.Id)'"
    } else {
        Invoke-SfQuery "SELECT Id,Name,phecc__Patient__c FROM phecc__Patient_Preference__c"
    }
}