CDA Best Practices
Assert the Template Identifier as a Constraint(s)
- On every template, create a constraint for "templateId"
- Create a constraint for "@root" equal to the OID of the template's identifier
- Create a constraint for "@extension" equal to the extension of the template's identifier (if any)
Constraints with Data-type CS
Coded Simple Value (CS)
Definition: Coded data in its simplest form, where only the code is not predetermined. The code system and code system version are fixed by the context in which the CS value occurs. CS is used for coded attributes that have a single HL7-defined value set.
This means that you should only specify the "Code" attribute for a single-value binding. An example of where this is commonly the case is with the "statusCode" element.
Constraints on nullFlavor
Flavors of null are defined as follows:
NI No information. This is the most general and default null flavor.
NA Not applicable. Known to have no proper value (e.g., last menstrual period for a male).
UNK Unknown. A proper value is applicable, but is not known.
ASKU Asked, but not known. Information was sought, but not found (e.g., the patient was asked but did not know).
NAV Temporarily unavailable. The information is not available, but is expected to be available later.
NASK Not asked. The patient was not asked.
MSK There is information on this item available but it has not been provided by the sender due to security, privacy, or other reasons. There may be an alternate mechanism for gaining access to this information.
OTH The actual value is not an element in the value domain of a variable. (e.g., concept not provided by required code system).
Some use cases may justify optionally allowing for a nullFlavor [0..1], and requiring that the appropriate value for nullFlavor attribute be present (i.e. bind to single-value binding) when nullFlavor is present. In order to achieve this:
1. Create constraint on nullFlavor with MAY Cardinality [0..1]
2. Select the binding type of 'Single Value Binding'
3. Enter the appropriate Code, Display, and Code System for the flavor of null that will be required when nullFlavor is present
4. Add a Child Primitive constraint to nullFlavor by selecting the underscored 'T' icon in the constraint editor (right)
5. Select you're newly created primitive constraint. Add 'If nullFlavor is present, nullFlavor SHALL be 'NI'' into the text box.
6. In the bottom right 'View Mode', change view to Engineer, de-select 'Auto Generate' and enter to the custom schematron logic in order to technically validate that the desired value of nullFlavor is found when nullFlavor is present.
For the example above, the constraint states "MAY contain zero or one [0..1] @nullFlavor="NI" No Information (CodeSystem: HL7NullFlavor urn:oid:2.16.1.113883.5.1008)". The custom schematron to validate that nullFlavor has a value of 'NI' in all cases when nullFlavor exists is: "test=not(nullFlavor) or nullFlavor='NI'"