Skip to content

Commit

Permalink
[#272] Added Billing-related Domains. (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
ODORA0 authored Aug 13, 2024
1 parent d03d6bd commit 0b73171
Show file tree
Hide file tree
Showing 31 changed files with 1,015 additions and 7 deletions.
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.*" })
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

0 comments on commit 0b73171

Please sign in to comment.