Browse Source

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 2 years ago
parent
commit
e89f50acf0

+ 163 - 12
controllers/coordinate/coordinate_controller.go View File

1
 package coordinate
1
 package coordinate
2
 
2
 
3
 import (
3
 import (
4
+	"encoding/json"
4
 	"fmt"
5
 	"fmt"
5
 	"gdyb/controllers"
6
 	"gdyb/controllers"
7
+	"gdyb/enums"
8
+	"gdyb/models"
6
 	"gdyb/service"
9
 	"gdyb/service"
10
+	"gdyb/utils"
7
 	"github.com/astaxie/beego"
11
 	"github.com/astaxie/beego"
12
+	"math/rand"
13
+	"os"
14
+	"strconv"
15
+	"strings"
16
+	"time"
8
 )
17
 )
9
 
18
 
10
 type CoordinateController struct {
19
 type CoordinateController struct {
14
 type ResultReg struct {
23
 type ResultReg struct {
15
 	ResultCode string `json:"resultCode"`
24
 	ResultCode string `json:"resultCode"`
16
 	ResultDesc string `json:"resultDesc"`
25
 	ResultDesc string `json:"resultDesc"`
17
-	InfoSeq    int64  `json:"infoSeq"`
26
+	InfoSeq    string `json:"infoSeq"`
18
 }
27
 }
19
 
28
 
20
 func CoordinateRegistRouters() {
29
 func CoordinateRegistRouters() {
32
 }
41
 }
33
 
42
 
34
 func (c *CoordinateController) Register() {
43
 func (c *CoordinateController) Register() {
35
-	//var reg models.Reg
36
-	//reg.
37
-	//
38
-	//
39
-	//
40
-	//result, request_log := service.SaveReg()
41
-	//fmt.Println(result)
42
-	//fmt.Println(request_log)
44
+	patient_id, _ := c.GetInt64("patient_id")
45
+	diagnosis_time := c.GetString("diagnosis_time")
46
+	record_date := c.GetString("record_date")
47
+	admin_user_id, _ := c.GetInt64("admin_user_id")
48
+
49
+	patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
50
+
51
+	timeLayout := "2006-01-02"
52
+	loc, _ := time.LoadLocation("Local")
53
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
54
+	if err != nil {
55
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
56
+		return
57
+	}
58
+	recordDateTime := theTime.Unix()
59
+
60
+	patientPrescription, _ := service.FindPatientPrescriptionInfo(c.GetAdminUserInfo().CurrentOrgId, patient.ID, recordDateTime)
61
+	if patientPrescription.ID == 0 {
62
+		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(c.GetAdminUserInfo().CurrentOrgId, patient.ID, recordDateTime)
63
+	}
64
+	department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
65
+	doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, patientPrescription.DoctorId)
66
+
67
+	admin_user_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
68
+
69
+	reg := models.Reg{
70
+		DeptId:      department.Number,
71
+		PatientId:   patient.ZbPatientId,
72
+		PatientName: patient.Name,
73
+		DoctorId:    doctor_info.DoctorNumber,
74
+		RegDate:     strings.Split(diagnosis_time, " ")[0],
75
+		RegFee:      "0",
76
+		TreatFee:    "0",
77
+		OperatorId:  admin_user_info.UserName,
78
+	}
79
+
80
+	result, request_log := service.SaveReg(reg)
81
+	fmt.Println(result)
82
+	fmt.Println(request_log)
83
+
84
+	saveLog(result, request_log, "reg", "挂号")
85
+	var res ResultReg
86
+	if err := json.Unmarshal([]byte(result), &res); err != nil {
87
+		utils.ErrorLog("解析失败:%v", err)
88
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
89
+		return
90
+	}
91
+
92
+	timestamp := time.Now().Unix()
93
+	tempTime := time.Unix(timestamp, 0)
94
+	timeFormat := tempTime.Format("20060102150405")
95
+	chrgBchno := rand.Intn(100000) + 10000
96
+	ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
43
 
97
 
98
+	his := models.VMHisPatient{
99
+		Name:                   patient.Name,
100
+		Gender:                 patient.Gender,
101
+		Birthday:               patient.Birthday,
102
+		MedicalTreatmentType:   0,
103
+		IdType:                 1,
104
+		IdCardNo:               patient.IdCardNo,
105
+		BalanceAccountsType:    1,
106
+		SocialType:             0,
107
+		MedicalInsuranceNumber: "",
108
+		RegisterType:           0,
109
+		RegisterCost:           0,
110
+		TreatmentCost:          0,
111
+		Status:                 1,
112
+		Ctime:                  time.Now().Unix(),
113
+		Mtime:                  time.Now().Unix(),
114
+		PsnNo:                  patient.ZbPatientId,
115
+		PsnCertType:            "",
116
+		Certno:                 patient.IdCardNo,
117
+		PsnName:                patient.Name,
118
+		Gend:                   "",
119
+		Naty:                   "",
120
+		Brdy:                   "",
121
+		Age:                    0,
122
+		Iinfo:                  "",
123
+		Idetinfo:               "",
124
+		PatientId:              patient.ID,
125
+		RecordDate:             theTime.Unix(),
126
+		UserOrgId:              c.GetAdminUserInfo().CurrentOrgId,
127
+		AdminUserId:            admin_user_id,
128
+		IsReturn:               1,
129
+		IdCardType:             1,
130
+		Doctor:                 patientPrescription.DoctorId,
131
+		Departments:            patientPrescription.Departments,
132
+		IptOtpNo:               ipt_otp_no,
133
+		Number:                 res.InfoSeq,
134
+		PhoneNumber:            patient.Phone,
135
+	}
136
+	service.UpdateHisPatientStatus(&his)
137
+	service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, c.GetAdminUserInfo().CurrentOrgId)
138
+	c.ServeSuccessJSON(map[string]interface{}{
139
+		"his_info": his,
140
+	})
44
 }
141
 }
