Public/Get-SfPlannedEntries.ps1

<#
    .SYNOPSIS
    Queries salesforce for patient calendar planned entries that are not deleted
 
    .DESCRIPTION
    Can be used for a single patient or for all patients
 
    .INPUTS
    None. You cannot pipe objects to Get-SfPlannedEntries.
 
    .OUTPUTS
    An array of PSCustomObject with the properties:
        CreatedDate
        Id
        phecc__Measurement_Type__c
        phecc__Permission__c
 
    .PARAMETER Patient
    The patient object from Get-Patients
 
    .PARAMETER Type
    The type of planned entry. Defaults to "Measurement"
 
    .EXAMPLE
    PS> $pes = Get-SfPlannedEntries -Patient (Get-Patients -SelectCdrIds @("36eeb673-9dc2-409e-a328-b994b377244d"))
 
    .LINK
    Set-FileConfig
 
    .NOTES
    Assumes config is initialized for org access.
#>

function Get-SfPlannedEntries {
    param($Patient, $Type = "Measurement")
    if ($Patient) {
        Invoke-SfQuery "SELECT Id,phecc__Measurement_Type__c,CreatedDate FROM phecc__Planned_Entry__c WHERE phecc__Permission__c='$($Patient.sfPatient.phecc__Permission__c)' AND IsDeleted = false AND phecc__Type__c = '$($Type)'"
    } else {
        Invoke-SfQuery "SELECT Id,phecc__Measurement_Type__c,CreatedDate,phecc__Permission__c FROM phecc__Planned_Entry__c WHERE IsDeleted = false AND phecc__Type__c = '$($Type)'"
    }
}