Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
14 changes: 14 additions & 0 deletions api-2.7/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<properties>
<openmrsPlatformVersion>${openmrsVersion2.7}</openmrsPlatformVersion>
<fhir2Version2.2>2.2.0</fhir2Version2.2>
<billing2Version>2.0.0-SNAPSHOT</billing2Version>
</properties>

<dependencies>
Expand Down Expand Up @@ -79,6 +80,19 @@
<scope>provided</scope>
</dependency>

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

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>stockmanagement-api</artifactId>
<version>${stockmanagementVersion}</version>
<scope>provided</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.BillableServiceService;
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:2.0.0 - 9.*" })
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you mentioned "Billing v2 now requires OpenMRS Core 2.7.8-SNAPSHOT”, shouldn’t we add that requirement as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to add that. Billing module won't even start if we are using a core version lower than 2.7.8-SNAPSHOT

Copy link
Contributor

Choose a reason for hiding this comment

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

Billing module won't even start if we are using a core version lower than 2.7.8-SNAPSHOT

I understand that. Won’t it be better to add that, especially since this requirement would get documented.

public class BillableServicesCsvParser extends CsvParser<BillableService, BaseLineProcessor<BillableService>> {

private final BillableServiceService billableServiceService;

private final BillableServicesLineProcessor billableServicesLineProcessor;

@Autowired
public BillableServicesCsvParser(@Qualifier("billableServiceService") BillableServiceService billableServiceService,
BillableServicesLineProcessor billableServicesLineProcessor) {
super(billableServicesLineProcessor);
this.billableServiceService = billableServiceService;
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 = billableServiceService.getBillableServiceByUuid(uuid);

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

return billableService;
}

@Override
public BillableService save(BillableService instance) {
return billableServiceService.saveBillableService(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:2.0.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.*" })
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@OpenmrsProfile(modules = { "billing:1.1.0 - 9.*" })
@OpenmrsProfile(modules = { "billing:2.0.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:2.0.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:2.0.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:2.0.0 - 9.*" })
public class CashPointsLoader extends BaseCsvLoader<CashPoint, CashPointsCsvParser> {

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

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

import org.apache.commons.lang3.StringUtils;
import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.module.billing.api.IPaymentModeService;
import org.openmrs.module.billing.api.model.PaymentMode;
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:2.0.0 - 9.*" })
public class PaymentModesCsvParser extends CsvParser<PaymentMode, BaseLineProcessor<PaymentMode>> {

private final IPaymentModeService paymentModeService;

@Autowired
public PaymentModesCsvParser(@Qualifier("cashierPaymentModeService") IPaymentModeService paymentModeService,
PaymentModesLineProcessor processor) {
super(processor);
this.paymentModeService = paymentModeService;
}

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

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

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

import org.apache.commons.lang3.StringUtils;
import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.module.billing.api.model.PaymentMode;
import org.openmrs.module.initializer.api.BaseLineProcessor;
import org.openmrs.module.initializer.api.CsvLine;

@OpenmrsProfile(modules = { "billing:2.0.0 - 9.*" })
public class PaymentModesLineProcessor extends BaseLineProcessor<PaymentMode> {

protected static final String HEADER_ATTRIBUTES = "attributes";

public PaymentModesLineProcessor() {
super();
}

@Override
public PaymentMode fill(PaymentMode paymentMode, CsvLine line) throws IllegalArgumentException {
paymentMode.setName(line.get(HEADER_NAME, true));

String attributes = line.get(HEADER_ATTRIBUTES, false);
if (StringUtils.isNotBlank(attributes)) {
if (paymentMode.getAttributeTypes() != null) {
paymentMode.getAttributeTypes().clear();
}
for (String attribute : attributes.split(BaseLineProcessor.LIST_SEPARATOR)) {
String[] parts = attribute.trim().split("::");
if (parts.length > 3) {
paymentMode.addAttributeType(parts[0].trim(), parts[1].trim(), parts[2].trim(),
Boolean.parseBoolean(parts[3].trim()));
} else if (parts.length > 2) {
paymentMode.addAttributeType(parts[0].trim(), parts[1].trim(), parts[2].trim(), false);
} else if (parts.length > 1) {
paymentMode.addAttributeType(parts[0].trim(), parts[1].trim(), null, false);
} else {
paymentMode.addAttributeType(parts[0].trim(), null, null, false);
}
}
}

return paymentMode;
}
}
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.PaymentMode;
import org.openmrs.module.initializer.api.loaders.BaseCsvLoader;
import org.springframework.beans.factory.annotation.Autowired;

@OpenmrsProfile(modules = { "billing:2.0.0 - 9.*" })
public class PaymentModesLoader extends BaseCsvLoader<PaymentMode, PaymentModesCsvParser> {

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