Report Template Objects
Null Objects
A null object is returned whenever the referenced object (encounter or medication) cannot be located. The null objects allow you to access the object as if one were found making it much easier to create reports. Null objects are returned for encounters and medications.
Encounter Object
Properties
- EncounterDateObject – The date value of the encounter. Will return DateTime.MinValue if the encounter is null.
- EncounterDate – the string value of the encounter. Will return an empty string if the encounter is null.
- IsBaseline – returns true if the encounter is the baseline encounter, otherwise false.
- IsFixed – returns true if the encounter is for a fixed interval, otherwise false.
- IsNull – returns true if the encounter is null, otherwise false.
- #VariableCode – returns the value of the variable with the specified variable code. If the value is null, an empty string is returned.
- #VariableCode.Name – returns the pick list name associated with the value of the variable with the specified variable code. If the value is null, an empty string is returned.
- #VariableCode.ID – returns the ID of the variable with the specified variable code. This is used for methods that take a variableId.
Methods
- GetVariableLabel(variableId) – if the variable is categorical (pick list or radio buttons), it will return the display name, otherwise it will return the value of the variable.
Encounter Collection (ENCOUNTERS)
Overview
Data (including variable values) about any of the subject's encounters can be accessed via a special object named "ENCOUNTERS". This object is a collection of "Encounter" objects (described above). Following is an example of using this collection in code:
To access encounter variables, either loop through the ENCOUNTERS collection or use one of the properties or methods described below to obtain a reference to an Encounter object. At that point you can access a variable value with the encounter.#VariableCode syntax as described above.
See Examples.
Properties
- Count – returns the number of encounters in the collection.
- FirstEncounter – returns the first encounter in the collection. If no encounter is found, a null encounter is returned.
- Example: Â var dayStart = ENCOUNTERS.FirstEncounter.#EncounterDate.value;Â
- Sets the value of variable dayStart to the Encounter Date of the first encounter
- Example: Â var dayStart = ENCOUNTERS.FirstEncounter.#EncounterDate.value;Â
- LastEncounter – returns the last encounter in the collection. If no encounter is found, a null encounter is returned.
- Example: Â var dayEnd = ENCOUNTERS.LastEncounter.#EncounterDate.value;
- Sets the value of variable dayEnd to the Encounter Date of the last encounter
- Example: Â var dayEnd = ENCOUNTERS.LastEncounter.#EncounterDate.value;
Methods
- Average(variableId) – returns the average value of the variable specified by variableId for all encounters in the collection. Returns NaN if any values are null.
- Sum(variableId) – returns the sum of the variable specified by variableId for all encounters in the collection. Returns NaN if any values are null.
- Filter(variableId, "compareOperator", compareValue) – returns a collection of encounters that are not excluded by the specified filter. The valid values for compareOperator are:
- IS NOT NULL
- IS NULL
- =
- !=
- <>
- <
- <=
- >
- >=
- Example: var filteredEnc = ENCOUNTERS.Filter(#IntervalName.ID,"=", "Clinic Visit");
- The encounters are filtered to only include those named "Clinic Visit"
- Example: Â var sortedFilteredEnc = ENCOUNTERS.Filter(#IntervalName.ID, "=", "Clinic Visit").Sort(#EncounterDate.ID, true);
- The encounters are filtered to only include those named "Clinic Visit" and they are sorted in ascending order by the Encounter Date (see sort information below)
- Example: var filteredEnc = ENCOUNTERS.Filter(#IntervalName.ID,"=", "Clinic Visit");
- GetCount(variableId) – returns the number of encounters in the collection that have a non-null value for the specified variableId.
- GetEncounter(encounterDate) – returns the first encounter in the collection with the specified encounterDate if found, otherwise it returns a null encounter.
- GetEncounter(encounterDateString) – attempts to convert the string to a date and then returns the first encounter in the collection with the specified encounterDate, if found, otherwise it returns a null encounter.
- GetEncounter(index) – returns the encounter at the specified index in the collection. If the index is greater than the number of items in the collection, a null encounter is returned.
- GetFirstEncounter()- returns the same as the FirstEncounter property. If no encounter is found, a null encounter is returned.
- GetNextEncounter(encounterObject) – returns the encounter in the collection that follows the specified encounter. If no encounter is found, a null encounter is returned.
- GetNextEncounter(encounterDate) – returns the encounter in the collection that follows the encounter with the specified date. If no encounter is found, a null encounter is returned.
- GetNextEncounter(encounterDateString) – attempts to convert the string to a date and then returns the encounter in the collection that follows the encounter with the specified date. If no encounter is found, a null encounter is returned.
- GetPriorEncounter(encounterObject) – returns the encounter in the collection that precedes the specified encounter. If no encounter is found, a null encounter is returned.
- GetPriorEncounter(encounterDate) – returns the encounter in the collection that precedes the encounter with the specified date. If no encounter is found, a null encounter is returned.
- GetPriorEncounter(encounterDateString) – attempts to convert the string to a date and then returns the encounter in the collection that precedes the encounter with the specified date. If no encounter is found, a null encounter is returned.
- IndexOf(encounterObject) – returns the index of the specified encounter object. If no encounter is found, a null encounter is returned.
- IndexOf(encounterDate) – returns the index of the first encounter with the specified encounterDate. If no encounter is found, a null encounter is returned.
- IndexOf(encounterDateString) – attempts to convert the string to a date and then returns the index of the first encounter with the specified encounterDate. If no encounter is found, a null encounter is returned.
- MaxEncounter(variableId) – returns the first encounter in the collection containing the max value for the specified variableId. If no encounter is found, a null encounter is returned.
- MaxValue(variableId) – return the max value for the specified variableId. An empty string is returned if no values are found.
- MinEncounter(variableId) – returns the first encounter in the collection containing the min value for the specified variableId. If no encounter is found, a null encounter is returned.
- MinValue(variableId) – return the min value for the specified variableId. An empty string is returned if no values are found.
- Offset(encounter, offset) – returns the encounter that is offset positions away from the specified encounter. If no encounter is found, a null encounter is returned. Offset can be negative. Ex.
// returns the second to last encounter.
ENCOUNTERS.Offset(ENCOUNTERS.LastEncounter, -1)* Offset(encounterDate, offset) – returns the encounter that is offset positions away from the encounter with the specified Date. If no encounter is found, a null encounter is returned. Offset can be negative. - Offset(encounterDateString, offset) – attempts to convert the string to a date and then returns the encounter that is offset positions away from the encounter with the specified Date. If no encounter is found, a null encounter is returned. Offset can be negative.
- Sort(variableId, ascending) – returns a collection of encounters sorted by the values of the specified variableId. If ascending is true, the collection will be sorted in ascending order, otherwise it will be sorted in descending order.
- Example:Â var encountersSorted = ENCOUNTERS.Sort(#EncounterDate.ID, true);
- The ENCOUNTERS collection is sorted by Encounter Date in ascending order
- Example:Â var encountersSorted = ENCOUNTERS.Sort(#EncounterDate.ID, true);
Medication Object
Properties
- Administration Route – the administration route for this medication. Will be an empty string on a null medication.
- AR – a shortcut for Administration Route.
- Description – the description of the medication. Will be an empty string on a null medication.
- DoseValue – the numeric value for the dose. Will be decimal.MinValue on a null medication.
- Dose – the string value for the dose. Will be an empty string on a null medication.
- DoseNTZ – the same as Dose with trailing zeros removed.
- ED – Shortcut for End Date
- EndDate – the string value for the end date. Will be an empty string on a null medication. Uses the format MM/DD/YYYY
- EndDateDate- the date value for the end date. Will be SqlDateTime.Null on a null medication.
- GenericName- the generic name for this medication. Will be an empty string on a null medication.
- GN – a shortcut for GenericName.
- IsNull – true if medication is null, otherwise false.
- SD – shortcut for StartDate.
- StartDate – the string value for the start date. Will be an empty string on a null medication.
- StartDateDate – the date value for the start date. Will be SqlDateTime.Null on a null medication.
- TimesPerDay – the string value for times per day. Will be an empty string on a null medication.
- TimesPerDayValue – the numeric value for times per day. Will be int.MinValue on a null medication.
- TN – shortcut for TradeName.
- TPD – shortcut for TimesPerDay.
- TradeName – the trade name for the medication. Will be an empty string on a null medication.
- UnitOfMeasure – the unit of measure for the medication. Will be an empty string on a null medication.
- UOM – shortcut for UnitOfMeasure.
Medication Collection (MEDICATIONS)
All of the subject's medications are stored in a collection for each report. These medications can be accessed via the MEDICATIONS collection. See the Medication Object description for a list of properties.
Properties
- Count – returns the number of medications in the collection.
- Medications - returns a list of all the medications contained in this collection.
Methods
- CurrentMedications() – returns a collection of the current medications. This includes any medication whose start date is before the current date and the end date is null or after the current date.
- MedicationAsOf(date) – returns a collection of medications whose start date is before the specified date and the end date is null or after the specified date.
- Sort(field, ascending) – returns a collection of medications sorted by the specified field. If ascending is true, the collection will be sorted in ascending order, otherwise it will be sorted in descending order.
Valid values for field:
- StartDate
- EndDate
- TradeName
- GenericName
- AdministrationRoute
- Description
- Dose
- UnitOfMeasure
- TimesPerDay
- Indication