package thyyxxk.webserver.controller.outpatient.thmz;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.outpatient.thmz.MzEmrPatientData;
import thyyxxk.webserver.entity.outpatient.thmz.MzEmrPatientVo;
import thyyxxk.webserver.entity.outpatient.thmz.req.MzEmrAddDirReq;
import thyyxxk.webserver.entity.outpatient.thmz.req.MzEmrAddFileReq;
import thyyxxk.webserver.entity.outpatient.thmz.req.MzSaveFileReq;
import thyyxxk.webserver.service.outpatient.thmz.MzEmrService;
import thyyxxk.webserver.utils.ResultVoUtil;

import javax.validation.Valid;
import java.util.List;

/**
 * @Description:门诊电子病历
 * @Author:lihong
 * @Date: 2023/10/18
 */
@Slf4j
@RestController
@RequestMapping("/mzEmr")
public class MzEmrController {
    @Autowired
    private MzEmrService service;

    @PostMapping("/queryMzEmrTree")
    public ResultVo<List<MzEmrPatientData>> queryMzEmrTree(@RequestBody MzEmrPatientVo param) {
        return ResultVoUtil.success(service.queryMzEmrTree(param));
    }

    @PostMapping("/saveMzEmrModel")
    public ResultVo<String> saveMzEmrModel(@RequestBody MzEmrPatientData param) {
        return service.saveMzEmrModel(param);
    }

    @GetMapping("/getMzEmrModel")
    public ResultVo<JSONArray> getMzEmrModel() {
        return ResultVoUtil.success(service.getMzEmrModel());
    }

    @GetMapping("/getSnippet")
    public ResultVo<List<JSONObject>> getSnippet() {
        return service.getSnippet();
    }

    @PostMapping("/queryMzPatientInfo")
    public ResultVo<MzEmrPatientVo> queryMzPatientInfo(@RequestBody MzEmrPatientVo param) {
        return ResultVoUtil.success(service.queryMzPatientInfo(param));
    }

    @GetMapping("/getEmrModelByPatientId")
    public ResultVo<List<MzEmrPatientData>> getEmrModelByPatientId(@RequestParam("patientNo") String patientNo,
                                                                   @RequestParam("times") Integer times) {
        return service.getEmrModelByPatientId(patientNo, times);
    }

    @PostMapping("/addDir")
    public ResultVo<String> addDir(@Valid @RequestBody MzEmrAddDirReq value) {
        return service.addDir(value);
    }

    @PostMapping("/addFile")
    public ResultVo<MzEmrPatientData> addFile(@Valid @RequestBody MzEmrAddFileReq value) {
        return service.addFile(value);
    }

    @PostMapping("/updateFile")
    public ResultVo<String> updateFile(@Valid @RequestBody MzSaveFileReq value) {
        return service.updateFile(value);
    }

    @GetMapping("/delFile")
    public ResultVo<String> delFile(@RequestParam("documentId") String documentId) {
        return service.delFile(documentId);
    }

    @GetMapping("/getRecycleBinMedicalRecords")
    public ResultVo<List<MzEmrPatientData>> getRecycleBinMedicalRecords(@RequestParam("patientNo") String patientNo,
                                                                        @RequestParam("times") Integer times) {
        return service.getRecycleBinMedicalRecords(patientNo, times);
    }

    @GetMapping("/restoreMedicalRecords")
    public ResultVo<String> restoreMedicalRecords(@RequestParam("documentId") String documentId) {
        return service.restoreMedicalRecords(documentId);
    }

    @GetMapping("/getHistoryTimes")
    public ResultVo<List<MzEmrPatientData>> getHistoryTimes(@RequestParam("patientNo") String patientNo,
                                                            @RequestParam("times") Integer times) {
        return service.getHistoryTimes(patientNo, times);
    }

    @GetMapping("/print")
    public ResultVo<String> print(@RequestParam("documentId") String documentId) {
        return service.print(documentId);
    }

    @GetMapping("/endOfVisit")
    public ResultVo<String> endOfVisit(@RequestParam("patientNo") String patientNo,
                                       @RequestParam("times") Integer times) {
        return service.endOfVisit(patientNo, times);
    }

}
