Public/Get-FlagsForPatient.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
42
43
44
45
46
47
48
49
50
51
52
53
54
<#
    .SYNOPSIS
    Query flags from salesforce for a specific patient.

    .DESCRIPTION
    Each object in the array contains the members
        - Id
        - phecc__Description__c
        - phecc__Intervention_Rule__c
        - phecc__Patient__c

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

    .OUTPUTS
    An array of PSCustomObject

    .PARAMETER Patient
    A patient PSCustomObject from Get-Patients

    .EXAMPLE
    C:\PS> $result = Get-FlagsForPatient -Patient (Get-Patients -SelectCdrIds @("41dd4997-9d17-4527-8e86-6bdf4a102173"))

    .LINK
    Set-Config
    Get-Patients

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

function Get-FlagsForPatient {

    [CmdletBinding()]
    [OutputType([PSCustomObject[]])]
    param(
        [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline)]
        [ValidateNotNullOrEmpty()]
        [PSCustomObject]
        $Patient
    )

    begin {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
    }

    end {
        Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
    }

    process {
        Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"
        Invoke-SfQuery "SELECT+Id,phecc__Description__c,phecc__Intervention_Rule__c,phecc__Patient__c+FROM+phecc__Flag__c+WHERE+phecc__Patient__c='$($Patient.sfPatient.Id)'"
    }
}