Public/Get-SfPlannedEntries.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<#
    .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)'"
    }
}