-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportController.java
More file actions
51 lines (44 loc) · 2.03 KB
/
Copy pathImportController.java
File metadata and controls
51 lines (44 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.openelisglobal.admin.controller;
import java.io.IOException;
import org.openelisglobal.dataexchange.fhir.exception.FhirGeneralException;
import org.openelisglobal.dataexchange.fhir.exception.FhirLocalPersistingException;
import org.openelisglobal.organization.service.OrganizationImportService;
import org.openelisglobal.provider.service.ProviderImportService;
import org.openelisglobal.spring.util.SpringContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/import")
public class ImportController {
private enum ResourceType {
ORGANIZATION, PROVIDER
}
private void importDataFromFhir(ResourceType resourceType)
throws FhirLocalPersistingException, FhirGeneralException, IOException {
switch (resourceType) {
case ORGANIZATION:
SpringContext.getBean(OrganizationImportService.class).importOrganizationList();
break;
case PROVIDER:
SpringContext.getBean(ProviderImportService.class).importPractitionerList();
break;
default:
// Handle invalid resource type
throw new UnsupportedOperationException("Unsupported resource type");
}
}
@GetMapping(value = "/all")
public void importAll() throws FhirLocalPersistingException, FhirGeneralException, IOException {
importDataFromFhir(ResourceType.ORGANIZATION);
importDataFromFhir(ResourceType.PROVIDER);
}
@GetMapping(value = "/organization")
public void importOrganizations() throws FhirLocalPersistingException, FhirGeneralException, IOException {
importDataFromFhir(ResourceType.ORGANIZATION);
}
@GetMapping(value = "/provider")
public void importProviders() throws FhirLocalPersistingException, FhirGeneralException, IOException {
importDataFromFhir(ResourceType.PROVIDER);
}
}