-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
193 changed files
with
5,334 additions
and
2,272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
base/src/main/resources/db/migration/V21__ehr_status_name_archetype_node_id.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-- Add support for attribute name and archetype_node_id in ehr_status | ||
|
||
-- modify table ehr.status to add the missing attributes | ||
|
||
ALTER TABLE ehr.status | ||
ADD COLUMN archetype_node_id TEXT NOT NULL DEFAULT 'openEHR-EHR-EHR_STATUS.generic.v1', | ||
ADD COLUMN name ehr.dv_coded_text NOT NULL DEFAULT ('EHR Status',NULL,NULL,NULL,NULL)::ehr.dv_coded_text ; | ||
|
||
-- modify function to return ehr_status canonical json to support the new attributes | ||
CREATE OR REPLACE FUNCTION ehr.js_ehr_status(UUID) | ||
RETURNS JSON AS | ||
$$ | ||
DECLARE | ||
ehr_uuid ALIAS FOR $1; | ||
BEGIN | ||
RETURN ( | ||
WITH ehr_status_data AS ( | ||
SELECT | ||
status.other_details as other_details, | ||
status.party as subject, | ||
status.is_queryable as is_queryable, | ||
status.is_modifiable as is_modifiable, | ||
status.sys_transaction as time_created, | ||
status.name as status_name, | ||
status.archetype_node_id as archetype_node_id | ||
FROM ehr.status | ||
WHERE status.ehr_id = ehr_uuid | ||
LIMIT 1 | ||
) | ||
SELECT | ||
jsonb_strip_nulls( | ||
jsonb_build_object( | ||
'_type', 'EHR_STATUS', | ||
'archetype_node_id', archetype_node_id, | ||
'name', status_name, | ||
'subject', ehr.js_party(subject), | ||
'is_queryable', is_queryable, | ||
'is_modifiable', is_modifiable, | ||
'other_details', other_details | ||
) | ||
) | ||
FROM ehr_status_data | ||
); | ||
END | ||
$$ | ||
LANGUAGE plpgsql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- concept as json | ||
CREATE OR REPLACE FUNCTION ehr.js_concept(UUID) | ||
RETURNS JSON AS | ||
$$ | ||
DECLARE | ||
concept_id ALIAS FOR $1; | ||
BEGIN | ||
|
||
IF (concept_id IS NULL) THEN | ||
RETURN NULL; | ||
END IF; | ||
|
||
RETURN ( | ||
SELECT ehr.js_dv_coded_text(description, ehr.js_code_phrase(conceptid :: TEXT, 'openehr')) | ||
FROM ehr.concept | ||
WHERE id = concept_id AND language = 'en' | ||
); | ||
END | ||
$$ | ||
LANGUAGE plpgsql; |
3 changes: 3 additions & 0 deletions
3
base/src/main/resources/db/migration/V23__ehr_status_history_fix.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE ehr.status_history | ||
ADD COLUMN archetype_node_id TEXT NOT NULL DEFAULT 'openEHR-EHR-EHR_STATUS.generic.v1', | ||
ADD COLUMN name ehr.dv_coded_text NOT NULL DEFAULT ('EHR Status',NULL,NULL,NULL,NULL)::ehr.dv_coded_text; |
53 changes: 53 additions & 0 deletions
53
base/src/main/resources/db/migration/V24__typed_element_value.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
-- convert to lower snake case | ||
CREATE OR REPLACE FUNCTION ehr.camel_to_snake(literal TEXT) | ||
RETURNS TEXT AS | ||
$$ | ||
DECLARE | ||
out_literal TEXT := ''; | ||
literal_size INT; | ||
char_at TEXT; | ||
ndx INT; | ||
BEGIN | ||
literal_size := length(literal); | ||
if (literal_size = 0) then | ||
return literal; | ||
end if; | ||
ndx = 1; | ||
while ndx <= literal_size loop | ||
char_at := substr(literal, ndx , 1); | ||
if (char_at ~ '[A-Z]') then | ||
if (ndx > 1 AND substr(literal, ndx - 1, 1) <> '<') then | ||
out_literal = out_literal || '_'; | ||
end if; | ||
out_literal = out_literal || lower(char_at); | ||
else | ||
out_literal = out_literal || char_at; | ||
end if; | ||
ndx := ndx + 1; | ||
end loop; | ||
out_literal := replace(replace(replace(out_literal, 'u_r_i', 'uri'), 'i_d', 'id'), 'i_s_m', 'ism'); | ||
return out_literal; | ||
END | ||
$$ | ||
LANGUAGE plpgsql; | ||
|
||
-- add the _type into an element value block | ||
CREATE OR REPLACE FUNCTION ehr.js_typed_element_value(JSONB) | ||
RETURNS JSONB AS | ||
$$ | ||
DECLARE | ||
element_value ALIAS FOR $1; | ||
BEGIN | ||
RETURN ( | ||
SELECT | ||
jsonb_strip_nulls( | ||
(element_value #>>'{/value}')::jsonb || | ||
jsonb_build_object( | ||
'_type', | ||
upper(ehr.camel_to_snake(element_value #>>'{/$CLASS$}')) | ||
) | ||
) | ||
); | ||
END | ||
$$ | ||
LANGUAGE plpgsql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.