|
@@ -1,12 +1,12 @@
|
1
|
1
|
package coordinate
|
2
|
2
|
|
3
|
3
|
import (
|
|
4
|
+ "XT_New/enums"
|
|
5
|
+ "XT_New/models"
|
|
6
|
+ "XT_New/service"
|
4
|
7
|
"encoding/json"
|
5
|
8
|
"fmt"
|
6
|
9
|
"gdyb/controllers"
|
7
|
|
- "gdyb/enums"
|
8
|
|
- "gdyb/models"
|
9
|
|
- "gdyb/service"
|
10
|
10
|
"gdyb/utils"
|
11
|
11
|
"github.com/astaxie/beego"
|
12
|
12
|
"math/rand"
|
|
@@ -16,6 +16,37 @@ import (
|
16
|
16
|
"time"
|
17
|
17
|
)
|
18
|
18
|
|
|
19
|
+type ResultUpload struct {
|
|
20
|
+ Code string `json:"code"`
|
|
21
|
+ Msg string `json:"msg"`
|
|
22
|
+ Result []struct {
|
|
23
|
+ List []interface{} `json:"list"`
|
|
24
|
+ Page int64 `json:"page"`
|
|
25
|
+ Pagenumber int64 `json:"pagenumber"`
|
|
26
|
+ Records int64 `json:"records"`
|
|
27
|
+ RecordsFiltered int64 `json:"recordsFiltered"`
|
|
28
|
+ RecordsTotal int64 `json:"recordsTotal"`
|
|
29
|
+ Result string `json:"result"`
|
|
30
|
+ ResultMsg string `json:"resultMsg"`
|
|
31
|
+ Total int64 `json:"total"`
|
|
32
|
+ TotalPage int64 `json:"totalPage"`
|
|
33
|
+ Userdata string `json:"userdata"`
|
|
34
|
+ Code string `json:"code"`
|
|
35
|
+ } `json:"result"`
|
|
36
|
+}
|
|
37
|
+
|
|
38
|
+type ResultQuery struct {
|
|
39
|
+ Msg string `json:"msg"`
|
|
40
|
+ Result []struct {
|
|
41
|
+ Type string `json:"type"`
|
|
42
|
+ Name string `json:"name"`
|
|
43
|
+ Vaa01 int `json:"vaa01"`
|
|
44
|
+ Vaa07 int `json:"vaa07"`
|
|
45
|
+ Visittime string `json:"visittime"`
|
|
46
|
+ } `json:"result"`
|
|
47
|
+ Code string `json:"code"`
|
|
48
|
+}
|
|
49
|
+
|
19
|
50
|
type CoordinateController struct {
|
20
|
51
|
controllers.BaseAuthAPIController
|
21
|
52
|
}
|
|
@@ -27,147 +58,486 @@ type ResultReg struct {
|
27
|
58
|
}
|
28
|
59
|
|
29
|
60
|
func CoordinateRegistRouters() {
|
30
|
|
- beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
|
31
|
|
- beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
|
32
|
|
- beego.Router("/coordinate/getWaitPayDetail", &CoordinateController{}, "get:GetWaitPayDetail")
|
33
|
|
- beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
|
34
|
|
- beego.Router("/coordinate/opCancelKeepAccounts", &CoordinateController{}, "get:OpCancelKeepAccounts")
|
|
61
|
+ beego.Router("/coordinate/settleAccount", &CoordinateController{}, "get:SettleAccount")
|
35
|
62
|
|
36
|
63
|
}
|
37
|
64
|
|
38
|
|
-func (c *CoordinateController) SavePatientMessageInfo() {
|
39
|
|
- //result, request_log := service.SavePatientMessageInfo()
|
40
|
|
-
|
41
|
|
-}
|
42
|
|
-
|
43
|
|
-func (c *CoordinateController) Register() {
|
|
65
|
+func (c *CoordinateController) SettleAccount() {
|
44
|
66
|
patient_id, _ := c.GetInt64("patient_id")
|
45
|
|
- diagnosis_time := c.GetString("diagnosis_time")
|
46
|
67
|
record_date := c.GetString("record_date")
|
47
|
68
|
admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
69
|
+ diagnosis_id := c.GetString("diagnosis")
|
|
70
|
+ sick_type, _ := c.GetInt64("sick_type")
|
|
71
|
+ reg_type, _ := c.GetInt64("p_type")
|
|
72
|
+ org_id, _ := c.GetInt64("org_id")
|
|
73
|
+ org_id = 10340
|
|
74
|
+ org, _ := service.GetOrgById(org_id)
|
|
75
|
+ patient, _ := service.GetPatientByID(org.Id, patient_id)
|
|
76
|
+ settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
|
48
|
77
|
|
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
|
|
78
|
+ result, request := service.GetHisPatientForCoordinate(patient.IdCardNo)
|
|
79
|
+ saveLog(result, request, "查询", "查询", org.OrgName)
|
|
80
|
+ var res ResultQuery
|
86
|
81
|
if err := json.Unmarshal([]byte(result), &res); err != nil {
|
87
|
82
|
utils.ErrorLog("解析失败:%v", err)
|
88
|
83
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
89
|
84
|
return
|
90
|
85
|
}
|
|
86
|
+ if res.Code == "10000" {
|
|
87
|
+ if len(res.Result) == 0 {
|
|
88
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientNoRegException)
|
|
89
|
+ return
|
|
90
|
+ }
|
|
91
|
+ timeLayout := "2006-01-02"
|
|
92
|
+ loc, _ := time.LoadLocation("Local")
|
|
93
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
94
|
+ if err != nil {
|
|
95
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
96
|
+ return
|
|
97
|
+ }
|
|
98
|
+ org_id := org.Id
|
|
99
|
+ recordDateTime := theTime.Unix()
|
|
100
|
+ patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
|
|
101
|
+ if patientPrescription.ID == 0 {
|
|
102
|
+ patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
|
|
103
|
+ }
|
|
104
|
+ departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
|
105
|
+ doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
|
|
106
|
+ //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
|
91
|
107
|
|
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)
|
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
|
|
- })
|
141
|
|
-}
|
|
108
|
+ var prescriptions []*models.HisPrescription
|
142
|
109
|
|
143
|
|
-func (c *CoordinateController) GetWaitPayDetail() {
|
144
|
|
- result, request_log := service.GetWaitPayDetail()
|
145
|
|
- fmt.Println(result)
|
146
|
|
- fmt.Println(request_log)
|
|
110
|
+ if settle_accounts_type == 1 { //日结
|
|
111
|
+ prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, patient_id, recordDateTime, 2)
|
|
112
|
+ } else { //月结
|
147
|
113
|
|
148
|
|
-}
|
|
114
|
+ start_time_str := c.GetString("start_time")
|
|
115
|
+ end_time_str := c.GetString("end_time")
|
|
116
|
+ timeLayout := "2006-01-02"
|
|
117
|
+ loc, _ := time.LoadLocation("Local")
|
|
118
|
+ theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
|
|
119
|
+ if err != nil {
|
|
120
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
121
|
+ return
|
|
122
|
+ }
|
|
123
|
+ recordStartTime := theStartTime.Unix()
|
|
124
|
+ theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
|
|
125
|
+ if err != nil {
|
|
126
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
127
|
+ return
|
|
128
|
+ }
|
|
129
|
+ recordEndTime := theEndTime.Unix()
|
|
130
|
+ prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
|
|
131
|
+ }
|
|
132
|
+ var total float64
|
|
133
|
+
|
|
134
|
+ for _, item := range prescriptions {
|
|
135
|
+ fmt.Println(item)
|
|
136
|
+ if item.Type == 1 { //药品
|
|
137
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
138
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
139
|
+ }
|
|
140
|
+ }
|
|
141
|
+ if item.Type == 2 { //项目
|
|
142
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
143
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
144
|
+ total = total + (subItem.Price * cnt)
|
|
145
|
+ }
|
|
146
|
+ }
|
|
147
|
+
|
|
148
|
+ }
|
|
149
|
+
|
|
150
|
+ var ids []int64
|
|
151
|
+
|
|
152
|
+ for _, item := range prescriptions {
|
|
153
|
+ ids = append(ids, item.ID)
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ var customs []*models.NewCustomTwo
|
|
157
|
+ for _, item := range prescriptions {
|
|
158
|
+ if item.Type == 1 { //药品
|
|
159
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
160
|
+ cus := &models.NewCustomTwo{
|
|
161
|
+ AdviceId: subItem.ID,
|
|
162
|
+ ProjectId: 0,
|
|
163
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
|
|
164
|
+ Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
|
|
165
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
166
|
+ Price: fmt.Sprintf("%.2f", subItem.Price),
|
|
167
|
+ MedListCodg: subItem.Drug.MedicalInsuranceNumber,
|
|
168
|
+ Type: 1,
|
|
169
|
+ }
|
|
170
|
+ customs = append(customs, cus)
|
|
171
|
+ }
|
|
172
|
+ }
|
|
173
|
+ if item.Type == 2 { //项目
|
|
174
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
175
|
+ if subItem.Type == 2 {
|
|
176
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
177
|
+ cus := &models.NewCustomTwo{
|
|
178
|
+ AdviceId: 0,
|
|
179
|
+ ProjectId: subItem.ID,
|
|
180
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
|
|
181
|
+ Cut: fmt.Sprintf("%.4f", cnt),
|
|
182
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
183
|
+ Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
|
|
184
|
+ MedListCodg: subItem.HisProject.MedicalCode,
|
|
185
|
+ Type: 2,
|
|
186
|
+ }
|
|
187
|
+ customs = append(customs, cus)
|
|
188
|
+
|
|
189
|
+ } else {
|
|
190
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
|
191
|
+ cus := &models.NewCustomTwo{
|
|
192
|
+ AdviceId: 0,
|
|
193
|
+ ProjectId: subItem.ID,
|
|
194
|
+ DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
|
|
195
|
+ Cut: fmt.Sprintf("%.4f", cnt),
|
|
196
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
197
|
+ Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
|
|
198
|
+ MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
|
|
199
|
+ Type: 3,
|
|
200
|
+ }
|
|
201
|
+ customs = append(customs, cus)
|
|
202
|
+ }
|
|
203
|
+
|
|
204
|
+ }
|
|
205
|
+ }
|
|
206
|
+ }
|
|
207
|
+
|
|
208
|
+ var info models.UploadInfo
|
|
209
|
+ info.Vaa01 = res.Result[0].Vaa01
|
|
210
|
+ info.Fasong = "1"
|
|
211
|
+ info.Vaa07 = res.Result[0].Vaa07
|
|
212
|
+ info.Bck01c = departmwnt.Number
|
|
213
|
+ info.Bce02a = doctor_info.DoctorNumber
|
|
214
|
+
|
|
215
|
+ diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
|
|
216
|
+ var config []*models.HisXtDiagnoseConfig
|
|
217
|
+ for _, item := range diagnosis_ids {
|
|
218
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
219
|
+ diagnosisConfig, _ := service.FindDiagnoseById(id)
|
|
220
|
+ config = append(config, diagnosisConfig)
|
|
221
|
+ }
|
|
222
|
+ for index, item := range config {
|
|
223
|
+ var diag models.Diag
|
|
224
|
+ diag.Vao06 = strconv.FormatInt(int64(index+1), 10)
|
|
225
|
+ diag.Bak02 = item.CountryCode
|
|
226
|
+ info.Diag = append(info.Diag, &diag)
|
|
227
|
+ }
|
|
228
|
+ var presInfos []*models.PresInfo
|
|
229
|
+ var presDetails []*models.PresDetail
|
|
230
|
+ for index, item := range prescriptions {
|
|
231
|
+ var presDetail models.PresDetail
|
|
232
|
+ var presInfo models.PresInfo
|
|
233
|
+ presInfo.Cbmid = strconv.FormatInt(item.ID, 10)
|
|
234
|
+ if item.Type == 1 {
|
|
235
|
+ presInfo.Cbm06 = "0"
|
|
236
|
+ } else {
|
|
237
|
+ presInfo.Cbm06 = "5"
|
|
238
|
+ }
|
|
239
|
+
|
|
240
|
+ if item.Type == 1 {
|
|
241
|
+ presInfo.Cbm07 = item.MedType
|
|
242
|
+ } else {
|
|
243
|
+ presInfo.Cbm07 = item.MedType
|
|
244
|
+ }
|
|
245
|
+
|
|
246
|
+ presDetail.Vaf59 = strconv.FormatInt(int64(index+1), 10)
|
|
247
|
+ var infoItems []*models.Item
|
|
248
|
+ for index, subItem := range item.HisDoctorAdviceInfo {
|
|
249
|
+ ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
|
|
250
|
+
|
|
251
|
+ var infoItem models.Item
|
|
252
|
+ infoItem.Rownr = strconv.FormatInt(int64(index+1), 10)
|
|
253
|
+ infoItem.Vaf11 = "2"
|
|
254
|
+ infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
|
|
255
|
+ infoItem.Bbx01 = subItem.Drug.MedicalInsuranceNumber
|
|
256
|
+ infoItem.Bda01 = "1"
|
|
257
|
+ infoItem.Bby01 = ""
|
|
258
|
+ if subItem.Drug.MinUnit != subItem.Drug.DoseUnit {
|
|
259
|
+ infoItem.Vaf22 = subItem.Drug.DrugName + " " + subItem.Drug.Dose + subItem.Drug.DoseUnit + "*" + strconv.FormatInt(subItem.Drug.MinNumber, 10) + subItem.Drug.MinUnit + "/" + subItem.Drug.MaxUnit
|
|
260
|
+ }
|
|
261
|
+ infoItem.Vaf14 = subItem.Drug.DrugName
|
|
262
|
+ infoItem.Bdi01 = ef.Code
|
|
263
|
+ infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10)
|
|
264
|
+ infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
|
|
265
|
+ infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
|
|
266
|
+ infoItem.Vaf35 = "0"
|
|
267
|
+ infoItem.Vaf32 = "0"
|
|
268
|
+ infoItem.Bck01b = departmwnt.Number
|
|
269
|
+ infoItem.Bck01d = departmwnt.Number
|
|
270
|
+ infoItem.Vaf58 = "0"
|
|
271
|
+ infoItem.Vaf61 = "1"
|
|
272
|
+ infoItems = append(infoItems, &infoItem)
|
|
273
|
+ }
|
|
274
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
275
|
+ //ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
|
|
276
|
+
|
|
277
|
+ if subItem.Type == 2 {
|
|
278
|
+ if subItem.HisProject.CostClassify == 10 {
|
|
279
|
+ var infoItem models.Item
|
|
280
|
+ infoItem.Rownr = "0"
|
|
281
|
+ infoItem.Vaf11 = "2"
|
|
282
|
+ infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
|
|
283
|
+ infoItem.Bbx01 = subItem.HisProject.MedicalCode
|
|
284
|
+ infoItem.Bda01 = "Z"
|
|
285
|
+ infoItem.Bby01 = ""
|
|
286
|
+ infoItem.Vaf14 = subItem.HisProject.ProjectName
|
|
287
|
+ infoItem.Vaf15 = subItem.HisProject.ProjectName
|
|
288
|
+ infoItem.Bdi01 = "160"
|
|
289
|
+ infoItem.Vaf17 = subItem.Day
|
|
290
|
+ infoItem.Vaf20 = subItem.SingleDose
|
|
291
|
+ infoItem.Vaf21 = subItem.Count
|
|
292
|
+ infoItem.Vaf35 = "0"
|
|
293
|
+ infoItem.Vaf18 = 0
|
|
294
|
+ infoItem.Vaf32 = "1"
|
|
295
|
+ infoItem.Bck01b = departmwnt.Number
|
|
296
|
+ infoItem.Bck01d = departmwnt.Number
|
|
297
|
+ infoItem.Vaf58 = "0"
|
|
298
|
+ infoItem.Vaf61 = "1"
|
|
299
|
+ infoItems = append(infoItems, &infoItem)
|
|
300
|
+
|
|
301
|
+ } else {
|
|
302
|
+
|
|
303
|
+ var infoItem models.Item
|
|
304
|
+ infoItem.Rownr = "0"
|
|
305
|
+ infoItem.Vaf11 = "1"
|
|
306
|
+ infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
|
|
307
|
+ infoItem.Bbx01 = subItem.HisProject.MedicalCode
|
|
308
|
+
|
|
309
|
+ if subItem.HisProject.CostClassify == 2 {
|
|
310
|
+ infoItem.Bda01 = "T"
|
|
311
|
+ } else if subItem.HisProject.CostClassify == 3 {
|
|
312
|
+ infoItem.Bda01 = "L"
|
|
313
|
+ } else {
|
|
314
|
+ infoItem.Bda01 = "T"
|
|
315
|
+ }
|
|
316
|
+ infoItem.Bby01 = ""
|
|
317
|
+ infoItem.Vaf14 = subItem.HisProject.ProjectName
|
|
318
|
+
|
|
319
|
+ infoItem.Bdi01 = "160"
|
|
320
|
+ infoItem.Vaf17 = subItem.Day
|
|
321
|
+ infoItem.Vaf20 = subItem.SingleDose
|
|
322
|
+ infoItem.Vaf21 = subItem.Count
|
|
323
|
+ infoItem.Vaf35 = "0"
|
|
324
|
+ infoItem.Vaf18 = 0
|
|
325
|
+ infoItem.Vaf32 = "0"
|
|
326
|
+ infoItem.Bck01b = departmwnt.Number
|
|
327
|
+ infoItem.Bck01d = departmwnt.Number
|
|
328
|
+ infoItem.Vaf58 = "0"
|
|
329
|
+ infoItem.Vaf61 = "1"
|
|
330
|
+ infoItems = append(infoItems, &infoItem)
|
|
331
|
+
|
|
332
|
+ }
|
|
333
|
+
|
|
334
|
+ } else {
|
|
335
|
+ var infoItem models.Item
|
|
336
|
+ infoItem.Rownr = "0"
|
|
337
|
+ infoItem.Vaf11 = "1"
|
|
338
|
+ infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
|
|
339
|
+ infoItem.Bbx01 = subItem.GoodInfo.MedicalInsuranceNumber
|
|
340
|
+ infoItem.Bda01 = "M"
|
|
341
|
+ infoItem.Bby01 = ""
|
|
342
|
+ infoItem.Vaf14 = subItem.GoodInfo.GoodName + " " + subItem.GoodInfo.SpecificationName
|
|
343
|
+ infoItem.Bdi01 = "160"
|
|
344
|
+ infoItem.Vaf17 = subItem.Day
|
|
345
|
+ infoItem.Vaf20 = subItem.SingleDose
|
|
346
|
+ infoItem.Vaf21 = subItem.Count
|
|
347
|
+ infoItem.Vaf35 = "0"
|
|
348
|
+ infoItem.Vaf32 = "0"
|
|
349
|
+ infoItem.Bck01b = departmwnt.Number
|
|
350
|
+ infoItem.Bck01d = departmwnt.Number
|
|
351
|
+ infoItem.Vaf58 = "0"
|
|
352
|
+ infoItem.Vaf61 = "1"
|
|
353
|
+ infoItems = append(infoItems, &infoItem)
|
|
354
|
+
|
|
355
|
+ }
|
|
356
|
+
|
|
357
|
+ }
|
|
358
|
+ presDetail.Item = infoItems
|
|
359
|
+ presDetails = append(presDetails, &presDetail)
|
|
360
|
+ presInfo.PresDetail = presDetails
|
|
361
|
+ presInfos = append(presInfos, &presInfo)
|
|
362
|
+ }
|
|
363
|
+ info.PresInfo = presInfos
|
|
364
|
+ var result2 string
|
|
365
|
+ var request2 string
|
|
366
|
+ if res.Result[0].Type == "1" {
|
|
367
|
+ result2, request2 = service.UploadPrescriptionForCoordinate(info)
|
|
368
|
+ } else {
|
|
369
|
+ result2, request2 = service.UploadPrescriptionForCoordinateHospital(info)
|
|
370
|
+ }
|
|
371
|
+ saveLog(result2, request2, "上传明细", "上传明细", org.OrgName)
|
|
372
|
+
|
|
373
|
+ var res2 ResultUpload
|
|
374
|
+ if err := json.Unmarshal([]byte(result2), &res2); err != nil {
|
|
375
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
376
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
377
|
+ return
|
|
378
|
+ }
|
|
379
|
+ if res2.Code == "10000" && len(res2.Result) > 0 && res2.Result[0].Code != "500" && len(res2.Result[0].List) > 0 {
|
|
380
|
+
|
|
381
|
+ timestamp := time.Now().Unix()
|
|
382
|
+ tempTime := time.Unix(timestamp, 0)
|
|
383
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
384
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
385
|
+ ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
|
|
386
|
+ his := models.VMHisPatient{
|
|
387
|
+ Name: patient.Name,
|
|
388
|
+ Gender: patient.Gender,
|
|
389
|
+ Birthday: patient.Birthday,
|
|
390
|
+ MedicalTreatmentType: 0,
|
|
391
|
+ IdType: 1,
|
|
392
|
+ IdCardNo: patient.IdCardNo,
|
|
393
|
+ BalanceAccountsType: 1,
|
|
394
|
+ MedicalInsuranceNumber: "",
|
|
395
|
+ RegisterType: 0,
|
|
396
|
+ RegisterCost: 0,
|
|
397
|
+ TreatmentCost: 0,
|
|
398
|
+ Status: 1,
|
|
399
|
+ Ctime: time.Now().Unix(),
|
|
400
|
+ Mtime: time.Now().Unix(),
|
|
401
|
+ PsnNo: strconv.FormatInt(int64(res.Result[0].Vaa01), 10),
|
|
402
|
+ PsnCertType: "",
|
|
403
|
+ Certno: patient.IdCardNo,
|
|
404
|
+ PsnName: patient.Name,
|
|
405
|
+ Gend: "",
|
|
406
|
+ Naty: "",
|
|
407
|
+ Brdy: "",
|
|
408
|
+ Age: 0,
|
|
409
|
+ Iinfo: "",
|
|
410
|
+ Idetinfo: "",
|
|
411
|
+ PatientId: patient.ID,
|
|
412
|
+ RecordDate: theTime.Unix(),
|
|
413
|
+ UserOrgId: org_id,
|
|
414
|
+ AdminUserId: admin_user_id,
|
|
415
|
+ IsReturn: 1,
|
|
416
|
+ Doctor: patientPrescription.DoctorId,
|
|
417
|
+ Departments: patientPrescription.Departments,
|
|
418
|
+ IptOtpNo: ipt_otp_no,
|
|
419
|
+ Number: strconv.FormatInt(int64(res.Result[0].Vaa07), 10),
|
|
420
|
+ PhoneNumber: patient.Phone,
|
|
421
|
+ }
|
|
422
|
+ service.UpdateHisPatientStatus(&his)
|
|
423
|
+ service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
|
|
424
|
+ tm := time.Unix(time.Now().Unix(), 0)
|
|
425
|
+
|
|
426
|
+ order := &models.HisOrder{
|
|
427
|
+ PsnNo: his.PsnNo,
|
|
428
|
+ UserOrgId: org_id,
|
|
429
|
+ HisPatientId: his.ID,
|
|
430
|
+ PatientId: patient_id,
|
|
431
|
+ SettleAccountsDate: recordDateTime,
|
|
432
|
+ Ctime: time.Now().Unix(),
|
|
433
|
+ Mtime: time.Now().Unix(),
|
|
434
|
+ Status: 1,
|
|
435
|
+ OrderStatus: 1,
|
|
436
|
+ MdtrtId: his.Number,
|
|
437
|
+ Number: ipt_otp_no,
|
|
438
|
+ SetlId: "",
|
|
439
|
+ MedfeeSumamt: total,
|
|
440
|
+ MedType: strconv.Itoa(int(reg_type)),
|
|
441
|
+ SettleEndTime: 0,
|
|
442
|
+ SettleStartTime: 0,
|
|
443
|
+ SettleType: settle_accounts_type,
|
|
444
|
+ Diagnosis: diagnosis_id,
|
|
445
|
+ PType: 2,
|
|
446
|
+ SetlTime: tm.Format("2006-01-02 15:04:05"),
|
|
447
|
+ }
|
|
448
|
+ err = service.CreateOrder(order)
|
|
449
|
+ if err != nil {
|
|
450
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
|
451
|
+ return
|
|
452
|
+ }
|
|
453
|
+
|
|
454
|
+ for _, item := range customs {
|
|
455
|
+ var advice_id int64 = 0
|
|
456
|
+ var project_id int64 = 0
|
|
457
|
+ var item_id int64 = 0
|
|
458
|
+
|
|
459
|
+ var types int64 = 0
|
|
460
|
+
|
|
461
|
+ if item.Type == 1 {
|
|
462
|
+ advice_id = item.AdviceId
|
|
463
|
+ project_id = 0
|
|
464
|
+ item_id = 0
|
|
465
|
+ } else if item.Type == 2 {
|
|
466
|
+ advice_id = 0
|
|
467
|
+ item_id = 0
|
|
468
|
+
|
|
469
|
+ project_id = item.ProjectId
|
|
470
|
+ } else if item.Type == 3 {
|
|
471
|
+ advice_id = 0
|
|
472
|
+ item_id = item.ItemId
|
|
473
|
+ project_id = 0
|
|
474
|
+ }
|
|
475
|
+ detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
|
|
476
|
+ cut, _ := strconv.ParseFloat(item.Cut, 32)
|
|
477
|
+ pric, _ := strconv.ParseFloat(item.Price, 32)
|
|
478
|
+ info := &models.HisOrderInfo{
|
|
479
|
+ OrderNumber: order.Number,
|
|
480
|
+ UploadDate: time.Now().Unix(),
|
|
481
|
+ AdviceId: advice_id,
|
|
482
|
+ DetItemFeeSumamt: detItemFeeSumamt,
|
|
483
|
+ Cnt: cut,
|
|
484
|
+ Pric: pric,
|
|
485
|
+ PatientId: patient_id,
|
|
486
|
+ Status: 1,
|
|
487
|
+ Mtime: time.Now().Unix(),
|
|
488
|
+ Ctime: time.Now().Unix(),
|
|
489
|
+ UserOrgId: org_id,
|
|
490
|
+ HisPatientId: his.ID,
|
|
491
|
+ OrderId: order.ID,
|
|
492
|
+ ProjectId: project_id,
|
|
493
|
+ Type: types,
|
|
494
|
+ ItemId: item_id,
|
|
495
|
+ }
|
|
496
|
+ service.CreateOrderInfo(info)
|
|
497
|
+ }
|
|
498
|
+ his.Diagnosis = diagnosis_id
|
|
499
|
+ his.SickType = sick_type
|
|
500
|
+ his.RegisterType = reg_type
|
|
501
|
+ his.MedicalTreatmentType = reg_type
|
|
502
|
+ service.UpdataHisPateintTwo(&his)
|
|
503
|
+ err = service.UpDatePrescriptionNumber(org_id, ids, order.Number)
|
|
504
|
+ err = service.UpDateHisPrescriptionInfoNumber(org_id, patient_id, order.Number, recordDateTime, his.ID)
|
|
505
|
+ err = service.UpdataOrderStatusThree(strconv.FormatInt(int64(chrgBchno), 10), org_id)
|
|
506
|
+
|
|
507
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
508
|
+ "msg": "医嘱保存成功",
|
|
509
|
+ })
|
|
510
|
+
|
|
511
|
+ } else {
|
|
512
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
513
|
+ "failed_code": -10,
|
|
514
|
+ "msg": res2.Msg + "----" + res2.Result[0].ResultMsg,
|
|
515
|
+ })
|
|
516
|
+
|
|
517
|
+ }
|
|
518
|
+
|
|
519
|
+ } else {
|
|
520
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
521
|
+ "failed_code": -10,
|
|
522
|
+ "msg": res.Msg,
|
|
523
|
+ })
|
|
524
|
+
|
|
525
|
+ }
|
149
|
526
|
|
150
|
|
-func (c *CoordinateController) OpKeepAccounts() {
|
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)
|
159
|
|
-}
|
160
|
|
-func (c *CoordinateController) OpCancelKeepAccounts() {
|
161
|
|
- result, request_log := service.OpCancelKeepAccounts()
|
162
|
|
- fmt.Println(result)
|
163
|
|
- fmt.Println(request_log)
|
164
|
527
|
}
|
165
|
528
|
|
166
|
|
-func saveLog(result string, request string, infno string, desc string) {
|
|
529
|
+type Charset string
|
|
530
|
+
|
|
531
|
+const (
|
|
532
|
+ UTF8 = Charset("UTF-8")
|
|
533
|
+ GB18030 = Charset("GB18030")
|
|
534
|
+)
|
|
535
|
+
|
|
536
|
+func saveLog(result string, request string, infno string, desc string, org_name string) {
|
167
|
537
|
|
168
|
|
- org_id, _ := beego.AppConfig.Int64("org_id")
|
169
|
|
- miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
|
170
|
|
- dir := miConfig.OrgName + "日志"
|
|
538
|
+ //org_id, _ := beego.AppConfig.Int64("org_id")
|
|
539
|
+ //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
|
|
540
|
+ dir := org_name + "日志"
|
171
|
541
|
utils.Mkdir(dir)
|
172
|
542
|
month := time.Unix(1557042972, 0).Format("1")
|
173
|
543
|
year := time.Now().Format("2006")
|
|
@@ -179,9 +549,9 @@ func saveLog(result string, request string, infno string, desc string) {
|
179
|
549
|
|
180
|
550
|
result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
|
181
|
551
|
|
182
|
|
- file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
|
|
552
|
+ file := org_name + "_" + year + month + day + "_log"
|
183
|
553
|
file_name := file + ".txt"
|
184
|
|
- file_path := miConfig.OrgName + "日志" + "/" + file_name
|
|
554
|
+ file_path := org_name + "日志" + "/" + file_name
|
185
|
555
|
exist, _ := utils.PathExists(file_path)
|
186
|
556
|
if exist { //存在
|
187
|
557
|
fmt.Println("存在")
|
|
@@ -195,7 +565,7 @@ func saveLog(result string, request string, infno string, desc string) {
|
195
|
565
|
|
196
|
566
|
} else { //不存在
|
197
|
567
|
fmt.Println("文件不存在,创建文件")
|
198
|
|
- f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
|
|
568
|
+ f, err := os.Create(org_name + "日志" + "/" + file_name)
|
199
|
569
|
defer f.Close()
|
200
|
570
|
if err != nil {
|
201
|
571
|
} else {
|
|
@@ -204,10 +574,3 @@ func saveLog(result string, request string, infno string, desc string) {
|
204
|
574
|
}
|
205
|
575
|
|
206
|
576
|
}
|
207
|
|
-
|
208
|
|
-type Charset string
|
209
|
|
-
|
210
|
|
-const (
|
211
|
|
- UTF8 = Charset("UTF-8")
|
212
|
|
- GB18030 = Charset("GB18030")
|
213
|
|
-)
|