From 2cd95c04f5d066e8ef160d28cb9ac4b9dc6693a2 Mon Sep 17 00:00:00 2001 From: Cosmin Date: Thu, 18 Jan 2024 08:04:58 -0500 Subject: [PATCH] O3-2446: parse and load queue priority concept --- .../initializer/api/queues/QueueLineProcessor.java | 12 +++++++++++- .../api/queues/QueueLoaderIntegrationTest.java | 1 + .../testAppDataDir/configuration/queues/queues.csv | 8 ++++---- api/src/test/resources/testdata/test-queues.xml | 2 ++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/api-2.3/src/main/java/org/openmrs/module/initializer/api/queues/QueueLineProcessor.java b/api-2.3/src/main/java/org/openmrs/module/initializer/api/queues/QueueLineProcessor.java index cd5cd89a..37046907 100644 --- a/api-2.3/src/main/java/org/openmrs/module/initializer/api/queues/QueueLineProcessor.java +++ b/api-2.3/src/main/java/org/openmrs/module/initializer/api/queues/QueueLineProcessor.java @@ -19,7 +19,9 @@ public class QueueLineProcessor extends BaseLineProcessor { protected static String HEADER_SERVICE = "service"; - protected static String HEADER_STATUS_CONCEPT_SET = "statusConceptSet"; + 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"; @@ -55,6 +57,14 @@ public Queue fill(Queue queue, CsvLine line) throws IllegalArgumentException { 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)) { diff --git a/api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java b/api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java index 3266ac99..736f5eb2 100644 --- a/api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java +++ b/api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java @@ -73,6 +73,7 @@ public void load_shouldLoadAccordingToCsvFiles() throws Exception { 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()); } } diff --git a/api-2.3/src/test/resources/testAppDataDir/configuration/queues/queues.csv b/api-2.3/src/test/resources/testAppDataDir/configuration/queues/queues.csv index 78993d4d..9daa918a 100644 --- a/api-2.3/src/test/resources/testAppDataDir/configuration/queues/queues.csv +++ b/api-2.3/src/test/resources/testAppDataDir/configuration/queues/queues.csv @@ -1,4 +1,4 @@ -Uuid,Void/Retire,Name,Description,Service,StatusConceptSet,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,Xanadu +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 diff --git a/api/src/test/resources/testdata/test-queues.xml b/api/src/test/resources/testdata/test-queues.xml index a958b799..9e7765a0 100644 --- a/api/src/test/resources/testdata/test-queues.xml +++ b/api/src/test/resources/testdata/test-queues.xml @@ -5,10 +5,12 @@ + +