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
    None.

    .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 {
    param([String]$PatientId, [System.DateTime]$DateTime, [String]$DeviceType, [String]$DeviceId, [String]$Gateway,[String]$GatewayDeviceId, [String]$ExternalObsId)
    @{
        "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"
    }
}