forked from mekomsolutions/openmrs-module-initializer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mekomsolutions#284] - Support "dispositions" domain
- Loading branch information
1 parent
714ca3e
commit bd1c216
Showing
9 changed files
with
163 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
api/src/main/java/org/openmrs/module/initializer/api/loaders/DispositionsLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
api/src/test/java/org/openmrs/module/initializer/api/DispositionsLoaderIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
api/src/test/resources/testAppDataDir/configuration/dispositions/dispositionConfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" : [ ] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |