NINS_CODE/bahmni_config/openmrs/migrations/openmrs-patient-attributes-liquibase.xml

414 lines
20 KiB
XML
Raw Normal View History

2024-12-12 22:37:39 +06:00
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<!-- This Liquibase file is meant to contain changesets for Patient Attributes Only -->
<changeSet id="BAHMNI-IMPL-OMRS-PA-001" author="tw">
<comment>Add patient attributes</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('education', 'Education Details', 'org.openmrs.Concept', '1', 1, curdate(), 0, 6, uuid());
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('occupation', 'Occupation', 'org.openmrs.Concept', '1', 1, curdate(), 0, 7, uuid());
</sql>
</changeSet>
<changeSet id="BD-20150421-1921" author="neha">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from concept_name where name = 'Education Details';
</sqlCheck>
</preConditions>
<comment>Adding Concept Education Details</comment>
<sql>
set @concept_id = 0;
set @concept_name_short_id = 0;
set @concept_name_full_id = 0;
call add_concept(@concept_id, @concept_name_short_id, @concept_name_full_id, 'Education Details', 'education', 'Coded', 'Misc', false);
UPDATE person_attribute_type SET format = 'org.openmrs.Concept', foreign_key = @concept_id WHERE name = 'education';
</sql>
</changeSet>
<changeSet id="BD-20150421-1924" author="neha">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from concept_name where name = 'Occupation';
</sqlCheck>
</preConditions>
<comment>Adding Concept Occupation</comment>
<sql>
set @concept_id = 0;
set @concept_name_short_id = 0;
set @concept_name_full_id = 0;
call add_concept(@concept_id, @concept_name_short_id, @concept_name_full_id, 'Occupation', 'occupation', 'Coded', 'Misc', false);
UPDATE person_attribute_type SET format = 'org.openmrs.Concept', foreign_key = @concept_id WHERE name = 'occupation';
</sql>
</changeSet>
<include file = "openmrs-patient-education.xml"/>
<include file = "openmrs-patient-occupation-liquibase.xml"/>
<changeSet id="BD-20150407-1245" author="Hitansu,Dubey" context="setup">
<comment>Creating House Hold Code person attribute fields</comment>
<insert tableName="person_attribute_type">
<column name="name" value="House Hold Code"/>
<column name="description" value="House Hold Code"/>
<column name="format" value="java.lang.String"/>
<column name="searchable" value="1"/>
<column name="creator" value="1"/>
<column name="date_created" valueDate="now()"/>
<column name="retired" value="0"/>
<column name="sort_weight" value="6"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>
<changeSet id="BD-20150225-1138" author="neha" context="setup">
<comment>Creating Birth registration number and Unique id number person attribute feilds</comment>
<insert tableName="person_attribute_type">
<column name="name" value="Birth Registration Id"/>
<column name="description" value="Birth Registration Number"/>
<column name="format" value="java.lang.String"/>
<column name="searchable" value="1"/>
<column name="creator" value="1"/>
<column name="date_created" valueDate="now()"/>
<column name="retired" value="0"/>
<column name="sort_weight" value="4"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
<insert tableName="person_attribute_type">
<column name="name" value="Unique Id"/>
<column name="description" value="Unique Identifier"/>
<column name="format" value="java.lang.String"/>
<column name="searchable" value="1"/>
<column name="creator" value="1"/>
<column name="date_created" valueDate="now()"/>
<column name="retired" value="0"/>
<column name="sort_weight" value="5"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>
<changeSet id="BD-20150424-1632" author="neha" context="setup">
<preConditions>
<sqlCheck expectedResult="0">
select count(*) from person_attribute_type where name = 'primaryContact';
</sqlCheck>
</preConditions>
<comment>Creating Primary Contact person attribute feilds</comment>
<insert tableName="person_attribute_type">
<column name="name" value="primaryContact"/>
<column name="description" value="Primary Contact"/>
<column name="format" value="java.lang.String"/>
<column name="searchable" value="0"/>
<column name="creator" value="1"/>
<column name="date_created" valueDate="now()"/>
<column name="retired" value="0"/>
<column name="sort_weight" value="8"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>
<changeSet id="BD-20150427-1345" author="neha" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from concept_name where name = "uncategorized diagnoses";
</sqlCheck>
</preConditions>
<sql>
set @concept_id = 0;
set @concept_name_short_id = 0;
set @concept_name_full_id = 0;
call add_concept(@concept_id, @concept_name_short_id, @concept_name_full_id, 'uncategorized diagnoses', 'uncategorized diagnoses', 'N/A', 'ConvSet', true);
</sql>
</changeSet>
<changeSet id="BD-20150427-1346" author="neha" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from concept_name where name = "Diagnosis Answers";
</sqlCheck>
</preConditions>
<sql>
set @concept_id = 0;
set @concept_name_short_id = 0;
set @concept_name_full_id = 0;
call add_concept(@concept_id, @concept_name_short_id, @concept_name_full_id, 'Diagnosis Answers', 'Diagnosis Answers', 'Coded', 'Misc', false);
</sql>
</changeSet>
<changeSet id="BD-20150528-1630" author="utsab" context="setup">
<comment>Deleting all the person attributes, referring to Unique Id or primaryContact</comment>
<sql>
delete from person_attribute where person_attribute_type_id = (select person_attribute_type_id from person_attribute_type where name = 'Unique Id');
delete from person_attribute where person_attribute_type_id = (select person_attribute_type_id from person_attribute_type where name = 'primaryContact');
</sql>
</changeSet>
<changeSet id="BD-20150528-1640" author="utsab" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'Unique Id';
</sqlCheck>
</preConditions>
<comment>Removing Unique Id Attribute</comment>
<sql>
delete from person_attribute_type where name = 'Unique Id';
</sql>
</changeSet>
<changeSet id="BD-20150528-1643" author="utsab" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'primaryContact';
</sqlCheck>
</preConditions>
<comment>Removing Primary Contact Attribute</comment>
<sql>
delete from person_attribute_type where name = 'primaryContact';
</sql>
</changeSet>
<changeSet id="BD-20150528-1703" author="utsab" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from person_attribute_type where name = 'Phone Number';
</sqlCheck>
</preConditions>
<comment>Add Patient Phone Number Attribute</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('Phone Number', 'Phone Number', 'java.lang.String', '1', 1, curdate(), 0, 8, uuid());
</sql>
</changeSet>
<changeSet id="BD-20151005-1301" author="sanjana" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from person_attribute_type where name = 'fatherName';
</sqlCheck>
</preConditions>
<comment>Add Father's name attribute</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('fatherName', 'Father\'s Name', 'java.lang.String', '1', 1, now(), 0, 9, uuid());
</sql>
</changeSet>
<changeSet id="BD-20151005-1436" author="sanjana" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from person_attribute_type where name = 'spouseName';
</sqlCheck>
</preConditions>
<comment>Add Spouse's name attribute</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('spouseName', 'Spouse\'s Name', 'java.lang.String', '1', 1, now(), 0, 10, uuid());
</sql>
</changeSet>
<changeSet id="BD-20151005-1437" author="sanjana" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from person_attribute_type where name = 'motherName';
</sqlCheck>
</preConditions>
<comment>Add Spouse's name attribute</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('motherName', 'Mother\'s Name', 'java.lang.String', '1', 1, now(), 0, 10, uuid());
</sql>
</changeSet>
<changeSet id="BD-20150421-1440" author="apaule">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'Birth Registration Id';
</sqlCheck>
</preConditions>
<comment>Updating the attribute Birth Registration ID </comment>
<sql>
UPDATE person_attribute_type SET name = 'birthRegistrationId' WHERE name = 'Birth Registration Id';
</sql>
</changeSet>
<changeSet id="BD-20150421-1441" author="apaule">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'House Hold Code';
</sqlCheck>
</preConditions>
<comment>Updating the attribute House hold code</comment>
<sql>
UPDATE person_attribute_type SET name = 'householdCode' WHERE name = 'House Hold Code';
</sql>
</changeSet>
<changeSet id="BD-20150421-1442" author="apaule">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'Occupation';
</sqlCheck>
</preConditions>
<comment>Updating the attribute Occupation</comment>
<sql>
UPDATE person_attribute_type SET name = 'occupation' WHERE name = 'Occupation';
</sql>
</changeSet>
<changeSet id="BD-20150421-1443" author="apaule">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'Phone Number';
</sqlCheck>
</preConditions>
<comment>Updating the attribute Phone Number </comment>
<sql>
UPDATE person_attribute_type SET name = 'phoneNumber' WHERE name = 'Phone Number';
</sql>
</changeSet>
<changeSet id="BD-20150528-1445" author="apaule" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'familyNameLocal';
</sqlCheck>
</preConditions>
<comment>Removing family Name Local Attribute</comment>
<sql>
UPDATE person_attribute_type SET retired = 1, retired_by = 1, date_retired=now(), retire_reason = 'Not required' WHERE name = 'familyNameLocal';
</sql>
</changeSet>
<changeSet id="BD-20150528-1446" author="apaule" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'givenNameLocal';
</sqlCheck>
</preConditions>
<comment>Removing given Name Local Attribute</comment>
<sql>
UPDATE person_attribute_type SET retired = 1, retired_by = 1, date_retired=now(), retire_reason = 'Not required' WHERE name = 'givenNameLocal';
</sql>
</changeSet>
<changeSet id="BD-20150528-1447" author="apaule" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'middleNameLocal';
</sqlCheck>
</preConditions>
<comment>Removing middle Name Local Attribute</comment>
<sql>
UPDATE person_attribute_type SET retired = 1, retired_by = 1, date_retired=now(), retire_reason = 'Not required' WHERE name = 'middleNameLocal';
</sql>
</changeSet>
<changeSet id="BD-20150421-1448" author="apaule">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'fatherName';
</sqlCheck>
</preConditions>
<comment>Updating the sortweight of the attribute father Name</comment>
<sql>
UPDATE person_attribute_type SET sort_weight = '1' WHERE name = 'fatherName';
</sql>
</changeSet>
<changeSet id="BD-20150421-1449" author="apaule">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'motherName';
</sqlCheck>
</preConditions>
<comment>Updating the sortweight of the attribute mother Name</comment>
<sql>
UPDATE person_attribute_type SET sort_weight = '2' WHERE name = 'motherName';
</sql>
</changeSet>
<changeSet id="BD-20150421-1450" author="apaule">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'spouseName';
</sqlCheck>
</preConditions>
<comment>Updating the sortweight of the attribute spouse Name</comment>
<sql>
UPDATE person_attribute_type SET sort_weight = '3' WHERE name = 'spouseName';
</sql>
</changeSet>
<changeSet id="BD-20150421-1453" author="apaule">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'birthRegistrationId';
</sqlCheck>
</preConditions>
<comment>Updating the sortweight of the attribute birthRegistrationId</comment>
<sql>
UPDATE person_attribute_type SET sort_weight = '6' WHERE name = 'birthRegistrationId';
</sql>
</changeSet>
<changeSet id="BD-20160307-1231" author="neha,sukreet">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
select count(*) from person_attribute_type where name = 'motherName';
</sqlCheck>
</preConditions>
<comment>Updating the sortweight of the attribute mother Name</comment>
<sql>
UPDATE person_attribute_type SET retired = 0, retired_by = null, date_retired = null
WHERE name = 'motherName';
</sql>
</changeSet>
<changeSet id='BD-201612021256' author='Neha,Sukreet' context='setup'>
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT COUNT(*) FROM person_attribute_type WHERE name = 'healthId';
</sqlCheck>
</preConditions>
<comment>Insert Health ID and National ID. Split from changeset BD-201406241630</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('healthId', 'Unique Health ID', 'java.lang.String', '1', 1, curdate(), 0, 4, uuid());
</sql>
</changeSet>
<changeSet id='BD-201612021258' author='Neha,Sukreet' context='setup'>
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT COUNT(*) FROM person_attribute_type WHERE name = 'nationalId';
</sqlCheck>
</preConditions>
<comment>Insert Health ID and National ID. Split from changeset BD-201406241630</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('nationalId', 'National ID', 'java.lang.String', '1', 1, curdate(), 0, 5, uuid());
</sql>
</changeSet>
<changeSet id="BD-20170224-1445" author="anjaly,abhilash" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from person_attribute_type where name = 'givenNameLocal';
</sqlCheck>
</preConditions>
<comment>Add given name local attribute</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('givenNameLocal', 'রোগীর নাম', 'java.lang.String', '1', 1, now(), 1, 3, uuid());
</sql>
</changeSet>
<changeSet id="BD-20170224-1451" author="anjaly,abhilash" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from person_attribute_type where name = 'familyNameLocal';
</sqlCheck>
</preConditions>
<comment>Add family name local attribute</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('familyNameLocal', 'পদবি', 'java.lang.String', '1', 1, now(), 1, 3, uuid());
</sql>
</changeSet>
<changeSet id="BD-20170224-1455" author="anjaly,abhilash" context="setup">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from person_attribute_type where name = 'middleNameLocal';
</sqlCheck>
</preConditions>
<comment>Add middle name local attribute</comment>
<sql>
INSERT INTO person_attribute_type (name, description, format, searchable, creator, date_created, retired, sort_weight, uuid)
VALUES ('middleNameLocal', 'middleNameLocal', 'java.lang.String', '1', 1, now(), 1, 3, uuid());
</sql>
</changeSet>
</databaseChangeLog>