Skip to content

Commit 88cc779

Browse files
authored
Merge branch 'master' into ContactPointMap-impl
2 parents c2b5957 + 583aee2 commit 88cc779

File tree

10 files changed

+106
-13
lines changed

10 files changed

+106
-13
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,11 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo
197197
## Releases notes
198198

199199
#### Version 2.7.0
200+
* Added support for 'fhircontactpointmap' domain.
200201
* Added support for 'queues' domain.
201202
* Added support for 'addresshierarchy' domain.
202203
* Fix for Liquibase Loader to ensure compatibility with OpenMRS versions 2.5.5+
203-
* Added support for 'fhircontactpointmap' domain.
204+
* Fix for OCL Loader to ensure it throws an Exception if the OCL import fails
204205

205206
#### Version 2.6.0
206207
* Added support for 'cohorttypes' and 'cohortattributetypes' domains.

api-2.3/src/main/java/org/openmrs/module/initializer/api/queues/QueueLineProcessor.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public class QueueLineProcessor extends BaseLineProcessor<Queue> {
1919

2020
protected static String HEADER_SERVICE = "service";
2121

22+
protected static String HEADER_STATUS_CONCEPT_SET = "status concept set";
23+
24+
protected static String HEADER_PRIORITY_CONCEPT_SET = "priority concept set";
25+
2226
protected static String HEADER_LOCATION = "location";
2327

2428
private final ConceptService conceptService;
@@ -45,6 +49,22 @@ public Queue fill(Queue queue, CsvLine line) throws IllegalArgumentException {
4549
queue.setService(null);
4650
}
4751
}
52+
if (line.containsHeader(HEADER_STATUS_CONCEPT_SET)) {
53+
String statusConceptSet = line.getString(HEADER_STATUS_CONCEPT_SET);
54+
if (StringUtils.isNotBlank(statusConceptSet)) {
55+
queue.setStatusConceptSet(Utils.fetchConcept(statusConceptSet, conceptService));
56+
} else {
57+
queue.setStatusConceptSet(null);
58+
}
59+
}
60+
if (line.containsHeader(HEADER_PRIORITY_CONCEPT_SET)) {
61+
String priorityConceptSet = line.getString(HEADER_PRIORITY_CONCEPT_SET);
62+
if (StringUtils.isNotBlank(priorityConceptSet)) {
63+
queue.setPriorityConceptSet(Utils.fetchConcept(priorityConceptSet, conceptService));
64+
} else {
65+
queue.setPriorityConceptSet(null);
66+
}
67+
}
4868
if (line.containsHeader(HEADER_LOCATION)) {
4969
String location = line.getString(HEADER_LOCATION);
5070
if (StringUtils.isNotBlank(location)) {

api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,16 @@ public void load_shouldLoadAccordingToCsvFiles() throws Exception {
6565
Assert.assertEquals(2001, queue.getService().getConceptId().intValue());
6666
Assert.assertEquals(3, queue.getLocation().getLocationId().intValue());
6767
}
68+
// Queue with statuses
69+
{
70+
Queue queue = queueService.getQueueByUuid("4856c1c1-c9b3-4a7e-8669-4220051ab640").orElse(null);
71+
Assert.assertNotNull(queue);
72+
Assert.assertEquals("Triage Queue", queue.getName());
73+
Assert.assertEquals("Queue with custom statuses", queue.getDescription());
74+
Assert.assertEquals(2001, queue.getService().getConceptId().intValue());
75+
Assert.assertEquals(2003, queue.getStatusConceptSet().getConceptId().intValue());
76+
Assert.assertEquals("Triage queue priorities", queue.getPriorityConceptSet().getName().getName());
77+
Assert.assertEquals("Xanadu", queue.getLocation().getName());
78+
}
6879
}
6980
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
Uuid,Void/Retire,Name,Description,Service,Location
2-
2a0e0eee-6888-11ee-ab8d-0242ac120002,,Revised Queue,Revised Description,68b910bd-298c-4ecf-a632-661ae2f446op,Xanadu
3-
288db1cc-688a-11ee-ab8d-0242ac120002,,New Queue,New Description,Triage,167ce20c-4785-4285-9119-d197268f7f4a
1+
Uuid,Void/Retire,Name,Description,Service,Status Concept Set,Priority Concept Set,Location
2+
2a0e0eee-6888-11ee-ab8d-0242ac120002,,Revised Queue,Revised Description,68b910bd-298c-4ecf-a632-661ae2f446op,,,Xanadu
3+
288db1cc-688a-11ee-ab8d-0242ac120002,,New Queue,New Description,Triage,,,167ce20c-4785-4285-9119-d197268f7f4a
4+
4856c1c1-c9b3-4a7e-8669-4220051ab640,,Triage Queue,Queue with custom statuses,67b910bd-298c-4ecf-a632-661ae2f446op,1d2a73ca-20aa-4218-b4d2-043024a9156e,24932838-60ca-44e8-840f-4184b368643c,Xanadu

api/src/main/java/org/openmrs/module/initializer/api/c/ConceptNumericLineProcessor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ public Concept fill(Concept instance, CsvLine line) throws IllegalArgumentExcept
4242
return instance;
4343
}
4444

