Skip to content

Commit

Permalink
Bring in changes from main branch (#78)
Browse files Browse the repository at this point in the history
* BAH-3842 | Add. Application Properties In API Resources (#60)

* BAH-3842 | Add. Application Properties In API Resources (#61)

* Merge IPD Branch Latest Changes To Master

* Parvathy | BAH-4017 | Add. Global Property bahmni-ipd.allowSlotStopOnDrugOrderStop (#69)

* BAH-4001 | Add. Set flag to mark system generated tasks (#70)

* BAH-4033 | Refactor. Get task type for system generated tasks from configuration (#71)

* BAH-4062 | Refactor. Move privilege creation to config.xml (#72)

* BAH-4062 | Refactor. Extract privilege creation to config.xml

* BAH-4062 | Fix. Error messages for privilege check failures

* BAH-4073 | Refactor. Change LICENSE to OMRS MPLv2 (#74)

* BAH-4073 | Refactor. Change LICENSE to OMRS MPLv2

* BAH-4073 | Fix. License information in pom.xml

* BAH-4061 | Refactor. Change Medication Administration Status Type As VarChar (#73)

* [Rahul] | BAH-4061 | Refactor. Change Medication Administration Status Type As VarChar

* [Rahul] | BAH-4061 | Refactor. Remove Unused Dependencies

* [Rahul] | BAH-4061 | Refactor. Change Status Value In Test

* [Rahul] | BAH-4061 | Refactor. Remove MedicationAdministration Status Null Check

* [Rahul] | BAH-4061 | Fix. MedicationAdministrationStatus Test Data

* Merge main branch changes

* BAH-4093 | Add. Workflow to release artifacts on push of a tag (#77)

* BAH-4093 | Upgrade depencies for release

* BAH-4093 | Release of version 1.0.0

* BAH-4093 | Incrementing dev version to 1.1.0-SNAPSHOT

---------

Co-authored-by: Rahul Ramesh <[email protected]>
Co-authored-by: Parvathy Babu <[email protected]>
Co-authored-by: MOHANKUMAR T <[email protected]>
Co-authored-by: MOHANKUMAR T <[email protected]>
  • Loading branch information
5 people authored Aug 28, 2024
1 parent 9ce0056 commit cdd0212
Show file tree
Hide file tree
Showing 25 changed files with 585 additions and 776 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ jobs:
server-username: NEXUS_USERNAME
server-password: NEXUS_PASSWORD
- name: Build and deploy with Maven
run: ./mvnw --no-transfer-progress clean -U deploy
run: |
PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ "$PROJECT_VERSION" == *"-SNAPSHOT" ]]; then
./mvnw --no-transfer-progress clean -U deploy
else
echo "❌ The current push is for release. So skipping build."
fi
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
37 changes: 37 additions & 0 deletions .github/workflows/release_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and Release package
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
build-release-package:
name: Build and Release package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: nexus-sonatype
server-username: NEXUS_USERNAME
server-password: NEXUS_PASSWORD
gpg-private-key: ${{ secrets.BAHMNI_INFRA_GPG_KEY }}
- name: Compare Git tag with Maven version
run: |
export GIT_TAG=${GITHUB_REF#refs/tags/}
PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
if [ "$PROJECT_VERSION" != "$GIT_TAG" ]; then
echo "❌ The Git tag ($GIT_TAG) does not match the Maven version ($PROJECT_VERSION)."
exit 1
else
echo "✅ The Git tag matches the Maven version."
fi
- name: Build and deploy with Maven
run: ./mvnw --no-transfer-progress clean -U deploy -DperformRelease=true
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.BAHMNI_INFRA_GPG_PASSPHRASE }}
2 changes: 1 addition & 1 deletion .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
with:
java-version: 1.8
- name: Build with Maven
run: mvn clean package
run: ./mvnw clean package
1,062 changes: 401 additions & 661 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.bahmni.module</groupId>
<artifactId>bahmni-ipd</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>bahmni-ipd-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class IPDEventUtils {

public static TaskRequest createNonMedicationTaskRequest(IPDEvent ipdEvent, String name, String taskType) {
public static TaskRequest createNonMedicationTaskRequest(IPDEvent ipdEvent, String name, String taskType, Boolean isSystemGenerated) {
TaskRequest taskRequest = new TaskRequest();
taskRequest.setName(name);
taskRequest.setTaskType(taskType);
Expand All @@ -17,6 +17,7 @@ public static TaskRequest createNonMedicationTaskRequest(IPDEvent ipdEvent, Stri
taskRequest.setRequestedStartTime(new Date());
taskRequest.setIntent(FhirTask.TaskIntent.ORDER);
taskRequest.setStatus(FhirTask.TaskStatus.REQUESTED);
taskRequest.setIsSystemGeneratedTask(isSystemGenerated);
return taskRequest;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public class PatientAdmitEventHandler implements IPDEventHandler {
public void handleEvent(IPDEvent event) {
List<ConfigDetail> configList = configLoader.getConfigs();
ConfigDetail eventConfig = configList.stream()
.filter(config -> config.getType().equals(event.getIpdEventType().name()))
.filter(config -> config.getEvent().equals(event.getIpdEventType().name()))
.findFirst()
.orElse(null);
if (eventConfig != null) {
for(TaskDetail taskDetail : eventConfig.getTasks()) {
TaskRequest taskRequest = IPDEventUtils.createNonMedicationTaskRequest(event, taskDetail.getName(), "nursing_activity_system");
TaskRequest taskRequest = IPDEventUtils.createNonMedicationTaskRequest(event, taskDetail.getName(), taskDetail.getType(), true);
Task task = taskMapper.fromRequest(taskRequest);
taskService.saveTask(task);
log.info("Task created " + taskDetail.getName());
Expand All @@ -49,4 +49,4 @@ public void handleEvent(IPDEvent event) {


}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class RolloverTaskEventHandler implements IPDEventHandler {
public void handleEvent(IPDEvent event) {
List<ConfigDetail> configList = configLoader.getConfigs();
ConfigDetail eventConfig = configList.stream()
.filter(config -> config.getType().equals(event.getIpdEventType().name()))
.filter(config -> config.getEvent().equals(event.getIpdEventType().name()))
.findFirst()
.orElse(null);

Expand All @@ -54,4 +54,4 @@ public void handleEvent(IPDEvent event) {
}
taskRequestedPeriodDao.update(fhirTaskRequestedPeriods);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void handleEvent(IPDEvent event) {
String patientUuid = admittedPatient.getBedPatientAssignment().getPatient().getUuid();
IPDEvent ipdEvent = new IPDEvent(null, patientUuid, event.getIpdEventType());
for(TaskDetail taskDetail : eventConfig.getTasks()) {
TaskRequest taskRequest = IPDEventUtils.createNonMedicationTaskRequest(ipdEvent, taskDetail.getName(), "nursing_activity_system");
TaskRequest taskRequest = IPDEventUtils.createNonMedicationTaskRequest(ipdEvent, taskDetail.getName(), taskDetail.getType(), true);
Task task = taskMapper.fromRequest(taskRequest);
tasks.add(task);
}
Expand All @@ -52,9 +52,9 @@ public void handleEvent(IPDEvent event) {
private ConfigDetail getEventConfig(IPDEvent event){
List<ConfigDetail> configList = configLoader.getConfigs();
ConfigDetail eventConfig = configList.stream()
.filter(config -> config.getType().equals(event.getIpdEventType().name()))
.filter(config -> config.getEvent().equals(event.getIpdEventType().name()))
.findFirst()
.orElse(null);
return eventConfig;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
@NoArgsConstructor
@AllArgsConstructor
public class ConfigDetail {
private String type;
private String event;
private List<TaskDetail> tasks;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
@AllArgsConstructor
public class TaskDetail {
private String name;
private String type;
}
3 changes: 3 additions & 0 deletions api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Route definitions
config-file.path=/etc/bahmni_config/openmrs/apps/ipdDashboard/eventsConfig.json
61 changes: 1 addition & 60 deletions api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,64 +467,5 @@
'2024-04-11 19:00:00', 'MM/dd/yyyy HH:mm:ss', 86400, true, 1, NOW(), UUID());
</sql>
</changeSet>
<changeSet id="ipd-edit-medication-tasks" author="Bahmni">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from privilege where privilege = 'Edit Medication Tasks'</sqlCheck>
</preConditions>
<insert tableName="privilege">
<column name="privilege" value="Edit Medication Tasks"/>
<column name="description" value="Edit Medication Tasks description"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>
<changeSet id="ipd-delete-medication-tasks" author="Bahmni">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from privilege where privilege = 'Delete Medication Tasks'</sqlCheck>
</preConditions>
<insert tableName="privilege">
<column name="privilege" value="Delete Medication Tasks"/>
<column name="description" value="Delete Medication Tasks description"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>
<changeSet id="ipd-edit-adhoc-medication-tasks" author="Bahmni">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from privilege where privilege = 'Edit adhoc medication tasks'</sqlCheck>
</preConditions>
<insert tableName="privilege">
<column name="privilege" value="Edit adhoc medication tasks"/>
<column name="description" value="Edit adhoc medication tasks description"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>
<changeSet id="ipd-edit-medication-administration-tasks" author="Bahmni">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from privilege where privilege = 'Edit Medication Administration'</sqlCheck>
</preConditions>
<insert tableName="privilege">
<column name="privilege" value="Edit Medication Administration"/>
<column name="description" value="Edit Medication Administration description"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>
<changeSet id="ipd-get-medication-administration" author="Bahmni">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from privilege where privilege = 'Get Medication Administration'</sqlCheck>
</preConditions>
<insert tableName="privilege">
<column name="privilege" value="Get Medication Administration"/>
<column name="description" value="Get Medication Administration description"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>
<changeSet id="ipd-get-medication-tasks" author="Bahmni">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from privilege where privilege = 'Get Medication Tasks'</sqlCheck>
</preConditions>
<insert tableName="privilege">
<column name="privilege" value="Get Medication Tasks"/>
<column name="description" value="Get Medication Tasks description"/>
<column name="uuid" valueComputed="uuid()"/>
</insert>
</changeSet>

</databaseChangeLog>
3 changes: 2 additions & 1 deletion api/src/main/resources/moduleApplicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<context:component-scan base-package="org.openmrs.module.ipd.api"/>
<context:annotation-config/>
<context:property-placeholder location="classpath:application.properties"/>
<bean id="hibernateSlotDAO" class="org.openmrs.module.ipd.api.dao.impl.HibernateSlotDAO"/>
<bean id="slotServiceImpl" class="org.openmrs.module.ipd.api.service.impl.SlotServiceImpl"/>
<bean id="slotService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
Expand All @@ -35,4 +36,4 @@
</property>
</bean>

</beans>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ public void shouldGetTheSavedSlotsForPatientByAdministeredTime() {


MedicationAdministration medicationAdministration=new MedicationAdministration();
medicationAdministration.setStatus(testConcept);
medicationAdministration.setStatus(org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.COMPLETED);
medicationAdministration.setAdministeredDateTime(DateTimeUtil.convertLocalDateTimeDate(medicationAdministeredTime));
MedicationAdministration savedMedicationAdministration= medicationAdministrationDao.createOrUpdate(medicationAdministration);

MedicationAdministration medicationAdministration2=new MedicationAdministration();
medicationAdministration2.setStatus(testConcept);
medicationAdministration2.setStatus(org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.COMPLETED);
medicationAdministration2.setAdministeredDateTime(DateTimeUtil.convertLocalDateTimeDate(medicationAdministeredTime2));
MedicationAdministration savedMedicationAdministration2= medicationAdministrationDao.createOrUpdate(medicationAdministration2);

Expand Down Expand Up @@ -376,12 +376,12 @@ public void shouldGetTheSavedSlotsForPatientBySubjectReferenceAndAGivenTimeFrame


MedicationAdministration medicationAdministration=new MedicationAdministration();
medicationAdministration.setStatus(testConcept);
medicationAdministration.setStatus(org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.COMPLETED);
medicationAdministration.setAdministeredDateTime(DateTimeUtil.convertLocalDateTimeDate(medicationAdministeredTime));
MedicationAdministration savedMedicationAdministration= medicationAdministrationDao.createOrUpdate(medicationAdministration);

MedicationAdministration medicationAdministration2=new MedicationAdministration();
medicationAdministration2.setStatus(testConcept);
medicationAdministration2.setStatus(org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationStatus.COMPLETED);
medicationAdministration2.setAdministeredDateTime(DateTimeUtil.convertLocalDateTimeDate(medicationAdministeredTime2));
MedicationAdministration savedMedicationAdministration2= medicationAdministrationDao.createOrUpdate(medicationAdministration2);

Expand Down
4 changes: 2 additions & 2 deletions api/src/test/resources/scheduleMedicationsTestData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<ipd_schedule schedule_id="1" uuid="23255323d-e887-4485-bc19-756cdbf00001" subject_reference_id="2" actor_reference_id="1" service_type_id="101" active="true" start_date="2024-01-27 15:48:00.0" creator="1" date_created="2024-01-27 15:48:00.0" voided="false" visit_id="1"/>

<concept concept_id="103" retired="false" datatype_id="4" class_id="11" is_set="false" creator="1" date_created="2024-01-27 15:48:00.0" version="" uuid="0abca361-f6bf-49cc-97de-b2f37f099125"/>
<medication_administration medication_administration_id="1" uuid="23255323d-e887-4485-bc19-756cdbf10101" status="103" creator="1" date_created="2024-01-27 20:00:00.0" voided="false"/>
<medication_administration medication_administration_id="2" uuid="23255323d-e887-4485-bc19-756cdbf10102" status="103" creator="1" date_created="2024-01-28 14:00:00.0" voided="false"/>
<medication_administration medication_administration_id="1" uuid="23255323d-e887-4485-bc19-756cdbf10101" status="COMPLETED" creator="1" date_created="2024-01-27 20:00:00.0" voided="false"/>
<medication_administration medication_administration_id="2" uuid="23255323d-e887-4485-bc19-756cdbf10102" status="COMPLETED" creator="1" date_created="2024-01-28 14:00:00.0" voided="false"/>

<ipd_slot slot_id="1" uuid="23255323d-e887-4485-bc19-756cdbf00101" service_type_id="101" schedule_id="1" status="COMPLETED" start_date_time="2024-01-27 20:00:00.0" creator="1" date_created="2024-01-27 15:48:00.0" voided="false" order_id="1" medication_administration_id="1"/>
<ipd_slot slot_id="2" uuid="23255323d-e887-4485-bc19-756cdbf00102" service_type_id="101" schedule_id="1" status="SCHEDULED" start_date_time="2024-01-28 08:00:00.0" creator="1" date_created="2024-01-27 15:48:00.0" voided="false" order_id="1"/>
Expand Down
2 changes: 1 addition & 1 deletion omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>bahmni-ipd</artifactId>
<groupId>org.bahmni.module</groupId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>bahmni-ipd-omod</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static MedicationAdministrationResponse createFrom(org.openmrs.module.ipd
if (openmrsMedicationAdministration == null) {
return null;
}
String status = openmrsMedicationAdministration.getStatus() != null ? openmrsMedicationAdministration.getStatus().getShortNameInLocale(Context.getLocale()).getName() : null;
String status = openmrsMedicationAdministration.getStatus().toCode() != null ? openmrsMedicationAdministration.getStatus().toCode() : null;
String statusReason = openmrsMedicationAdministration.getStatusReason() != null ? openmrsMedicationAdministration.getStatusReason().getDisplayString() : null;
String patientUuid = openmrsMedicationAdministration.getPatient() != null ? openmrsMedicationAdministration.getPatient().getUuid() : null;
String encounterUuid = openmrsMedicationAdministration.getEncounter() != null ? openmrsMedicationAdministration.getEncounter().getUuid() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.RestUtil;
import org.openmrs.module.webservices.rest.web.v1_0.controller.BaseRestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
Expand All @@ -30,6 +32,7 @@ public class IPDMedicationAdministrationController extends BaseRestController {

private final IPDMedicationAdministrationService ipdMedicationAdministrationService;
private final MedicationAdministrationFactory medicationAdministrationFactory;
private static final Logger log = LoggerFactory.getLogger(IPDMedicationAdministrationController.class);

@Autowired
public IPDMedicationAdministrationController(IPDMedicationAdministrationService ipdMedicationAdministrationService,
Expand Down Expand Up @@ -63,8 +66,8 @@ public ResponseEntity<Object> createScheduledMedicationAdministration(@RequestBo
@ResponseBody
public ResponseEntity<Object> createAdhocMedicationAdministration(@RequestBody MedicationAdministrationRequest medicationAdministrationRequest) {
try {
if (!Context.getUserContext().hasPrivilege(PrivilegeConstants.EDIT_ADHOC_MEDICATION_TASKS) || !Context.getUserContext().hasPrivilege(PrivilegeConstants.EDIT_MEDICATION_ADMINISTRATION)) {
return new ResponseEntity<>(RestUtil.wrapErrorResponse(new Exception(), "User doesn't have the following privilege(s) " + PrivilegeConstants.EDIT_MEDICATION_TASKS + ", "+PrivilegeConstants.EDIT_MEDICATION_ADMINISTRATION), FORBIDDEN);
if (!Context.getUserContext().hasPrivilege(PrivilegeConstants.EDIT_ADHOC_MEDICATION_TASKS)) {
return new ResponseEntity<>(RestUtil.wrapErrorResponse(new Exception(), "User doesn't have the following privilege(s) " + PrivilegeConstants.EDIT_ADHOC_MEDICATION_TASKS), FORBIDDEN);
}
MedicationAdministration medicationAdministration = ipdMedicationAdministrationService.saveAdhocMedicationAdministration(medicationAdministrationRequest);
MedicationAdministrationResponse medicationAdministrationResponse = medicationAdministrationFactory.mapMedicationAdministrationToResponse(medicationAdministration);
Expand Down
Loading

0 comments on commit cdd0212

Please sign in to comment.