Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to make this run in the RefApp #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.properties</include>
<include>*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.properties</exclude>
<exclude>*.xml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>

<testResources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,135 @@
*/
package org.openmrs.module.edtriageapp;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.Concept;
import org.openmrs.ConceptSource;
import org.openmrs.EncounterRole;
import org.openmrs.EncounterType;
import org.openmrs.api.ConceptService;
import org.openmrs.api.EncounterService;
import org.openmrs.api.context.Context;
import org.openmrs.module.BaseModuleActivator;
import org.openmrs.module.ModuleActivator;
import org.openmrs.module.DaemonToken;
import org.openmrs.module.DaemonTokenAware;
import org.openmrs.module.ModuleActivator;
import org.openmrs.module.Module;
import org.openmrs.module.ModuleFactory;
import org.openmrs.module.edtriageapp.task.TriageTask;
import org.openmrs.module.emrapi.utils.MetadataUtil;
import org.springframework.transaction.annotation.Transactional;

/**
* This class contains the logic that is run every time this module is either started or stopped.
*/
public class EDTriageAppActivator extends BaseModuleActivator implements DaemonTokenAware{

protected Log log = LogFactory.getLog(getClass());

@SuppressWarnings("unused")
public class EDTriageAppActivator extends BaseModuleActivator implements DaemonTokenAware {

protected Log log = LogFactory.getLog(getClass());
private ConceptService conceptService;
private EncounterService encounterService;

/**
* @see ModuleActivator#started()
*/
@Transactional
public void started() {
if (conceptService == null) {
conceptService = Context.getConceptService();
}

if (encounterService == null) {
encounterService = Context.getEncounterService();
}

log.info("Checking and creating metadata for the ED Triage module");
retireOldConcepts();

// ensure we have the required concept sources
addConceptSource("ICD-10-WHO 2nd", EDTriageConstants.ICD_10_WHO_2ND_MAP_UUID,
"Preferred secondary map to ICD-10-WHO");
addConceptSource("org.openmrs.module.mirebalaisreports", EDTriageConstants.MIREBALAIS_REPORTS_CONCEPT_SOURCE_UUID,
"Used to indicate concepts that are used and grouped to represent various notifiable diseases to the Haiti" +
" Ministry of Health (ie. Tetanus)");

// ensure we have the required encounter type
EncounterType edTriageEncounterType = encounterService.getEncounterTypeByUuid(
EDTriageConstants.ED_TRIAGE_ENCOUNTER_TYPE_UUID);
if (edTriageEncounterType == null) {
edTriageEncounterType = new EncounterType();
edTriageEncounterType.setUuid(EDTriageConstants.ED_TRIAGE_ENCOUNTER_TYPE_UUID);
edTriageEncounterType.setName("Emergency Triage");
edTriageEncounterType.setDescription("Emergency Department patient triage");
encounterService.saveEncounterType(edTriageEncounterType);
}

// ensure we have the consulting clinician encounter role
EncounterRole edTriageEncounterRole = encounterService.getEncounterRoleByUuid(
EDTriageConstants.CONSULTING_CLINICIAN_ENCOUNTER_ROLE_UUID);
if (edTriageEncounterRole == null) {
edTriageEncounterRole = new EncounterRole();
edTriageEncounterRole.setUuid(EDTriageConstants.CONSULTING_CLINICIAN_ENCOUNTER_ROLE_UUID);
edTriageEncounterRole.setName("Consulting Clinician");
edTriageEncounterRole.setDescription(
"Clinician who is primarily responsible for examining and diagnosing a patient");
encounterService.saveEncounterRole(edTriageEncounterRole);
}

try {
// Note that this has been specifically setup to run in PEER_TO_PEER mode, meaning that all current
// mappings will be used
log.info("Importing ED Triage Metadata");
MetadataUtil.setupSpecificMetadata(getClass().getClassLoader(), "HUM_Emergency_Triage");
}
catch (Exception e) {
try {
Module mod = ModuleFactory.getModuleById(EDTriageConstants.ED_TRIAGE_MOD);
ModuleFactory.stopModule(mod);
}
catch (Exception ignored) {}

throw new RuntimeException("Failed to start the edtriageapp module", e);
}

TriageTask.setEnabled(true);
log.info("ED Triage App Module started");
}

private void addConceptSource(String name, String uuid, String description) {
ConceptSource conceptSource = conceptService.getConceptSourceByName(name);

if (conceptSource == null) {
conceptSource = new ConceptSource();
conceptSource.setUuid(uuid);
conceptSource.setName(name);
conceptSource.setDescription(description);
conceptService.saveConceptSource(conceptSource);
}
}

private void retireOldConcepts() {
// Retire YES and NO so as to prevent duplicate errors
Concept yesConcept = conceptService.getConcept(1);
if (!yesConcept.isRetired()) {
log.warn("Retiring default YES concept in favor of CIEL:1065");
conceptService.retireConcept(conceptService.getConcept(1), "Replaced by CIEL:1065");
}

Concept noConcept = conceptService.getConcept(2);
if (!noConcept.isRetired()) {
log.warn("Retiring default NO concept in favor of CIEL:1066");
conceptService.retireConcept(conceptService.getConcept(2), "Replaced by CIEL:1066");
}

// Adopted from PIH
// Removed concept "cerebellar infarction” from HUM ED set, and added “cerebral infarction"
Concept concept = conceptService.getConceptByUuid("145906AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
if (concept != null) {
conceptService.retireConcept(concept, "replaced with by 155479AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
}
}

/**
* @see ModuleActivator#stopped()
*/
Expand All @@ -50,4 +153,12 @@ public void stopped() {
public void setDaemonToken(DaemonToken daemonToken) {
TriageTask.setDaemonToken(daemonToken);
}

public void setConceptService(ConceptService conceptService) {
this.conceptService = conceptService;
}

public void setEncounterService(EncounterService encounterService) {
this.encounterService = encounterService;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package org.openmrs.module.edtriageapp;


@SuppressWarnings({"unused"})
public class EDTriageConstants {

public static final String ED_TRIAGE_MOD = "edtriageapp";
public static final String ED_TRIAGE = "edtriageapp.app.edTriage";
public static final String PRIVILEGE_ED_TRIAGE = "App: edtriageapp.edtriage";
public static final String PRIVILEGE_ED_TRIAGE_QUEUE = "App: edtriageapp.edtriage.queue";
public static final String ED_TRIAGE_QUEUE = "edtriageapp.app.triageQueue";
public static final String TRIAGE_QUEUE_STATUS_CONCEPT_UUID = "66c18ba5-459e-4049-94ab-f80aca5c6a98";
public static final String TRIAGE_QUEUE_WAITING_FOR_EVALUATION_CONCEPT_UUID = "4dd3244d-fcb9-424d-ad8a-afd773c69923";
public static final String TRIAGE_QUEUE_EXPIRED_CONCEPT_UUID = "1fa8d25e-7471-4201-815f-79fac44d9a5f";
public static final String TRIAGE_WAITING_TIME_UUID = "d9a8fc6f-8695-46b8-854f-2c9e818b4568";
public static final String ED_TRIAGE_ENCOUNTER_TYPE_NAME = "Emergency Triage";
public static final String ED_TRIAGE_ENCOUNTER_TYPE_UUID = "74cef0a6-2801-11e6-b67b-9e71128cae77";
public static final String CONSULTING_CLINICIAN_ENCOUNTER_ROLE_UUID = "4f10ad1a-ec49-48df-98c7-1391c6ac7f05";
public static final String ICD_10_WHO_2ND_MAP_UUID = "8ADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD";
public static final String MIREBALAIS_REPORTS_CONCEPT_SOURCE_UUID = "947a1410-1987-4399-8017-c1ea70f242d1";

}
50 changes: 25 additions & 25 deletions api/src/main/java/org/openmrs/module/edtriageapp/EDTriageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@

public class EDTriageUtil {

public static String parseUrl(String url, String parameterName) {
String parameterValue = null;
public static String parseUrl(String url, String parameterName) {
String parameterValue = null;

if (StringUtils.isNotBlank(url)) {
String substring = url.substring(url.indexOf("?") + 1);
if (StringUtils.isNotBlank(substring)) {
String[] kvPairs = substring.split("&");
if (kvPairs != null && kvPairs.length > 0) {
for (String kvPair: kvPairs) {
int i = kvPair.indexOf("=");
String key = null;
String value = null;
if (i > 0) {
key = kvPair.substring(0, i);
value = kvPair.substring(i + 1);
if (StringUtils.equals(key, parameterName)) {
parameterValue = value;
break;
}
}
}
}
}
}
return parameterValue;
}
if (StringUtils.isNotBlank(url)) {
int parameterStart = url.indexOf("?");
if (parameterStart >= 0) {
String substring = url.substring(parameterStart + 1);
if (StringUtils.isNotBlank(substring)) {
String[] kvPairs = substring.split("&");
for (String kvPair : kvPairs) {
int i = kvPair.indexOf("=");
if (i > 0) {
String key = kvPair.substring(0, i);
String value = kvPair.substring(i + 1);
if (StringUtils.equals(key, parameterName)) {
parameterValue = value;
break;
}
}
}
}
}
}

return parameterValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ public interface EdTriageAppService extends OpenmrsService {
*/
Encounter getEDTriageEncounterForActiveVisit(String locationUuid, String patientUuid);

/**
* Get the ED Triage encounter (if any) for the patient's active visit
* (Note that getEDTriageEncounterForActiveVisit should be preferred if a location is available)
* @param patientUuid - the uuid for the patient in question
*/
Encounter getEDTriageEncounterForActiveVisit(String patientUuid);

/*
* expires ED Triage encounters with a status of "waiting for evaluation" that are part of non-active visits
*/
void expireEDTriageEncounters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import org.openmrs.Location;
import org.openmrs.Obs;
import org.openmrs.Patient;
import org.openmrs.Visit;
import org.openmrs.api.ConceptService;
import org.openmrs.api.EncounterService;
import org.openmrs.api.LocationService;
import org.openmrs.api.ObsService;
import org.openmrs.api.PatientService;
import org.openmrs.api.context.Context;
import org.openmrs.api.impl.BaseOpenmrsService;
import org.openmrs.module.edtriageapp.EDTriageConstants;
import org.openmrs.module.edtriageapp.api.EdTriageAppService;
Expand All @@ -41,6 +43,7 @@
/**
* It is a default implementation of {@link EdTriageAppService}.
*/
@SuppressWarnings("unused")
public class EdTriageAppServiceImpl extends BaseOpenmrsService implements EdTriageAppService {

private AdtService adtService;
Expand Down Expand Up @@ -173,6 +176,30 @@ public Encounter getEDTriageEncounterForActiveVisit(String locationUuid, String
return null;
}

@Override
public Encounter getEDTriageEncounterForActiveVisit(String patientUuid) {

if (StringUtils.isBlank(patientUuid)) {
return null;
}

Patient patient = patientService.getPatientByUuid(patientUuid);

if (patient == null) {
return null;
}

for (Visit visit : Context.getVisitService().getActiveVisitsByPatient(patient)) {
for (Encounter encounter : visit.getEncounters()) {
if (EDTriageConstants.ED_TRIAGE_ENCOUNTER_TYPE_UUID.equals(encounter.getEncounterType().getUuid())) {
return encounter;
}
}
}

return null;
}

@Override
@Transactional
public void expireEDTriageEncounters() {
Expand All @@ -198,4 +225,4 @@ public void expireEDTriageEncounters() {
}
}

}
}
Binary file not shown.
10 changes: 6 additions & 4 deletions api/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ edtriageapp.confirmSubmit=Are you sure you want to submit the form?
edtriageapp.formHistory=Form History

# symptoms that need translations
edtriageapp.5242AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Respitory rate
edtriageapp.5092AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Blood oxygen saturation
edtriageapp.117617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Pregnancy & trauma or vaginal bleeding
edtriageapp.120977AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Burn - facial/inhalation
edtriageapp.120977AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Burn - facial / inhalation
edtriageapp.12d9f052-6980-4542-91ef-190247811228=Shortness of breath - acute
edtriageapp.130334AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Vomiting - persistent
edtriageapp.139006AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Vomiting - fresh blood
edtriageapp.163476AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Burn over 10% or circumferential
edtriageapp.3ccccc20-26fe-102b-80cb-0017a47871b2=Poisoning/overdose
edtriageapp.3ccccc20-26fe-102b-80cb-0017a47871b2=Poisoning / Overdose
edtriageapp.c05b25f1-07d1-47de-a61e-fc9d3bfe95eb=Burn - electrical or chemical
edtriageapp.3ccd21e8-26fe-102b-80cb-0017a47871b2=Burn - other
edtriageapp.3cce938e-26fe-102b-80cb-0017a47871b2=Seizure - convulsive
edtriageapp.206AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Seizure - convulsive
edtriageapp.f7ef0b85-6af3-43b9-87a5-5abf89e3a3f5=Hypersalivation
edtriageapp.24fa118d-f81d-439d-82a5-d7c6ac6ef72b=Laryngeal stridor
edtriageapp.3ceade68-26fe-102b-80cb-0017a47871b2=Sibilance
Expand All @@ -109,5 +111,5 @@ edtriageapp.2b436367-c44b-4835-90ad-e93e77d45a97=Floppy infant syndrome
edtriageapp.143582AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Constantly crying
edtriageapp.aca0abff-a38a-4191-a5c4-041fa1809306=Dislocation of large joint
edtriageapp.a218b3d9-2ead-4fa2-afbd-64849012e125=Dislocation of small joint
edtriageapp.3ccea7fc-26fe-102b-80cb-0017a47871b2=Psychosis/Aggression
edtriageapp.3ccea7fc-26fe-102b-80cb-0017a47871b2=Psychosis / Aggression
edtriageapp.dd050085-ef34-4318-9423-c4ed666ac372=Left without seeing a clinician
8 changes: 5 additions & 3 deletions api/src/main/resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ edtriageapp.warning.noSymptoms=Pas de symptômes qui ont ete sélectionnés
edtriageapp.confirmSubmit=Est ce que vous etes sûr que vous voulez envoyer le formulaire?

# symptoms that need translations
edtriageapp.5242AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Fréquence respiratoire
edtriageapp.5092AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Saturation en oxygène du sang
edtriageapp.117617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Grossesse & traumatisme ou saignements vaginaux
edtriageapp.120977AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Brûlure ‐ visage /inhalation
edtriageapp.120977AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Brûlure ‐ visage / inhalation
edtriageapp.12d9f052-6980-4542-91ef-190247811228=Dyspnée ‐ aigue
edtriageapp.130334AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Vomissements ‐ tenaces
edtriageapp.139006AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Vomissements ‐ saignements aigus
edtriageapp.163476AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Brûlure dépassant 10% ou circonférentielle
edtriageapp.3ccccc20-26fe-102b-80cb-0017a47871b2=Empoisonnement /Overdose
edtriageapp.3ccccc20-26fe-102b-80cb-0017a47871b2=Empoisonnement / Overdose
edtriageapp.c05b25f1-07d1-47de-a61e-fc9d3bfe95eb=Brûlure ‐ électrique ou chimique
edtriageapp.3ccd21e8-26fe-102b-80cb-0017a47871b2=Brûlure ‐ autres
edtriageapp.3cce938e-26fe-102b-80cb-0017a47871b2=Crise - convulsive
edtriageapp.206AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Crise - convulsive
edtriageapp.f7ef0b85-6af3-43b9-87a5-5abf89e3a3f5=Hypersialorrhée
edtriageapp.24fa118d-f81d-439d-82a5-d7c6ac6ef72b=Stridor Laryngé
edtriageapp.3ceade68-26fe-102b-80cb-0017a47871b2=Sibilance
Expand Down
Loading