Skip to content

[#272] Added Billing-related Domains. #269

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

Merged
merged 30 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c8e5b97
Add Billing Domains to Iniz
ODORA0 Jun 7, 2024
54000c5
Align billableServicesLineProcessor and servicePricesLoader
ODORA0 Jun 7, 2024
711cf11
Add CashPoints Domain
ODORA0 Jun 10, 2024
5055f58
update tests
ODORA0 Jun 12, 2024
db8b3f6
Address clean up PR Comments
ODORA0 Jun 20, 2024
b154b8d
Refactor class to be more concise and seperate concerns more clearly
ODORA0 Jun 21, 2024
cdfea87
Address PR comments, validator dry run
ODORA0 Jun 28, 2024
ceb2276
Add intergration tests
ODORA0 Jul 2, 2024
00861f9
PR comments
ODORA0 Jul 2, 2024
e9f6402
PR comments
ODORA0 Jul 4, 2024
16bb47d
PR comments
ODORA0 Jul 4, 2024
860070c
Change dep to api sub modules, add integration tests for other domain…
ODORA0 Jul 8, 2024
3a96e62
Documentation PR comments
ODORA0 Jul 12, 2024
620fdcc
Add scenarios for integration test
ODORA0 Jul 16, 2024
846bb52
Module version, run loader once without redundant calls, ensure getRe…
ODORA0 Jul 17, 2024
2ddc8ba
PR comments
ODORA0 Jul 17, 2024
0f9777b
Improve tests
Ruhanga Jul 19, 2024
777f242
Improve tests
Ruhanga Jul 19, 2024
df550bb
[#272]: Fix tests for Billable Services Domain
Ruhanga Jul 26, 2024
8083779
[#272]: Fix api-2.3 test failures
Ruhanga Jul 26, 2024
b1b9dc5
Lower version of core 2.4.x to 2.4.3
Ruhanga Jul 28, 2024
8a9e94b
Setup tests to run conviniently + formatting changes
Ruhanga Jul 29, 2024
76c7b43
Enhance Integration Tests
ODORA0 Jul 30, 2024
3e5e8f1
Remove wildcards
ODORA0 Aug 1, 2024
5c12731
Refining tests and improving documentation.
Ruhanga Aug 8, 2024
7ae0b77
Payment mode attribute types to be properly overridden
Ruhanga Aug 9, 2024
903ef1e
Normalise java file names
Ruhanga Aug 12, 2024
5f131d8
Update paymentmodes.md
Ruhanga Aug 12, 2024
f01d0b0
Changes to Readme
ODORA0 Aug 12, 2024
bff56c7
Reveiw changes
Ruhanga Aug 12, 2024
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
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.configuration.updateBuildConfiguration" : "automatic",
"java.debug.settings.onBuildFailureProceed" : true
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [Setting up and controlling logging](#setting-up-and-controlling-logging)
- [Get in touch](#get-in-touch)
- [Releases notes](#releases-notes)
+ [Version 2.8.0](#version-280)
+ [Version 2.7.0](#version-270)
+ [Version 2.6.0](#version-260)
+ [Version 2.5.2](#version-252)
Expand Down Expand Up @@ -48,6 +49,8 @@ configuration/
├── attributetypes/
├── autogenerationoptions/
├── bahmniforms/
├── billableservices/
├── cashpoints/
├── cohorttypes/
├── cohortattributetypes/
├── conceptclasses/
Expand Down Expand Up @@ -76,6 +79,7 @@ configuration/
├── ocl/
├── orderfrequencies/
├── ordertypes/
├── paymentmodes/
├── patientidentifiertypes/
├── personattributetypes/
├── privileges/
Expand Down Expand Up @@ -127,6 +131,9 @@ This is the list of currently supported domains in their loading order:
1. [Concept Sources (CSV files)](readme/conceptsources.md)
1. [Open Concept Lab (ZIP Files)](readme/ocl.md)
1. [Concepts (CSV files)](readme/concepts.md)
1. [Billable Services (CSV files)](readme/billableservices.md)
1. [Cash Points (CSV files)](readme/cashpoints.md)
1. [Payment Modes (CSV files)](readme/paymentmodes.md)
1. [Concept Sets and Answers (CSV files)](readme/conceptsets.md)
1. [Programs (CSV files)](readme/prog.md)
1. [Program Worklows (CSV files)](readme/prog.md)
Expand Down Expand Up @@ -166,6 +173,7 @@ mvn clean package
* Bahmni Appointments 1.2.1 (*compatible*)
* Bahmni Core 0.93 (*compatible*)
* Bahmni I.e Apps 1.1.0 (*compatible*)
* Billing 1.1.0 (*compatible*)
* Data Filter 1.0.0 (*compatible*)
* HTML Form Entry 4.0.0 (*compatible*)
* ID Gen 4.3 (*compatible*)
Expand Down Expand Up @@ -197,6 +205,7 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo
#### Version 2.8.0
* Ampath forms translation files will now generate checksums.
* Enhancement to ensure that when an Ampath forms file is loaded, a new resource with the existing Ampath forms translations is created.
* Added support for 'billing' (billableservices, paymentmodes, cashpoints) domains.

#### Version 2.7.0
* Added support for 'queues' domain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.hamcrest.Matchers.greaterThan;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -68,11 +69,19 @@ private static class AllDomainsMatcher extends TypeSafeDiagnosingMatcher<List<Lo

@Override
protected boolean matchesSafely(List<Loader> loaders, Description mismatchDescription) {
Set<String> exclude = new HashSet<>();
exclude.add(Domain.PAYMENT_MODES.getName());
exclude.add(Domain.BILLABLE_SERVICES.getName());
exclude.add(Domain.CASH_POINTS.getName());

boolean result = true;
Set<String> loaderDomains = loaders.stream().map(Loader::getDomainName).collect(Collectors.toSet());
for (Domain domain : Domain.values()) {
if (exclude.contains(domain.getName())) {
continue;
}
if (!loaderDomains.contains(domain.getName())) {
mismatchDescription.appendText("no loader for domain ").appendText(domain.toString())
mismatchDescription.appendText(" no loader for domain ").appendText(domain.toString())
.appendText(" was found");
result = false;
}
Expand Down
48 changes: 46 additions & 2 deletions api-2.4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,26 @@

<properties>
<openmrsPlatformVersion>${openmrsVersion2.4}</openmrsPlatformVersion>
<datafilterVersion>2.2.0</datafilterVersion>
<billingVersion>1.1.0</billingVersion>
<stockmanagementVersion>2.0.0</stockmanagementVersion>
</properties>

<dependencies>
<dependency>
<groupId>org.openmrs.test</groupId>
<artifactId>openmrs-test</artifactId>
<type>pom</type>
<version>${openmrsPlatformVersion}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-api</artifactId>
Expand All @@ -33,7 +50,7 @@
<scope>test</scope>
<type>test-jar</type>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-api-2.3</artifactId>
Expand Down Expand Up @@ -63,6 +80,33 @@
<scope>test</scope>
<type>test-jar</type>
</dependency>
</dependencies>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>billing-api</artifactId>
<version>${billingVersion}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>stockmanagement-api</artifactId>
<version>${stockmanagementVersion}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-api-2.5</artifactId>
<version>${fhir2Version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>datafilter-api</artifactId>
<version>${datafilterVersion}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.openmrs.module.initializer.api.billing;

import org.apache.commons.lang3.StringUtils;
import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.module.billing.api.IBillableItemsService;
import org.openmrs.module.billing.api.model.BillableService;
import org.openmrs.module.initializer.Domain;
import org.openmrs.module.initializer.api.BaseLineProcessor;
import org.openmrs.module.initializer.api.CsvLine;
import org.openmrs.module.initializer.api.CsvParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

@OpenmrsProfile(modules = { "billing:1.1.0 - 9.*" })
public class BillableServicesCsvParser extends CsvParser<BillableService, BaseLineProcessor<BillableService>> {

private final IBillableItemsService billableItemsService;

private final BillableServicesLineProcessor billableServicesLineProcessor;

@Autowired
public BillableServicesCsvParser(@Qualifier("billableItemsService") IBillableItemsService billableItemsService,
BillableServicesLineProcessor billableServicesLineProcessor) {
super(billableServicesLineProcessor);
this.billableItemsService = billableItemsService;
this.billableServicesLineProcessor = billableServicesLineProcessor;
}

@Override
public Domain getDomain() {
return Domain.BILLABLE_SERVICES;
}

@Override
public BillableService bootstrap(CsvLine line) throws IllegalArgumentException {
String uuid = line.getUuid();

BillableService billableService = billableItemsService.getByUuid(uuid);

if (billableService == null) {
billableService = new BillableService();
if (!StringUtils.isEmpty(uuid)) {
billableService.setUuid(uuid);
}
}

return billableService;
}

@Override
public BillableService save(BillableService instance) {
return billableItemsService.save(instance);
}

@Override
protected void setLineProcessors(String version) {
lineProcessors.clear();
lineProcessors.add(billableServicesLineProcessor);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.openmrs.module.initializer.api.billing;

import org.apache.commons.lang3.StringUtils;
import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.api.ConceptService;
import org.openmrs.module.billing.api.model.BillableService;
import org.openmrs.module.billing.api.model.BillableServiceStatus;
import org.openmrs.module.initializer.api.BaseLineProcessor;
import org.openmrs.module.initializer.api.CsvLine;
import org.openmrs.module.initializer.api.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
* This is the first level line processor for Billable Services
*/
@OpenmrsProfile(modules = { "billing:1.1.0 - 9.*" })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ODORA0 @Ruhanga why not just

@OpenmrsProfile(modules = { "billing:1.1.0" })

?
That should, normally, mean what we're intending no?

Copy link
Contributor

@Ruhanga Ruhanga Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s quite restrictive to specify version 1.1.0 as the required version. We would prefer to set 1.1.0 as the minimum version instead. Version 9.* provides a more flexible range for usage, accommodating future updates until potential incompatibility issues arise.

public class BillableServicesLineProcessor extends BaseLineProcessor<BillableService> {

protected static final String HEADER_NAME = "service name";

protected static final String HEADER_DESC = "short name";

protected static final String HEADER_SERVICE = "concept";

protected static final String HEADER_SERVICE_TYPE = "service type";

protected static final String HEADER_SERVICE_STATUS = "service status";

private final ConceptService conceptService;

@Autowired
public BillableServicesLineProcessor(@Qualifier("conceptService") ConceptService conceptService) {
super();
this.conceptService = conceptService;
}

@Override
public BillableService fill(BillableService billableService, CsvLine line) throws IllegalArgumentException {
billableService.setName(line.get(HEADER_NAME, true));
billableService.setShortName(line.getString(HEADER_DESC));

String service = line.get(HEADER_SERVICE, true);
billableService.setConcept(Utils.fetchConcept(service, conceptService));

String serviceType = line.get(HEADER_SERVICE_TYPE, true);
billableService.setServiceType(Utils.fetchConcept(serviceType, conceptService));

String serviceStatus = line.getString(HEADER_SERVICE_STATUS);
billableService.setServiceStatus(
StringUtils.isNotBlank(serviceStatus) ? BillableServiceStatus.valueOf(serviceStatus.toUpperCase())
: BillableServiceStatus.ENABLED);

return billableService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.openmrs.module.initializer.api.billing;

import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.module.billing.api.model.BillableService;
import org.openmrs.module.initializer.api.loaders.BaseCsvLoader;
import org.springframework.beans.factory.annotation.Autowired;

@OpenmrsProfile(modules = { "billing:1.1.0 - 9.*" })
public class BillableServicesLoader extends BaseCsvLoader<BillableService, BillableServicesCsvParser> {

@Autowired
public void setParser(BillableServicesCsvParser parser) {
this.parser = parser;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.openmrs.module.initializer.api.billing;

import org.apache.commons.lang3.StringUtils;
import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.module.billing.api.ICashPointService;
import org.openmrs.module.billing.api.model.CashPoint;
import org.openmrs.module.initializer.Domain;
import org.openmrs.module.initializer.api.BaseLineProcessor;
import org.openmrs.module.initializer.api.CsvLine;
import org.openmrs.module.initializer.api.CsvParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

@OpenmrsProfile(modules = { "billing:1.1.0 - 9.*" })
public class CashPointsCsvParser extends CsvParser<CashPoint, BaseLineProcessor<CashPoint>> {

private final ICashPointService iCashPointService;

@Autowired
public CashPointsCsvParser(@Qualifier("cashierCashPointService") ICashPointService iCashPointService,
CashPointsLineProcessor processor) {
super(processor);
this.iCashPointService = iCashPointService;
}

@Override
public Domain getDomain() {
return Domain.CASH_POINTS;
}

@Override
public CashPoint bootstrap(CsvLine line) throws IllegalArgumentException {
String uuid = line.getUuid();
CashPoint cashPoint = null;
if (StringUtils.isNotBlank(uuid)) {
cashPoint = iCashPointService.getByUuid(uuid);
}
if (cashPoint == null) {
cashPoint = new CashPoint();
if (StringUtils.isNotBlank(uuid)) {
cashPoint.setUuid(uuid);
}
}
return cashPoint;
}

@Override
public CashPoint save(CashPoint instance) {
return iCashPointService.save(instance);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.openmrs.module.initializer.api.billing;

import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.api.LocationService;
import org.openmrs.module.billing.api.model.CashPoint;
import org.openmrs.module.initializer.api.BaseLineProcessor;
import org.openmrs.module.initializer.api.CsvLine;
import org.openmrs.module.initializer.api.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

@OpenmrsProfile(modules = { "billing:1.1.0 - 9.*" })
public class CashPointsLineProcessor extends BaseLineProcessor<CashPoint> {

protected static final String HEADER_DESCRIPTION = "description";

protected static final String HEADER_LOCATION = "location";

private final LocationService locationService;

@Autowired
public CashPointsLineProcessor(@Qualifier("locationService") LocationService locationService) {
super();
this.locationService = locationService;
}

@Override
public CashPoint fill(CashPoint cashPoint, CsvLine line) throws IllegalArgumentException {
cashPoint.setName(line.get(HEADER_NAME, true));
cashPoint.setDescription(line.getString(HEADER_DESCRIPTION));
String location = line.get(HEADER_LOCATION, true);
cashPoint.setLocation(Utils.fetchLocation(location, locationService));

return cashPoint;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.openmrs.module.initializer.api.billing;

import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.module.billing.api.model.CashPoint;
import org.openmrs.module.initializer.api.loaders.BaseCsvLoader;
import org.springframework.beans.factory.annotation.Autowired;

@OpenmrsProfile(modules = { "billing:1.1.0 - 9.*" })
public class CashPointsLoader extends BaseCsvLoader<CashPoint, CashPointsCsvParser> {

@Autowired
public void setParser(CashPointsCsvParser parser) {
this.parser = parser;
}

}
Loading
Loading