Salman Manoe 115bc86893 Update service migrasi pasien
Perbaikan performance update flag status migrasi etl pasien di sistem smart
2024-07-31 11:00:09 +07:00

52 lines
1.9 KiB
Java

package com.jasamedika.medifirst2000.controller;
import com.jasamedika.medifirst2000.etl.pasien.dto.PasienDto;
import com.jasamedika.medifirst2000.service.MigrasiPasienService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/**
* @author Salman
* @version 1.0.0
* @since 06/11/2023
*/
@RestController
@RequestMapping("/migrasi/pasien")
public class MigrasiPasienController {
@Autowired
private MigrasiPasienService migrasiPasienService;
@RequestMapping(value = "/init", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Object> initiateMigrasiPasien() {
migrasiPasienService.newMigrate();
return new ResponseEntity<>(null, HttpStatus.OK);
}
@RequestMapping(value = "/extraction/transformation", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<PasienDto>> extractAndTransform() {
List<PasienDto> result = migrasiPasienService.extractAndTransform();
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/status", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Object> setStatus(@RequestBody List<String> noRekamMedisList) {
try {
migrasiPasienService.setStatus(noRekamMedisList);
return new ResponseEntity<>(null, HttpStatus.ACCEPTED);
} catch (Exception e) {
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}