Public/New-FakePatients.ps1
<# .SYNOPSIS Creates fake patients in eCC with option to activate the patients. .DESCRIPTION Creates fake patients in eCC with option to activate the patients. .INPUTS The number of patients to create .OUTPUTS An array of PSCustomObjects that represent the patients .PARAMETER Count The number of hashtables to generate. Defaults to 1 if not specified .PARAMETER Status The status to set the patient. .EXAMPLE PS> $Patients = New-FakePatients -Count 2 .LINK New-Patient New-PatientCalendar Set-PatientStatus .NOTES If the status is anything other then 'Pending - Activation' then the patient will have measurements added to the calendar and then the patient will be set to status='Active'. If the status is anything other than 'Active' then the status will be set. #> function New-FakePatients { [OutputType([PSCustomObject])] param( [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline)] [int]$Count, [ValidateSet("Pending - Activation", "Active", "Suspended", "Pending - Removal", "Removed")] $Status = "Pending - Activation" ) 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)" if (-not $PSBoundParameters.ContainsKey('Count')) { $Count = 1 } New-FakePatientParameters -Count $Count | ForEach-Object { $Patient = New-Patient @_ if ($Status -ne "Pending - Activation") { New-PatientCalendar -Patient $Patient | Out-Null Set-PatientStatus -Patient $Patient -Status "Active" | Out-Null if ($Status -ne "Active") { Set-PatientStatus -Patient $Patient -Status $Status | Out-Null } $Patient = [PSCustomObject](Get-Patients -sfid $Patient.sfPatient.Id | Select-Object -First 1) } Write-Output $Patient } } } |