package com.docus.server.fsy.service.impl;

import com.docus.server.archive.utils.JaxWsDynamicClientUtil;
import com.docus.server.fsy.api.LisReportService;
import com.docus.server.fsy.api.dto.LisPatientGroupReportRequest;
import com.docus.server.fsy.api.dto.LisPatientGroupReportResponse;
import com.docus.server.fsy.api.dto.LisPatientListRequest;
import com.docus.server.fsy.api.dto.LisPatientListResponse;
import com.docus.server.fsy.api.dto.LisPatientReportRequest;
import com.docus.server.fsy.api.dto.LisPatientReportResponse;
import com.docus.server.fsy.converter.LisReportConverter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author YongBin Wen
 * @date 2024/3/29 10:20
 */
@Service
@Slf4j
public class LisReportServiceImpl implements LisReportService {
    @Value("${fsy.lis.ws-url}")
    private String lisUrl;

    @Value("${fsy.lis.gp-ws-url}")
    private String lisGroupPrintUrl;

    @Override
    public LisPatientListResponse getPatientList(LisPatientListRequest request) {
        final String method="GetPatientList";
        Object[] params = new Object[2];
        params[0]=method;
        params[1]=LisReportConverter.convertWsParam(request);;
        String result = JaxWsDynamicClientUtil.send(lisUrl, null, "DCLInterface", params);
        return LisReportConverter.convertWsPatientListResponse(result);
    }

    @Override
    public LisPatientReportResponse getPatientReport(LisPatientReportRequest request) {
        final String method="GetPatientReport";
        Object[] params = new Object[2];
        params[0]=method;
        params[1]= LisReportConverter.convertWsParam(request);
        String result = JaxWsDynamicClientUtil.send(lisUrl, null, "DCLInterface", params);
        return LisReportConverter.convertWsPatientReportResponse(result);
    }

    @Override
    public LisPatientGroupReportResponse getPatientGroupReport(LisPatientGroupReportRequest request) {
        final String method="GetPatientReportByReportCode";
        Object[] params = new Object[2];
        params[0]=method;
        params[1]= LisReportConverter.convertWsParam(request);
        String result = JaxWsDynamicClientUtil.send(lisGroupPrintUrl, null, "DCLInterface", params);
        return LisReportConverter.convertWsPatientGroupReportResponse(result);
    }





}
