-
Notifications
You must be signed in to change notification settings - Fork 3
Allow registering multiple InvoicedItemsProcessingService impls #1102
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
base: develop
Are you sure you want to change the base?
Changes from all commits
9a068a0
e5e61d6
e9dc6c3
5460be7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- ehr.Project.Created and ehr.Project.Modified are NULL on SQL Server but NOT NULL on PostgreSQL. Set the NULL values | ||
| -- and switch the columns to NOT NULL to match PostgreSQL. | ||
| UPDATE ehr.Project SET Created = diCreated WHERE Created IS NULL; | ||
| UPDATE ehr.Project SET Modified = diModified WHERE Modified IS NULL; | ||
|
|
||
| ALTER TABLE ehr.Project ALTER COLUMN Created DATETIME NOT NULL; | ||
| ALTER TABLE ehr.Project ALTER COLUMN Modified DATETIME NOT NULL; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,32 +22,45 @@ | |
| import org.labkey.api.data.SimpleFilter; | ||
| import org.labkey.api.data.TableInfo; | ||
| import org.labkey.api.data.TableSelector; | ||
| import org.labkey.api.module.Module; | ||
| import org.labkey.api.pipeline.PipelineJobException; | ||
| import org.labkey.api.query.FieldKey; | ||
| import org.labkey.api.query.QueryService; | ||
| import org.labkey.api.security.User; | ||
| import org.labkey.api.services.ServiceRegistry; | ||
| import org.labkey.api.util.Pair; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.Date; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.concurrent.CopyOnWriteArrayList; | ||
|
|
||
| /** | ||
| * Service to get a list of queries to be processed during a Billing Run. The listing is a collection of | ||
| * BillingPipelineJobProcess objects that define what schema.query to execute and the mapping from that query's | ||
| * columns to the ehr_billing.invoicedItem table's columns. | ||
| * Additionally, get center specific generated invoice number. | ||
| * | ||
| * Currently registered server wide but should allow multiple co-existing services and resolve per container's active modules | ||
| */ | ||
| public interface InvoicedItemsProcessingService | ||
| { | ||
| record Registration(String moduleName, InvoicedItemsProcessingService impl){} | ||
|
|
||
| List<Registration> REGISTRATION_LIST = new CopyOnWriteArrayList<>(); | ||
|
|
||
| static void register(Module module, InvoicedItemsProcessingService impl) | ||
| { | ||
| REGISTRATION_LIST.add(new Registration(module.getName(), impl)); | ||
| } | ||
|
|
||
| @Nullable | ||
| static InvoicedItemsProcessingService get() | ||
| static InvoicedItemsProcessingService get(Container billingContainer) | ||
| { | ||
| return ServiceRegistry.get().getService(InvoicedItemsProcessingService.class); | ||
| // Return the service implementation based on the registering module being active in the provided container | ||
| return REGISTRATION_LIST.stream() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In some other EHR contexts, we use a module-dependency ordering to choose between something provided by the core EHR module and a center-specific module. Here, I believe that the core EHR module would startup first, and therefore have register things first. Then center-specific modules would register.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assumed we were just registering this in the center specific modules (not in any core EHR modules) so there would be just one service registered in the billing container for each center's project. I believe that would work for the test server with multiple EHR projects.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I believe that's the current state in terms of what needs to be registered, but I'm advocating that we consider being consistent so we don't have to remember which one will win in scenarios like this.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. Makes sense. |
||
| .filter(reg -> billingContainer.hasActiveModuleByName(reg.moduleName())) | ||
| .map(Registration::impl) | ||
| .findFirst() | ||
| .orElse(null); | ||
| } | ||
|
|
||
| /** @return the inputs to the billing process that are capable of generating charges */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could fall back on
GETDATE()if thedicolumns are null. Unless we want to hard-fail the upgrade on a server that might not have values as a way of assessing real-world data.