45-
ConceptNumeric cn = new ConceptNumeric(instance);
45+
ConceptNumeric cn = null;
4646
if (instance.getId() != null) { // below overrides any other processors work, so this one should be called first
4747
cn = conceptService.getConceptNumeric(instance.getId());
4848
}
49+
50+
if (cn == null) {
51+
cn = new ConceptNumeric(instance);
52+
}
53+
4954
cn.setDatatype(conceptService.getConceptDatatypeByName(DATATYPE_NUMERIC));
5055

5156
cn.setHiAbsolute(line.getDouble(HEADER_AH));

api/src/main/java/org/openmrs/module/initializer/api/loaders/OpenConceptLabLoader.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package org.openmrs.module.initializer.api.loaders;
22

3-
import java.io.File;
4-
import java.util.zip.ZipFile;
5-
3+
import org.apache.commons.lang.StringUtils;
64
import org.openmrs.annotation.OpenmrsProfile;
75
import org.openmrs.api.context.Context;
86
import org.openmrs.module.initializer.Domain;
7+
import org.openmrs.module.openconceptlab.Import;
8+
import org.openmrs.module.openconceptlab.ImportService;
99
import org.openmrs.module.openconceptlab.importer.Importer;
1010

11+
import java.io.File;
12+
import java.util.zip.ZipFile;
13+
1114
@OpenmrsProfile(modules = { "openconceptlab:1.2.9" })
1215
public class OpenConceptLabLoader extends BaseFileLoader {
1316

@@ -25,7 +28,29 @@ protected String getFileExtension() {
2528
protected void load(File file) throws Exception {
2629
ZipFile zip = new ZipFile(file);
2730
Importer importer = Context.getRegisteredComponent("openconceptlab.importer", Importer.class);
31+
ImportService importService = Context.getService(ImportService.class);
32+
33+
Import lastImport = importService.getLastImport();
34+
log.debug("Starting OCL importer");
2835
importer.run(zip);
36+
Import oclImport = importService.getLastImport();
37+
38+
// Import failed to start. This can happen another import is already currently running
39+
if (oclImport == null || oclImport.equals(lastImport)) {
40+
throw new IllegalStateException("OCL import did not start successfully");
41+
}
42+
43+
// Import detected errors
44+
if (StringUtils.isNotBlank(oclImport.getErrorMessage())) {
45+
throw new IllegalStateException(oclImport.getErrorMessage());
46+
}
47+
48+
// Import never stopped
49+
if (!oclImport.isStopped()) {
50+
throw new IllegalStateException("OCL import did not complete successfully");
51+
}
52+
53+
log.debug("OCL import completed successfully: " + oclImport.getLocalDateStopped());
2954
}
3055

3156
}

api/src/test/java/org/openmrs/module/initializer/api/c/ConceptNumericLineProcessorTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.openmrs.module.initializer.api.c;
22

33
import static org.mockito.Matchers.any;
4+
import static org.mockito.Mockito.atLeast;
45
import static org.mockito.Mockito.mock;
6+
import static org.mockito.Mockito.verify;
57
import static org.mockito.Mockito.when;
68

79
import org.junit.Assert;
@@ -89,4 +91,22 @@ public void fill_shouldFailWhenCannotParse() {
8991
ConceptNumericLineProcessor p = new ConceptNumericLineProcessor(cs);
9092
p.fill(new Concept(), new CsvLine(headerLine, line));
9193
}
94+
95+
@Test
96+
public void fill_shouldOverrideProvidedDataType() {
97+
98+
// Setup
99+
when(cs.getConceptNumeric(any(Integer.class))).thenReturn(null);
100+
String[] headerLine = { "Data type", "Absolute low" };
101+
String[] line = { "Numeric", "11.11" };
102+
103+
// Replay
104+
ConceptNumericLineProcessor p = new ConceptNumericLineProcessor(cs);
105+
ConceptNumeric cn = (ConceptNumeric) p.fill(new Concept(1), new CsvLine(headerLine, line));
106+
107+
// Verify
108+
verify(cs, atLeast(1)).getConceptNumeric(any(Integer.class));
109+
Assert.assertEquals(ConceptNumericLineProcessor.DATATYPE_NUMERIC, cn.getDatatype().getName());
110+
Assert.assertEquals(0, cn.getLowAbsolute().compareTo(11.11));
111+
}
92112
}

