Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleClick here to view details for the configuration..
  1. The code has three parts - records, forms and rules

    1. records - Whenever any of these specified records are modified; the constraint rules should be evaluated/enforced. Refers to the fields at the data entry level for which the validation is to be applied. The value for records can be cpr, specimen, visit or a combination of these.

    2. forms - Optional field. If present, specifies the list of forms whose data is used to enforce the constraints.

    3. rules - List of integrity rules that should be satisfied by the records and forms.

  2. A ‘rule’ is made up of three attributes when, expr, and description.

    1. when: The attribute 'when' is optional and specifies when the rule is applicable. For example, the rule is applicable only for primary specimens

    2. expr: The attribute 'expr' specifies the check constraint that should be satisfied.

    3. description: The attribute 'description' describes the constraint in user-friendly language. This is also used in error messages when the rule is broken or not satisfied.

  3. Aliases for rules are - “cpr, visit, primarySpecimen, specimen”, which are self-explanator.

  4. Aliases for accessing the form records are cprForms, visitForms, primarySpecimenForms, specimenForms. These are maps that can be indexed by the form name to access the relevant form data. For example, specimenForms['SpecimenFrozenEvent'] can be used to access the latest frozen event. Similarly, specimenForms['SpecimenFrozenEvent$Array'] can be used to access the list of all the frozen events for the specimen in question.

Example: Visit date should be same or later than the registration date

For more examples, please refer to the wiki page Data Validation Examples

Expand
titleClick here to view details..
Code Block
languagejson
{
  "name" : "editChecks",
  "data" : {
    "constraints" : [ 
      {
        "records" : [ "cpr", "visit" ],
        "rules" : [
          {
            "expr" : "#cpr.registrationDate != null && #visit.visitDate != null && !#cpr.registrationDate.after(#visit.visitDate)",
            "description" : "Visit date should be same or later than the registration date!"
          } 
        ]
      }
    ]
  }
}

Data Validation Fields

We can set up data validation on these 3 types of fields and their combinations:

  1. Core fields

  2. Custom fields

  3. Custom form fields

  4. Combination of the core fields, custom fields, custom form fields

Expand
titleField dictionary used to create the expression in data validations

Level

Field Name

Field Expression

Participant

PPID

Code Block
languagejson
#cpr.ppid

Participant

First Name

Code Block
languagejson
#cpr.participant.firstName

Participant

Middle Name

Code Block
languagejson
#cpr.participant.middleName

Participant

Last Name

Code Block
languagejson
#cpr.participant.lastName

Participant

Registration Date

Code Block
languagejson
#cpr.registrationDate

Participant

External Subject ID

Code Block
languagejson
#cpr.externalSubjectId

Participant

Registration Site

Code Block
languagejson
#cpr.site

Participant

Birth Date

Code Block
languagejson
#cpr.participant.birthDate

Participant

Social Security Number

Code Block
languagejson
#cpr.participant.uid

Participant

eMPI

Code Block
languagejson
#cpr.participant.empi

Participant

Gender

Code Block
languagejson
#cpr.participant.gender

Participant

Vital Status

Code Block
languagejson
#cpr.participant.vitalStatus

Participant

Death Date

Code Block
languagejson
#cpr.participant.deathDate

Participant

Races

Code Block
languagejson
#cpr.participant.races

Participant

Ethnicity

Code Block
languagejson
#cpr.participant.ethnicities

Participant

MRN

Code Block
languagejson
#cpr.participant.pmis

Visit

Name

Code Block
languagejson
#cpr.participant.pmis

Visit

Name

Code Block
languagejson
#visit.name

Visit

Status

Code Block
languagejson
#visit.status

Visit

Missed By

Code Block
languagejson
#visit.missedBy

Visit

Missed Reason

Code Block
languagejson
#visit.missedReason

Visit

Visit Date

Code Block
languagejson
#visit.visitDate

Visit

Visit Site

Code Block
languagejson
#visit.site

Visit

Clinical Diagnosis

Code Block
languagejson
#visit.clinicalDiagnoses

Visit

Clinical Status

Code Block
languagejson
#visit.surgicalPathologyNumber

Visit

SPR

Code Block
languagejson
#visit.clinicalStatus

Visit

Visit Comments

Code Block
languagejson
#visit.comments

Specimen

Label

Code Block
languagejson
#specimen.label

Specimen

Barcode

Code Block
languagejson
#specimen.barcode

Specimen

Lineage

Code Block
languagejson
#specimen.lineage

Specimen

Collection Status

Code Block
languagejson
#specimen.status

Specimen

Type

Code Block
languagejson
#specimen.type

Specimen

Anatomic Site

Code Block
languagejson
#specimen.anatomicSite

Specimen

Laterality

Code Block
languagejson
#specimen.laterality

Specimen

Pathology Status

Code Block
languagejson
#specimen.pathology

Specimen

Initial Qty

Code Block
languagejson
#specimen.initialQty

Specimen

Available Qty

Code Block
languagejson
#specimen.availableQty

Specimen

Concentration

Code Block
languagejson
#specimen.concentration

Specimen

Parent Specimen Label

Code Block
languagejson
#specimen.parentLabel

Specimen

Biohazard

Code Block
languagejson
#specimen.biohazards

Specimen

Location

Code Block
languagejson
#specimen.storageLocation

Specimen

Created On

Code Block
languagejson
#specimen.createdOn

Specimen

Freezer Thaw Cycle

Code Block
languagejson
#specimen.freezeThawCycles

Specimen

Increment Freeze Thaw Cycle

Code Block
languagejson
#specimen.incrParentFreezeThaw

Specimen

Comments

Code Block
languagejson
#specimen.comments

Specimen

Collection Date

Code Block
languagejson
#specimen.collectionEvent.time

Specimen

Collector

Code Block
languagejson
#specimen.collectionEvent.user

Specimen

Received Date

Code Block
languagejson
#specimen.receivedEvent.time

Specimen

Receiver

Code Block
languagejson
#specimen.receivedEvent.user

Specimen

Collection Container

Code Block
languagejson
#specimen.collectionEvent.container

Specimen

Collection Procedure

Code Block
languagejson
#specimen.collectionEvent.procedure

Specimen

Received Quality

Code Block
languagejson
#specimen.receivedEvent.receivedQuality

Specimen

Frozen Time

Code Block
languagejson
#specimen.events.SpecimenFrozenEvent.time

Specimen

Frozen Method

Code Block
languagejson
#specimen.events.SpecimenFrozenEvent.frozenMethod

Specimen

Frozen Comments

Code Block
languagejson
#specimen.events.SpecimenFrozenEvent.comments

Adding Multiple Data Validations

In case there are many data validations to be performed, here is a tip that could help in avoiding errors:

...