Public/Get-SfPatients.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
41
<#
    .SYNOPSIS
    Queries salesforce for patients

    .DESCRIPTION
    Used to query for patients in the salesforce org by status

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

    .OUTPUTS
    An array of PSCustomObject with the properties:
        Id
        phecc__CDRPID__c
        phecc__Delivery_Channel__c
        phecc__Permission__c
        phecc__Status__c
        phecc__Tier_of_Service__c

    .PARAMETER Status
    The status to query patients. If not supplid then the default is "Active". Use $null for all patients.

    .EXAMPLE
    PS> $allPatients = Get-Patients -Status $null
    PS> $activePatients = Get-Patients
    PS> $pending = Get-Patients -Status "Pending - Activation"

    .LINK
    Set-FileConfig

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

function Get-SfPatients {
    param($Status = "Active")
    if ($Status) {
        Invoke-SfQuery "SELECT Id,phecc__CDRPID__c,phecc__Permission__c,phecc__Status__c,phecc__Tier_of_Service__c,phecc__Delivery_Channel__c FROM phecc__Patient__c WHERE IsDeleted=False AND phecc__Status__c='$($Status)'"
    } else {
        Invoke-SfQuery "SELECT Id,phecc__CDRPID__c,phecc__Permission__c,phecc__Status__c,phecc__Tier_of_Service__c,phecc__Delivery_Channel__c FROM phecc__Patient__c WHERE IsDeleted=False"
    }
}