You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue applies to the ImportController class and specifically the methods importOrganizations and importProviders.
2. Steps to reproduce:
Access the OpenELIS application.
Navigate to any functionality that utilizes the ImportController for importing data (This information might require further investigation).
Observe that the importOrganizations and importProviders methods contain duplicate logic for fetching the relevant service and calling the import method.
3. Severity:
This issue is something we would like to see improved in the future but does not significantly affect our work.
While the current functionality works, refactoring the code improves readability and maintainability, especially if additional import functionalities are implemented in the future.
### Detailed Description:
The current implementation of importOrganizations and importProviders methods contain duplicate logic for fetching the service and calling the import method. This makes the code less readable and harder to maintain.
Here's the current code snippet: @GetMapping(value = "/organization") public void importOrganizations() throws FhirLocalPersistingException, FhirGeneralException, IOException { SpringContext.getBean(OrganizationImportService.class).importOrganizationList(); }
### Proposed Solution
Extract the common logic into a separate private method to improve readability and maintainability. Here's an example of the refactored code:
private void importDataFromFhir(String fhirResourceType) throws FhirLocalPersistingException, FhirGeneralException, IOException { // Get the appropriate service based on resource type ImportService importService; if (fhirResourceType.equals("organization")) { importService = SpringContext.getBean(OrganizationImportService.class); } else if (fhirResourceType.equals("provider")) { importService = SpringContext.getBean(ProviderImportService.class); } else { // Handle invalid resource type (optional) }
// Call the import method based on the service importService.importList(fhirResourceType); // Assuming a generic importList method } @GetMapping(value = "/organization") public void importOrganizations() throws FhirLocalPersistingException, FhirGeneralException, IOException { importDataFromFhir("organization"); }
1. Section, tab, or page affected:
This issue applies to the ImportController class and specifically the methods importOrganizations and importProviders.
2. Steps to reproduce:
Access the OpenELIS application.
Navigate to any functionality that utilizes the ImportController for importing data (This information might require further investigation).
Observe that the importOrganizations and importProviders methods contain duplicate logic for fetching the relevant service and calling the import method.
3. Severity:
While the current functionality works, refactoring the code improves readability and maintainability, especially if additional import functionalities are implemented in the future.
### Detailed Description:
The current implementation of importOrganizations and importProviders methods contain duplicate logic for fetching the service and calling the import method. This makes the code less readable and harder to maintain.
Here's the current code snippet:
@GetMapping(value = "/organization")
public void importOrganizations() throws FhirLocalPersistingException, FhirGeneralException, IOException {
SpringContext.getBean(OrganizationImportService.class).importOrganizationList();
}
@GetMapping(value = "/provider")
public void importProviders() throws FhirLocalPersistingException, FhirGeneralException, IOException {
SpringContext.getBean(ProviderImportService.class).importPractitionerList();
}
### Proposed Solution
Extract the common logic into a separate private method to improve readability and maintainability. Here's an example of the refactored code:
private void importDataFromFhir(String fhirResourceType) throws FhirLocalPersistingException, FhirGeneralException, IOException {
// Get the appropriate service based on resource type
ImportService importService;
if (fhirResourceType.equals("organization")) {
importService = SpringContext.getBean(OrganizationImportService.class);
} else if (fhirResourceType.equals("provider")) {
importService = SpringContext.getBean(ProviderImportService.class);
} else {
// Handle invalid resource type (optional)
}
// Call the import method based on the service
importService.importList(fhirResourceType); // Assuming a generic importList method
}
@GetMapping(value = "/organization")
public void importOrganizations() throws FhirLocalPersistingException, FhirGeneralException, IOException {
importDataFromFhir("organization");
}
@GetMapping(value = "/provider")
public void importProviders() throws FhirLocalPersistingException, FhirGeneralException, IOException {
importDataFromFhir("provider");
}
This approach promotes code reuse and simplifies future modifications if additional resource types are introduced.
The text was updated successfully, but these errors were encountered: