|
@@ -91,180 +91,181 @@ func (c *HisHospitalApiController) GetUploadInfo() {
|
91
|
91
|
for _, item := range prescriptions {
|
92
|
92
|
ids = append(ids, item.ID)
|
93
|
93
|
}
|
94
|
|
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
95
|
|
- if config.IsOpen == 1 { //对接了医保,走医保流程
|
96
|
|
-
|
97
|
|
- var customs []*models.NewCustom
|
98
|
|
-
|
99
|
|
- for _, item := range prescriptions {
|
100
|
|
- tm := time.Unix(item.PreTime, 0)
|
101
|
|
- if item.Type == 1 { //药品
|
102
|
|
- for _, subItem := range item.HisDoctorAdviceInfo {
|
103
|
|
- if len(subItem.Drug.MedicalInsuranceNumber) > 0 && subItem.Drug.IsUser != 1 {
|
104
|
|
- //var randNum int
|
105
|
|
- //randNum = rand.Intn(10000) + 1000
|
|
94
|
+ //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
|
95
|
+
|
|
96
|
+ var customs []*models.NewCustom
|
|
97
|
+
|
|
98
|
+ for _, item := range prescriptions {
|
|
99
|
+ tm := time.Unix(item.PreTime, 0)
|
|
100
|
+ if item.Type == 1 { //药品
|
|
101
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
102
|
+ if len(subItem.Drug.MedicalInsuranceNumber) > 0 && subItem.Drug.IsUser != 1 {
|
|
103
|
+ //var randNum int
|
|
104
|
+ //randNum = rand.Intn(10000) + 1000
|
|
105
|
+ cus := &models.NewCustom{
|
|
106
|
+ DetItemFeeSumamt: subItem.Price * subItem.PrescribingNumber,
|
|
107
|
+ Cut: subItem.PrescribingNumber,
|
|
108
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
109
|
+ Price: subItem.Price,
|
|
110
|
+ MedListCodg: subItem.Drug.MedicalInsuranceNumber,
|
|
111
|
+ HospApprFlag: subItem.Drug.HospApprFlag,
|
|
112
|
+ FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ customs = append(customs, cus)
|
|
116
|
+ }
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+
|
|
120
|
+ if item.Type == 2 { //项目
|
|
121
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
122
|
+ if subItem.Type == 2 {
|
|
123
|
+ if len(subItem.HisProject.MedicalCode) > 0 {
|
|
124
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
106
|
125
|
cus := &models.NewCustom{
|
107
|
|
- DetItemFeeSumamt: subItem.Price * subItem.PrescribingNumber,
|
108
|
|
- Cut: subItem.PrescribingNumber,
|
|
126
|
+ DetItemFeeSumamt: subItem.Price * cnt,
|
|
127
|
+ Cut: cnt,
|
109
|
128
|
FeedetlSn: subItem.FeedetlSn,
|
110
|
|
- Price: subItem.Price,
|
111
|
|
- MedListCodg: subItem.Drug.MedicalInsuranceNumber,
|
112
|
|
- HospApprFlag: subItem.Drug.HospApprFlag,
|
|
129
|
+ Price: float64(subItem.Price),
|
|
130
|
+ MedListCodg: subItem.HisProject.MedicalCode,
|
|
131
|
+ HospApprFlag: -1,
|
113
|
132
|
FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
114
|
133
|
}
|
115
|
|
-
|
116
|
134
|
customs = append(customs, cus)
|
117
|
135
|
}
|
118
|
|
- }
|
119
|
|
- }
|
|
136
|
+ } else if subItem.Type == 3 {
|
|
137
|
+ if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
|
|
138
|
+ cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
120
|
139
|
|
121
|
|
- if item.Type == 2 { //项目
|
122
|
|
- for _, subItem := range item.HisPrescriptionProject {
|
123
|
|
- if subItem.Type == 2 {
|
124
|
|
- if len(subItem.HisProject.MedicalCode) > 0 {
|
125
|
|
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
126
|
|
- cus := &models.NewCustom{
|
127
|
|
- DetItemFeeSumamt: subItem.Price * cnt,
|
128
|
|
- Cut: cnt,
|
129
|
|
- FeedetlSn: subItem.FeedetlSn,
|
130
|
|
- Price: float64(subItem.Price),
|
131
|
|
- MedListCodg: subItem.HisProject.MedicalCode,
|
132
|
|
- HospApprFlag: -1,
|
133
|
|
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
134
|
|
- }
|
135
|
|
- customs = append(customs, cus)
|
136
|
|
- }
|
137
|
|
- } else if subItem.Type == 3 {
|
138
|
|
- if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
|
139
|
|
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
|
140
|
|
-
|
141
|
|
- cus := &models.NewCustom{
|
142
|
|
- DetItemFeeSumamt: subItem.Price * cnt,
|
143
|
|
- Cut: cnt,
|
144
|
|
- FeedetlSn: subItem.FeedetlSn,
|
145
|
|
- Price: float64(subItem.Price),
|
146
|
|
- MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
|
147
|
|
- HospApprFlag: -1,
|
148
|
|
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
149
|
|
- }
|
150
|
|
- customs = append(customs, cus)
|
|
140
|
+ cus := &models.NewCustom{
|
|
141
|
+ DetItemFeeSumamt: subItem.Price * cnt,
|
|
142
|
+ Cut: cnt,
|
|
143
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
144
|
+ Price: float64(subItem.Price),
|
|
145
|
+ MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
|
|
146
|
+ HospApprFlag: -1,
|
|
147
|
+ FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
|
151
|
148
|
}
|
|
149
|
+ customs = append(customs, cus)
|
152
|
150
|
}
|
153
|
151
|
}
|
154
|
152
|
}
|
155
|
|
-
|
156
|
153
|
}
|
157
|
154
|
|
158
|
|
- if settle_accounts_type == 1 {
|
159
|
|
- for _, subItem := range customs {
|
160
|
|
- temp := strings.Split(subItem.FeedetlSn, "-")
|
161
|
|
- var advice_id int64 = 0
|
162
|
|
- var project_id int64 = 0
|
163
|
|
- var types int64 = 0
|
164
|
|
-
|
165
|
|
- id, _ := strconv.ParseInt(temp[2], 10, 64)
|
166
|
|
- types, _ = strconv.ParseInt(temp[1], 10, 64)
|
167
|
|
-
|
168
|
|
- if temp[1] == "1" {
|
169
|
|
- advice_id = id
|
170
|
|
- project_id = 0
|
171
|
|
- } else if temp[1] == "2" {
|
172
|
|
- advice_id = 0
|
173
|
|
- project_id = id
|
174
|
|
- }
|
175
|
|
- info := &models.HisOrderInfo{
|
176
|
|
- OrderNumber: record.Number,
|
177
|
|
- FeedetlSn: subItem.FeedetlSn,
|
178
|
|
- UploadDate: recordDateTime,
|
179
|
|
- AdviceId: advice_id,
|
180
|
|
- DetItemFeeSumamt: subItem.DetItemFeeSumamt,
|
181
|
|
- Cnt: subItem.Cut,
|
182
|
|
- Pric: float64(subItem.Price),
|
183
|
|
- PatientId: record.PatientId,
|
184
|
|
- PricUplmtAmt: 0,
|
185
|
|
- SelfpayProp: 0,
|
186
|
|
- FulamtOwnpayAmt: 0,
|
187
|
|
- OverlmtAmt: 0,
|
188
|
|
- PreselfpayAmt: 0,
|
189
|
|
- Status: 1,
|
190
|
|
- Mtime: time.Now().Unix(),
|
191
|
|
- Ctime: time.Now().Unix(),
|
192
|
|
- UserOrgId: adminUser.CurrentOrgId,
|
193
|
|
- HisPatientId: record.ID,
|
194
|
|
- OrderId: 0,
|
195
|
|
- ProjectId: project_id,
|
196
|
|
- Type: types,
|
197
|
|
- SettleType: settle_accounts_type,
|
198
|
|
- }
|
199
|
|
- service.CreateOrderInfo(info)
|
200
|
|
- }
|
|
155
|
+ }
|
201
|
156
|
|
202
|
|
- err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
|
203
|
|
- service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
|
204
|
|
- service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
|
205
|
|
- if err == nil {
|
206
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
207
|
|
- "msg": "上传费用明细成功",
|
208
|
|
- })
|
209
|
|
- return
|
210
|
|
- } else {
|
211
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
212
|
|
- return
|
213
|
|
- }
|
|
157
|
+ fmt.Println(settle_accounts_type)
|
214
|
158
|
|
215
|
|
- } else {
|
|
159
|
+ if settle_accounts_type == 1 {
|
|
160
|
+ fmt.Println(customs)
|
|
161
|
+ for _, subItem := range customs {
|
|
162
|
+ temp := strings.Split(subItem.FeedetlSn, "-")
|
|
163
|
+ var advice_id int64 = 0
|
|
164
|
+ var project_id int64 = 0
|
|
165
|
+ var types int64 = 0
|
216
|
166
|
|
217
|
|
- for _, subItem := range customs {
|
218
|
|
- temp := strings.Split(subItem.FeedetlSn, "-")
|
219
|
|
- var advice_id int64 = 0
|
220
|
|
- var project_id int64 = 0
|
221
|
|
- var types int64 = 0
|
222
|
|
-
|
223
|
|
- id, _ := strconv.ParseInt(temp[2], 10, 64)
|
224
|
|
- types, _ = strconv.ParseInt(temp[1], 10, 64)
|
225
|
|
-
|
226
|
|
- if temp[1] == "1" {
|
227
|
|
- advice_id = id
|
228
|
|
- project_id = 0
|
229
|
|
- } else if temp[1] == "2" {
|
230
|
|
- advice_id = 0
|
231
|
|
- project_id = id
|
232
|
|
- }
|
233
|
|
- info := &models.HisOrderInfo{
|
234
|
|
- OrderNumber: record.Number,
|
235
|
|
- FeedetlSn: subItem.FeedetlSn,
|
236
|
|
- UploadDate: recordDateTime,
|
237
|
|
- AdviceId: advice_id,
|
238
|
|
- DetItemFeeSumamt: subItem.DetItemFeeSumamt,
|
239
|
|
- Cnt: subItem.Cut,
|
240
|
|
- Pric: float64(subItem.Price),
|
241
|
|
- PatientId: record.PatientId,
|
242
|
|
- PricUplmtAmt: 0,
|
243
|
|
- SelfpayProp: 0,
|
244
|
|
- FulamtOwnpayAmt: 0,
|
245
|
|
- OverlmtAmt: 0,
|
246
|
|
- PreselfpayAmt: 0,
|
247
|
|
- Status: 1,
|
248
|
|
- Mtime: time.Now().Unix(),
|
249
|
|
- Ctime: time.Now().Unix(),
|
250
|
|
- UserOrgId: adminUser.CurrentOrgId,
|
251
|
|
- HisPatientId: record.ID,
|
252
|
|
- OrderId: 0,
|
253
|
|
- ProjectId: project_id,
|
254
|
|
- Type: types,
|
255
|
|
- SettleType: settle_accounts_type,
|
256
|
|
- }
|
257
|
|
- service.CreateOrderInfo(info)
|
|
167
|
+ id, _ := strconv.ParseInt(temp[2], 10, 64)
|
|
168
|
+ types, _ = strconv.ParseInt(temp[1], 10, 64)
|
|
169
|
+
|
|
170
|
+ if temp[1] == "1" {
|
|
171
|
+ advice_id = id
|
|
172
|
+ project_id = 0
|
|
173
|
+ } else if temp[1] == "2" {
|
|
174
|
+ advice_id = 0
|
|
175
|
+ project_id = id
|
|
176
|
+ }
|
|
177
|
+ info := &models.HisOrderInfo{
|
|
178
|
+ OrderNumber: record.Number,
|
|
179
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
180
|
+ UploadDate: recordDateTime,
|
|
181
|
+ AdviceId: advice_id,
|
|
182
|
+ DetItemFeeSumamt: subItem.DetItemFeeSumamt,
|
|
183
|
+ Cnt: subItem.Cut,
|
|
184
|
+ Pric: float64(subItem.Price),
|
|
185
|
+ PatientId: record.PatientId,
|
|
186
|
+ PricUplmtAmt: 0,
|
|
187
|
+ SelfpayProp: 0,
|
|
188
|
+ FulamtOwnpayAmt: 0,
|
|
189
|
+ OverlmtAmt: 0,
|
|
190
|
+ PreselfpayAmt: 0,
|
|
191
|
+ Status: 1,
|
|
192
|
+ Mtime: time.Now().Unix(),
|
|
193
|
+ Ctime: time.Now().Unix(),
|
|
194
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
195
|
+ HisPatientId: record.ID,
|
|
196
|
+ OrderId: 0,
|
|
197
|
+ ProjectId: project_id,
|
|
198
|
+ Type: types,
|
|
199
|
+ SettleType: settle_accounts_type,
|
258
|
200
|
}
|
|
201
|
+ service.CreateOrderInfo(info)
|
|
202
|
+ }
|
259
|
203
|
|
260
|
|
- service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
|
261
|
|
- service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
|
262
|
|
- service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
|
|
204
|
+ err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
|
|
205
|
+ service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
|
|
206
|
+ service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
|
|
207
|
+ if err == nil {
|
263
|
208
|
c.ServeSuccessJSON(map[string]interface{}{
|
264
|
209
|
"msg": "上传费用明细成功",
|
265
|
210
|
})
|
|
211
|
+ return
|
|
212
|
+ } else {
|
|
213
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
214
|
+ return
|
|
215
|
+ }
|
266
|
216
|
|
|
217
|
+ } else {
|
|
218
|
+
|
|
219
|
+ for _, subItem := range customs {
|
|
220
|
+ temp := strings.Split(subItem.FeedetlSn, "-")
|
|
221
|
+ var advice_id int64 = 0
|
|
222
|
+ var project_id int64 = 0
|
|
223
|
+ var types int64 = 0
|
|
224
|
+
|
|
225
|
+ id, _ := strconv.ParseInt(temp[2], 10, 64)
|
|
226
|
+ types, _ = strconv.ParseInt(temp[1], 10, 64)
|
|
227
|
+
|
|
228
|
+ if temp[1] == "1" {
|
|
229
|
+ advice_id = id
|
|
230
|
+ project_id = 0
|
|
231
|
+ } else if temp[1] == "2" {
|
|
232
|
+ advice_id = 0
|
|
233
|
+ project_id = id
|
|
234
|
+ }
|
|
235
|
+ info := &models.HisOrderInfo{
|
|
236
|
+ OrderNumber: record.Number,
|
|
237
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
238
|
+ UploadDate: recordDateTime,
|
|
239
|
+ AdviceId: advice_id,
|
|
240
|
+ DetItemFeeSumamt: subItem.DetItemFeeSumamt,
|
|
241
|
+ Cnt: subItem.Cut,
|
|
242
|
+ Pric: float64(subItem.Price),
|
|
243
|
+ PatientId: record.PatientId,
|
|
244
|
+ PricUplmtAmt: 0,
|
|
245
|
+ SelfpayProp: 0,
|
|
246
|
+ FulamtOwnpayAmt: 0,
|
|
247
|
+ OverlmtAmt: 0,
|
|
248
|
+ PreselfpayAmt: 0,
|
|
249
|
+ Status: 1,
|
|
250
|
+ Mtime: time.Now().Unix(),
|
|
251
|
+ Ctime: time.Now().Unix(),
|
|
252
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
253
|
+ HisPatientId: record.ID,
|
|
254
|
+ OrderId: 0,
|
|
255
|
+ ProjectId: project_id,
|
|
256
|
+ Type: types,
|
|
257
|
+ SettleType: settle_accounts_type,
|
|
258
|
+ }
|
|
259
|
+ service.CreateOrderInfo(info)
|
267
|
260
|
}
|
|
261
|
+
|
|
262
|
+ service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
|
|
263
|
+ service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
|
|
264
|
+ service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
|
|
265
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
266
|
+ "msg": "上传费用明细成功",
|
|
267
|
+ })
|
|
268
|
+
|
268
|
269
|
}
|
269
|
270
|
}
|
270
|
271
|
|