Skip to content

Commit

Permalink
[mekomsolutions#284] - Support "dispositions" domain
Browse files Browse the repository at this point in the history
  • Loading branch information
mogoodrich committed Oct 24, 2024
1 parent 714ca3e commit bd1c216
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ configuration/
├── concepts/
├── conceptsets/
├── datafiltermappings/
├── dispositions/
├── drugs/
├── encountertypes/
├── encounterroles/
Expand Down Expand Up @@ -159,6 +160,7 @@ This is the list of currently supported domains in their loading order:
1. [AMPATH Forms (JSON files)](readme/ampathforms.md)
1. [AMPATH Forms Translations (JSON files)](readme/ampathformstranslations.md)
1. [HTML Forms (XML files)](readme/htmlforms.md)
1. [Disposition Config (json files)](readme/dispositions.md)

## Try it out
Build the master branch and install the built OMOD to your OpenMRS instance:
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/openmrs/module/initializer/Domain.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public enum Domain {
FHIR_PATIENT_IDENTIFIER_SYSTEMS,
AMPATH_FORMS,
AMPATH_FORMS_TRANSLATIONS,
HTML_FORMS;
HTML_FORMS,
DISPOSITIONS;

public int getOrder() {
return ArrayUtils.indexOf(values(), this) + 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.openmrs.module.initializer.api.loaders;

import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.module.emrapi.disposition.DispositionService;
import org.openmrs.module.initializer.Domain;
import org.openmrs.module.initializer.api.ConfigDirUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;

@OpenmrsProfile(modules = { "emrapi:2.1.0-SNAPSHOT-9.*" })
public class DispositionsLoader extends BaseFileLoader {

@Autowired
private DispositionService dispositionService;

private boolean fileFound = false;

@Override
protected Domain getDomain() {
return Domain.DISPOSITIONS;
}

@Override
protected String getFileExtension() {
return "json";
}

@Override
public void load() {
fileFound = false;
super.load();
}

@Override
protected void load(File file) throws Exception {
if (fileFound) {
throw new IllegalArgumentException(
"Multiple disposition files found in the disposition configuration directory.");
}
fileFound = true;
dispositionService.setDispositionConfig("file:" + file.getAbsolutePath());
}

@Override
public ConfigDirUtil getDirUtil() {
// skip checksums, this needs to be processed every time
return new ConfigDirUtil(iniz.getConfigDirPath(), iniz.getChecksumsDirPath(), getDomainName(), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public DomainBaseModuleContextSensitiveTest() {
mod.setFile(new File(""));
ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod);
}
{
Module mod = new Module("", "emrapi", "", "", "", "2.1.0-SNAPSHOT");
mod.setFile(new File(""));
ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod);
}
{
try {
Class.forName("org.bahmni.module.bahmnicore.Activator");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.openmrs.module.initializer.api;

import org.junit.Test;
import org.openmrs.module.emrapi.disposition.DispositionService;
import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest;
import org.openmrs.module.initializer.api.loaders.DispositionsLoader;
import org.springframework.beans.factory.annotation.Autowired;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class DispositionsLoaderIntegrationTest extends DomainBaseModuleContextSensitiveTest {

@Autowired
protected InitializerService iniz;

@Autowired
private DispositionsLoader loader;

@Autowired
private DispositionService dispositionService;

@Test
public void load_shouldLoadDisposition() {
loader.load();
assertEquals(5, dispositionService.getDispositions().size());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[
{
"uuid" : "d2d89630-b698-11e2-9e96-0800200c9a66",
"name" : "disposition.death",
"conceptCode" : "org.openmrs.module.emrapi:Death",
"actions" : [
"closeCurrentVisitAction",
"markPatientDeadAction"
],
"additionalObs" : [
{
"label" : "emr.dateOfDeath",
"conceptCode" : "org.openmrs.module.emrapi:Date of death"
}
]
},
{
"uuid" : "66de7f60-b73a-11e2-9e96-0800200c9a66",
"name" : "disposition.admit",
"type" : "ADMIT",
"conceptCode" : "org.openmrs.module.emrapi:Admit to hospital",
"actions" : [ ],
"additionalObs" : [ ]
},
{
"uuid" : "8297651b-4046-11ef-ba6a-0242ac120002",
"name" : "disposition.transfer",
"type" : "TRANSFER",
"conceptCode" : "org.openmrs.module.emrapi:Transfer out of hospital",
"actions" : [ ],
"additionalObs" : [ ]
},
{
"uuid" : "687d966bb-9c91-4886-b8b0-e63361f495f0",
"name" : "disposition.observation",
"conceptCode" : "org.openmrs.module.emrapi:ED Observation",
"keepsVisitOpen" : "true",
"actions" : [ ],
"additionalObs" : [ ]
},
{
"uuid" : "12129630-b698-11e2-9e96-0800200c9a66",
"name" : "disposition.discharge",
"type" : "DISCHARGE",
"conceptCode" : "org.openmrs.module.emrapi:Discharged",
"actions" : [
"closeCurrentVisitAction"
],
"additionalObs" : [ ]
}
]
3 changes: 3 additions & 0 deletions omod/src/main/resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
<aware_of_module version="${cohortModuleVersion}">
org.openmrs.module.cohort
</aware_of_module>
<aware_of_module version="${emrapiModuleVersion}">
org.openmrs.module.emrapi
</aware_of_module>
<aware_of_module version="${fhir2Version}">
org.openmrs.module.fhir2
</aware_of_module>
Expand Down
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<bahmniIeAppsVersion>1.1.0</bahmniIeAppsVersion>
<bahmniCoreVersion>0.93-1.1.0</bahmniCoreVersion>
<cohortModuleVersion>3.5.0</cohortModuleVersion>
<emrapiModuleVersion>2.1.0-SNAPSHOT</emrapiModuleVersion>
<htmlformentryVersion>4.0.0</htmlformentryVersion>
<idgenVersion>4.6.0</idgenVersion>
<metadatasharingVersion>1.2.2</metadatasharingVersion>
Expand Down Expand Up @@ -181,6 +182,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>emrapi-api</artifactId>
<version>${emrapiModuleVersion}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>exti18n-api</artifactId>
Expand Down
14 changes: 14 additions & 0 deletions readme/dispositions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Domain 'dispositions'
**Dispositions** subfolder contains a single JSON that defines the dispositions available in the system::

```bash
cashpoints/
├──dispositions.json
```

#### Requirements
* The [emr-api](https://github.com/openmrs/openmrs-module-emrapi) version 2.1.0 or higher must be installed
* The OpenMRS version must be 2.2.1 or higher most be installed

#### Further examples:
Please look at the test configuration folder for dispositions file, see [here](../api/src/test/resources/testAppDataDir/configuration/dispositions/dispositionConfig.json).

0 comments on commit bd1c216

Please sign in to comment.