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

Medication Administration Feature #7

Merged
merged 46 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1a1a1b8
[Ritesh] | 1. Repo set up. 2. Created Slot and Schedule entity 3.Savi…
riteshghiya90 Jul 26, 2023
5624b68
[Ritesh] | 1. Update package name 2. Added Dao and Service layer for …
riteshghiya90 Jul 27, 2023
d660aca
[Ritesh] | 1.Rename Schedule Strategy to MedicationFrequency
riteshghiya90 Jul 28, 2023
f1f7c84
[Ritesh] | 1. Migration for slot. 2. Slot creation from schedule
riteshghiya90 Jul 31, 2023
631e13c
[Ritesh] | 1. Refactor SlotTimeCreationService
riteshghiya90 Aug 2, 2023
b25f1ff
[Ritesh] | 1. Handle time zone issue while creating slots and schedule.
riteshghiya90 Aug 3, 2023
164d2f6
[Ritesh] | 1. Changing the url of saving medication
riteshghiya90 Aug 3, 2023
4dd314d
[Ritesh] | 1. Returning slots
riteshghiya90 Aug 3, 2023
6f705b2
[Ritesh] | Get schedule for Drug chart
riteshghiya90 Aug 3, 2023
6e2b5fb
[Ritesh] | Fix date time issue in slots response
riteshghiya90 Aug 3, 2023
4c85e25
[Ritesh] | Refactoring and Added test
riteshghiya90 Aug 6, 2023
46ea8ce
[Ritesh] | 1. Change for reference id to subject reference id and by …
riteshghiya90 Aug 7, 2023
7a1b137
[Ritesh] | 1. Refactoring ServiceType
riteshghiya90 Aug 7, 2023
02430d8
[Ritesh] | 1. Bug Fix return empty list if now slots are not present …
riteshghiya90 Aug 8, 2023
a30b081
[Ritesh] | 1. Updated README file
riteshghiya90 Aug 8, 2023
b22fb92
[Ritesh] | 1. Fixed time zone issue in test
riteshghiya90 Aug 8, 2023
258bcf2
add. endpoint to get list of IPD medications scheduled for a patient
Arjun-Go Aug 8, 2023
e14c6f3
refactor. endpoint and updated tests in DAO and service classes
Arjun-Go Aug 9, 2023
b543981
Merge branch 'ipd-slot-schedule' into fetch-schedule-for-order
Arjun-Go Aug 10, 2023
bf25de2
refactor. namings for schedule DAO methods
Arjun-Go Aug 21, 2023
83d4321
Merge pull request #2 from Bahmni/fetch-schedule-for-order
Arjun-Go Aug 22, 2023
c95019c
fix. test failures in ScheduleImpl
Arjun-Go Aug 22, 2023
d04db9b
add. changes to create one schedule for a patient
Arjun-Go Nov 20, 2023
49914ba
update. columns in Schedule and Slot table
Arjun-Go Nov 21, 2023
ab1f30c
update. set end date as null
Arjun-Go Nov 21, 2023
84dede0
fix tests for Slot and Schedule Hiberate and DAOs. Updated responses …
Arjun-Go Nov 21, 2023
e065535
fix tests Schedule DAO
Arjun-Go Nov 22, 2023
5478304
remove unnecessary fields
Arjun-Go Nov 22, 2023
9c7a32c
API Change to accomodate Editable Remaining day slot start time for m…
kalai-tw Nov 24, 2023
215fa8d
Kavitha|Kalai Add Change for Medication Administration Save
kalai-tw Nov 29, 2023
64aa18b
Kavitha|Kalai - Medication Administration Create API Changes
kalai-tw Nov 30, 2023
77606dd
Kavitha|Kalai - Medication Administration Create API Changes
kalai-tw Dec 1, 2023
14e979c
Kavitha, Kalai | refactored patient reference param
kavitha-sundararajan Dec 1, 2023
9cd90b6
Kavitha|Kalai - Medication Administration Create API Changes
kalai-tw Dec 1, 2023
3927a48
Kavitha|Kalai - Medication Administration Create API Changes
kalai-tw Dec 12, 2023
dd0bd15
Kavitha|Kalai - Medication Administration Create API Changes
kalai-tw Dec 12, 2023
c1ab970
Kavitha|Kalai - Medication Administration Create API Changes
kalai-tw Dec 13, 2023
6fbfa62
Kavitha, Kalai | add medication administration reference in slot db a…
kavitha-sundararajan Dec 15, 2023
ff0398e
Kavitha|Kalai - Medication Administration Create API Changes
kalai-tw Dec 17, 2023
4911585
Kavitha, Kalai | added provider mapper and time converter
kavitha-sundararajan Dec 18, 2023
1049ce5
Kavitha | add adhoc and refactored scheduled medication administration
kavitha-sundararajan Dec 27, 2023
5e85a0d
Merge branch 'Bahmni-IPD-master' into medication-administration
kavitha-sundararajan Dec 27, 2023
b8c4daa
refactored schedule from medication administration request
kavitha-sundararajan Dec 27, 2023
1dbad33
Kavitha | refactored medication administration request and response
kavitha-sundararajan Dec 27, 2023
cadcc34
Kavitha | refactored annotation to medicationAdministrationNote
kavitha-sundararajan Dec 27, 2023
c2941b8
Kavitha | removed unused methods
kavitha-sundararajan Dec 28, 2023
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
22 changes: 22 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,17 @@
<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openmrs.web</groupId>
<artifactId>openmrs-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
Expand All @@ -125,6 +128,25 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-omod</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.bahmni.module</groupId>
<artifactId>medication-administration-api</artifactId>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>webservices.rest-omod-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
import org.openmrs.module.ipd.api.model.Schedule;
import org.openmrs.api.db.DAOException;
import org.springframework.stereotype.Repository;
import org.openmrs.Concept;
import org.openmrs.module.ipd.api.model.Reference;

