Public/New-Observation.ps1

<#
    .SYNOPSIS
    Creates an observation object.

    .DESCRIPTION
    Creates the observation portion of the JSON message in hashtable form to send to the eCC Salesforce API to accept measurements

    .INPUTS
    None. You cannot pipe objects to New-Observation.

    .OUTPUTS
    PSCustomObject that contains the observation data

    .PARAMETER PatientId
    The salesforce Patient__c object Id

    .PARAMETER DateTime
    Datetime of the measurements

    .PARAMETER DeviceType
    The device type

    .PARAMETER DeviceId
    The device id

    .PARAMETER Gateway
    The gatway name

    .PARAMETER GatewayDeviceId
    The gatway device id

    .PARAMETER ExternalObsId
    An external observation id
#>

function New-Observation {

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

        [Parameter(Mandatory = $true, Position = 1)]
        [System.DateTime]
        $DateTime,

        [Parameter(Mandatory = $true, Position = 2)]
        [ValidateNotNullOrEmpty()]
        [String]
        $DeviceType,

        [Parameter(Mandatory = $true, Position = 3)]
        [ValidateNotNullOrEmpty()]
        [String]$DeviceId,

        [Parameter(Mandatory = $true, Position = 4)]
        [ValidateNotNullOrEmpty()]
        [String]$Gateway,

        [Parameter(Mandatory = $true, Position = 5)]
        [ValidateNotNullOrEmpty()]
        [String]$GatewayDeviceId,

        [Parameter(Mandatory = $true, Position = 6)]
        [ValidateNotNullOrEmpty()]
        [String]$ExternalObsId
    )
    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)"
        @{
            "attributes"                    = @{
                "type" = "Observation__c"
            }
            "External_Observation_ID__c"    = $ExternalObsId
            "Patient_ID__c"                 = $PatientId
            "Patient__c"                    = $PatientId
            "Assigning_Authority__c"        = "eCareCoordinator"
            "Device_ID__c"                  = $DeviceId
            "Device_Type__c"                = $DeviceType
            "Observation_Date_Time__c"      = ("{0:o}" -f $DateTime) -replace "00.0000000", "00"
            "Sending_Application__c"        = "PwshDataTool"
            "Measurement_Device_Gateway__c" = $Gateway
            "Gateway_Device_ID__c"          = $GatewayDeviceId
            "Device_Message__c"             = "msg-here"
        }
    }
}