Skip to content

Commit

Permalink
Merge branch 'master' into ContactPointMap-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher authored May 20, 2024
2 parents c2b5957 + 583aee2 commit 88cc779
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo
## Releases notes

#### Version 2.7.0
* Added support for 'fhircontactpointmap' domain.
* Added support for 'queues' domain.
* Added support for 'addresshierarchy' domain.
* Fix for Liquibase Loader to ensure compatibility with OpenMRS versions 2.5.5+
* Added support for 'fhircontactpointmap' domain.
* Fix for OCL Loader to ensure it throws an Exception if the OCL import fails

#### Version 2.6.0
* Added support for 'cohorttypes' and 'cohortattributetypes' domains.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class QueueLineProcessor extends BaseLineProcessor<Queue> {

protected static String HEADER_SERVICE = "service";

protected static String HEADER_STATUS_CONCEPT_SET = "status concept set";

protected static String HEADER_PRIORITY_CONCEPT_SET = "priority concept set";

protected static String HEADER_LOCATION = "location";

private final ConceptService conceptService;
Expand All @@ -45,6 +49,22 @@ public Queue fill(Queue queue, CsvLine line) throws IllegalArgumentException {
queue.setService(null);
}
}
if (line.containsHeader(HEADER_STATUS_CONCEPT_SET)) {
String statusConceptSet = line.getString(HEADER_STATUS_CONCEPT_SET);
if (StringUtils.isNotBlank(statusConceptSet)) {
queue.setStatusConceptSet(Utils.fetchConcept(statusConceptSet, conceptService));
} else {
queue.setStatusConceptSet(null);
}
}
if (line.containsHeader(HEADER_PRIORITY_CONCEPT_SET)) {
String priorityConceptSet = line.getString(HEADER_PRIORITY_CONCEPT_SET);
if (StringUtils.isNotBlank(priorityConceptSet)) {
queue.setPriorityConceptSet(Utils.fetchConcept(priorityConceptSet, conceptService));
} else {
queue.setPriorityConceptSet(null);
}
}
if (line.containsHeader(HEADER_LOCATION)) {
String location = line.getString(HEADER_LOCATION);
if (StringUtils.isNotBlank(location)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,16 @@ public void load_shouldLoadAccordingToCsvFiles() throws Exception {
Assert.assertEquals(2001, queue.getService().getConceptId().intValue());
Assert.assertEquals(3, queue.getLocation().getLocationId().intValue());
}
// Queue with statuses
{
Queue queue = queueService.getQueueByUuid("4856c1c1-c9b3-4a7e-8669-4220051ab640").orElse(null);
Assert.assertNotNull(queue);
Assert.assertEquals("Triage Queue", queue.getName());
Assert.assertEquals("Queue with custom statuses", queue.getDescription());
Assert.assertEquals(2001, queue.getService().getConceptId().intValue());
Assert.assertEquals(2003, queue.getStatusConceptSet().getConceptId().intValue());
Assert.assertEquals("Triage queue priorities", queue.getPriorityConceptSet().getName().getName());
Assert.assertEquals("Xanadu", queue.getLocation().getName());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Uuid,Void/Retire,Name,Description,Service,Location
2a0e0eee-6888-11ee-ab8d-0242ac120002,,Revised Queue,Revised Description,68b910bd-298c-4ecf-a632-661ae2f446op,Xanadu
288db1cc-688a-11ee-ab8d-0242ac120002,,New Queue,New Description,Triage,167ce20c-4785-4285-9119-d197268f7f4a
Uuid,Void/Retire,Name,Description,Service,Status Concept Set,Priority Concept Set,Location
2a0e0eee-6888-11ee-ab8d-0242ac120002,,Revised Queue,Revised Description,68b910bd-298c-4ecf-a632-661ae2f446op,,,Xanadu
288db1cc-688a-11ee-ab8d-0242ac120002,,New Queue,New Description,Triage,,,167ce20c-4785-4285-9119-d197268f7f4a
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ public Concept fill(Concept instance, CsvLine line) throws IllegalArgumentExcept
return instance;
}

ConceptNumeric cn = new ConceptNumeric(instance);
ConceptNumeric cn = null;
if (instance.getId() != null) { // below overrides any other processors work, so this one should be called first
cn = conceptService.getConceptNumeric(instance.getId());
}

if (cn == null) {
cn = new ConceptNumeric(instance);
}

cn.setDatatype(conceptService.getConceptDatatypeByName(DATATYPE_NUMERIC));

cn.setHiAbsolute(line.getDouble(HEADER_AH));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.openmrs.module.initializer.api.loaders;

import java.io.File;
import java.util.zip.ZipFile;

import org.apache.commons.lang.StringUtils;
import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.api.context.Context;
import org.openmrs.module.initializer.Domain;
import org.openmrs.module.openconceptlab.Import;
import org.openmrs.module.openconceptlab.ImportService;
import org.openmrs.module.openconceptlab.importer.Importer;

import java.io.File;
import java.util.zip.ZipFile;

@OpenmrsProfile(modules = { "openconceptlab:1.2.9" })
public class OpenConceptLabLoader extends BaseFileLoader {

Expand All @@ -25,7 +28,29 @@ protected String getFileExtension() {
protected void load(File file) throws Exception {
ZipFile zip = new ZipFile(file);
Importer importer = Context.getRegisteredComponent("openconceptlab.importer", Importer.class);
ImportService importService = Context.getService(ImportService.class);

Import lastImport = importService.getLastImport();
log.debug("Starting OCL importer");
importer.run(zip);
Import oclImport = importService.getLastImport();

// Import failed to start. This can happen another import is already currently running
if (oclImport == null || oclImport.equals(lastImport)) {
throw new IllegalStateException("OCL import did not start successfully");
}

// Import detected errors
if (StringUtils.isNotBlank(oclImport.getErrorMessage())) {
throw new IllegalStateException(oclImport.getErrorMessage());
}

// Import never stopped
if (!oclImport.isStopped()) {
throw new IllegalStateException("OCL import did not complete successfully");
}

log.debug("OCL import completed successfully: " + oclImport.getLocalDateStopped());
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.openmrs.module.initializer.api.c;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.junit.Assert;
Expand Down Expand Up @@ -89,4 +91,22 @@ public void fill_shouldFailWhenCannotParse() {
ConceptNumericLineProcessor p = new ConceptNumericLineProcessor(cs);
p.fill(new Concept(), new CsvLine(headerLine, line));
}

@Test
public void fill_shouldOverrideProvidedDataType() {

// Setup
when(cs.getConceptNumeric(any(Integer.class))).thenReturn(null);
String[] headerLine = { "Data type", "Absolute low" };
String[] line = { "Numeric", "11.11" };

// Replay
ConceptNumericLineProcessor p = new ConceptNumericLineProcessor(cs);
ConceptNumeric cn = (ConceptNumeric) p.fill(new Concept(1), new CsvLine(headerLine, line));

// Verify
verify(cs, atLeast(1)).getConceptNumeric(any(Integer.class));
Assert.assertEquals(ConceptNumericLineProcessor.DATATYPE_NUMERIC, cn.getDatatype().getName());
Assert.assertEquals(0, cn.getLowAbsolute().compareTo(11.11));
}
}
4 changes: 4 additions & 0 deletions api/src/test/resources/testdata/test-queues.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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"/>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

<!-- Modules compatibility > Core 2.3.0 -->
<datafilterVersion>1.0.0</datafilterVersion>
<queueVersion>1.0.0-SNAPSHOT</queueVersion>
<queueVersion>2.1.0</queueVersion>

<!-- For Validator -->
<reportingVersion>1.19.0</reportingVersion>
Expand Down
14 changes: 10 additions & 4 deletions readme/queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ queues/
```
There is currently only one format for the queue CSV line, here are the possible headers with a sample data set:

| <sub>Uuid</sub> | <sub>Void/Retire</sub> | <sub>Name</sub> | <sub>Description</sub> | <sub>Service</sub> | <sub>Location</sub> |
|--------------------------------------|-------------|-----------------------------|---------------|--------------------|--------------------|
| <sub>32176576-1652-4835-8736-826eb0237482</sub> | | <sub>Clinical Consultation Queue</sub> | <sub>Consult Queue</sub> | <sub>Outpatient Service</sub> | <sub>Outpatient Clinic</sub>| |
| <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> |
|--------------------------------------|-------------|-----------------------------|---------------|--------------------|--------------------|-----------------------------------|--------------------|
| <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>| |

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.

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

###### Header `Status Concept Set`
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.

###### Header `Priority Concept Set`
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.

###### Header `Location`
This is a reference (UUID or name) to an existing location that defines the location associated with this queue.

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

#### Further examples:
Expand Down

0 comments on commit 88cc779

Please sign in to comment.