import java.util.List;

@Repository
public interface ScheduleDAO {

Schedule getSchedule(Integer scheduleId) throws DAOException;

Schedule saveSchedule(Schedule schedule) throws DAOException;

Schedule getScheduleByVisit(Visit visit) throws DAOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
public interface SlotDAO {

Slot getSlot(Integer slotId) throws DAOException;


Slot getSlotByUUID(String uuid) throws DAOException;

Slot saveSlot(Slot slot) throws DAOException;

List<Slot> getSlotsBySubjectReferenceIdAndForDateAndServiceType(Reference subject, LocalDate forDate, Concept serviceType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ public HibernateSlotDAO(SessionFactory sessionFactory) {
public Slot getSlot(Integer slotId) throws DAOException {
return sessionFactory.getCurrentSession().get(Slot.class, slotId);
}


@Override
public Slot getSlotByUUID(String uuid) throws DAOException {
Slot s = (Slot)this.sessionFactory.getCurrentSession().createQuery("from Slot s where s.uuid = :uuid").setString("uuid", uuid).uniqueResult();
return s;
}

@Override
public Slot saveSlot(Slot slot) throws DAOException {
sessionFactory.getCurrentSession().saveOrUpdate(slot);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.openmrs.module.ipd.api.model;

public enum ServiceType {
MEDICATION_REQUEST("MedicationRequest");
MEDICATION_REQUEST("MedicationRequest"),
EMERGENCY_MEDICATION_REQUEST("EmergencyMedicationRequest"),
AS_NEEDED_MEDICATION_REQUEST("AsNeededMedicationRequest");

private final String conceptName;

Expand Down
7 changes: 7 additions & 0 deletions api/src/main/java/org/openmrs/module/ipd/api/model/Slot.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public enum SlotStatus {
@Column(name = "status", nullable = false)
@Enumerated(EnumType.STRING)
private SlotStatus status = SlotStatus.SCHEDULED;

/**
* The reference of medication administration if the medication is administered
*/
@OneToOne
@JoinColumn(name = "medication_administration_id", referencedColumnName = "medication_administration_id")
private MedicationAdministration medicationAdministration;
}


Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package org.openmrs.module.ipd.api.service;

import org.openmrs.Concept;
import org.openmrs.Visit;
import org.openmrs.module.ipd.api.model.Reference;
import org.openmrs.module.ipd.api.model.Schedule;
import org.openmrs.api.APIException;
import org.openmrs.api.OpenmrsService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public interface ScheduleService extends OpenmrsService {

// @Authorized({ PrivilegeConstants.EDIT_IPD_SCHEDULES })
Schedule getSchedule(Integer scheduleId) throws APIException;

// @Authorized({ PrivilegeConstants.EDIT_IPD_SCHEDULES })
Schedule saveSchedule(Schedule schedule) throws APIException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public interface SlotService extends OpenmrsService {
// @Authorized({ PrivilegeConstants.EDIT_IPD_SLOTS })
Slot getSlot(Integer slotId) throws APIException;

// @Authorized({ PrivilegeConstants.EDIT_IPD_SLOTS })
Slot getSlotByUUID(String uuid) throws APIException;

// @Authorized({ PrivilegeConstants.EDIT_IPD_SLOTS })
Slot saveSlot(Slot slot) throws APIException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.openmrs.module.ipd.api.service.impl;

import org.openmrs.Concept;
import org.openmrs.Visit;
import org.openmrs.module.ipd.api.dao.ScheduleDAO;
import org.openmrs.module.ipd.api.model.Reference;
import org.openmrs.module.ipd.api.model.Schedule;
import org.openmrs.module.ipd.api.service.ScheduleService;
import org.openmrs.api.APIException;
Expand All @@ -14,8 +12,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ScheduleServiceImpl extends BaseOpenmrsService implements ScheduleService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ public SlotServiceImpl(SlotDAO slotDAO) {
public Slot getSlot(Integer slotId) throws APIException {
return slotDAO.getSlot(slotId);
}


@Override
public Slot getSlotByUUID(String uuid) throws APIException {
return slotDAO.getSlotByUUID(uuid);
}

@Override
public Slot saveSlot(Slot slot) throws APIException {
return slotDAO.saveSlot(slot);
Expand Down
58 changes: 58 additions & 0 deletions api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,62 @@
ALTER TABLE ipd_schedule MODIFY COLUMN end_date datetime NULL;
</sql>
</changeSet>

<changeSet id="add_medication_administration_id_202312141530" author="Bahmni">
<addColumn tableName="ipd_slot">
<column name="medication_administration_id" type="int" />
</addColumn>
<addForeignKeyConstraint baseTableName="ipd_slot" baseColumnNames="medication_administration_id"
constraintName="ipd_slot_medication_administration_fk"
referencedTableName="medication_administration" referencedColumnNames="medication_administration_id"/>
</changeSet>

<changeSet id="add_emergency_medication_concept_202312270121" author="Bahmni">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT COUNT(*) FROM concept where short_name='EmergencyMedicationRequest' and description='EmergencyMedicationRequest';
</sqlCheck>
<sqlCheck expectedResult="0">
SELECT COUNT(*) FROM concept_name where name ='EmergencyMedicationRequest';
</sqlCheck>
</preConditions>
<comment>Add concept for Emergency Medication Request</comment>
<sql>
insert into concept (retired, short_name, description, datatype_id, class_id, is_set, creator, date_created,
changed_by, date_changed, uuid)
values (0, 'EmergencyMedicationRequest', 'EmergencyMedicationRequest',
(select concept_datatype_id from concept_datatype where name = 'Text'),
(select concept_class_id from concept_class where name = 'Misc'),
0, 1, now(), 1, now(), uuid());
insert into concept_name (concept_id, name, locale, locale_preferred, creator, date_created,
concept_name_type, voided, uuid)
values ((select concept_id from concept where short_name='EmergencyMedicationRequest'),
'EmergencyMedicationRequest', 'en', 1, 1, now(), 'FULLY_SPECIFIED', 0, uuid());
</sql>
</changeSet>

<changeSet id="add_as_needed_medication_concept_202312270121" author="Bahmni">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
SELECT COUNT(*) FROM concept where short_name='AsNeededMedicationRequest' and description='AsNeededMedicationRequest';
</sqlCheck>
<sqlCheck expectedResult="0">
SELECT COUNT(*) FROM concept_name where name ='AsNeededMedicationRequest';
</sqlCheck>
</preConditions>
<comment>Add concept for As Needed Medication Request</comment>
<sql>
insert into concept (retired, short_name, description, datatype_id, class_id, is_set, creator, date_created,
changed_by, date_changed, uuid)
values (0, 'AsNeededMedicationRequest', 'AsNeededMedicationRequest',
(select concept_datatype_id from concept_datatype where name = 'Text'),
(select concept_class_id from concept_class where name = 'Misc'),
0, 1, now(), 1, now(), uuid());
insert into concept_name (concept_id, name, locale, locale_preferred, creator, date_created,
concept_name_type, voided, uuid)
values ((select concept_id from concept where short_name='AsNeededMedicationRequest'),
'AsNeededMedicationRequest', 'en', 1, 1, now(), 'FULLY_SPECIFIED', 0, uuid());
</sql>
</changeSet>

</databaseChangeLog>
18 changes: 18 additions & 0 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-omod</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.bahmni.module</groupId>
<artifactId>medication-administration-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.test</groupId>
<artifactId>openmrs-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.openmrs.module.ipd.contract;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import java.util.Date;
import java.util.concurrent.TimeUnit;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties
public class MedicationAdministrationNoteRequest {
private String uuid;
private String authorUuid;
private Long recordedTime;
private String text;

public Date getRecordedTimeAsLocaltime() {
return this.recordedTime != null ? new Date(TimeUnit.SECONDS.toMillis(this.recordedTime)): new Date();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.openmrs.module.ipd.contract;

import lombok.*;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.openmrs.module.ipd.api.model.MedicationAdministrationNote;
import org.openmrs.module.webservices.rest.web.ConversionUtil;
import org.openmrs.module.webservices.rest.web.representation.Representation;

import java.util.Date;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties
public class MedicationAdministrationNoteResponse {
private String uuid;
private Object author;
private Date recordedTime;
private String text;

public static MedicationAdministrationNoteResponse createFrom(MedicationAdministrationNote openmrsObject) {
return MedicationAdministrationNoteResponse.builder()
.uuid(openmrsObject.getUuid())
.author(ConversionUtil.convertToRepresentation(openmrsObject.getAuthor(), Representation.REF))
.recordedTime(openmrsObject.getRecordedTime())
.text(openmrsObject.getText())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.openmrs.module.ipd.contract;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import java.util.Date;
import java.util.concurrent.TimeUnit;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties
public class MedicationAdministrationPerformerRequest {
private String uuid;
private String providerUuid;
private String function;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.openmrs.module.ipd.contract;

import lombok.*;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.openmrs.module.ipd.api.model.MedicationAdministrationPerformer;
import org.openmrs.module.webservices.rest.web.ConversionUtil;
import org.openmrs.module.webservices.rest.web.representation.Representation;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties
public class MedicationAdministrationPerformerResponse {
private String uuid;
private Object provider;
private String function;

public static MedicationAdministrationPerformerResponse createFrom(MedicationAdministrationPerformer openmrsMedicationAdministrationPerformer) {
String function = openmrsMedicationAdministrationPerformer.getFunction() != null ? openmrsMedicationAdministrationPerformer.getFunction().getDisplayString() : null;
return MedicationAdministrationPerformerResponse.builder()
.uuid(openmrsMedicationAdministrationPerformer.getUuid())
.provider(ConversionUtil.convertToRepresentation(openmrsMedicationAdministrationPerformer.getActor(), Representation.REF))
.function(function)
.build();
}
}
Loading
Loading