7878public class BillingTask extends PipelineJob .Task <BillingTask .Factory >
7979{
8080 private final static DbSchema EHR_BILLING_SCHEMA = EHR_BillingSchema .getInstance ().getSchema ();
81- private final static InvoicedItemsProcessingService processingService = InvoicedItemsProcessingService .get ();
81+
82+ private final InvoicedItemsProcessingService _processingService ;
8283
8384 protected BillingTask (Factory factory , PipelineJob job )
8485 {
8586 super (factory , job );
87+ _processingService = InvoicedItemsProcessingService .get (EHR_BillingManager .get ().getBillingContainer (job .getContainer ()));
8688 }
8789
8890 public static class Factory extends AbstractTaskFactory <AbstractTaskFactorySettings , Factory >
@@ -148,16 +150,16 @@ public RecordedActionSet run() throws PipelineJobException
148150 {
149151 getOrCreateInvoiceRunRecord ();
150152 loadTransactionNumber ();
151- processingService .setBillingStartDate (getSupport ().getStartDate ());
153+ _processingService .setBillingStartDate (getSupport ().getStartDate ());
152154
153155 if (null != _previousInvoice )
154156 {
155- processingService .processBillingRerun (_invoiceId , _invoiceRowId , getSupport ().getStartDate (), getSupport ().getEndDate (), getNextTransactionNumber (), user , billingContainer , getJob ().getLogger ());
157+ _processingService .processBillingRerun (_invoiceId , _invoiceRowId , getSupport ().getStartDate (), getSupport ().getEndDate (), getNextTransactionNumber (), user , billingContainer , getJob ().getLogger ());
156158 }
157159 else
158160 {
159161
160- for (BillingPipelineJobProcess process : processingService .getProcessList ())
162+ for (BillingPipelineJobProcess process : _processingService .getProcessList ())
161163 {
162164 Container billingRunContainer = process .isUseEHRContainer () ? ehrContainer : billingContainer ;
163165 runProcessing (process , billingRunContainer );
@@ -166,7 +168,7 @@ public RecordedActionSet run() throws PipelineJobException
166168
167169 updateInvoiceTable (billingContainer );
168170
169- processingService .performAdditionalProcessing (_invoiceId , user , container );
171+ _processingService .performAdditionalProcessing (_invoiceId , user , container );
170172
171173 transaction .commit ();
172174 }
@@ -278,7 +280,7 @@ private String getOrCreateInvoiceRunRecord() throws PipelineJobException
278280 @ Nullable
279281 private String getOrCreateInvoiceRecord (Map <String , Object > row , Date endDate ) throws PipelineJobException
280282 {
281- String invoiceNumber = processingService .getInvoiceNum (row , endDate );
283+ String invoiceNumber = _processingService .getInvoiceNum (row , endDate );
282284 if (null != invoiceNumber )
283285 {
284286 try
@@ -499,25 +501,25 @@ private void runProcessing(BillingPipelineJobProcess process, Container billingR
499501
500502 // get cost
501503 Double unitCost = ci .getUnitCost ();
502- procedureRow .put (processingService .getUnitCostColName (), unitCost );
504+ procedureRow .put (_processingService .getUnitCostColName (), unitCost );
503505
504506 // total cost
505507 Double totalCost = unitCost * (Double ) procedureRow .get ("quantity" );
506- procedureRow .put (processingService .getTotalCostColName (), totalCost );
508+ procedureRow .put (_processingService .getTotalCostColName (), totalCost );
507509
508510 // calculate total cost with additional/other rate (ex. tier rate for WNPRC)
509511 Double otherRate = (Double ) procedureRow .get ("otherRate" );
510512 Double unitCostWithOtherRate ;
511513 double totalCostWithOtherRate ;
512514 if (null != otherRate &&
513- null != processingService .getAdditionalUnitCostColName () &&
514- null != processingService .getAdditionalTotalCostColName ())
515+ null != _processingService .getAdditionalUnitCostColName () &&
516+ null != _processingService .getAdditionalTotalCostColName ())
515517 {
516518 unitCostWithOtherRate = unitCost + (unitCost * otherRate );
517- procedureRow .put (processingService .getAdditionalUnitCostColName (), unitCostWithOtherRate );
519+ procedureRow .put (_processingService .getAdditionalUnitCostColName (), unitCostWithOtherRate );
518520
519521 totalCostWithOtherRate = unitCostWithOtherRate * (Double ) procedureRow .get ("quantity" );
520- procedureRow .put (processingService .getAdditionalTotalCostColName (), totalCostWithOtherRate );
522+ procedureRow .put (_processingService .getAdditionalTotalCostColName (), totalCostWithOtherRate );
521523 }
522524 }
523525 writeToInvoicedItems (process , procedureRows , getSupport ());
0 commit comments