Skip to content

GetCDMVisitId

aggregating category: cdm-helpers no `||`

Looks up a visit id on a named CDM table by key with the narrowest matching date interval.

Collects a visit id from a named table — typically visit_occurrence or visit_detail. The returned id is the one whose start_date/end_date interval most narrowly contains the start date (and optional end date) given as parameters.

Parameters

Default key/value, single date

1table Mandatory — accepts: table

The CDM table the id is collected from, in @-notation. With this form the key field defaults to <table_name>_source_value and the value field to <table_name>_id.

2keyValue Mandatory — accepts: field

Field whose value must match the key field on the CDM table.

3date Mandatory — accepts: field

A date field whose value must be contained in the visit interval.

Default key/value, start/end date

1table Mandatory — accepts: table

The CDM table, in @-notation.

2keyValue Mandatory — accepts: field

Field whose value must match the key field on the CDM table.

3startDate Mandatory — accepts: field

Start date — the visit interval must contain this value.

4endDate Mandatory — accepts: field

End date — the visit interval must contain this value.

Explicit key/value fields

1table Mandatory — accepts: table

The CDM table, in @-notation.

2key Mandatory — accepts: field

The key field on the CDM table, in :-notation. Defaults to <table_name>_source_value if omitted.

3value Mandatory — accepts: field

The value field on the CDM table, in :-notation. Defaults to <table_name>_id if omitted.

4keyValue Mandatory — accepts: field

Field whose value must match the key field.

5startDate Mandatory — accepts: field

Start date of the interval to match.

6endDate Mandatory — accepts: field

End date of the interval to match.

Input type

Parameter 1 is the CDM table; parameters 2 and 4 are field references of any matching type; parameters 5 and 6 are date fields.

Output type

The output type matches the type of the value field.

Examples

Default fields, single date

GetCDMVisitId(@visit_occurrence, :recnum, :date)

Default fields, start and end date

GetCDMVisitId(@visit_occurrence, :recnum, :start_date, :end_date)

Explicit key/value with start and end date

GetCDMVisitId(@visit_occurrence, :visit_occurrence_source_value, :visit_occurrence_id, :recnum, :start_date, :end_date)

See also

GetCDMTableId, GetCDMFieldValue