package com.jasamedika.medifirst2000.controller; import com.jasamedika.medifirst2000.vo.custom.BridgeEKlaimVO; import org.apache.commons.io.IOUtils; import org.json.JSONException; import org.json.JSONObject; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.util.ArrayList; @RestController @RequestMapping("/e-klaim") public class BridgingEKlaimController { @RequestMapping(value = "/ri", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE }) public ArrayList eKlaimRi(@RequestParam(value = "startdate", required = true) String start, @RequestParam(value = "enddate", required = true) String end) throws IOException { java.net.URL obj = new java.net.URL("http://localhost/E-Klaim/ws.php?mode=debug"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/json"); con.setDoInput(true); con.setDoOutput(true); String strJson = "{\"metadata\":{\"method\":\"pull_claim\"},\"data\":{\"start_dt\":\""+start+"\",\"stop_dt\":\""+end+"\",\"jenis_rawat\":\"1\"}}"; OutputStream os = con.getOutputStream(); os.write(strJson.getBytes("UTF-8")); os.close(); InputStream in = new BufferedInputStream(con.getInputStream()); String result = IOUtils.toString(in, "UTF-8"); ArrayList ret = new ArrayList(); try { JSONObject jsonObject = new JSONObject(result); JSONObject metadata = (JSONObject) jsonObject.get("metadata"); System.out.println(metadata.get("code")); System.out.println(metadata.get("message")); JSONObject response = (JSONObject) jsonObject.get("response"); String dataKlaim = response.get("data").toString(); System.out.println(dataKlaim); String data[] = dataKlaim.split("\n"); for(int i=1;i eKlaimRj(@RequestParam(value = "startdate", required = true) String start, @RequestParam(value = "enddate", required = true) String end) throws IOException { java.net.URL obj = new java.net.URL("http://localhost/E-Klaim/ws.php?mode=debug"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/json"); con.setDoInput(true); con.setDoOutput(true); String strJson = "{\"metadata\":{\"method\":\"pull_claim\"},\"data\":{\"start_dt\":\""+start+"\",\"stop_dt\":\""+end+"\",\"jenis_rawat\":\"2\"}}"; OutputStream os = con.getOutputStream(); os.write(strJson.getBytes("UTF-8")); os.close(); InputStream in = new BufferedInputStream(con.getInputStream()); String result = IOUtils.toString(in, "UTF-8"); ArrayList ret = new ArrayList(); try { JSONObject jsonObject = new JSONObject(result); JSONObject metadata = (JSONObject) jsonObject.get("metadata"); System.out.println(metadata.get("code")); System.out.println(metadata.get("message")); JSONObject response = (JSONObject) jsonObject.get("response"); String dataKlaim = response.get("data").toString(); System.out.println(dataKlaim); String data[] = dataKlaim.split("\n"); for(int i=1;i