api/src/test/resources/testdata/test-queues.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
<concept concept_id="2000" retired="false" is_set="true" creator="1" date_created="2022-02-02 14:31:00.0" uuid="907eba27-2b38-43e8-91a9-4dfe3956a35t"/>
55
<concept concept_id="2001" retired="false" is_set="false" creator="1" date_created="2022-02-02 14:40:00.0" uuid="67b910bd-298c-4ecf-a632-661ae2f446op"/>
66
<concept concept_id="2002" retired="false" is_set="false" creator="1" date_created="2022-03-08 15:40:00.0" uuid="68b910bd-298c-4ecf-a632-661ae2f446op"/>
7+
<concept concept_id="2003" retired="false" is_set="false" creator="1" date_created="2024-01-16 15:40:00.0" uuid="1d2a73ca-20aa-4218-b4d2-043024a9156e"/>
8+
<concept concept_id="2004" retired="false" is_set="false" creator="1" date_created="2024-01-18 05:40:00.0" uuid="24932838-60ca-44e8-840f-4184b368643c"/>
79
<concept_name concept_name_id="893" concept_id="2000" name="Queue Service" locale="en" creator="1" date_created="2022-02-02 14:40:00.0" voided="0" uuid="9cp62348-5bf2-4050-b824-0aa009436ed6" concept_name_type="FULLY_SPECIFIED" locale_preferred="0"/>
810
<concept_name concept_name_id="210" concept_id="2001" name="Triage" locale="en" creator="1" date_created="2022-02-02 14:40:00.0" voided="0" uuid="9i667348-5bf2-4050-b824-0aa009436kl0" concept_name_type="FULLY_SPECIFIED" locale_preferred="0"/>
911
<concept_name concept_name_id="211" concept_id="2002" name="Consultation" locale="en" creator="1" date_created="2022-02-02 14:40:00.0" voided="0" uuid="5t747348-5bf2-4050-b824-0aa009436kl0" concept_name_type="FULLY_SPECIFIED" locale_preferred="0"/>
12+
<concept_name concept_name_id="212" concept_id="2003" name="Triage statuses" locale="en" creator="1" date_created="2024-01-15 14:40:00.0" voided="0" uuid="9b6d5a44-47b0-4ed2-873b-5b317721ca9a" concept_name_type="FULLY_SPECIFIED" locale_preferred="0"/>
13+
<concept_name concept_name_id="213" concept_id="2004" name="Triage queue priorities" locale="en" creator="1" date_created="2024-01-16 14:40:00.0" voided="0" uuid="9f2af84d-5e4c-43d9-bdde-fea4a3f15744" concept_name_type="FULLY_SPECIFIED" locale_preferred="0"/>
1014
<concept_set concept_set_id="389000" concept_set="2000" concept_id="2001" sort_weight="0" date_created="2022-02-02 14:40:00.0" creator="1" uuid="470b910bd-298c-4ecf-a632-661ae2f886bf"/>
1115
<concept_set concept_set_id="389001" concept_set="2000" concept_id="2002" sort_weight="0" date_created="2022-03-08 15:50:00.0" creator="1" uuid="380b910bd-298c-4ecf-a632-661ae2f886bf"/>
1216

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
<!-- Modules compatibility > Core 2.3.0 -->
7777
<datafilterVersion>1.0.0</datafilterVersion>
78-
<queueVersion>1.0.0-SNAPSHOT</queueVersion>
78+
<queueVersion>2.1.0</queueVersion>
7979

