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 initiateMigrasiPasien() { migrasiPasienService.newMigrate(); return new ResponseEntity<>(null, HttpStatus.OK); } @RequestMapping(value = "/extraction/transformation", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> extractAndTransform() { List result = migrasiPasienService.extractAndTransform(); return new ResponseEntity<>(result, HttpStatus.OK); } @RequestMapping(value = "/status", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) public ResponseEntity setStatus(@RequestBody List noRekamMedisList) { try { migrasiPasienService.setStatus(noRekamMedisList); return new ResponseEntity<>(null, HttpStatus.ACCEPTED); } catch (Exception e) { return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } }