Public/Get-SfPatientPreferences.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 55 56 57 58 |
<# .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-Config Get-Patients .NOTES Assumes config is initialized for org access. #> function Get-SfPatientPreferences { [CmdletBinding()] [OutputType([PSCustomObject[]])] param( [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline)] [ValidateNotNull()] [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)" $query = "SELECT Id,Name,phecc__Patient__c FROM phecc__Patient_Preference__c" if ($PSBoundParameters.ContainsKey('Patient')) { $query += " WHERE phecc__Patient__c='$($Patient.sfPatient.Id)'" } Invoke-SfQuery $query } } |