123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "github.com/astaxie/beego"
- "time"
- )
-
- type ZuobiaoApiController struct {
- BaseAuthAPIController
- }
-
- func ZuobiaoApiRegistRouters() {
- beego.Router("/api/zuobiaodetail/list", &ZuobiaoApiController{}, "get:GetHisZuoBiaoDetailPatientList")
- beego.Router("/api/zuobiaodetail/info", &ZuobiaoApiController{}, "get:GetHisZuoBiaoDetailInfo")
-
- beego.Router("/api/uploadzuobiaodetail/info", &ZuobiaoApiController{}, "get:GetUploadHisZuoBiaoDetailInfo")
-
- beego.Router("/api/zuobiaomonthdetail/info", &ZuobiaoApiController{}, "get:GetHisZuoBiaoMonthDetailInfo")
-
- }
-
- func (c *ZuobiaoApiController) GetHisZuoBiaoDetailPatientList() {
- 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
- }
- var patients []*service.NewTempPatients
- var patienttwos []*service.NewTempPatients
-
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- UnuploadTempPatients, _ := service.GetNewAllUnHisZuoBiaoPatientList(adminInfo.CurrentOrgId, recordDateTime)
- uploadTempPatients, _ := service.GetNewAllChargeHisZuoBiaoPatientList(adminInfo.CurrentOrgId, recordDateTime)
- uploadPatient, _ := service.GetUploadHisZuoBiaoPatientList(adminInfo.CurrentOrgId, recordDateTime)
- for _, item := range UnuploadTempPatients {
- //if len(item.HisPrescription) > 0 {
- patients = append(patients, item)
- //}
- }
- for _, item := range uploadTempPatients {
- if len(item.HisPrescription) > 0 {
- patienttwos = append(patienttwos, item)
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- "list_two": patienttwos,
- "upload_list": uploadPatient,
- "upload_num": len(uploadPatient),
- "un_upload_num": len(patients),
- })
- }
- func (c *ZuobiaoApiController) GetHisZuoBiaoDetailInfo() {
- record_date := c.GetString("record_date")
- is_upload, _ := c.GetInt64("is_upload")
- patient_id, _ := c.GetInt64("id")
- start_time_str := c.GetString("start_time")
- end_time_str := c.GetString("end_time")
-
- 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()
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartTime := theStartTime.Unix()
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndTime := theEndTime.Unix()
- var prescriptions []*models.HisPrescription
- if is_upload == 1 { //未上传
- prescriptions, _ = service.GetUnUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordDateTime)
- } else if is_upload == 2 { //已上传
- prescriptions, _ = service.GetUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordDateTime)
- }
- patient, _ := service.GetPatientByIDThree(c.GetAdminUserInfo().CurrentOrgId, patient_id)
- var monthPrescriptions []*models.HisPrescription
- if is_upload == 1 {
- monthPrescriptions, _ = service.GetMonthUnUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
- } else if is_upload == 2 {
- monthPrescriptions, _ = service.GetMonthUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
- }
- prescription_info, _ := service.GetZuoBiaoPrescriptionInfo(adminInfo.CurrentOrgId, patient.ID)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "prescription": prescriptions,
- "month_prescriptions": monthPrescriptions,
- "patient": patient,
- "prescription_info": prescription_info,
- })
- }
-
- func (c *ZuobiaoApiController) GetUploadHisZuoBiaoDetailInfo() {
- id, _ := c.GetInt64("id")
- _, zuobiao_info := service.GetZuobiaoInfoById(id)
- patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, zuobiao_info.PatientId)
- order, _ := service.GetHisOrderByID(zuobiao_info.Oid)
- prescription, _ := service.GetHisPrescriptionByBatchNumber(c.GetAdminUserInfo().CurrentOrgId, order.Number)
- prescription_info, _ := service.GetZuoBiaoPrescriptionInfo(c.GetAdminUserInfo().CurrentOrgId, patient.ID)
- c.ServeSuccessJSON(map[string]interface{}{
- "month_prescriptions": prescription,
- "patient": patient,
- "zuobiao_info": zuobiao_info,
- "prescription_info": prescription_info,
- })
- }
-
- func (c *ZuobiaoApiController) GetHisZuoBiaoMonthDetailInfo() {
- patient_id, _ := c.GetInt64("id")
- is_upload, _ := c.GetInt64("is_upload")
- //patient_id, _ := c.GetInt64("patient_id")
- start_time_str := c.GetString("start_time")
- end_time_str := c.GetString("end_time")
-
- //record, _ := service.GetInHospitalRecord(id)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- adminInfo := c.GetAdminUserInfo()
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartTime := theStartTime.Unix()
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndTime := theEndTime.Unix()
- //var prescriptions []*models.HisPrescription
-
- var monthPrescriptions []*models.HisPrescription
- if is_upload == 1 {
- monthPrescriptions, _ = service.GetMonthUnUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
- } else if is_upload == 2 {
- monthPrescriptions, _ = service.GetMonthUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
- } else {
- monthPrescriptions, _ = service.GetAllMonthHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
- }
- patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "month_prescriptions": monthPrescriptions,
- //"his_info": record,
- "patient": patient,
- })
- }
|