45
 
142
 
46
 func (c *CoordinateController) GetWaitPayDetail() {
143
 func (c *CoordinateController) GetWaitPayDetail() {
51
 }
148
 }
52
 
149
 
53
 func (c *CoordinateController) OpKeepAccounts() {
150
 func (c *CoordinateController) OpKeepAccounts() {
54
-	result, request_log := service.OpKeepAccounts()
55
-	fmt.Println(result)
56
-	fmt.Println(request_log)
151
+	//patient_id, _ := c.GetInt64("patient_id")
152
+	//diagnosis_time := c.GetString("diagnosis_time")
153
+	//record_date := c.GetString("record_date")
154
+	//admin_user_id, _ := c.GetInt64("admin_user_id")
155
+	//
156
+	//result, request_log := service.OpKeepAccounts()
157
+	//fmt.Println(result)
158
+	//fmt.Println(request_log)
57
 }
159
 }
58
 func (c *CoordinateController) OpCancelKeepAccounts() {
160
 func (c *CoordinateController) OpCancelKeepAccounts() {
59
 	result, request_log := service.OpCancelKeepAccounts()
161
 	result, request_log := service.OpCancelKeepAccounts()
60
 	fmt.Println(result)
162
 	fmt.Println(result)
61
 	fmt.Println(request_log)
163
 	fmt.Println(request_log)
62
 }
164
 }
165
+
166
+func saveLog(result string, request string, infno string, desc string) {
167
+
168
+	org_id, _ := beego.AppConfig.Int64("org_id")
169
+	miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
170
+	dir := miConfig.OrgName + "日志"
171
+	utils.Mkdir(dir)
172
+	month := time.Unix(1557042972, 0).Format("1")
173
+	year := time.Now().Format("2006")
174
+	month = time.Now().Format("01")
175
+	day := time.Now().Format("02")
176
+	hour := time.Now().Format("15")
177
+	min := time.Now().Format("04")
178
+	sec := time.Now().Format("05")
179
+
180
+	result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
181
+
182
+	file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
183
+	file_name := file + ".txt"
184
+	file_path := miConfig.OrgName + "日志" + "/" + file_name
185
+	exist, _ := utils.PathExists(file_path)
186
+	if exist { //存在
187
+		fmt.Println("存在")
188
+		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
189
+		if err != nil {
190
+			fmt.Println("read fail")
191
+		}
192
+		content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
193
+		n, _ := f.Seek(0, 2)
194
+		_, err = f.WriteAt([]byte(content), n)
195
+
196
+	} else { //不存在
197
+		fmt.Println("文件不存在,创建文件")
198
+		f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
199
+		defer f.Close()
200
+		if err != nil {
201
+		} else {
202
+			_, err = f.Write([]byte("记录日志"))
203
+		}
204
+	}
205
+
206
+}
207
+
208
+type Charset string
209
+
210
+const (
211
+	UTF8    = Charset("UTF-8")
212
+	GB18030 = Charset("GB18030")
213
+)

+ 1 - 0
controllers/sg/his_api_controller.go View File

3851
 	if patientPrescription.ID == 0 {
3851
 	if patientPrescription.ID == 0 {
3852
 		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
3852
 		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
3853
 	}
3853
 	}
3854
+
3854
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
3855
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
3855
 	if patient.ID == 0 {
3856
 	if patient.ID == 0 {
3856
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
3857
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)

+ 1 - 0
models/patient_models.go View File

115
 	UserSysBeforeCount       int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
115
 	UserSysBeforeCount       int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
116
 	IsExcelExport            int64  `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
116
 	IsExcelExport            int64  `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
117
 	SchRemark                string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
117
 	SchRemark                string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
118
+	ZbPatientId              string `gorm:"column:zb_patient_id" json:"zb_patient_id" form:"zb_patient_id"`
118
 
119
 
119
 	ContagionIds []int64 `gorm:"-"`
120
 	ContagionIds []int64 `gorm:"-"`
120
 	DryWeight    float64 `gorm:"-"`
121
 	DryWeight    float64 `gorm:"-"`