123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "github.com/astaxie/beego"
- "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/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/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")
-
- }
-
- 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() {
- 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
-
- }
-
- }
-
- 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")
-
- 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()
- labels, total, err := service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword)
- 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
-
- }
-
- }
|