Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Bahmni/bahmni-core
Browse files Browse the repository at this point in the history
  • Loading branch information
Eyal Golan committed May 22, 2018
2 parents 5a04180 + 4b82757 commit 767f916
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 15 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: java
jdk:
- oraclejdk8
script: mvn clean install
branches:
only:
- master
notifications:
email: false
sudo: false
- oraclejdk8
install:
- travis_wait mvn install -Dmaven.javadoc.skip=true -V -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
script:
- mvn verify -P IT -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -pl bahmni-emr-api/
- mvn verify -P IT -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -pl bahmnicore-api/
- mvn verify -P IT -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -pl bahmnicore-omod/
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class ConceptPersisterIT extends BaseIntegrationTest {

public static final String SAME_AS = "SAME-AS";

@Autowired
private ConceptPersister conceptPersister;

Expand Down Expand Up @@ -167,7 +168,7 @@ public void shouldSetConceptReferenceTerms() throws Exception {
conceptRow.conceptClass = "New Class";
conceptRow.dataType = "Coded";
conceptRow.shortName = "NConcept";
ConceptReferenceTermRow conceptReferenceTermRow = new ConceptReferenceTermRow( "org.openmrs.module.emrapi","New Code", SAME_AS);
ConceptReferenceTermRow conceptReferenceTermRow = new ConceptReferenceTermRow("org.openmrs.module.emrapi", "New Code", SAME_AS);
List<ConceptReferenceTermRow> conceptReferenceTermsList = new ArrayList<>(Arrays.asList(conceptReferenceTermRow));
conceptRow.referenceTerms = conceptReferenceTermsList;

Expand Down Expand Up @@ -247,7 +248,7 @@ public void shouldCreateNewMappingForExistingConcept() throws Exception {
conceptRow.name = "Existing Concept";
conceptRow.conceptClass = "New Class";
conceptRow.description = "Some Description";
ConceptReferenceTermRow conceptReferenceTermRow = new ConceptReferenceTermRow( "org.openmrs.module.emrapi","New Code", SAME_AS);
ConceptReferenceTermRow conceptReferenceTermRow = new ConceptReferenceTermRow("org.openmrs.module.emrapi", "New Code", SAME_AS);
List<ConceptReferenceTermRow> conceptReferenceTermsList = new ArrayList<>(Arrays.asList(conceptReferenceTermRow));
conceptRow.referenceTerms = conceptReferenceTermsList;

Expand Down Expand Up @@ -288,7 +289,7 @@ public void shouldCreateNewMappingsForExistingConcept() throws Exception {
conceptRow.name = "Existing Concept";
conceptRow.conceptClass = "New Class";
conceptRow.description = "Some Description";
ConceptReferenceTermRow conceptReferenceTermRow = new ConceptReferenceTermRow( "org.openmrs.module.emrapi","New Code", SAME_AS);
ConceptReferenceTermRow conceptReferenceTermRow = new ConceptReferenceTermRow("org.openmrs.module.emrapi", "New Code", SAME_AS);
List<ConceptReferenceTermRow> conceptReferenceTermsList = new ArrayList<>(Arrays.asList(conceptReferenceTermRow));
conceptRow.referenceTerms = conceptReferenceTermsList;

Expand Down Expand Up @@ -328,7 +329,7 @@ public void createNewConceptOfTypeNumericWithUnitsAndHinormalLownormal() throws
conceptRow.name = "New Concept";
conceptRow.conceptClass = "New Class";
conceptRow.description = "Some Description";
ConceptReferenceTermRow conceptReferenceTermRow = new ConceptReferenceTermRow( "org.openmrs.module.emrapi","New Code", SAME_AS);
ConceptReferenceTermRow conceptReferenceTermRow = new ConceptReferenceTermRow("org.openmrs.module.emrapi", "New Code", SAME_AS);
List<ConceptReferenceTermRow> conceptReferenceTermsList = new ArrayList<>(Arrays.asList(conceptReferenceTermRow));
conceptRow.referenceTerms = conceptReferenceTermsList;
conceptRow.dataType = "Numeric";
Expand Down Expand Up @@ -369,4 +370,30 @@ public void createNewConceptOfTypeNumericWithUnitsAndHinormalLownormal() throws
Context.flushSession();
Context.closeSession();
}

@Test
public void shouldCreateNewConceptWithGivenUUID() throws Exception {
String uuid = UUID.randomUUID().toString();
ConceptRow conceptRow = new ConceptRow();
conceptRow.name = "New concept";
conceptRow.conceptClass = "New Class";
conceptRow.description = "New concept description";
conceptRow.uuid = uuid;

Messages errorMessages = conceptPersister.persist(conceptRow);

assertTrue(errorMessages.isEmpty());
Context.openSession();
Context.authenticate("admin", "test");
Concept persistedConcept = conceptService.getConceptByName(conceptRow.name);
assertNotNull(persistedConcept);
assertEquals(uuid, persistedConcept.getUuid());
assertEquals(conceptRow.name, persistedConcept.getName(Context.getLocale()).getName());
assertEquals(conceptRow.conceptClass, persistedConcept.getConceptClass().getName());
assertEquals("New concept description", persistedConcept.getDescription().getDescription());
assertEquals(0, persistedConcept.getSynonyms().size());
Context.flushSession();
Context.closeSession();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -157,4 +158,29 @@ public void should_fail_to_persist_if_conceptSetRow_introduces_cycle() throws Ex
Context.closeSession();
}

@Test
public void shouldCreateNewConceptSetWithGivenUUID() throws Exception {
String uuid = UUID.randomUUID().toString();
ConceptSetRow conceptRow = new ConceptSetRow();
conceptRow.name = "New concept";
conceptRow.conceptClass = "New Class";
conceptRow.description = "some description";
conceptRow.uuid = uuid;

Messages persistErrorMessages = conceptSetPersister.persist(conceptRow);

assertTrue(persistErrorMessages.isEmpty());
Context.openSession();
Context.authenticate("admin", "test");
Concept persistedConcept = conceptService.getConceptByName(conceptRow.name);
assertNotNull(persistedConcept);
assertEquals(conceptRow.name, persistedConcept.getName(Context.getLocale()).getName());
assertEquals(uuid, persistedConcept.getUuid());
Context.flushSession();
Context.closeSession();
}




}
139 changes: 139 additions & 0 deletions bahmnicore-omod/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4254,4 +4254,143 @@
INSERT INTO role_role(child_role, parent_role) VALUES ('Appointments:FullAccess', 'Appointments:ManageAppointments');
</sql>
</changeSet>
<changeSet id="Amman-201707101139" author="Shireesha, Pramida" context="rel3.2">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT count(*) FROM role where role = "OT: FullAccess";
</sqlCheck>
</preConditions>
<comment> Creating a role for OT: FullAccess</comment>
<sql>
INSERT INTO role(role, description, uuid) VALUES ("OT: FullAccess", "Ability to access and modify OT schedules", uuid());
</sql>
</changeSet>
<changeSet id="Amman-201707101152" author="Shireesha, Pramida" context="rel3.2">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT count(*) FROM role where role = "OT: ReadOnly";
</sqlCheck>
</preConditions>
<comment> Creating a role for OT- ReadOnly</comment>
<sql>
INSERT INTO role(role, description, uuid) VALUES ("OT: ReadOnly", "Ability to access and modify OT schedules", uuid());
</sql>
</changeSet>
<changeSet id="Amman-201707101154" author="Shireesha, Pramida" context="rel3.2">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT count(*) FROM privilege where privilege = "app:ot";
</sqlCheck>
</preConditions>
<comment> Creating a privilege for viewing the OT module</comment>
<sql>
INSERT INTO privilege(privilege, description, uuid) VALUES ("app:ot", "Ability to view OT module", uuid());
</sql>
</changeSet>
<changeSet id="Amman-201707101156" author="Shireesha, Pramida" context="rel3.2">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT count(*) FROM privilege where privilege = "app:ot:write";
</sqlCheck>
</preConditions>
<comment> Creating a privilege for viewing the OT module</comment>
<sql>
INSERT INTO privilege(privilege, description, uuid) VALUES ("app:ot:write", "Ability to view new surgical block and other buttons to edit on OT module", uuid());
</sql>
</changeSet>
<changeSet id="Amman-201707101106" author="Shireesha, Pramida" context="rel3.2">
<preConditions onFail="CONTINUE">
<sqlCheck expectedResult="1">
SELECT count(*) FROM privilege WHERE privilege = "Manage OT Schedules";
</sqlCheck>
<sqlCheck expectedResult="0">
SELECT count(*) FROM role_privilege WHERE role = "OT: FullAccess" AND privilege = "Manage OT Schedules";
</sqlCheck>
</preConditions>
<comment>Adding Manage OT Schedules privilege to OT: FullAccess role</comment>
<sql>
INSERT INTO role_privilege(role, privilege) VALUES ("OT: FullAccess", "Manage OT Schedules");
INSERT INTO role_privilege(role, privilege) VALUES ("OT: FullAccess", "View OT Schedules");
INSERT INTO role_privilege(role, privilege) VALUES ("OT: FullAccess", "app:ot");
INSERT INTO role_privilege(role, privilege) VALUES ("OT: FullAccess", "app:ot:write");
</sql>
</changeSet>
<changeSet id="Amman-201707101159" author="Shireesha, Pramida" context="rel3.2">
<preConditions onFail="CONTINUE">
<sqlCheck expectedResult="1">
SELECT count(*) FROM privilege WHERE privilege = "View OT Schedules";
</sqlCheck>
<sqlCheck expectedResult="0">
SELECT count(*) FROM role_privilege WHERE role = "OT: ReadOnly" AND privilege = "View OT Schedules";
</sqlCheck>
</preConditions>
<comment>Adding view OT Schedules privilege to OT: ReadOnly role</comment>
<sql>
INSERT INTO role_privilege(role, privilege) VALUES ("OT: ReadOnly", "View OT Schedules");
INSERT INTO role_privilege(role, privilege) VALUES ("OT: ReadOnly", "app:ot");
</sql>
</changeSet>
<changeSet id="201805112235" author="Suman">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
SELECT count(*) FROM concept_view WHERE concept_full_name = 'Bahmni Initial Diagnosis';
</sqlCheck>
<sqlCheck expectedResult="1">
SELECT count(*) FROM concept WHERE is_set= TRUE AND concept_id = (SELECT concept_id FROM concept_view
WHERE concept_full_name = 'Bahmni Initial Diagnosis');
</sqlCheck>
<sqlCheck expectedResult="0">
SELECT count(*) FROM concept_set WHERE concept_set = (SELECT concept_id FROM concept_view
WHERE concept_full_name = 'Bahmni Initial Diagnosis');
</sqlCheck>
</preConditions>
<comment>Updating 'Bahmni Initial Diagnosis' concept to non-set concept</comment>
<sql>
SET @concept_id=0;
SELECT concept_id FROM concept_view WHERE concept_full_name = 'Bahmni Initial Diagnosis' INTO @concept_id;
UPDATE concept SET is_set = FALSE WHERE concept_id = @concept_id;
</sql>
</changeSet>
<changeSet id="201805112237" author="Suman">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
SELECT count(*) FROM concept_view WHERE concept_full_name = 'Bahmni Diagnosis Status';
</sqlCheck>
<sqlCheck expectedResult="1">
SELECT count(*) FROM concept WHERE is_set= TRUE AND concept_id = (SELECT concept_id FROM concept_view
WHERE concept_full_name = 'Bahmni Diagnosis Status');
</sqlCheck>
<sqlCheck expectedResult="0">
SELECT count(*) FROM concept_set WHERE concept_set = (SELECT concept_id FROM concept_view
WHERE concept_full_name = 'Bahmni Diagnosis Status');
</sqlCheck>
</preConditions>
<comment>Updating 'Bahmni Diagnosis Status' concept to non-set concept</comment>
<sql>
SET @concept_id=0;
SELECT concept_id FROM concept_view WHERE concept_full_name = 'Bahmni Diagnosis Status' INTO @concept_id;
UPDATE concept SET is_set = FALSE WHERE concept_id = @concept_id;
</sql>
</changeSet>
<changeSet id="201805112239" author="Suman">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
SELECT count(*) FROM concept_view WHERE concept_full_name = 'Bahmni Diagnosis Revised';
</sqlCheck>
<sqlCheck expectedResult="1">
SELECT count(*) FROM concept WHERE is_set= TRUE AND concept_id = (SELECT concept_id FROM concept_view
WHERE concept_full_name = 'Bahmni Diagnosis Revised');
</sqlCheck>
<sqlCheck expectedResult="0">
SELECT count(*) FROM concept_set WHERE concept_set = (SELECT concept_id FROM concept_view
WHERE concept_full_name = 'Bahmni Diagnosis Revised');
</sqlCheck>
</preConditions>
<comment>Updating 'Bahmni Diagnosis Revised' concept to non-set concept</comment>
<sql>
SET @concept_id=0;
SELECT concept_id FROM concept_view WHERE concept_full_name = 'Bahmni Diagnosis Revised' INTO @concept_id;
UPDATE concept SET is_set = FALSE WHERE concept_id = @concept_id;
</sql>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public org.openmrs.Concept map(ConceptCommon conceptCommon, ConceptMetaData conc
org.openmrs.Concept openmrsConcept = new org.openmrs.Concept();
if (conceptMetaData.getExistingConcept() != null) {
openmrsConcept = conceptMetaData.getExistingConcept();
} else if (StringUtils.isNotBlank(conceptCommon.getUuid())){
openmrsConcept.setUuid(conceptCommon.getUuid());
}
String displayName = conceptCommon.getDisplayName();
openmrsConcept = addConceptName(openmrsConcept, getConceptName(conceptCommon.getUniqueName(), ConceptNameType.FULLY_SPECIFIED, conceptMetaData.getLocale()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private org.openmrs.Concept getConceptSet(ConceptSet conceptSet, ConceptMetaData
return mappedConceptSet;
}

private org.openmrs.Concept getConcept(Concept conceptData, ConceptMetaData conceptMetaData) {
private org.openmrs.Concept getConcept(Concept conceptData, ConceptMetaData conceptMetaData) {
List<ConceptAnswer> conceptAnswers = getConceptAnswers(conceptData.getAnswers());
conceptValidator.validate(conceptData, conceptMetaData.getConceptClass(), conceptMetaData.getConceptDatatype(), notFound);
org.openmrs.Concept mappedConcept = conceptMapper.map(conceptData, conceptMetaData, conceptAnswers);
Expand Down

0 comments on commit 767f916

Please sign in to comment.