Skip to content

Commit

Permalink
added center or district initial requirement information set
Browse files Browse the repository at this point in the history
  • Loading branch information
spbogui committed Jan 6, 2021
1 parent 4ff89de commit 08ec0d6
Show file tree
Hide file tree
Showing 33 changed files with 704 additions and 2,315 deletions.
6 changes: 0 additions & 6 deletions META-INF/MANIFEST.MF

This file was deleted.

5 changes: 0 additions & 5 deletions META-INF/maven/org.openmrs.module/pharmacy-api/pom.properties

This file was deleted.

125 changes: 0 additions & 125 deletions META-INF/maven/org.openmrs.module/pharmacy-api/pom.xml

This file was deleted.

20 changes: 0 additions & 20 deletions Pharmacy.hbm.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public interface ProductDispensationService extends OpenmrsService {
@Authorized(value = {PrivilegeConstants.SAVE_DISPENSATION})
MobilePatient saveMobilePatient(MobilePatient patient) throws APIException;
@Authorized(value = {PrivilegeConstants.VIEW_DISPENSATION})
List<MobilePatient> getAllMobilePatients(Location location);
@Authorized(value = {PrivilegeConstants.VIEW_DISPENSATION})
MobilePatientDispensationInfo getOneMobilePatientDispensationInfoByDispensation(ProductDispensation productDispensation) throws APIException;
@Authorized(value = {PrivilegeConstants.VIEW_DISPENSATION})
MobilePatient getOneMobilePatientById(Integer mobilePatientId);
Expand All @@ -106,4 +108,5 @@ public interface ProductDispensationService extends OpenmrsService {
DispensationTransformationResultDTO transformDispensation(Location location);
@Authorized(value = {PrivilegeConstants.TRANSFORM_DISPENSATION})
DispensationTransformationResultDTO transformPatientDispensation(MobilePatient mobilePatient);
Integer countPatientToTransform(Location location);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public interface ProductDispensationDAO {
MobilePatient getOneMobilePatientByIdentifier(String patientIdentifier);

MobilePatient saveMobilePatient(MobilePatient patient);
List<MobilePatient> getAllMobilePatients(Location location);

Patient getPatientByIdentifier(String identifier);

Expand All @@ -73,4 +74,6 @@ public interface ProductDispensationDAO {

DispensationTransformationResultDTO transformDispensation(Location location);
DispensationTransformationResultDTO transformPatientDispensation(MobilePatient mobilePatient);

Integer countPatientToTransform(Location location);
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ public MobilePatient saveMobilePatient(MobilePatient patient) {
return patient;
}

@SuppressWarnings("unchecked")
@Override
public List<MobilePatient> getAllMobilePatients(Location location) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(MobilePatient.class);
return criteria
.add(Restrictions.eq("location", location)).list();
}

@Override
public Patient getPatientByIdentifier(String identifier) {
return (Patient) sessionFactory.getCurrentSession().createQuery("" +
Expand Down Expand Up @@ -556,6 +564,18 @@ public DispensationTransformationResultDTO transformPatientDispensation(MobilePa
return transformationResultDTO;
}

@Override
public Integer countPatientToTransform(Location location) {
int quantity = 0;
List<MobilePatient> mobilePatients = getAllMobilePatients(location);
for (MobilePatient patient : mobilePatients) {
if (getPatientByIdentifier(patient.getIdentifier()) != null) {
quantity = quantity + 1;
}
}
return quantity;
}

private Encounter createEncounter(Patient patient, MobilePatientDispensationInfo dispensationInfo) {
Encounter encounter = new Encounter();
encounter.setEncounterDatetime(dispensationInfo.getDispensation().getOperationDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,23 @@ public List<ProductReport> getAllProductDistributionReports(Location location, B
@Override
public List<ProductReport> getAllSubmittedChildProductReports(Location location, Boolean includeVoided) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ProductReport.class);
return criteria
.add(Restrictions.in("location", location.getChildLocations(includeVoided)))
.add(Restrictions.eq("operationStatus", OperationStatus.SUBMITTED))
.add(Restrictions.eq("voided", includeVoided))
.list();
List<String> locations = new ArrayList<>();
for (Location userLocation : location.getChildLocations()) {
locations.add(userLocation.getName());
}
if (locations.size() != 0) {
return criteria
.add(
Restrictions.and(
Restrictions.and(
Restrictions.eq("voided", includeVoided),
Restrictions.eq("operationStatus", OperationStatus.SUBMITTED)
),
Restrictions.in("location.name", locations)
)
).list();
}
return new ArrayList<>();
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public MobilePatient saveMobilePatient(MobilePatient patient) {
return dao.saveMobilePatient(patient);
}

@Override
public List<MobilePatient> getAllMobilePatients(Location location) {
return dao.getAllMobilePatients(location);
}

@Override
public MobilePatientDispensationInfo getOneMobilePatientDispensationInfoByDispensation(ProductDispensation productDispensation) {
return dao.getOneMobilePatientDispensationInfoByDispensation(productDispensation);
Expand Down Expand Up @@ -195,4 +200,9 @@ public DispensationTransformationResultDTO transformDispensation(Location locati
public DispensationTransformationResultDTO transformPatientDispensation(MobilePatient mobilePatient) {
return dao.transformPatientDispensation(mobilePatient);
}

@Override
public Integer countPatientToTransform(Location location) {
return dao.countPatientToTransform(location);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,19 @@ public static String generateNumber() {

return returnedNumber.toUpperCase();
}

public static Boolean canDistribute(Location location) {
return location.getChildLocations() != null && location.getChildLocations().size() != 0;
}

public static Boolean isDirectClient(Location location) {
for (LocationAttribute attribute : location.getActiveAttributes()) {
if (attribute.getAttributeType().getName().equals("Client Direct NPSP")) {
if (attribute.getValue().equals(true)) {
return true;
}
}
}
return false;
}
}
25 changes: 18 additions & 7 deletions api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@
</changeSet>

<changeSet id="pharmacy-create-role-auxiliary" author="BOGUI SERGE">
<preConditions>
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(role) FROM role WHERE role = 'AUXILIAIRE'</sqlCheck>
</preConditions>
<sql>
Expand Down Expand Up @@ -1353,10 +1353,15 @@
REPLACE INTO role_privilege (role, privilege) VALUES ('AUXILIAIRE', 'Transform Dispensation');
</sql>
</changeSet>
<changeSet id="pharmacy_create-role-pgp" author="BOGUI SERGE">
<changeSet id="pharmacy-create-role-pgp" author="BOGUI SERGE">
<preConditions>
<sqlCheck expectedResult="0">SELECT COUNT(role) FROM role WHERE role = 'PGP'</sqlCheck>
</preConditions>
<sql>
INSERT INTO role (role, description, uuid) VALUE ('PGP', 'Pharmacien de la pharmacie', 'PGPRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR');
</sql>
</changeSet>
<changeSet id="pharmacy_create-add-pgp-privileges" author="BOGUI SERGE">
<sql>
REPLACE INTO role_privilege (role, privilege) VALUES ('PGP', 'View Edit Product Back Supplier');
REPLACE INTO role_privilege (role, privilege) VALUES ('PGP', 'View Transfer');
Expand All @@ -1376,10 +1381,16 @@
REPLACE INTO role_privilege (role, privilege) VALUES ('PGP', 'Save Reception');
</sql>
</changeSet>
<changeSet id="pharmacy-create-role-pharmacist" author="">
<changeSet id="pharmacy-create-role-pharmacist" author="BOGUI SERGE">
<preConditions>
<sqlCheck expectedResult="0">SELECT COUNT(role) FROM role WHERE role = 'PHARMACIEN'</sqlCheck>
</preConditions>
<sql>
INSERT INTO role (role, description, uuid) VALUE ('PHARMACIEN', 'Pharmacien de la pharmacie', 'PHARMACIENRRRRRRRRRRRRRRRRRRRRRRRRRR');
</sql>
</changeSet>

<changeSet id="pharmacy-add-pharmacist-privileges" author="BOGUI SERGE">
<sql>
REPLACE INTO role_privilege (role, privilege) VALUES ('PHARMACIEN', 'Manage Dispensation');
REPLACE INTO role_privilege (role, privilege) VALUES ('PHARMACIEN', 'Manage Exchange Entity');
Expand Down Expand Up @@ -1423,17 +1434,17 @@
</changeSet>

<changeSet id="pharmacy-create-role-pgp-auxiliary" author="BOGUI SERGE">
<preConditions>
<sqlCheck expectedResult="0">SELECT COUNT(*) FROM role_role WHERE parent_role = 'AUXILIAIRE' AND child_role 'PGP'</sqlCheck>
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(*) FROM role_role WHERE parent_role = 'AUXILIAIRE' AND child_role = 'PGP'</sqlCheck>
</preConditions>
<sql>
INSERT INTO role_role (parent_role, child_role) VALUES ('AUXILIAIRE', 'PGP');
</sql>
</changeSet>

<changeSet id="pharmacy-create-role-pgp-pharmacist" author="BOGUI SERGE">
<preConditions>
<sqlCheck expectedResult="0">SELECT COUNT(*) FROM role_role WHERE parent_role = 'PGP' AND child_role 'PHARMACIEN'</sqlCheck>
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(*) FROM role_role WHERE parent_role = 'PGP' AND child_role = 'PHARMACIEN'</sqlCheck>
</preConditions>
<sql>
INSERT INTO role_role (parent_role, child_role) VALUES ('PGP', 'PHARMACIEN');
Expand Down
Loading

0 comments on commit 08ec0d6

Please sign in to comment.