Update service migrasi pasien
Pembuatan scheduler untuk update status terkirim dari database baru ke status migrasi di smart
This commit is contained in:
parent
f41595aa89
commit
e9608d50ee
@ -1,13 +1,27 @@
|
|||||||
package com.jasamedika.medifirst2000.task.schedule;
|
package com.jasamedika.medifirst2000.task.schedule;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jasamedika.medifirst2000.service.MigrasiPasienService;
|
import com.jasamedika.medifirst2000.service.MigrasiPasienService;
|
||||||
|
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.jasamedika.medifirst2000.task.schedule.config.HeaderHandler.getHttpHeaders;
|
||||||
|
import static org.springframework.http.HttpMethod.GET;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author salmanoe
|
* @author salmanoe
|
||||||
@ -18,13 +32,37 @@ import java.time.LocalDateTime;
|
|||||||
public class MigrasiPasienTask {
|
public class MigrasiPasienTask {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(MigrasiPasienTask.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(MigrasiPasienTask.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MigrasiPasienService migrasiPasienService;
|
private MigrasiPasienService migrasiPasienService;
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 0 * * ?")
|
@Value("${app.etl.migrasi.pasien}")
|
||||||
|
String baseUrl;
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0/15 * * * ?")
|
||||||
public void newMigrate() {
|
public void newMigrate() {
|
||||||
LOGGER.info("Task MigrasiPasienTask.newMigrate {}", LocalDateTime.now());
|
LOGGER.info("Task MigrasiPasienTask.newMigrate {}", LocalDateTime.now());
|
||||||
|
|
||||||
migrasiPasienService.newMigrate();
|
migrasiPasienService.newMigrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 * 0/1 * * ?")
|
||||||
|
public void setStatusTerkirim() throws URISyntaxException {
|
||||||
|
LOGGER.info("Task MigrasiPasienTask.setStatusTerkirim {}", LocalDateTime.now());
|
||||||
|
|
||||||
|
URI uri = new URI(baseUrl + "/status");
|
||||||
|
HttpEntity<Object> entity = new HttpEntity<>(new Object(), getHttpHeaders());
|
||||||
|
ResponseEntity<Object> exchange = restTemplate.exchange(uri, GET, entity, Object.class);
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(exchange.getBody())) {
|
||||||
|
List<Map<String, Object>> dtoList = objectMapper.convertValue(exchange.getBody(), List.class);
|
||||||
|
List<String> noRekamMedisList = dtoList.stream().map(dto -> dto.get("noRekamMedis").toString())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
migrasiPasienService.setStatus(noRekamMedisList);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.jasamedika.medifirst2000.task.schedule.config;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Salman
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 29/07/2024
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class HeaderHandler {
|
||||||
|
|
||||||
|
public static HttpHeaders getHttpHeaders() {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setAccept(Collections.singletonList(APPLICATION_JSON));
|
||||||
|
headers.setContentType(APPLICATION_JSON);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,11 +1,13 @@
|
|||||||
package com.jasamedika.medifirst2000.task.schedule.config;
|
package com.jasamedika.medifirst2000.task.schedule.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Salman
|
* @author Salman
|
||||||
@ -23,4 +25,14 @@ public class ScheduleTaskConfig {
|
|||||||
threadPoolTaskScheduler.setThreadNamePrefix("BridgingThreadPoolTaskScheduler");
|
threadPoolTaskScheduler.setThreadNamePrefix("BridgingThreadPoolTaskScheduler");
|
||||||
return threadPoolTaskScheduler;
|
return threadPoolTaskScheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ObjectMapper objectMapper() {
|
||||||
|
return new ObjectMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,4 +17,6 @@ import java.util.List;
|
|||||||
public interface MigrasiPasienDao extends JpaRepository<MigrasiPasien, String> {
|
public interface MigrasiPasienDao extends JpaRepository<MigrasiPasien, String> {
|
||||||
@Query("select mp.pasien from MigrasiPasien mp where mp.statusMigrasi in (:listStatusMigrasi)")
|
@Query("select mp.pasien from MigrasiPasien mp where mp.statusMigrasi in (:listStatusMigrasi)")
|
||||||
List<Pasien> findPasienByStatusMigrasiIn(@Param("listStatusMigrasi") List<StatusMigrasi> statusMigrasiList);
|
List<Pasien> findPasienByStatusMigrasiIn(@Param("listStatusMigrasi") List<StatusMigrasi> statusMigrasiList);
|
||||||
|
|
||||||
|
List<MigrasiPasien> findByPasienNoCmIn(List<String> noCmList);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,4 +13,6 @@ public interface MigrasiPasienService {
|
|||||||
void newMigrate();
|
void newMigrate();
|
||||||
|
|
||||||
List<PasienDto> extractAndTransform();
|
List<PasienDto> extractAndTransform();
|
||||||
|
|
||||||
|
void setStatus(List<String> noRekamMedisList);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,8 +23,7 @@ import static com.jasamedika.medifirst2000.etl.pasien.constant.JenisAlamat.IDENT
|
|||||||
import static com.jasamedika.medifirst2000.etl.pasien.constant.JenisIdentitas.KTP;
|
import static com.jasamedika.medifirst2000.etl.pasien.constant.JenisIdentitas.KTP;
|
||||||
import static com.jasamedika.medifirst2000.etl.pasien.constant.Pekerjaan.*;
|
import static com.jasamedika.medifirst2000.etl.pasien.constant.Pekerjaan.*;
|
||||||
import static com.jasamedika.medifirst2000.etl.pasien.constant.Pendidikan.*;
|
import static com.jasamedika.medifirst2000.etl.pasien.constant.Pendidikan.*;
|
||||||
import static com.jasamedika.medifirst2000.etl.pasien.constant.StatusMigrasi.BELUM_KIRIM;
|
import static com.jasamedika.medifirst2000.etl.pasien.constant.StatusMigrasi.*;
|
||||||
import static com.jasamedika.medifirst2000.etl.pasien.constant.StatusMigrasi.PEMBAHARUAN;
|
|
||||||
import static com.jasamedika.medifirst2000.etl.pasien.constant.StatusPerkawinan.*;
|
import static com.jasamedika.medifirst2000.etl.pasien.constant.StatusPerkawinan.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -285,4 +284,12 @@ public class MigrasiPasienServiceImpl implements MigrasiPasienService {
|
|||||||
private String numbersOnly(String str) {
|
private String numbersOnly(String str) {
|
||||||
return str.replaceAll("\\D", "");
|
return str.replaceAll("\\D", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStatus(List<String> noRekamMedisList) {
|
||||||
|
List<MigrasiPasien> byPasienNoCmIn = migrasiPasienDao.findByPasienNoCmIn(noRekamMedisList);
|
||||||
|
byPasienNoCmIn.stream().filter(migrasiPasien -> !TERKIRIM.equals(migrasiPasien.getStatusMigrasi()))
|
||||||
|
.forEach(migrasiPasien -> migrasiPasien.setStatusMigrasi(TERKIRIM));
|
||||||
|
migrasiPasienDao.save(byPasienNoCmIn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,3 +23,5 @@ reportDirectory=/home/svradmin/app-back/uploadfile/
|
|||||||
|
|
||||||
urlServiceSarPras=https://smart.rsabhk.co.id:2222/jasamedika-web/
|
urlServiceSarPras=https://smart.rsabhk.co.id:2222/jasamedika-web/
|
||||||
urlService=https://smart.rsabhk.co.id:2222/simrs_harkit/service/transaksi/
|
urlService=https://smart.rsabhk.co.id:2222/simrs_harkit/service/transaksi/
|
||||||
|
|
||||||
|
app.etl.migrasi.pasien=http://localhost:8081/simrs/pasien/migrasi
|
||||||
|
|||||||
@ -23,3 +23,5 @@ reportDirectory=/home/svradmin/app-back/uploadfile/
|
|||||||
|
|
||||||
urlServiceSarPras=http://192.168.12.3:8080/jasamedika-web/
|
urlServiceSarPras=http://192.168.12.3:8080/jasamedika-web/
|
||||||
urlService=http://192.168.12.3:5555/simrs_harkit/service/transaksi/
|
urlService=http://192.168.12.3:5555/simrs_harkit/service/transaksi/
|
||||||
|
|
||||||
|
app.etl.migrasi.pasien=http://localhost:8081/simrs/pasien/migrasi
|
||||||
|
|||||||
@ -23,3 +23,5 @@ reportDirectory=/home/svradmin/app-back/uploadfile/
|
|||||||
|
|
||||||
urlServiceSarPras=http://192.168.12.3:8080/jasamedika-web/
|
urlServiceSarPras=http://192.168.12.3:8080/jasamedika-web/
|
||||||
urlService=http://192.168.12.3:5555/simrs_harkit/service/transaksi/
|
urlService=http://192.168.12.3:5555/simrs_harkit/service/transaksi/
|
||||||
|
|
||||||
|
app.etl.migrasi.pasien=http://localhost:8081/simrs/pasien/migrasi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user