You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removing Dependency from Org 1 for Calcutta Kids Implementation
Objective:
The primary objective of this documentation is to remove the dependency of the Calcutta Kids organization's implementation from Org 1.
Steps Taken:
Step 1: Database Restoration
Task:
Downloaded the latest dump from the pre-release DB bundle and restored it to the local database. Given the file's size (32GB), this step was time-consuming.
# The size of the database dump poses challenges, especially when frequent restorations are required. An alternative approach should be considered!
Once the dump was downloaded, it was restored to the local database to be used as the primary database for server, webapp, and client applications.
Step 2: Identifying Core Entities Dependent on Org 1
Task:
Firstly, identified all core entities that are related to Org 1 and determined which ones need to be migrated to Org 2 (Calcutta Kids org) and which ones are no longer required. The following is the query used to identify tables containing the organisation_id column, which indicates potential organization level separation concerns.
Manually checked which entities belong to Org 2 (CK org) and which belong to Org 1 and then a SQL update query was written to change the organisation_id from Org 1 to Org 2.
On doing so the previous step, the following is a list of entities that require update queries to be written and executed:
concept
concept_answer
encounter_type
form_element
form_element_group
form_mapping
gender
individual_relation
individual_relation_gender_mapping
individual_relationship_type
program
program_organisation_config
subject_type
form
1. Concept: As there were so many concepts, reviewing each one to determine their relevance for the Calcutta Kids implementation was quite challenging and time-consuming. Since there's no issues in retaining unused concepts, all concepts in the public.concepts table from Org 1 were updated.
insert into concept (data_type, high_absolute, high_normal, low_absolute, low_normal, name, uuid, version, unit,
organisation_id, is_voided, audit_id, key_values, active, created_by_id, last_modified_by_id,
created_date_time, last_modified_date_time)
select data_type,
high_absolute,
high_normal,
low_absolute,
low_normal,
name,
uuid,
version,
unit,
19,
is_voided,
audit_id,
key_values,
active,
1,
1,
now(),
now()
from concept
where uuid in (select uuid
from concept
where organisation_id =1)
and organisation_id =1;
2. concept_answer:
insert into concept_answer (concept_id, answer_concept_id, uuid, version, answer_order, organisation_id, abnormal,
is_voided, uniq, audit_id, created_by_id, last_modified_by_id, created_date_time,
last_modified_date_time)
select concept_id,
answer_concept_id,
uuid,
version,
answer_order,
19,
abnormal,
is_voided,
uniq,
audit_id,
1,
1,
now(),
now()
from concept_answer
where uuid in (select uuid
from concept_answer
where organisation_id =1)
and organisation_id =1;
update concept_answer ca_target
set concept_id =newconcept.idfrom concept_answer ca_source
join concept org1concept onca_source.concept_id=org1concept.idjoin concept newconcept onorg1concept.name=newconcept.nameandnewconcept.organisation_id=19whereca_source.uuidin (select uuid
from concept_answer
where organisation_id =1)
andca_source.organisation_id=1andca_target.uuid=ca_source.uuidandca_target.organisation_id=19;
insert into gender (uuid, name, concept_id, version, audit_id, is_voided, organisation_id, created_by_id,
last_modified_by_id, created_date_time, last_modified_date_time)
select uuid,
name,
concept_id,
version,
audit_id,
is_voided,
19,
1,
1,
now(),
now()
from gender
where uuid in (
'ad7d1d14-54fd-45a2-86b7-ea329b744484',
'840de9fb-e565-4d7d-b751-90335ba20490',
'188ad77e-fe46-4328-b0e2-98f3a05c554c'
)
and organisation_id =1;
7. individual_relation:
insert into individual_relation (uuid, name, is_voided, organisation_id, version, audit_id, created_by_id,
last_modified_by_id, created_date_time, last_modified_date_time)
select uuid,
name,
is_voided,
19,
version,
audit_id,
1,
1,
now(),
now()
from individual_relation
where uuid in (select uuid
from individual_relation
where organisation_id =1)
and organisation_id =1;
8. individual_relation_gender_mapping:
insert into individual_relation_gender_mapping (uuid, relation_id, gender_id, is_voided, organisation_id, version,
audit_id, created_by_id, last_modified_by_id, created_date_time,
last_modified_date_time)
select uuid,
relation_id,
gender_id,
is_voided,
19,
version,
audit_id,
1,
1,
now(),
now()
from individual_relation_gender_mapping
where uuid in (select uuid
from individual_relation_gender_mapping
where organisation_id =1)
and organisation_id =1;
update individual_relation_gender_mapping irgm_target
set relation_id =newir.id,
gender_id =newgender.idfrom individual_relation_gender_mapping irgm_source
join individual_relation org1ir onirgm_source.relation_id=org1ir.idjoin individual_relation newir onorg1ir.name=newir.nameandnewir.organisation_id=19join gender org1gender onirgm_source.gender_id=org1gender.idjoin gender newgender onorg1gender.name=newgender.nameandnewgender.organisation_id=19whereirgm_source.uuidin (select uuid
from individual_relation_gender_mapping
where organisation_id =1)
andirgm_source.organisation_id=1andirgm_target.uuid=irgm_source.uuidandirgm_target.organisation_id=19;
9. individual_relationship_type:
insert into individual_relationship_type (uuid, name, individual_a_is_to_b_relation_id,
individual_b_is_to_a_relation_id, is_voided, organisation_id, version,
audit_id, created_by_id, last_modified_by_id, created_date_time,
last_modified_date_time)
select uuid,
name,
individual_a_is_to_b_relation_id,
individual_b_is_to_a_relation_id,
is_voided,
19,
version,
audit_id,
1,
1,
now(),
now()
from individual_relationship_type
where uuid in (select uuid
from individual_relationship_type
where organisation_id =1)
and organisation_id =1;
update individual_relationship_type irt_target
set individual_a_is_to_b_relation_id =newiratob.id,
individual_b_is_to_a_relation_id =newirbtoa.idfrom individual_relationship_type irt_source
join individual_relation org1iratob onirt_source.individual_a_is_to_b_relation_id=org1iratob.idjoin individual_relation newiratob onorg1iratob.name=newiratob.nameandnewiratob.organisation_id=19join individual_relation org1irbtoa onirt_source.individual_b_is_to_a_relation_id=org1irbtoa.idjoin individual_relation newirbtoa onorg1irbtoa.name=newirbtoa.nameandnewirbtoa.organisation_id=19whereirt_source.uuidin (select uuid
from individual_relationship_type
where organisation_id =1)
andirt_source.organisation_id=1andirt_target.uuid=irt_source.uuidandirt_target.organisation_id=19;
10. form:
insert into form (name, form_type, uuid, version, organisation_id, audit_id, is_voided, decision_rule,
validation_rule, visit_schedule_rule, checklists_rule, created_by_id, last_modified_by_id,
created_date_time, last_modified_date_time, validation_declarative_rule, decision_declarative_rule,
visit_schedule_declarative_rule, task_schedule_declarative_rule, task_schedule_rule)
select name,
form_type,
uuid,
version,
19,
audit_id,
is_voided,
decision_rule,
validation_rule,
visit_schedule_rule,
checklists_rule,
1,
1,
now(),
now(),
validation_declarative_rule,
decision_declarative_rule,
visit_schedule_declarative_rule,
task_schedule_declarative_rule,
task_schedule_rule
from form
where uuid in (
'aac5c57a-aa01-49bb-ad20-70536dd2907f',
'026e2f5c-8670-4e4b-9a54-cb03bbf3093d',
'3a95e9b0-731a-4714-ae7c-10e1d03cebfe',
'9ed7e0a9-6122-41ee-8413-1cef6792e2c6',
'cc6a3c6a-c3cc-488d-a46c-d9d538fcc9c2',
'32428a7e-d553-4172-b697-e8df3bbfb61d',
'78b1400e-8100-4ba6-b78e-fef580f7fb77',
'e57e2f11-6684-456a-bd00-6511d9b06eaa',
'901e2f48-2fb8-402b-9073-ee2fac33fce4',
'1608c2c0-0334-41a6-aab0-5c61ea1eb069',
'e09dddeb-ed72-40c4-ae8d-112d8893f18b',
'67165f46-890d-4747-ba9a-dbaa0cfa5353',
'd062907a-690c-44ca-b699-f8b2f688b075'
)
and organisation_id =1;
By following the above steps and recommendations, the dependency of Calcutta Kids organization's implementation on Org 1 can be successfully removed without causing any disruptions or issues.