Click or drag to resize

TOPICA Basic Class Record

[This is preliminary documentation and is subject to change.]

The Record class models one instance of a configured form (the data in one saved form) of patient record data. One form instance is stored in one database row, so there is a 1:1-relation between a Record object in TOPICA Basic and a row in one of the dynamically generated database tables.

Record properties

Property

Type

Version

Description

Table

DataDictionaryTable

The table the record belongs to.

Type

String

The StructureType defined in The Structure File

The TOPICA framework does not use this value for anything when generating Data Dictionary, i.e. the value does not have any influence on the dynamically generated database tables.

The value is used in the "Search Patient" dialog to group tables in logical groups. The user may optionaly display records belonging to tables having specified structure types. For example: the Data Dictionary may contain several tables, that all describe "encounters".

Equivalent to Table.Type

TableName

String

The table name specified in DataName in The Structure File - this is also the name of the dynamically generated database table.

Equivalent to Table.TableName

Caption

String

The caption specified in property Caption in The Structure File and hence saved in the Data Dictionary.

Equivalent to Table.Caption

Id

Integer

Internal ID of the record. Guaranteed to be unique in each table. Autogenerated (incremented) upon insertion in database table.

The key of a record is (TableName, Id).

DateCreate

DateTime

The system date/time when the record was created.

DateUpdate

DateTime

The system date/time when the record was LAST updated.

DateDelete

DateTime

4.31+

Date/time for logical deletion - null if NOT logically deleted.

Deleted

Boolean

4.31+

Whether the record is logically deleted.

DeletedByEmployee (alias DeletedBy)

Employee

4.31+

The employee user that logically deleted this record.

DateStart

DateTime

The value of the DATE_START column in the database table.

The value of this field is set whenever a record (form instance) is created or updated according to this algorithm:

  • If a DateStart computation is defined (in The Structure File), this computation is evaluated, and if the result has type DateTime, this value is used - else:

  • If one (and only one) DateTime field in the form has been marked as "DateStart", the value of this field is used - else:

  • The minimum value (i.e. earliest date/time value) of all DateTime fields in the form is used.

DateStop

DateTime

The value of the DATE_STOP column in the database table.

This value is automatically set to the current system date/time when a record is closed.

Closed

Boolean

The value of the STATUS_CLOSED column in the database table.

Closed status.

Completed

Boolean

The value of the STATUS_COMPLETE column in the database table.

Completed status.

Value true means, that all fields with FillInStatus not equal to "Optional" have been filled in (i.e. no fields are empty), AND that no errors or warnings were generated by any validation rule.

CreatedByEmployee

Obsolete alias: CreatedBy

Employee

The employee user that created this record - will be null if it was a logged in patient, that created the record.

UpdatedByEmployee

Obsolete alias: UpdatedBy

Employee

The employee user that last updated this record - will be null if the record has not been updated since it was created, or it was a logged in patient, that last updated the record.

EmployeeUser

Obsolete alias: User

Employee

If the record was last touched by a logged in employee, this property contains the employee user that last touched this record - i.e. equal to UpdatedByEmployee if the record has been updated, otherwise equal to CreatedByEmployee

record.EmployeeUser = if(IsNotNull(record.UpdatedByEmployee), record.UpdatedByEmployee, record.CreatedByEmployee)

CreatedByPatient

Patient

4.24+

The patient user that created this record will be null if it was a logged in patient, that created the record.

UpdatedByPatient

Patient

4.24+

The patient user that last updated this record - will be null if the record has not been updated since it was created, or it was a logged in employee, that last updated the record.

PatientUser

Patient

4.24+

If the record was last touched by a logged in patient, this property contains the patient user that last touched this record - i.e. equal to UpdatedByPatient if the record has been updated, otherwise equal to CreatedByPatient

record.PatientUser = If(IsNotNull(record.UpdatedByPatient), record.UpdatedByPatient, record.CreatedByPatient)

Patient

Patient

4.30+

The patient to which the record belongs.

There is a global variable Patient (holding the patient in context), and a record is nomally only handled when the patient that "owns" the record is in context. In most cases Record.Patient = Patient. So why is Record.Patient needed?

Because it is possible to "customize" values of fields when records are "merged" from one patient to another (by using the SetValueOnCopy property, that may be specified on all form elements generating fields in the database). Merging two patients involves copying records from one patient to another. Field values in records are per default copied unchanged. But in some situations field values should NOT be just copied (they should be set to a new fixed or computed value). The SetValueOnCopy property may hold a TOPICA Basic expression - whn this is presnet, it is valuated, and the result will be the field value in the copied record.

During the "merge" operation there are 2 patients involved:

  • Record refers to the "source" record (where data is copied FROM).

  • It follows that Record.Patient refers to the "source" patient (the patient data is copied FROM).

  • Patient refers to the "destination" patient (the patient data is copied TO).

For an example - see demo application DemoPatientMerge.

OrgUnit

OrgUnit

NOTE:

Note Note

Behavior of this property depends on the whether "external relations" are in use.

  • In versions 4.22 and earlier, "external relations" are not implemented.

    There is always one and only one relation from Record to OrgUnit (the so called "data ownership" relation),

    The value of the OrgUnit property will be the OrgUnit stored in that relation (the "data owner"). This value will be null if the configuration of the table is OrgUnitRelation=None (e.g. when the record is neither an encounter nor a subrecord to an encounter).

  • In versions 4.23 and later, it is possible to specify any number of (named) relations from Record to OrgUnit (the "external relations" feature). When the "external relations" feature is NOT used, OrgUnit works as above (as in earlier releases). When the "external relations" feature IS used, there are the following scenarios:

    • One of the relations to OrgUnit has blank name (the default, backward compatible relation). Then the value of the OrgUnit property will be the OrgUnit stored in that relation.

    • None of the relations have blank name - or you need to get the OrgUnit value in a named relation. In this scenario, you MUST supply the relation name as parameter.

      Example: Record.OrgUnit("MyRelation")

      If you specify the name of a relation, that is not defined on the table, an exception is thrown.

ParentRecord

Record

The "parent" record in the Patient Record Tree

Will be null if the record is directly below the root (= Patient).

SubRecords

RecordCollection

All subrecords (= "child" records) below this record.

RelationsFrom

RecordRelationCollection

4.24+

All relations from this record to any other records.

RelationsTo

RecordRelationCollection

4.24+

All relations to this record from any other records.

XXX (whatever)

Any

If the record contains a field with field name XXX (specified by DataName in the form) the value of this field is returned.

Type of the result obviously depends on the type of field.

Caution note Caution

Note that since a configured field with DataName="XXX" is accessed with the syntax Record.XXX, you should not use any of the "fixed" property names for your configured fields. If, for example, you configured a field with DataName = "OrgUnit", you would not be able to get the value of that field in TOPICA Basic, as Record.OrgUnit would return the data owner of the record, not the value of your field "OrgUnit".

Record indexing

The Record class supports indexing by strings. The index value (i.e. the string) must be the name of a table, to which there is a 1:1-relation from the table of the current record (specified in The Structure File and saved in the Data Dictionary).

If Record.TableName = "TableX", and there is a 1:1-relation between TableX and TableY where TableX is the "parent" and TableY is the "child" - then the expression Record["TableY"] will return the record (form instance) of type TableY. The result is an object of type Record, if the child form has been filled in, and null if the child form has NOT been filled in.

Example:

if(IsNull(Record["TableY"], "Form Y has not been filled in", "Value of form Y, field Z: " + Record["TableY"].Z)