package controllers import ( "XT_New/enums" "XT_New/models" "XT_New/service" "github.com/astaxie/beego" "strings" "time" ) type HisPrintApiController struct { BaseAuthAPIController } func HisPrintApiRegistRouters() { beego.Router("/api/his/prescription/print", &HisPrintApiController{}, "get:GetBatchHisPrescriptionData") beego.Router("/api/his/prescription/list", &HisPrintApiController{}, "get:GetUnChargePrescriptionList") beego.Router("/api/his/prescription/summary", &HisPrintApiController{}, "get:GetUnChargePrescriptionSummary") beego.Router("/api/his/label/create", &HisPrintApiController{}, "get:CreateLablePrint") beego.Router("/api/his/label/get", &HisPrintApiController{}, "get:GetLablePrint") //beego.Router("/api/his/checkprescription/print", &HisPrintApiController{}, "get:GetBatchCheckHisPrescriptionData") } //func (c *HisPrintApiController) GetBatchCheckHisPrescriptionData() { // record_date := c.GetString("record_date") // patient_ids := c.GetString("patient_ids") // 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() // ids := strings.Split(patient_ids, ",") // // //var newPatients []*models.PrintPatient // // patients, _ := service.GetBatchInspectionProjectHisPrescriptionTwo(ids, recordDateTime, adminInfo.CurrentOrgId) // // c.ServeSuccessJSON(map[string]interface{}{ // "patients": patients, // }) // break //} func (c *HisPrintApiController) GetLablePrint() { patient_id, _ := c.GetInt64("patient_id") ids := c.GetString("ids") record_date := c.GetString("record_date") labels, _ := service.GetLabelPrint(ids, c.GetAdminUserInfo().CurrentOrgId, record_date, patient_id) c.ServeSuccessJSON(map[string]interface{}{ "labels": labels, }) return } func (c *HisPrintApiController) CreateLablePrint() { patient_id, _ := c.GetInt64("patient_id") isCombinationPrint, _ := c.GetBool("is_combination_print") team_ids := c.GetString("team_ids") ids := c.GetString("ids") record_date := c.GetString("record_date") doctor_id, _ := c.GetInt64("doctor_id") project_ids := c.GetString("project_ids") is_team, _ := c.GetInt64("is_team") var hlpsi models.HisLabelPrintStatusInfo hlpsi.Status = 1 hlpsi.UserOrgId = c.GetAdminUserInfo().CurrentOrgId hlpsi.PatientId = patient_id hlpsi.RecordDate = record_date hlpsi.Mtime = time.Now().Unix() hlpsi.Ctime = time.Now().Unix() hlpsi.ItemIds = team_ids hlpsi.ProjectIds = project_ids hlpsi.Ids = ids hlpsi.DoctorId = doctor_id hlpsi.IsTeam = is_team hlpsi.IsPrint = 1 if isCombinationPrint == true { hlpsi.IsCombinationPrint = 1 } else { hlpsi.IsCombinationPrint = 0 } service.CreateLabelPrint(&hlpsi) c.ServeSuccessJSON(map[string]interface{}{ "msg": "保存成功", "hlpsi": hlpsi, }) return } func (c *HisPrintApiController) GetUnChargePrescriptionList() { patient_id, _ := c.GetInt64("patient_id") recordDateTime, _ := c.GetInt64("record_date") admin_user_id, _ := c.GetInt64("admin_user_id") p_type, _ := c.GetInt64("p_type", 0) admin := c.GetAdminUserInfo() xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id) record, _ := service.GetLastInHospitalRecord(patient_id, c.GetAdminUserInfo().CurrentOrgId) var prescriptions []*models.HisPrescription prescriptions, _ = service.GetUnChargeHisPrescriptionTen(admin.CurrentOrgId, patient_id, recordDateTime, p_type) admin_info, _ := service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId) //获取所有科室信息 c.ServeSuccessJSON(map[string]interface{}{ "xt_info": xt_patient_info, "prescription": prescriptions, "record": record, "admin_info": admin_info, }) return } func (c *HisPrintApiController) GetUnChargePrescriptionSummary() { patient_id, _ := c.GetInt64("patient_id") record_date, _ := c.GetInt64("record_date") admin_user_id, _ := c.GetInt64("admin_user_id") 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() admin := c.GetAdminUserInfo() xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id) record, _ := service.GetLastInHospitalRecord(patient_id, c.GetAdminUserInfo().CurrentOrgId) var prescriptions []*models.HisPrescription prescriptions, _ = service.GetUnChargeHisPrescriptionTen(admin.CurrentOrgId, patient_id, record_date, p_type) //doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId) service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId) //获取所有科室信息 c.ServeSuccessJSON(map[string]interface{}{ "xt_info": xt_patient_info, "prescription": prescriptions, "record": record, "admin_info": admin_user_id, }) return } func (c *HisPrintApiController) GetBatchHisPrescriptionData() { record_date := c.GetString("record_date") patient_ids := c.GetString("patient_ids") print_type, _ := c.GetInt64("type") 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() ids := strings.Split(patient_ids, ",") switch print_type { case 1: patients, _ := service.GetBatchDrugHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId) c.ServeSuccessJSON(map[string]interface{}{ "patients": patients, }) break case 2: //var newPatients []*models.PrintPatient patients, _ := service.GetBatchProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId) //for _, item := range patients { // for _, subItem := range item.HisPrintPrescription { // for _, subItemTwo := range subItem.HisPrescriptionProject { // if subItemTwo.HisProject.CostClassify != 3 { // // } // } // } //} c.ServeSuccessJSON(map[string]interface{}{ "patients": patients, }) break case 3: var newPatients []*models.PrintPatient var newPatientsTwo []*models.PrintPatient patients, _ := service.GetBatchInspectionProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId) for _, item := range patients { var newPatient *models.PrintPatient newPatient = item for index, subItem := range item.HisPrintPrescription { if index > 0 { item.HisPrintPrescription[0].HisPrescriptionProject = append(item.HisPrintPrescription[0].HisPrescriptionProject, subItem.HisPrescriptionProject...) } } newPatients = append(newPatients, newPatient) } for _, item := range patients { var newPatient *models.PrintPatient newPatient = item if len(item.HisPrintPrescription) > 0 { newPatient.NewHisPrintPrescription = append(newPatient.NewHisPrintPrescription, item.HisPrintPrescription[0]) newPatientsTwo = append(newPatientsTwo, newPatient) } } c.ServeSuccessJSON(map[string]interface{}{ "patients": newPatientsTwo, }) break } }