From fd3a55a0b90f4e40bdd1d26d26c6a291a04aa51d Mon Sep 17 00:00:00 2001 From: moshonk Date: Sun, 12 May 2024 05:21:49 +0300 Subject: [PATCH 1/9] chore: Update Maven repository URLs in pom.xml --- pom.xml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index b9276ba..e8c5f32 100644 --- a/pom.xml +++ b/pom.xml @@ -201,6 +201,11 @@ + + repsy + Maven Repository on Repsy + https://repo.repsy.io/mvn/intellisoftdev/default + openmrs-repo OpenMRS Nexus Repository @@ -229,18 +234,16 @@ github-packages - - github-packages - Github Maven Repo - https://maven.pkg.github.com/openmrs/openmrs-module-labonfhir - false - - github-packages - Github Maven Repo - https://maven.pkg.github.com/openmrs/openmrs-module-labonfhir - true + repsy + My Private Maven Repository on Repsy + https://repo.repsy.io/mvn/intellisoftdev/default + + repsy + My Private Maven Repository on Repsy + https://repo.repsy.io/mvn/intellisoftdev/default + From 16c4e52991aed5284dbe2a450229e9e0db388813 Mon Sep 17 00:00:00 2001 From: moshonk Date: Sun, 12 May 2024 05:22:31 +0300 Subject: [PATCH 2/9] [maven-release-plugin] prepare release 1.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e8c5f32..a5b0508 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ scm:git:git@github.com:openmrs/openmrs-module-labonfhir.git scm:git:git@github.com:openmrs/openmrs-module-labonfhir.git https://github.com/openmrs/openmrs-module-labonfhir/ - HEAD + 1.4.0 From 83a8f08ae4769762c56a89290ba542506e268ae8 Mon Sep 17 00:00:00 2001 From: moshonk Date: Sun, 12 May 2024 05:28:58 +0300 Subject: [PATCH 3/9] chore: Update labonfhir version to 1.4.0-SNAPSHOT --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a5b0508..17c13d5 100644 --- a/pom.xml +++ b/pom.xml @@ -19,9 +19,9 @@ https://wiki.openmrs.org/x/FQ4z - scm:git:git@github.com:openmrs/openmrs-module-labonfhir.git - scm:git:git@github.com:openmrs/openmrs-module-labonfhir.git - https://github.com/openmrs/openmrs-module-labonfhir/ + scm:git:git@bitbucket.org:botswana-emrs/openmrs-module-labonfhir.git + scm:git:git@bitbucket.org:botswana-emrs/openmrs-module-labonfhir.git + https://bitbucket.org/botswana-emrs/openmrs-module-labonfhir 1.4.0 From 3f2e4d71d6baa635afda1e38396df084621dba3f Mon Sep 17 00:00:00 2001 From: moshonk Date: Sun, 12 May 2024 05:29:06 +0300 Subject: [PATCH 4/9] chore: Update .gitignore to include openmrs.log --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6c44140..00d36d4 100644 --- a/.gitignore +++ b/.gitignore @@ -80,4 +80,5 @@ nb-configuration.xml ############################## .DS_Store -.flattened-pom.xml \ No newline at end of file +.flattened-pom.xml +openmrs.log From b7f446e0cee8a1d86e295c3f25b371ed982934d9 Mon Sep 17 00:00:00 2001 From: moshonk Date: Sun, 12 May 2024 05:39:37 +0300 Subject: [PATCH 5/9] chore: Update Maven repository URLs in pom.xml --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index 17c13d5..845c965 100644 --- a/pom.xml +++ b/pom.xml @@ -257,4 +257,17 @@ 2.3.1 4.2.0 + + + + repsy + My Private Maven Repository on Repsy + https://repo.repsy.io/mvn/intellisoftdev/default + + + repsy + My Private Maven Repository on Repsy + https://repo.repsy.io/mvn/intellisoftdev/default + + From af9dc6d4afd2649404f7c4ecc94071e76e76a179 Mon Sep 17 00:00:00 2001 From: moshonk Date: Sun, 12 May 2024 05:40:22 +0300 Subject: [PATCH 6/9] [maven-release-plugin] prepare release 1.4.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 845c965..59f1469 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ scm:git:git@bitbucket.org:botswana-emrs/openmrs-module-labonfhir.git scm:git:git@bitbucket.org:botswana-emrs/openmrs-module-labonfhir.git https://bitbucket.org/botswana-emrs/openmrs-module-labonfhir - 1.4.0 + 1.4.1 From 1a1e117e1482ff836ec6c2499a19fff869339895 Mon Sep 17 00:00:00 2001 From: moshonk Date: Sun, 12 May 2024 05:40:39 +0300 Subject: [PATCH 7/9] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 59f1469..845c965 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ scm:git:git@bitbucket.org:botswana-emrs/openmrs-module-labonfhir.git scm:git:git@bitbucket.org:botswana-emrs/openmrs-module-labonfhir.git https://bitbucket.org/botswana-emrs/openmrs-module-labonfhir - 1.4.1 + 1.4.0 From 1c1518ec0c854eb8573e725ba8816f8a2f87edc7 Mon Sep 17 00:00:00 2001 From: moshonk Date: Tue, 14 May 2024 14:44:15 +0300 Subject: [PATCH 8/9] chore: Add MFL Code as location identifier in LabCreationListener --- .../api/event/LabCreationListener.java | 54 ++++++++++++++++--- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/labonfhir/api/event/LabCreationListener.java b/api/src/main/java/org/openmrs/module/labonfhir/api/event/LabCreationListener.java index fbcdc9f..fab0b08 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/api/event/LabCreationListener.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/api/event/LabCreationListener.java @@ -1,6 +1,8 @@ package org.openmrs.module.labonfhir.api.event; import javax.jms.Message; + +import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -10,10 +12,16 @@ import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.param.TokenAndListParam; import ca.uhn.fhir.rest.param.TokenParam; +import org.hl7.fhir.r4.model.Location; + import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.r4.model.Task; +import org.openmrs.LocationAttribute; +import org.openmrs.LocationAttributeType; +import org.openmrs.api.LocationService; import org.openmrs.api.context.Daemon; import org.openmrs.event.EventListener; import org.openmrs.module.DaemonToken; @@ -31,6 +39,10 @@ public abstract class LabCreationListener implements EventListener { + private static final String MFL_LOCATION_IDENTIFIER_URI = "http://moh.bw.org/ext/location/identifier/mfl"; + + private static final String MFL_LOCATION_ATTRIBUTE_TYPE_UUID = "8a845a89-6aa5-4111-81d3-0af31c45c002"; + private static final Logger log = LoggerFactory.getLogger(EncounterCreationListener.class); private DaemonToken daemonToken; @@ -47,14 +59,17 @@ public abstract class LabCreationListener implements EventListener { private FhirContext ctx; @Autowired - FhirLocationService fhirLocationService ; + FhirLocationService fhirLocationService; @Autowired private FhirTaskService fhirTaskService; @Autowired - private LabOnFhirService labOnFhirService ; + private LabOnFhirService labOnFhirService; + @Autowired + private LocationService locationService; + public DaemonToken getDaemonToken() { return daemonToken; } @@ -70,8 +85,7 @@ public void onMessage(Message message) { Daemon.runInDaemonThread(() -> { try { processMessage(message); - } - catch (Exception e) { + } catch (Exception e) { log.error("Failed to update the user's last viewed patients property", e); } }, daemonToken); @@ -96,8 +110,35 @@ public Bundle createLabBundle(Task task) { if (!task.getLocation().isEmpty()) { labResources.add(fhirLocationService.get(FhirUtils.referenceToId(task.getLocation().getReference()).get())); } + for (IBaseResource r : labResources) { Resource resource = (Resource) r; + + // if resource is location, add MFL Code as location identifier + // TODO: Short term: Make the MFL Location attribute type to be a Global config variable + // TODO: Long term: Make the location translator pick enrich the MFL Code as appropriate + + if (resource instanceof Location) { + Location location = (Location) resource; + if (location != null) { + org.openmrs.Location openmrsLocation = locationService.getLocationByUuid(location.getId()); + if (openmrsLocation != null) { + LocationAttributeType mflLocationAttributeType = locationService.getLocationAttributeTypeByUuid(MFL_LOCATION_ATTRIBUTE_TYPE_UUID); + Collection locationAttributeTypes = openmrsLocation.getActiveAttributes(); + if (!locationAttributeTypes.isEmpty()) { + locationAttributeTypes.stream().filter(locationAttribute -> locationAttribute.getAttributeType().equals(mflLocationAttributeType)).findFirst().ifPresent(locationAttribute -> { + String mflCode = (String) locationAttribute.getValue(); + + Identifier mflIdentifier = new Identifier(); + mflIdentifier.setSystem(MFL_LOCATION_IDENTIFIER_URI); + mflIdentifier.setValue(mflCode); + location.addIdentifier(mflIdentifier); + }); + } + } + } + } + Bundle.BundleEntryComponent component = transactionBundle.addEntry(); component.setResource(resource); component.getRequest().setUrl(resource.fhirType() + "/" + resource.getIdElement().getIdPart()) @@ -113,8 +154,7 @@ protected void sendTask(Task task) { Bundle labBundle = createLabBundle(task); try { client.transaction().withBundle(labBundle).execute(); - } - catch (Exception e) { + } catch (Exception e) { saveFailedTask(task.getIdElement().getIdPart(), e.getMessage()); log.error("Failed to send Task with UUID " + task.getIdElement().getIdPart(), e); } @@ -123,7 +163,7 @@ protected void sendTask(Task task) { } } - private void saveFailedTask(String taskUuid ,String error) { + private void saveFailedTask(String taskUuid, String error) { FailedTask failedTask = new FailedTask(); failedTask.setError(error); failedTask.setIsSent(false); From e597f1817c91752a2a4d01da01bde65c8fa7ebec Mon Sep 17 00:00:00 2001 From: moshonk Date: Fri, 23 Aug 2024 07:55:36 +0300 Subject: [PATCH 9/9] Refactor code to replace component annotations with xml configurations --- .../openmrs/module/labonfhir/LabOnFhirActivator.java | 2 -- .../org/openmrs/module/labonfhir/LabOnFhirConfig.java | 3 +-- .../openmrs/module/labonfhir/api/LabOrderHandler.java | 3 +-- .../openmrs/module/labonfhir/api/LabOrderManager.java | 2 -- .../api/event/EncounterCreationListener.java | 1 - .../labonfhir/api/event/OrderCreationListener.java | 2 -- .../labonfhir/api/scheduler/FetchTaskUpdates.java | 1 - .../labonfhir/api/scheduler/RetryFailedTasks.java | 3 --- api/src/main/resources/moduleApplicationContext.xml | 11 +++++++++-- 9 files changed, 11 insertions(+), 17 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/labonfhir/LabOnFhirActivator.java b/api/src/main/java/org/openmrs/module/labonfhir/LabOnFhirActivator.java index d5d9c31..0610f51 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/LabOnFhirActivator.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/LabOnFhirActivator.java @@ -27,9 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; -@Component public class LabOnFhirActivator extends BaseModuleActivator implements ApplicationContextAware, DaemonTokenAware { private static final Logger log = LoggerFactory.getLogger(LabOnFhirActivator.class); diff --git a/api/src/main/java/org/openmrs/module/labonfhir/LabOnFhirConfig.java b/api/src/main/java/org/openmrs/module/labonfhir/LabOnFhirConfig.java index cc505fe..b68a98a 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/LabOnFhirConfig.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/LabOnFhirConfig.java @@ -28,9 +28,8 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -@Component + @Configuration public class LabOnFhirConfig implements ApplicationContextAware { diff --git a/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderHandler.java b/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderHandler.java index cfbd8a2..a2ca485 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderHandler.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderHandler.java @@ -27,9 +27,8 @@ import org.openmrs.module.labonfhir.LabOnFhirConfig; import org.openmrs.module.labonfhir.api.fhir.OrderCreationException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -@Component + public class LabOrderHandler { @Autowired diff --git a/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderManager.java b/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderManager.java index ea94b03..442bd10 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderManager.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderManager.java @@ -15,9 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -@Component public class LabOrderManager implements GlobalPropertyListener { private static final Logger log = LoggerFactory.getLogger(LabOrderManager.class); diff --git a/api/src/main/java/org/openmrs/module/labonfhir/api/event/EncounterCreationListener.java b/api/src/main/java/org/openmrs/module/labonfhir/api/event/EncounterCreationListener.java index c45c345..49684a2 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/api/event/EncounterCreationListener.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/api/event/EncounterCreationListener.java @@ -16,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -@Component("labEncounterListener") public class EncounterCreationListener extends LabCreationListener { private static final Logger log = LoggerFactory.getLogger(OrderCreationListener.class); @Autowired diff --git a/api/src/main/java/org/openmrs/module/labonfhir/api/event/OrderCreationListener.java b/api/src/main/java/org/openmrs/module/labonfhir/api/event/OrderCreationListener.java index e5ce142..40b65e8 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/api/event/OrderCreationListener.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/api/event/OrderCreationListener.java @@ -15,9 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -@Component("labOrderListener") public class OrderCreationListener extends LabCreationListener { private static final Logger log = LoggerFactory.getLogger(OrderCreationListener.class); diff --git a/api/src/main/java/org/openmrs/module/labonfhir/api/scheduler/FetchTaskUpdates.java b/api/src/main/java/org/openmrs/module/labonfhir/api/scheduler/FetchTaskUpdates.java index dcd14b4..2a46295 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/api/scheduler/FetchTaskUpdates.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/api/scheduler/FetchTaskUpdates.java @@ -49,7 +49,6 @@ import java.text.SimpleDateFormat; -@Component @Setter(AccessLevel.PACKAGE) public class FetchTaskUpdates extends AbstractTask implements ApplicationContextAware { diff --git a/api/src/main/java/org/openmrs/module/labonfhir/api/scheduler/RetryFailedTasks.java b/api/src/main/java/org/openmrs/module/labonfhir/api/scheduler/RetryFailedTasks.java index ce910c7..627e76a 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/api/scheduler/RetryFailedTasks.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/api/scheduler/RetryFailedTasks.java @@ -16,12 +16,9 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.client.api.IGenericClient; -@Component public class RetryFailedTasks extends AbstractTask implements ApplicationContextAware { private static Log log = LogFactory.getLog(RetryFailedTasks.class); diff --git a/api/src/main/resources/moduleApplicationContext.xml b/api/src/main/resources/moduleApplicationContext.xml index f7a0e78..82240bc 100644 --- a/api/src/main/resources/moduleApplicationContext.xml +++ b/api/src/main/resources/moduleApplicationContext.xml @@ -10,8 +10,15 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - - + + + + + + + + +