package com.zj365.health.vm

import androidx.lifecycle.MutableLiveData
import com.xty.base.vm.BaseVm
import com.xty.common.Const
import com.xty.network.model.*
import org.json.JSONArray
import org.json.JSONObject

class ElectronicListVm:BaseVm() {
    val  eleLive by lazy{MutableLiveData<RespBody<MutableList<EleTestBean>>>()}
    val  bloodLive by lazy{MutableLiveData<RespBody<PaingBean<BloodBean>>>()}
    val  medicalLive by lazy{MutableLiveData<RespBody<MutableList<MedicalBean>>>()}
    val deleteLive by lazy{ MutableLiveData<RespBody<Any>>()}
    val deleteClu by lazy{ MutableLiveData<RespBody<Any>>()}
    val deleteBlood by lazy{ MutableLiveData<RespBody<Any>>()}
    fun getList(pageNumber:Int){
        startHttp {
            var json=JSONObject()
            json.put("pageNum",pageNumber)
            json.put("pageSize",Const.PAGE_SIZE)
           var response= apiInterface().getElectronicList(retrofits.getRequestBody(json.toString()))
            response.getCodeStatus(eleLive,nowData)
        }
    }
    //血压
    fun getBlood(pageNumber:Int){
        startHttp {
             var json=JSONObject()
               json.put("pageNum",pageNumber)
               json.put("pageSize",Const.PAGE_SIZE)
             var response= apiInterface().getBloodList(retrofits.getRequestBody(json.toString()))
            response.getCodeStatus(bloodLive,nowData)
        }
    }


    //血糖
    fun getCluList(pageNumber:Int){
        startHttp {
             var json=JSONObject()
               json.put("pageNum",pageNumber)
               json.put("pageSize",Const.PAGE_SIZE)
            var response= apiInterface().getCluList(retrofits.getRequestBody(json.toString()))
            response.getCodeStatus(bloodLive,nowData)
        }
    }

    /**
     * 删除血糖上传上传
     */
    fun deleteClu(id:Int){
        startHttp {
            var array=JSONArray()
            array.put(id)
            var body=apiInterface().deleteClu(retrofits.getRequestBody(array.toString()))
            body.getCodeStatus(deleteClu,nowData)
        }
    }
    /**
     * 删除血压上传上传
     */
    fun deleteBlood(id:Int){
        startHttp {
            var array=JSONArray()
            array.put(id)
            var body=apiInterface().deleteBlood(retrofits.getRequestBody(array.toString()))
            body.getCodeStatus(deleteClu,nowData)
        }
    }

    //用药
    fun getMedicList(pageNumber:Int){
        startHttp {
             var json=JSONObject()
               json.put("pageNum",pageNumber)
               json.put("pageSize",Const.PAGE_SIZE)
            var response= apiInterface().getMedicList(retrofits.getRequestBody(json.toString()))
           response.getCodeStatus(medicalLive,nowData)
        }
    }

    /**
     * 删除用药上传
     */
    fun deleteMedic(id:Int){
        startHttp {
            var array=JSONArray()
            array.put(id)
           var body= apiInterface().deleteMedic(retrofits.getRequestBody(array.toString()))
            body.getCodeStatus(deleteLive,nowData)
        }
    }
    /**
     * 删除电子化验单
     */
    fun deleteEle(id:Int){
        startHttp {
            var array=JSONArray()
            array.put(id)
           var body= apiInterface().deleteEle(retrofits.getRequestBody(array.toString()))
            body.getCodeStatus(deleteLive,nowData)
        }
    }



}