123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- package controllers
-
- import (
- "Xcx_New/enums"
- "Xcx_New/models"
- "Xcx_New/service"
- "fmt"
- "github.com/astaxie/beego"
- "time"
- )
-
- type HisHospitalApiController struct {
- BaseAuthAPIController
- }
-
- func HisHospitalManagerApiRegistRouters() {
-
- beego.Router("/api/hishospitalpatient/list", &HisHospitalApiController{}, "get:GetHisHospitalPatientList")
-
- //beego.Router("/api/hishospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
-
- beego.Router("/api/hospitalcharge/list", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientList")
- beego.Router("/api/hospotalcharge/info", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientInfo")
-
- beego.Router("/api/hospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
- //beego.Router("/api/hishospitalprescription/info", &HisApiController{}, "get:GetHisHospitalPrescriptionInfo")
-
- //beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
- //beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
-
- //beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
- //beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
- //beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
-
- //beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
- //beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
-
- //beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
- //beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
-
- //beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
- //
- //beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
- //
- //beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
- //
- //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
- //
- //beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
-
- //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
- //新增附加费用
- //beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
- //beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
- //beego.Router("/api/hisprescription/get", &HisApiController{}, "Get:GetLastOrNextHisPrescription")
- //beego.Router("/api/callhisprescription/get", &HisApiController{}, "Get:GetCallHisPrescription")
- //beego.Router("/api/dayprescription/get", &HisApiController{}, "get:GetHisDayPrescription")
- //beego.Router("/api/charge/list", &HisApiController{}, "get:GetHisChargePatientList")
- //beego.Router("/api/charge/info", &HisApiController{}, "get:GetHisChargePatientInfo")
- //beego.Router("/api/unregister/list", &HisApiController{}, "get:GetHisUnRegisterPatientList")
- //beego.Router("/api/orderdetail/get", &HisApiController{}, "get:GetAllOrderDetail")
- //beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
- //beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
- //beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
- //
- //beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
- //beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
- //
- //beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
- //
- //beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
-
- }
-
- func (c *HisHospitalApiController) GetHisHospitalPatientList() {
- record_date := c.GetString("record_date")
- types, _ := c.GetInt64("type", 0)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- var patients []*service.HospitalPatient
- tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
-
- for _, item := range tempPatients {
- if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 && item.HisHospitalCheckRecord.OutHospitalStatus == 0 {
- patients = append(patients, item)
-
- }
-
- }
-
- var total_one int64
- var total_two int64
-
- for _, item := range patients {
-
- if item.VMHisPrescriptionInfo.ID == 0 {
- total_one = total_one + 1
- }
- if item.VMHisPrescriptionInfo.ID > 0 {
- total_two = total_two + 1
- }
- }
-
- adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
- doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
- department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
-
- if types == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- "total_one": total_one,
- "total_two": total_two,
- "info": adminUserInfo,
- "doctors": doctors,
- "department": department,
- })
-
- } else if types == 1 { //未就诊
- var patientsOne []*service.HospitalPatient
- for _, item := range tempPatients {
- if item.VMHisPrescriptionInfo.ID == 0 {
- patientsOne = append(patientsOne, item)
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patientsOne,
- "total_one": total_one,
- "total_two": total_two,
- "info": adminUserInfo,
- "doctors": doctors,
- "department": department,
- })
-
- } else if types == 2 { //已就诊
- var patientsTwo []*service.HospitalPatient
- for _, item := range tempPatients {
-
- if item.VMHisPrescriptionInfo.ID > 0 {
- patientsTwo = append(patientsTwo, item)
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patientsTwo,
- "total_one": total_one,
- "total_two": total_two,
- "info": adminUserInfo,
- "doctors": doctors,
- "department": department,
- })
- }
- }
-
- func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
- record_date := c.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- //tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
- tempPatients, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
-
- var patients []*service.HospitalPatient
- for _, item := range tempPatients {
- fmt.Println(item.ID)
- if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 &&
- item.HisHospitalCheckRecord.HisHospitalOrder.ID == 0 {
- patients = append(patients, item)
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- "list_two": patients,
- })
- }
-
- func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
- patient_id, _ := c.GetInt64("patient_id")
- his_patient_id, _ := c.GetInt64("his_patient_id")
- record_date := c.GetString("record_date")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- order_status, _ := c.GetInt64("type", 0)
- p_type, _ := c.GetInt64("p_type", 0)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
-
- startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
-
- }
- startRecordDateTime := startTime.Unix()
-
- endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
-
- }
- endRecordDateTime := endTime.Unix()
-
- admin := c.GetAdminUserInfo()
- his_patient_info, _ := service.GetNewHisHospitalPatientInfo(his_patient_id)
- xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
-
- var prescriptions []*models.HisPrescription
-
- if order_status == 1 || order_status == 0 {
- prescriptions, _ = service.GetUnChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
- } else if order_status == 2 {
- prescriptions, _ = service.GetChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
- }
-
- var monthPrescriptions []*models.HisPrescription
- if order_status == 1 || order_status == 0 {
- monthPrescriptions, _ = service.GetUnChargeMonthHisPrescriptionThree(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
- } else if order_status == 2 {
- monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFour(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
- }
- case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
- patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
- order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
- doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
- //获取所有科室信息
- department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "his_info": his_patient_info,
- "xt_info": xt_patient_info,
- "prescription": prescriptions,
- "case_history": case_history,
- "info": patientPrescriptionInfo,
- "month_prescriptions": monthPrescriptions,
- "order": order,
- "doctors": doctors,
- "department": department,
- })
- return
-
- }
-
- func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
- record_date := c.GetString("record_date")
- keywords := c.GetString("keywords")
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- prescriptionOrder, err, total := service.GetHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
-
- //adminInfo := c.GetAdminUserInfo()
- //prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
- //fmt.Println(prescriptionOrder)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "order": prescriptionOrder,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
- record_date := c.GetString("record_date")
- keywords := c.GetString("keywords")
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- prescriptionOrder, err, total := service.GetHisHospitalPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "order": prescriptionOrder,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }
|