Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Implement Server side settings functionality #483

Open
wants to merge 10 commits into
base: anc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Moved server default setting configurations to `../assets/server_defaults/` folder. Files follow a per project implementation hierachy pattern

### Added
- Client Server sync - settings functionality and rest endpoint. `../rest/settings/sync`
2 changes: 1 addition & 1 deletion assets/config/opensrp.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mcts-report-delay-in-days=10
mcts.poll.time.interval.in.minutes=10

# OpenMRS configuration
openmrs.url=http://localhost:8080/openmrs/
openmrs.url=https://openmrs.anc-stage.smartregister.org/openmrs/
openmrs.username=admin
openmrs.password=Admin123
openmrs.idgen.url=/module/idgen/exportIdentifiers.form
Expand Down
16 changes: 12 additions & 4 deletions assets/migrations/generator/generatorConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<classPathEntry
location="/Users/coder/Projects/opensrp-server/assets/migrations/drivers/postgresql-42.2.1.jar" />
location="/Users/ndegwamartin/Workspace/opensrp-server/assets/migrations/drivers/postgresql-42.2.1.jar" />
<context id="core">
<!-- <plugin type="org.mybatis.generator.plugins.RowBoundsPlugin"></plugin> -->
<jdbcConnection connectionURL="jdbc:postgresql://localhost:5432/opensrp"
<jdbcConnection connectionURL="jdbc:postgresql://localhost:5432/opensrp_anc"
driverClass="org.postgresql.Driver" password="admin" userId="opensrp_admin" />
<javaModelGenerator targetPackage="org.opensrp.domain.postgres"
targetProject="opensrp-core" />
Expand Down Expand Up @@ -62,7 +62,15 @@
<columnOverride column="json"
typeHandler="org.opensrp.repository.postgres.handler.ViewConfigurationTypeHandler" />
</table>
<table schema="core" tableName="view_configuration_metadata" /> -->

<table schema="core" tableName="view_configuration_metadata" />


<table schema="core" tableName="settings">
<columnOverride column="json"
typeHandler="org.opensrp.repository.postgres.handler.SettingTypeHandler" />
</table>
-->
<table schema="core" tableName="settings_metadata" />

</context>
</generatorConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ CREATE TABLE core.view_configuration_metadata
)
WITH (
OIDS = FALSE
);
);

-- //@UNDO
-- SQL to undo the change goes here.
DROP TABLE core.view_configuration_metadata;

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--
-- Copyright 2010-2016 the original author or authors.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

-- // create_settings_table.sql
-- Migration SQL that makes the change goes here.
CREATE TABLE core.settings
(
id bigserial NOT NULL,
json jsonb NOT NULL,
PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)


-- //@UNDO
-- SQL to undo the change goes here.

DROP TABLE core.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--
-- Copyright 2010-2016 the original author or authors.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

-- // create_settings_metadata_table.sql
-- Migration SQL that makes the change goes here.

CREATE TABLE core.settings_metadata
(
id bigserial NOT NULL,
settings_id bigint REFERENCES core.settings (id),
document_id character varying UNIQUE NOT NULL,
identifier varchar UNIQUE,
server_version bigint,
PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
);

-- //@UNDO
-- SQL to undo the change goes here.

DROP TABLE core.settings_metadata;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--
-- Copyright 2010-2016 the original author or authors.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

-- // add settings metadata columns team id team location_id and provider id
-- Migration SQL that makes the change goes here.

ALTER TABLE core.settings_metadata ADD COLUMN team VARCHAR;
ALTER TABLE core.settings_metadata ADD COLUMN team_id VARCHAR;
ALTER TABLE core.settings_metadata ADD COLUMN provider_id VARCHAR;
ALTER TABLE core.settings_metadata ADD COLUMN location_id VARCHAR;

-- //@UNDO
-- SQL to undo the change goes here.

ALTER TABLE core.settings_metadata DROP COLUMN team;
ALTER TABLE core.settings_metadata DROP COLUMN team_id;
ALTER TABLE core.settings_metadata DROP COLUMN provider_id;
ALTER TABLE core.settings_metadata DROP COLUMN location_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--
-- Copyright 2010-2016 the original author or authors.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

-- // alter settings metadata column identifier remove constraint
-- Migration SQL that makes the change goes here.

ALTER TABLE core.settings_metadata DROP CONSTRAINT settings_metadata_identifier_key

-- //@UNDO
-- SQL to undo the change goes here.