8080
<!-- For Validator -->
8181
<reportingVersion>1.19.0</reportingVersion>

readme/queues.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ queues/
77
```
88
There is currently only one format for the queue CSV line, here are the possible headers with a sample data set:
99

10-
| <sub>Uuid</sub> | <sub>Void/Retire</sub> | <sub>Name</sub> | <sub>Description</sub> | <sub>Service</sub> | <sub>Location</sub> |
11-
|--------------------------------------|-------------|-----------------------------|---------------|--------------------|--------------------|
12-
| <sub>32176576-1652-4835-8736-826eb0237482</sub> | | <sub>Clinical Consultation Queue</sub> | <sub>Consult Queue</sub> | <sub>Outpatient Service</sub> | <sub>Outpatient Clinic</sub>| |
10+
| <sub>Uuid</sub> | <sub>Void/Retire</sub> | <sub>Name</sub> | <sub>Description</sub> | <sub>Service</sub> | <sub>Status Concept Set</sub> | <sub>Priority Concept Set</sub> | <sub>Location</sub> |
11+
|--------------------------------------|-------------|-----------------------------|---------------|--------------------|--------------------|-----------------------------------|--------------------|
12+
| <sub>32176576-1652-4835-8736-826eb0237482</sub> | | <sub>Clinical Consultation Queue</sub> | <sub>Consult Queue</sub> | <sub>Outpatient Service</sub> |<sub>Queue entry statuses</sub> | <sub>Queue entry priorities</sub> | <sub>Outpatient Clinic</sub>| |
1313

1414
Headers that start with an underscore such as `_order:1000` are metadata headers. The values in the columns under those headers are never read by the CSV parser.
1515

@@ -25,11 +25,17 @@ A description is optional and will populate the queue description
2525
###### Header `Service`
2626
This is a reference (UUID, same as mapping or name) to an existing concept that defines the service associated with this queue.
2727

28+
###### Header `Status Concept Set`
29+
This is a reference (UUID, same as mapping or name) to an existing concept set that defines the queue statuses that could be assigned to the entries in this queue.
30+
31+
###### Header `Priority Concept Set`
32+
This is a reference (UUID, same as mapping or name) to an existing concept set that defines the queue priorities that could be assigned to the entries in this queue.
33+
2834
###### Header `Location`
2935
This is a reference (UUID or name) to an existing location that defines the location associated with this queue.
3036

3137
#### Requirements
32-
* The [queue module](https://github.com/openmrs/openmrs-module-queue) must be installed
38+
* The [queue module](https://github.com/openmrs/openmrs-module-queue) version 2.1 or higher must be installed
3339
* The OpenMRS version must be 2.3 or higher
3440

3541
#### Further examples:

0 commit comments

Comments
 (0)