-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
31 changed files
with
1,015 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration" : "automatic", | ||
"java.debug.settings.onBuildFailureProceed" : true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...4/src/main/java/org/openmrs/module/initializer/api/billing/BillableServicesCsvParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...c/main/java/org/openmrs/module/initializer/api/billing/BillableServicesLineProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
api-2.4/src/main/java/org/openmrs/module/initializer/api/billing/BillableServicesLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
api-2.4/src/main/java/org/openmrs/module/initializer/api/billing/CashPointsCsvParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...2.4/src/main/java/org/openmrs/module/initializer/api/billing/CashPointsLineProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
api-2.4/src/main/java/org/openmrs/module/initializer/api/billing/CashPointsLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
Oops, something went wrong.