ALTER TABLE core.settings_metadata ADD CONSTRAINT settings_metadata_identifier_key UNIQUE (identifier);
87 changes: 87 additions & 0 deletions assets/server_defaults/anc/population_characteristics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"_id": 2,
"_rev": 1,
"type": "SettingConfiguration",
"identifier": "population_characteristics",
"serverVersion": null,
"settings": [
{
"key": "pop_undernourish",
"label": "Undernourished prevalence 20% or higher",
"value": null,
"description": "The proportion of women in the adult population (18 years or older), with a BMI less than 18.5, is 20% or higher."
},
{
"key": "pop_anaemia_40",
"label": "Anaemia prevalence 40% or higher",
"value": null,
"description": "The proportion of pregnant women in the population with anaemia (haemoglobin level less than 11 g/dl) is 40% or higher."
},
{
"key": "pop_anaemia_20",
"label": "Anaemia prevalence 20% or lower",
"value": null,
"description": "The proportion of pregnant women in the population with anaemia (haemoglobin level less than 11 g/dl) is 20% or lower."
},
{
"key": "pop_low_calcium",
"label": "Low dietary calcium intake",
"value": null,
"description": "Women in the population are likely to have low dietary calcium intake (less than 900 mg of calcium per day)."
},
{
"key": "pop_tb",
"label": "TB prevalence 100/100,000 or high.",
"value": null,
"description": "The tuberculosis prevalence in the general population is 100 cases per 100,000 persons or greater."
},
{
"key": "pop_vita",
"label": "Vitamin A deficiency 5% or higher",
"value": null,
"description": "The prevalence of night blindness is 5% or higher in pregnant women or 5% or higher in children 24–59 months of age, or the proportion of pregnant women with a serum retinol level less than 0.7 mol/L is 20% or higher. "
},
{
"key": "pop_helminth",
"label": "Soil-transmitted helminth infection prevalence 20% or higher",
"value": null,
"description": "The percentage of individuals in the general population infected with at least one species of soil-transmitted helminth is 20% or higher."
},
{
"key": "pop_hiv_incidence",
"label": "HIV incidence greater than 3 per 100 person-years in the absence of PrEP",
"value": null,
"description": "Women in the population have a substantial risk of HIV infection. Substantial risk of HIV infection is provisionally defined as HIV incidence greater than 3 per 100 person–years in the absence of pre-exposure prophylaxis (PrEP)."
},
{
"key": "pop_hiv_prevalence",
"label": "HIV prevalence 5% or higher",
"value": null,
"description": "The HIV prevalence in pregnant women in the population is 5% or higher."
},
{
"key": "pop_malaria",
"label": "Malaria-endemic setting",
"value": null,
"description": "This is a malaria-endemic setting."
},
{
"key": "pop_syphilis",
"label": "Syphilis prevalence 5% or higher",
"value": null,
"description": "The prevalence of syphilis in pregnant women in the population is 5% or higher."
},
{
"key": "pop_hepb",
"label": "Hep B prevalence is intermediate (2% or higher) or high (5% or higher)",
"value": null,
"description": "The proportion of Hepatitis B surface antigen (HBsAg) seroprevalance in the general population is 2% or higher."
},
{
"key": "pop_hepc",
"label": "Hep C prevalence is intermediate (2% or higher) or high (5% or higher)",
"value": null,
"description": "The proportion of Hepatitis C virus (HCV) antibody seroprevalence in the general population is 2% or higher. "
}
]
}
37 changes: 37 additions & 0 deletions assets/server_defaults/anc/site_characteristics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"_id": "1",
"_rev": "v1",
"type": "SettingConfiguration",
"identifier": "site_characteristics",
"locationId": "",
"providerId": "",
"teamId": "",
"dateCreated": "1970-10-04T10:17:09.993+03:00",
"serverVersion": 1,
"settings": [
{
"key": "site_ipv_assess",
"label": "Minimum requirements for IPV assessment",
"value": null,
"description": "Are all of the following in place at your facility: \r\n\ta. A protocol or standard operating procedure for Intimate Partner Violence (IPV); \r\n\tb. A health worker trained on how to ask about IPV and how to provide the minimum response or beyond;\r\n\tc. A private setting; \r\n\td. A way to ensure confidentiality; \r\n\te. Time to allow for appropriate disclosure; and\r\n\tf. A system for referral in place. "
},
{
"key": "site_anc_hiv",
"label": "Generalized HIV epidemic",
"value": null,
"description": "Is the HIV prevalence consistently > 1% in pregnant women attending antenatal clinics at your facility?"
},
{
"key": "site_ultrasound",
"label": "Ultrasound available",
"value": null,
"description": "Is an ultrasound machine available and functional at your facility and a trained health worker available to use it?"
},
{
"key": "site_bp_tool",
"label": "Automated BP measurement tool",
"value": null,
"description": "Does your facility use an automated blood pressure (BP) measurement tool?"
}
]
}
Loading