123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "bytes"
- "compress/gzip"
- "encoding/json"
- "github.com/astaxie/beego"
- "net/http"
- "time"
- )
-
- type HisChargeApiController struct {
- BaseAuthAPIController
- }
-
- func HisChargeApiRegistRouters() {
- beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
- beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
-
- beego.Router("/api/his/prescription/detail", &HisChargeApiController{}, "get:GetPrescriptionStatisticsDetail")
- beego.Router("/api/his/prescription/initdata", &HisChargeApiController{}, "get:GetPrescriptionInitData")
-
- //beego.InsertFilter("/api/his/chargestatistics/detail", beego.BeforeRouter, GzipFilter)
-
- beego.Router("/api/his/patient", &HisChargeApiController{}, "get:GetAllPatient")
- //beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
-
- beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
-
- beego.Router("/api/his/inspectionlisttwo/get", &HisChargeApiController{}, "get:GetHisInspectionListTwo")
-
- beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
-
- //发票
- beego.Router("/api/fapiao/create", &HisChargeApiController{}, "post:CreateFaPiaoRecord")
- beego.Router("/api/fapiao/modify", &HisChargeApiController{}, "post:ModifyFaPiaoRecord")
- beego.Router("/api/fapiao/list", &HisChargeApiController{}, "get:GetFaPiaoRecordList")
- beego.Router("/api/fapiao/delete", &HisChargeApiController{}, "post:DeleteFaPiaoRecord")
- beego.Router("/api/fapiao", &HisChargeApiController{}, "get:GetFaPiaoRecord")
- beego.Router("/api/fapiao/is_use", &HisChargeApiController{}, "post:UpdateFaPiaoRecordIsUse")
-
- beego.Router("/api/his/getyidiclear", &HisChargeApiController{}, "get:GetHisYidiClearRecord")
-
- beego.Router("/api/his/getexportdata", &HisChargeApiController{}, "get:GetExportData")
-
- }
-
- func (c *HisChargeApiController) GetExportData() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- adminUser := c.GetAdminUserInfo()
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
- chargePatient, err := service.GetAllChargeDetailsTwo(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": chargePatient,
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
-
- func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {
- id, _ := c.GetInt64("id", 0)
- is_use, _ := c.GetInt64("is_use")
- if id <= 0 {
- utils.ErrorLog("id == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- record, _ := service.FindFapiaoById(id)
- adminUserInfo := c.GetAdminUserInfo()
- service.UpdateFapiaoIsUse(adminUserInfo.CurrentOrgId)
- records := models.HisFapiaoRecord{
- ID: id,
- FapiaoCode: record.FapiaoCode,
- FapiaoNumber: record.FapiaoNumber,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- IsUse: is_use,
- }
- err := service.ModifyFapiao(&records)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "fapiao_record": records,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *HisChargeApiController) CreateFaPiaoRecord() {
- fapiao_code := c.GetString("fapiao_code")
- fapiao_number := c.GetString("fapiao_number")
- if len(fapiao_code) <= 0 {
- utils.ErrorLog("len(fapiao_code) == 0")
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(fapiao_number) <= 0 {
- utils.ErrorLog("len(fapiao_number) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- record := models.HisFapiaoRecord{
- FapiaoCode: fapiao_code,
- FapiaoNumber: fapiao_number,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- IsUse: 0,
- }
-
- err, records := service.AddSigleFapiaoRecord(&record)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "fapiao_record": records,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
-
- }
-
- }
- func (c *HisChargeApiController) ModifyFaPiaoRecord() {
- id, _ := c.GetInt64("id", 0)
- fapiao_code := c.GetString("fapiao_code")
- fapiao_number := c.GetString("fapiao_number")
-
- if id <= 0 {
- utils.ErrorLog("id == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(fapiao_code) <= 0 {
- utils.ErrorLog("len(fapiao_code) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(fapiao_number) <= 0 {
- utils.ErrorLog("len(fapiao_number) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- record, _ := service.FindFapiaoById(id)
- adminUserInfo := c.GetAdminUserInfo()
- records := models.HisFapiaoRecord{
- ID: id,
- FapiaoCode: fapiao_code,
- FapiaoNumber: fapiao_number,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- IsUse: record.IsUse,
- }
-
- err := service.ModifyFapiao(&records)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "fapiao_record": records,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *HisChargeApiController) GetFaPiaoRecordList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 7)
- adminUserInfo := c.GetAdminUserInfo()
- fapiaoRecord, total, err := service.FindAllFapiaoList(adminUserInfo.CurrentOrgId, page, limit)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "fapiao_record": fapiaoRecord,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *HisChargeApiController) DeleteFaPiaoRecord() {
- id, _ := c.GetInt64("id", 0)
- err := service.DeleteFapiaoById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *HisChargeApiController) GetFaPiaoRecord() {
- id, _ := c.GetInt64("id", 0)
- fapiaoRecord, err := service.FindFapiaoById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "fapiao_record": fapiaoRecord,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *HisChargeApiController) GetChargeStatisticsDetail() {
- //c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "接口优化升级,如有数据需要,请联系客服!",
- //})
- //return
-
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- time_type := c.GetString("time_type")
- keyword := c.GetString("keyword")
- item_type, _ := c.GetInt64("type")
-
- adminUser := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
-
- switch item_type {
- case 0:
- chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structToBytes(chargeDrug)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
-
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- break
- case 1:
- chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- //chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
- //chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structToBytes(chargeDrug)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
-
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- break
- case 2:
- //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
- chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- //chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structToBytes(chargeProject)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
-
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- break
-
- case 3:
- //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
- chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- //chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structToBytes(chargeProject)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
-
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- break
- case 4:
- //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
- chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- //chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structToBytes(chargeProject)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
-
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- break
- case 5:
- //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
- chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- //chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structToBytes(chargeProject)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
-
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- break
- case 6:
- //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
- chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- //chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structToBytes(chargeProject)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
-
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- break
- case 7:
- //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
- chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
- //chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structToBytes(chargeProject)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
-
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- break
-
- }
-
- }
-
- func (c *HisChargeApiController) GetPrescriptionStatisticsDetail() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- patient_id, _ := c.GetInt64("patient_id")
- item_type, _ := c.GetInt64("type")
-
- date1, _ := time.Parse("2006-01-02", start_time)
- date2, _ := time.Parse("2006-01-02", end_time)
- // 计算日期间隔
- duration := date2.Sub(date1)
-
- // 一个月的时间跨度为30天 * 24小时 * 60分钟 * 60秒
- oneMonthDuration := 30 * 24 * time.Hour
-
- if duration <= oneMonthDuration {
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorTimeCodeParamWrong)
- return
- }
- adminUser := c.GetAdminUserInfo()
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
- chargeDrug, err := service.GetHisPrescriptionDrugDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, patient_id, item_type)
- chargeProject, err := service.GetHisPrescriptionProjectDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, patient_id, item_type)
- chargeDrug = append(chargeDrug, chargeProject...)
- b, _ := structpToBytes(chargeDrug)
- //cd, _ := compressData(b)
- // 使用 Gzip 压缩数据
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
- _, err = writer.Write(b)
- if err != nil {
- c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
- c.Ctx.WriteString(err.Error())
- return
- }
- writer.Close()
- // 设置响应头,表明数据经过了 Gzip 压缩
- c.Ctx.Output.Header("Content-Encoding", "gzip")
- // 发送压缩后的数据
- c.Ctx.ResponseWriter.Write(compressedData.Bytes())
- }
-
- func (c *HisChargeApiController) GetPrescriptionInitData() {
- var drugType = "药品类型"
- drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
- drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, c.GetAdminUserInfo().CurrentOrgId)
- var costClassify = "费用类别"
- costClassifyParent, _ := service.GetDrugDataConfig(0, costClassify)
- costClassifyList, _ := service.GetParentDataConfig(costClassifyParent.ID, c.GetAdminUserInfo().CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "drugTypeList": drugTypeList,
- "costClassifyList": costClassifyList,
- })
-
- }
-
- func structpToBytes(p []*models.NewPDetail) ([]byte, error) {
- data, err := json.Marshal(p)
- if err != nil {
- return nil, err
- }
- return data, nil
- }
-
- func structToBytes(p []*models.NewChargeDetail) ([]byte, error) {
- data, err := json.Marshal(p)
- if err != nil {
- return nil, err
- }
- return data, nil
- }
-
- func compressData(data []byte) ([]byte, error) {
- var compressedData bytes.Buffer
- writer := gzip.NewWriter(&compressedData)
-
- _, err := writer.Write(data)
- if err != nil {
- return nil, err
- }
-
- err = writer.Close()
- if err != nil {
- return nil, err
- }
-
- return compressedData.Bytes(), nil
- }
-
- func (c *HisChargeApiController) GetChargeStatisticsSettle() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- keyword := c.GetString("keyword")
- item_type, _ := c.GetInt64("type")
- adminUser := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
- chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": chargePatient,
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
-
- func (c *HisChargeApiController) GetHisInspectionList() {
- record_date := c.GetString("record_date")
- keyword := c.GetString("keyword")
- is_print, _ := c.GetInt64("is_print")
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
- tube_color, _ := c.GetInt64("tube_color")
-
- adminUser := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
-
- }
- record_time := startTime.Unix()
- var labels []*models.HisLabelPrintInfo
- var labels_two []*models.HisLabelPrintInfo
-
- var total int64
- var total_two int64
- //var err error
- if tube_color == 0 {
- labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
- } else {
- labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
- labels_two, total_two, err = service.GetLabelPrintListTwo(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
- total = total + total_two
- labels = append(labels, labels_two...)
- }
-
- if err == nil {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "labels": labels,
- "total": total,
- })
- return
-
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
-
- func (c *HisChargeApiController) GetHisInspectionListTwo() {
- record_date := c.GetString("record_date")
- keyword := c.GetString("keyword")
- is_print, _ := c.GetInt64("is_print")
- tube_color, _ := c.GetInt64("tube_color")
- adminUser := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
-
- }
- record_time := startTime.Unix()
- var labels []*models.HisLabelPrintInfo
- //var labels_two []*models.HisLabelPrintInfo
-
- //var total int64
- //var total_two int64
-
- labels, _, err = service.GetLabelPrintListThree(adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
- //labels_two, total_two, err = service.GetLabelPrintListFour(adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
- //total = total + total_two
- //labels = append(labels, labels_two...)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "labels": labels,
- //"total": total,
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
-
- func (c *HisChargeApiController) GetHisInspectionInfo() {
- id, _ := c.GetInt64("id")
- label, err := service.GetLabelPrintInfo(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "label": label,
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *HisChargeApiController) GetHisYidiClearRecord() {
- records, err := service.FindHisYidiClearRecord(c.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": records,
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *HisChargeApiController) GetAllPatient() {
- patients, err := service.GetAllPatientTwo(c.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *HisChargeApiController) GetStatisticsDetail() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- keyword := c.GetString("keyword")
- item_type, _ := c.GetInt64("type")
- p_type, _ := c.GetInt64("p_type")
- patinet_id, _ := c.GetInt64("patinet_id")
-
- adminUser := c.GetAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
-
- chargePatient, err := service.GetPatientChargeDetails(patinet_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type, p_type)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": chargePatient,
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
-
- func (c *HisChargeApiController) GetStatisticsGather() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- keyword := c.GetString("keyword")
- item_type, _ := c.GetInt64("type")
- adminUser := c.GetAdminUserInfo()
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- 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()
-
- chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": chargePatient,
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
|