Test Suite: EHR_SERVICE / I_CONTRIBUTION Interface
Normative Reference
Items under this validation suite conceptually use these abstract interfaces from the Abstract Platform Service Model, EHR/EHR_CONTRIBUTION component.
Dependencies
This test suite depends on other test suites:
-
Functional Conformance: Definitions Component, providing OPTs;
-
Functional Conformance: EHR Component, providing EHRs.
Test Environment
-
The server under test should support at least OPTs, 1.4 or 2, but OPT 1.4 if more frequent since modeling tools supporting this were around for a long time. Could also support ADL, 1.4 or 2.
-
The server should support at least one of the XML or JSON representations of
CONTRIBUTIONsfor committing data, and integrate the corresponding schemas (XML or JSON) to validate data syntactically (before validating against an OPT).
Test Data Sets
General CONTRIBUTION Commit Data Sets
-
CONTRIBUTIONswith single validVERSION<COMPOSITION>(minimal, one for each entry type) -
CONTRIBUTIONswith multiple validVERSION<COMPOSITION>(reuse the minimal ^) -
CONTRIBUTIONwith single validVERSION<COMPOSITION>with maximal data sets -
Empty
CONTRIBUTION(noVERSIONs) -
CONTRIBUTIONswith invalidVERSION<COMPOSITION>-
Invalid data
-
Wrong
change_type -
Wrong
lifecycle
-
-
CONTRIBUTIONswith multipleVERSION<COMPOSITION>, with mixed valid and invalid ones
these cases do not consider which RM type is contained in the VERSIONs, it could be COMPOSITION, FOLDER, EHR_STATUS, etc.
|
COMPOSITION CONTRIBUTION Commit Data Sets
Since there are many combinations of data that could be used for testing the Commit CONTRIBUTION service, we decided to create three main kinds of CONTRIBUTIONs that should be tested:
-
Valid
-
minimal
COMPOSITIONswith one type of ENTRY (oneENTRYeach, allENTRYscovered) -
maximal
COMPOSITION(all data types, allENTRYtypes, andSECTIONs) -
a persistent
COMPOSITION(e.g. problem list, medication list, immunization list, …) -
time series
COMPOSITION(observation with many events, e.g. CPR compressions intervals) -
COMPOSITIONwith alternative types (e.g. lab resultDV_COUNT,DV_QUANTITYandDV_CODED_TEXT) -
COMPOSITIONwithDV_CODED_TEXTinstance on nodes declared asDV_TEXTin the OPT -
COMPOSITIONwith emptyELEMENT.valueand not emptyELEMENT.null_flavour
-
-
Invalid
-
Invalid
COMPOSITIONs(e.g. mandatory items not present, wrong types, extra items not declared in OPT, invalid values) -
Referenced OPT not loaded (this has to do more with the state of the system than to invalid data)
-
-
Change type combinations (these are the minimal required, all supported change types can be found in the openEHR Terminology)
-
VERSION.commit_audit.change_type = creation -
VERSION.commit_audit.change_type = modification -
VERSION.commit_audit.change_type = delete
-
| there could be many combinations of flows to use the different Change Types mentioned above. The minimal required by this specification it that the server is capable of this flow: 1. creation 2. modification (one or many times) 3. deleted |
Data Set Considerations
change_type
Each VERSION in a CONTRIBUTION has an AUDIT_DETAILS which contains a change_type attribute. The value on that attribute determines the internal behavior for processing each VERSION, and each VERSION in the same CONTRIBUTION could have a different change_type. The most used change types are:
-
creation: the
VERSIONrepresents the first version of aCOMPOSITION. -
amendment: the
VERSIONrepresents a new version of an existingCOMPOSITION, with the purpose of adding data. -
modification: the
VERSIONrepresents a new version of an existingCOMPOSITION, with the purpose of changing data, maybe to fix an error. -
deleted:the
VERSIONrepresents a new version of an existingCOMPOSITION, with the purpose of deleting it.
Internally, amendment and modification might be processed in the exact same way, because the difference is semantic not functional.
lifecycle_state
Each VERSION in a CONTRIBUTION contains an lifecycle_state attribute, which value gives semantics about the contents of the VERSION. The values could be:
-
incomplete: the
COMPOSITIONwas committed incomplete and should be completed (reviewed, validated, amended) later. -
complete: the
COMPOSITIONwas complete at the moment it was committed. -
deleted: the
COMPOSITIONwas committed for deletion.
These codes are defined in the openEHR Terminology.
lifecycle state machine
Combinations of data sets
These combinations can be tested by doing a single commit. The same combinations with flows of multiple commits could lead to different results.
One commit (no previous commits were done), single version cases:
All change types but creation should fail on the first commit, since other change types need a previous commit. Last one could fail because the first commit can’t be change_type = deleted or because the lifecycle_state = |complete| can’t be with change_type = deleted.
|
| change_type | lifecycle_state* | composition category | composition validity** | expected |
|---|---|---|---|---|
creation |
complete |
event |
valid |
accepted |
amendment |
complete |
event |
valid |
rejected |
modification |
complete |
event |
valid |
rejected |
deleted |
complete |
event |
valid |
rejected |
creation |
complete |
persistent |
valid |
accepted |
amendment |
complete |
persistent |
valid |
rejected |
modification |
complete |
persistent |
valid |
rejected |
deleted |
complete |
persistent |
valid |
rejected |
creation |
deleted |
event |
valid |
rejected |
amendment |
deleted |
event |
valid |
rejected |
modification |
deleted |
event |
valid |
rejected |
deleted |
deleted |
event |
valid |
rejected |
| the incomplete cases should be equal to the complete, because the flag is just adding semantics about the content, not setting how the content should be processed. |
the invalid cases will make the accepted cases on the previous table to be rejected because the content in the COMPOSITION is not
valid.
|
One commit (no previous commits were done), multiple versions cases:
the tables below represent one VERSION in the committed CONTRIBUTION.
|
-
Creating two valid, complete event
COMPOSITIONsin one commit should be accepted.change_type+ lifecycle_state++ composition category composition validity creation
complete
event
valid
creation
complete
event
valid
This
CONTRIBUTIONshould be accepted. -
Creating two valid, complete persistent
COMPOSITIONsin one commit should be accepted.depending on the server implementation, some servers might not accept the second COMPOSITIONif bothCOMPOSITIONsreference the same persistent OPT. So this test case considers bothCOMPOSITIONsreference different persistent OPTs.change_type+ lifecycle_state++ composition category composition validity creation
complete
persistent
valid
creation
complete
persistent
valid
This
CONTRIBUTIONshould be accepted. -
Creating two valid, complete and mixed category
COMPOSITIONsin one commit should be accepted.change_type+ lifecycle_state++ composition category composition validity creation
complete
event
valid
creation
complete
persistent
valid
This
CONTRIBUTIONshould be accepted. -
If any
COMPOSITIONis invalid in aCONTRIBUTION, the whole commit should fail. It doesn’t matter if it is complete or incomplete, event or persistent (just showing some of the combinations below).change_type+ lifecycle_state++ composition category composition validity creation
complete
event
valid
creation
complete
event
invalid
change_type+ lifecycle_state++ composition category composition validity creation
complete
persistent
valid
creation
complete
persistent
invalid
change_type+ lifecycle_state++ composition category composition validity creation
complete
event
valid
creation
complete
persistent
invalid
change_type+ lifecycle_state++ composition category composition validity creation
complete
event
invalid
creation
complete
persistent
valid
These
CONTRIBUTIONsshould be REJECTED.
| (+) for other change types than creation, the first commit will be rejected, so not included in the table those cases but should be tested. |
| (++) the incomplete cases should be equal to the complete, because the flag is just adding semantics about the content, not setting how the content should be processed. |
EHR_STATUS CONTRIBUTION Commit Data Sets
Combinations for data sets
The following accepted and rejected apply under any of these scenarios:
-
The server has an EHR with the default
EHR_STATUS(the EHR was created without providing anEHR_STATUS). -
The server has an EHR created by providing an
EHR_STATUS. -
The server has an EHR with modifications already done to its
EHR_STATUS(consecutive modifications).
Reject Cases:
-
CONTRIBUTIONswithVERSION, whereVERSION.commit_audit.change_typeIN [creation,deleted] should be rejected, because the defaultEHR_STATUSwas already created in the EHR, and theEHR_STATUScan’t be deleted once created. -
CONTRIBUTIONswithVERSION, whereVERSION.lifecycle_state=incompleteshould be rejected, because theincompletestate doesn’t apply toEHR_STATUS. Though there is an open issue related to this: https://specifications.openehr.org/jira/browse/SPECPR-368 -
Any other case with an
invalidEHR_STATUSinVERSIONshould also be rejected.
Accepted Cases:
-
CONTRIBUTIONswithVERSIONwhereVERSION.commit_audit.change_typeIN [modification,amendment] andvalidEHR_STATUS, should be accepted. This inscludes the following combinations forEHR_STATUS:
| is_modifiable | is_queryable | subject.external_ref |
|---|---|---|
true |
true |
HIER_OBJECT_ID |
true |
true |
GENERIC_ID |
true |
true |
NULL |
true |
false |
HIER_OBJECT_ID |
true |
false |
GENERIC_ID |
true |
false |
NULL |
false |
true |
HIER_OBJECT_ID |
false |
true |
GENERIC_ID |
false |
true |
NULL |
false |
true |
HIER_OBJECT_ID |
false |
true |
GENERIC_ID |
false |
true |
NULL |
false |
false |
HIER_OBJECT_ID |
false |
false |
GENERIC_ID |
false |
false |
NULL |
Since EHR_STATUS is LOCATABLE, is should have an archetype_id assigned. It is recommended to test the combination described above, combined with different values for EHR_STATUS.archetype_id.
|
FOLDER CONTRIBUTION Commit Data Sets
All the datasets are specified at the EHR.directory level, since that is the current level of operation of the openEHR REST API for FOLDERs to create, update or delete.
Data Set Combinations
Valid payload should include these cases:
-
minimal directory
-
directory with items
-
directry with subfolders
-
directory with items and subfolders
-
directory with items and subfolders with items
Sample structure of FOLDERs with items:
Folders with items
Table of data combinations:
| change_type | lifecycle_state | payload | expected |
|---|---|---|---|
creation |
complete / incomplete |
valid |
accepted |
amendment / modification |
complete / incomplete |
valid |
accepted |
deleted |
deleted |
valid |
accepted |
Any invalid payload should be rejected.
Test Cases
Service Model operation: I_EHR_CONTRIBUTION.commit_contribution()
Service Model reference: I_EHR_CONTRIBUTION.commit_contribution()
Test Case I_EHR_CONTRIBUTION.commit_contribution-valid_composition
Description |
Successfully commit |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-invalid_composition
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-empty
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-valid_invalid_compositions
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
the whole commit should behave like a transaction and fail, no CONTRIBUTIONs or VERSIONs should be created on the server.
|
Test Case I_EHR_CONTRIBUTION.commit_contribution-event_composition
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-persistent_composition
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-delete
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-two_commits_second_invalid
Description |
Commit two |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-two_commits_second_creation
Description |
Commit two |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Validity criterion: only one 'create' operation is allowed for persistent COMPOSITIONs, the next operations over an existing persistent COMPOSITION should be modification.
|
Test Case I_EHR_CONTRIBUTION.commit_contribution-non_exiting_opt
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-minimal_ehr_status
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-full_ehr_status
| this case is the same as previous but the precondition 2. is different. |
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-ehr_status_invalid_change_type
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-invalid_ehr_status
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test Case I_EHR_CONTRIBUTION.commit_contribution-valid_directory
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-fail_create_existing_directory
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-fail_modify_non_existing_directory
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.commit_contribution-update_existing_directory
Description |
Commit |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Service Model operation: I_EHR_CONTRIBUTION.list_contributions()
Service Model reference: I_EHR_CONTRIBUTION.list_contributions()
CONTRIBUTIONs can contain COMPOSITION, EHR_STATUS or FOLDER, or any mix of those. Each flow below applies to a specific type, except when 'ANY' is mentioned, in which case the flow applies to any of those three types.
|
Test Case I_EHR_CONTRIBUTION.list_contributions-post_commit
Description |
List |
|---|---|
Pre-conditions |
|
Post-conditions |
|
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.list_contributions-empty
Description |
List |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.list_contributions-non_existing_ehr
Description |
List |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.list_contributions-ehr_containing_ehr_status
Description |
List |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.list_contributions-ehr_containing_directory
Description |
List |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Service Model operation: I_EHR_CONTRIBUTION.has_contribution()
Service Model reference: I_EHR_CONTRIBUTION.has_contribution()
Test Case I_EHR_CONTRIBUTION.has_contribution-existing
Description |
Test presence of |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.has_contribution-empty_ehr
Description |
Test presence of |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.has_contribution-bad_ehr
Description |
Test presence of |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.has_contribution-bad_contribution
Description |
Test presence of |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Service Model operation: I_EHR_CONTRIBUTION.get_contribution()
Service Model reference: I_EHR_CONTRIBUTION.get_contribution()
Test Case I_EHR_CONTRIBUTION.get_contribution-existing
Description |
Test get |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.get_contribution-empty_ehr
Description |
Test get |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.get_contribution-bad_ehr
Description |
Test get |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_EHR_CONTRIBUTION.get_contribution-bad_contribution
Description |
Test get |
|---|---|
Pre-conditions |
|
Post-conditions |
None |
Flow |
|
Test runners |