ehrbase icon indicating copy to clipboard operation
ehrbase copied to clipboard

Inconsistent formatting of DV_DATE_TIME

Open Kussie opened this issue 3 years ago • 1 comments

Description

Whilst the chances of this issue actually occurring in the real world is rare the fact it is happening does raises some warning flags around the consistency of data. DV_DATE_TIME fields require an ISO8601 complaint date string to be supplied, which require a four digit year, however querying the data via AQL can result in returning a non 8601 complaint date string. For example, storing 0111-01-01 works as expected, however querying that data back out results in 111-01-01 which is not a valid 8601 data string (It is trimming the leading zero).

Configuration information

  • EHRbase version: 0.21.1
  • openEHR_SDK version: 1.19.0
  • Archie version: 2.0.1
  • PostgreSQL version: PostgreSQL 14.4 (Debian 14.4-1.pgdg110+1)
  • Java Runtime version: Oracle Corporation 11.0.15+10
  • Operating System version: Linux amd64 5.10.102.1-microsoft-standard-WSL2

Steps to reproduce

  1. Create a template that has a DV_DATE_TIME in it
  2. Supply a value of 0111-01-01T01:01:01
  3. Fetch the composition via a GET request to the Ethercis endpoint (i.e http://localhost:8453/ehrbase/rest/ecis/v1/composition/d80b0924-369d-4ea8-ae1c-fef61aecbe83::local.ehrbase.org::1) (See Api Response section below, and note value of episode_onset)
  4. Query the composition via AQL and see the returned value of 111-01-01T00:00:00.000
API Response
{
	"meta": {
		"href": {
			"url": "http://localhost:8453/ehrbase/rest/ecis/v1/composition/d80b0924-369d-4ea8-ae1c-fef61aecbe83::local.ehrbase.org::1?format=FLAT&ehr_id/rest/ecis/v1/composition/d80b0924-369d-4ea8-ae1c-fef61aecbe83::local.ehrbase.org::1"
		}
	},
	"action": "RETRIEVE",
	"composition": {
		"presenting_complaint/category|value": "event",
		"presenting_complaint/category|code": "433",
		"presenting_complaint/category|terminology": "openehr",
		"presenting_complaint/context/start_time": "2022-07-25T04:58:17.184Z",
		"presenting_complaint/context/setting|code": "228",
		"presenting_complaint/context/setting|value": "primary medical care",
		"presenting_complaint/context/setting|terminology": "openehr",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/symptom_sign_name|code": "53430007",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/symptom_sign_name|terminology": "SNOMED-CT",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/symptom_sign_name|value": "Breast Pain",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/anatomical_location/body_site_name|terminology": "SNOMED-CT",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/anatomical_location/body_site_name|value": "Left Breast",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/anatomical_location/body_site_name|code": "80248007",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/episode_onset": "0111-01-01T00:00:00",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/severity_rating|unit": "1",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/severity_rating|magnitude": 5.0,
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/pattern|terminology": "SNOMED-CT",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/pattern|value": "Non-cyclical with menstruation",
		"presenting_complaint/presenting_complaint/any_event:0/symptom_sign/pattern|code": "237454007",
		"presenting_complaint/presenting_complaint/any_event:0/time": "2022-07-25T04:58:17.215Z",
		"presenting_complaint/presenting_complaint/language|code": "en",
		"presenting_complaint/presenting_complaint/language|terminology": "ISO_639-1",
		"presenting_complaint/presenting_complaint/encoding|terminology": "IANA_character-sets",
		"presenting_complaint/presenting_complaint/encoding|code": "UTF-8",
		"presenting_complaint/language|terminology": "ISO_639-1",
		"presenting_complaint/language|code": "en",
		"presenting_complaint/territory|code": "AU",
		"presenting_complaint/territory|terminology": "ISO_3166-1",
		"presenting_complaint/composer|name": "Super Admin",
		"presenting_complaint/composer|id": "c461852a-8961-4406-a077-57291e8174cf",
		"presenting_complaint/composer|id_namespace": "development-bigpicturemedical-com",
		"presenting_complaint/composer|id_scheme": "UUID",
		"presenting_complaint/_uid": "d80b0924-369d-4ea8-ae1c-fef61aecbe83::local.ehrbase.org::1"
	},
	"format": "FLAT",
	"templateId": "presenting_complaint_breast_pain.v0",
	"ehrId": "d9a930c1-0cbc-4b0a-b64f-b7e3ddeb40af",
	"compositionUid": "d80b0924-369d-4ea8-ae1c-fef61aecbe83::local.ehrbase.org::1"
}
AQL Query (localhost:8453/ehrbase/rest/openehr/v1/query/aql)
{
	"q": "SELECT c FROM EHR e[ehr_id/value=$ehr_id] CONTAINS COMPOSITION c WHERE c/archetype_details/template_id/value = $template_id ORDER BY c/context/start_time DESC",
	"query_parameters": {
		"ehr_id": "d9a930c1-0cbc-4b0a-b64f-b7e3ddeb40af",
		"template_id": "presenting_complaint_breast_pain.v0"
	}
}
AQL Query Results
{
	"q": "SELECT c FROM EHR e[ehr_id/value=$ehr_id] CONTAINS COMPOSITION c WHERE c/archetype_details/template_id/value = $template_id ORDER BY c/context/start_time DESC",
	"columns": [
		{
			"path": "c",
			"name": "#0"
		}
	],
	"rows": [
		[
			{
				"uid": {
					"_type": "OBJECT_VERSION_ID",
					"value": "d80b0924-369d-4ea8-ae1c-fef61aecbe83::local.ehrbase.org::1"
				},
				"name": {
					"_type": "DV_TEXT",
					"value": "presenting_complaint"
				},
				"_type": "COMPOSITION",
				"context": {
					"_type": "EVENT_CONTEXT",
					"setting": {
						"_type": "DV_CODED_TEXT",
						"value": "primary medical care",
						"defining_code": {
							"_type": "CODE_PHRASE",
							"code_string": "228",
							"terminology_id": {
								"_type": "TERMINOLOGY_ID",
								"value": "openehr"
							}
						}
					},
					"start_time": {
						"_type": "DV_DATE_TIME",
						"value": "2022-07-25T04:58:17.184Z"
					}
				},
				"category": {
					"_type": "DV_CODED_TEXT",
					"value": "event",
					"defining_code": {
						"_type": "CODE_PHRASE",
						"code_string": "433",
						"terminology_id": {
							"_type": "TERMINOLOGY_ID",
							"value": "openehr"
						}
					}
				},
				"composer": {
					"name": "Super Admin",
					"_type": "PARTY_IDENTIFIED",
					"external_ref": {
						"id": {
							"_type": "GENERIC_ID",
							"value": "c461852a-8961-4406-a077-57291e8174cf",
							"scheme": "UUID"
						},
						"type": "PARTY",
						"_type": "PARTY_REF",
						"namespace": "development-bigpicturemedical-com"
					}
				},
				"language": {
					"_type": "CODE_PHRASE",
					"code_string": "en",
					"terminology_id": {
						"_type": "TERMINOLOGY_ID",
						"value": "ISO_639-1"
					}
				},
				"territory": {
					"_type": "CODE_PHRASE",
					"code_string": "AU",
					"terminology_id": {
						"_type": "TERMINOLOGY_ID",
						"value": "ISO_3166-1"
					}
				},
				"archetype_details": {
					"_type": "ARCHETYPED",
					"rm_version": "1.0.4",
					"template_id": {
						"_type": "TEMPLATE_ID",
						"value": "presenting_complaint_breast_pain.v0"
					},
					"archetype_id": {
						"_type": "ARCHETYPE_ID",
						"value": "openEHR-EHR-COMPOSITION.encounter.v1"
					}
				},
				"archetype_node_id": "openEHR-EHR-COMPOSITION.encounter.v1",
				"content": [
					{
						"name": {
							"value": "Presenting complaint",
							"_type": "DV_TEXT"
						},
						"_type": "OBSERVATION",
						"subject": {
							"_type": "PARTY_SELF"
						},
						"encoding": {
							"_type": "CODE_PHRASE",
							"code_string": "UTF-8",
							"terminology_id": {
								"_type": "TERMINOLOGY_ID",
								"value": "IANA_character-sets"
							}
						},
						"language": {
							"_type": "CODE_PHRASE",
							"code_string": "en",
							"terminology_id": {
								"_type": "TERMINOLOGY_ID",
								"value": "ISO_639-1"
							}
						},
						"data": {
							"name": {
								"value": "Event Series",
								"_type": "DV_TEXT"
							},
							"origin": {
								"value": "2022-07-25T04:58:17.215Z",
								"_type": "DV_DATE_TIME"
							},
							"events": [
								{
									"name": {
										"value": "Any event",
										"_type": "DV_TEXT"
									},
									"time": {
										"value": "2022-07-25T04:58:17.215Z",
										"_type": "DV_DATE_TIME"
									},
									"_type": "POINT_EVENT",
									"data": {
										"name": {
											"value": "Tree",
											"_type": "DV_TEXT"
										},
										"archetype_node_id": "at0003",
										"_type": "ITEM_TREE",
										"items": [
											{
												"name": {
													"value": "Symptom/Sign",
													"_type": "DV_TEXT"
												},
												"archetype_node_id": "openEHR-EHR-CLUSTER.symptom_sign.v1",
												"_type": "CLUSTER",
												"items": [
													{
														"name": {
															"value": "Symptom/Sign name",
															"_type": "DV_TEXT"
														},
														"value": {
															"_type": "DV_CODED_TEXT",
															"value": "Breast Pain",
															"defining_code": {
																"_type": "CODE_PHRASE",
																"code_string": "53430007",
																"terminology_id": {
																	"_type": "TERMINOLOGY_ID",
																	"value": "SNOMED-CT"
																}
															}
														},
														"_type": "ELEMENT",
														"archetype_node_id": "at0001"
													},
													{
														"name": {
															"value": "Pattern",
															"_type": "DV_TEXT"
														},
														"value": {
															"_type": "DV_CODED_TEXT",
															"value": "Non-cyclical with menstruation",
															"defining_code": {
																"_type": "CODE_PHRASE",
																"code_string": "237454007",
																"terminology_id": {
																	"_type": "TERMINOLOGY_ID",
																	"value": "SNOMED-CT"
																}
															}
														},
														"_type": "ELEMENT",
														"archetype_node_id": "at0003"
													},
													{
														"name": {
															"value": "Severity rating",
															"_type": "DV_TEXT"
														},
														"value": {
															"_type": "DV_QUANTITY",
															"units": "1",
															"magnitude": 5.0
														},
														"_type": "ELEMENT",
														"archetype_node_id": "at0026"
													},
													{
														"name": {
															"value": "Episode onset",
															"_type": "DV_TEXT"
														},
														"value": {
															"_type": "DV_DATE_TIME",
															"value": "111-01-01T00:00:00.000"
														},
														"_type": "ELEMENT",
														"archetype_node_id": "at0152"
													},
													{
														"name": {
															"value": "Anatomical location",
															"_type": "DV_TEXT"
														},
														"archetype_node_id": "openEHR-EHR-CLUSTER.anatomical_location.v1",
														"_type": "CLUSTER",
														"items": [
															{
																"name": {
																	"value": "Body site name",
																	"_type": "DV_TEXT"
																},
																"value": {
																	"_type": "DV_CODED_TEXT",
																	"value": "Left Breast",
																	"defining_code": {
																		"_type": "CODE_PHRASE",
																		"code_string": "80248007",
																		"terminology_id": {
																			"_type": "TERMINOLOGY_ID",
																			"value": "SNOMED-CT"
																		}
																	}
																},
																"_type": "ELEMENT",
																"archetype_node_id": "at0001"
															}
														]
													}
												]
											}
										]
									},
									"archetype_node_id": "at0002"
								}
							],
							"_type": "HISTORY",
							"archetype_node_id": "at0001"
						},
						"archetype_details": {
							"rm_version": "1.0.4",
							"template_id": {
								"value": "presenting_complaint_breast_pain.v0"
							},
							"archetype_id": {
								"value": "openEHR-EHR-OBSERVATION.story.v1"
							}
						},
						"archetype_node_id": "openEHR-EHR-OBSERVATION.story.v1"
					}
				]
			}
		]
	]
}
Operational Template

presenting_complaint_breast_pain.v0.opt.zip

Actual result

As you can see in the episode_onset fields in the above responses the supplied date of 0111-01-01T01:01:01 is in fact being stored correctly (When queried directly), however when it is retrieved via AQL, it is returned in the format of 111-01-01T01:01:01 with the leading zero on the year having been stripped off.

Expected result (Acceptance Criteria)

The supplied date should be returned in the same format as how it is stored.

Definition of Done

  • [ ] The defect is checked by an unit or an integration test (Robot)
  • [ ] Merge Request approved
  • [ ] Unit tests passed
  • [ ] Build without errors
  • [ ] Release notes prepared
  • [ ] No additional runtime warnings

Kussie avatar Jul 25 '22 05:07 Kussie

Hello @Kussie, Analyzed above case and reported bug in Jira for tracking purposes. https://jira.vitagroup.ag/browse/CDR-499 Thank you!

CC: @stefanspiska, @vidi42

vladislavploaia avatar Aug 01 '22 07:08 vladislavploaia

Tested on EHRbase v. 0.30.0-SNAPSHOT Fixed. correct_dv_date_time_response.txt image Ticket closed. CC: @vidi42

vladislavploaia avatar Aug 10 '23 13:08 vladislavploaia