csx 4 년 전
부모
커밋
3006170496
1개의 변경된 파일192개의 추가작업 그리고 192개의 파일을 삭제
  1. 192 192
      controllers/his_api_controller.go

+ 192 - 192
controllers/his_api_controller.go 파일 보기

@@ -149,201 +149,200 @@ func (c *HisApiController) GetHisPatientInfo() {
149 149
 }
150 150
 
151 151
 func (c *HisApiController) Sscard() {
152
-	id_card_type, _ := c.GetInt64("id_card_type")
153
-	adminUser := c.GetAdminUserInfo()
154
-	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
152
+	//id_card_type, _ := c.GetInt64("id_card_type")
153
+	//adminUser := c.GetAdminUserInfo()
154
+	//miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
155 155
 
156 156
 	r := CardInit()
157
-
158 157
 	if r == 0 {
159
-		switch id_card_type {
160
-		case 1:
161
-			basStr, err := GetBasBaseInfo()
162
-
163
-			fmt.Println(LoadDllErr)
164
-			fmt.Println(FindPErr)
165
-			fmt.Println(FindPErr2)
166
-			fmt.Println(FindPErr3)
167
-
168
-			if err != nil {
169
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
170
-				return
171
-
172
-			} else {
173
-
174
-				bas := strings.Split(basStr, "|")
175
-
176
-				basNumber := bas[2]
177
-				card_sn := bas[3]
178
-
179
-				appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
180
-
181
-				api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
182
-				resp, requestErr := http.Get(api)
183
-				if requestErr != nil {
184
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
185
-					return
186
-				}
187
-				defer resp.Body.Close()
188
-				body, ioErr := ioutil.ReadAll(resp.Body)
189
-				if ioErr != nil {
190
-					utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
191
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
192
-					return
193
-				}
194
-				var respJSON map[string]interface{}
195
-
196
-				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
197
-					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
198
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
199
-					return
200
-				}
201
-
202
-				userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
203
-				userJSONBytes, _ := json.Marshal(userJSON)
204
-				var res ResultTwo
205
-				if err := json.Unmarshal(userJSONBytes, &res); err != nil {
206
-					utils.ErrorLog("解析失败:%v", err)
207
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
208
-					return
209
-				}
210
-				Iinfos, _ := json.Marshal(res.Output.Iinfo)
211
-				Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
212
-				infoStr := string(Iinfos)
213
-				idetinfoStr := string(Idetinfos)
214
-
215
-				if res.Infcode == 0 {
216
-					his := models.VMHisPatient{
217
-						Status:      1,
218
-						Ctime:       time.Now().Unix(),
219
-						Mtime:       time.Now().Unix(),
220
-						PsnNo:       res.Output.Baseinfo.PsnNo,
221
-						PsnCertType: res.Output.Baseinfo.PsnCertType,
222
-						Certno:      res.Output.Baseinfo.Certno,
223
-						PsnName:     res.Output.Baseinfo.PsnName,
224
-						Gend:        res.Output.Baseinfo.Gend,
225
-						Naty:        res.Output.Baseinfo.Naty,
226
-						Brdy:        res.Output.Baseinfo.Brdy,
227
-						Age:         res.Output.Baseinfo.Age,
228
-						Iinfo:       infoStr,
229
-						Idetinfo:    idetinfoStr,
230
-						UserOrgId:   adminUser.CurrentOrgId,
231
-						IsReturn:    1,
232
-						IdCardType:  id_card_type,
233
-					}
234
-
235
-					patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
236
-					if err == gorm.ErrRecordNotFound {
237
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
238
-						return
239
-
240
-					} else if err != nil {
241
-						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
242
-						return
243
-
244
-					} else {
245
-						c.ServeSuccessJSON(map[string]interface{}{
246
-							"patient": patient,
247
-							"his":     his,
248
-							"number":  basNumber,
249
-						})
250
-					}
251
-				} else {
252
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
253
-					return
254
-				}
255
-
256
-			}
257
-
258
-			break
259
-		case 2:
260
-			SFZStr, err := GetSFZBaseInfo()
261
-			if err != nil {
262
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
263
-				return
264
-
265
-			} else {
266
-
267
-				id_card_str := strings.Split(SFZStr, "^")
268
-				id_card_number := id_card_str[0]
269
-				//appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
270
-				//
271
-				//api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
272
-				//resp, requestErr := http.Get(api)
273
-				//if requestErr != nil {
274
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
275
-				//	return
276
-				//}
277
-				//defer resp.Body.Close()
278
-				//body, ioErr := ioutil.ReadAll(resp.Body)
279
-				//if ioErr != nil {
280
-				//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
281
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
282
-				//	return
283
-				//}
284
-				//var respJSON map[string]interface{}
285
-				//
286
-				//if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
287
-				//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
288
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
289
-				//	return
290
-				//}
291
-				//
292
-				//userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
293
-				//userJSONBytes, _ := json.Marshal(userJSON)
294
-				//var res ResultTwo
295
-				//if err := json.Unmarshal(userJSONBytes, &res); err != nil {
296
-				//	utils.ErrorLog("解析失败:%v", err)
297
-				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
298
-				//	return
299
-				//}
300
-				//Iinfos, _ := json.Marshal(res.Output.Iinfo)
301
-				//Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
302
-				//infoStr := string(Iinfos)
303
-				//idetinfoStr := string(Idetinfos)
304
-				//
305
-				//if res.Infcode == 0 {
306
-				//	his := models.VMHisPatient{
307
-				//		Status:      1,
308
-				//		Ctime:       time.Now().Unix(),
309
-				//		Mtime:       time.Now().Unix(),
310
-				//		PsnNo:       res.Output.Baseinfo.PsnNo,
311
-				//		PsnCertType: res.Output.Baseinfo.PsnCertType,
312
-				//		Certno:      res.Output.Baseinfo.Certno,
313
-				//		PsnName:     res.Output.Baseinfo.PsnName,
314
-				//		Gend:        res.Output.Baseinfo.Gend,
315
-				//		Naty:        res.Output.Baseinfo.Naty,
316
-				//		Brdy:        res.Output.Baseinfo.Brdy,
317
-				//		Age:         res.Output.Baseinfo.Age,
318
-				//		Iinfo:       infoStr,
319
-				//		Idetinfo:    idetinfoStr,
320
-				//		UserOrgId:   adminUser.CurrentOrgId,
321
-				//		IsReturn:    1,
322
-				//		IdCardType:  id_card_type,
323
-				//	}
324
-
325
-				patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
326
-				if err == gorm.ErrRecordNotFound {
327
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
328
-					return
329
-
330
-				} else if err != nil {
331
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
332
-					return
333
-
334
-				} else {
335
-					c.ServeSuccessJSON(map[string]interface{}{
336
-						"patient": patient,
337
-						"number":  id_card_number,
338
-					})
339
-				}
340
-			}
341
-			break
342
-		case 3:
343
-
344
-			break
345
-
346
-		}
158
+		//switch id_card_type {
159
+		//case 1:
160
+		//	basStr, err := GetBasBaseInfo()
161
+		//
162
+		//	fmt.Println(LoadDllErr)
163
+		//	fmt.Println(FindPErr)
164
+		//	fmt.Println(FindPErr2)
165
+		//	fmt.Println(FindPErr3)
166
+		//
167
+		//	if err != nil {
168
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
169
+		//		return
170
+		//
171
+		//	} else {
172
+		//
173
+		//		bas := strings.Split(basStr, "|")
174
+		//
175
+		//		basNumber := bas[2]
176
+		//		card_sn := bas[3]
177
+		//
178
+		//		appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
179
+		//
180
+		//		api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
181
+		//		resp, requestErr := http.Get(api)
182
+		//		if requestErr != nil {
183
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
184
+		//			return
185
+		//		}
186
+		//		defer resp.Body.Close()
187
+		//		body, ioErr := ioutil.ReadAll(resp.Body)
188
+		//		if ioErr != nil {
189
+		//			utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
190
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
191
+		//			return
192
+		//		}
193
+		//		var respJSON map[string]interface{}
194
+		//
195
+		//		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
196
+		//			utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
197
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
198
+		//			return
199
+		//		}
200
+		//
201
+		//		userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
202
+		//		userJSONBytes, _ := json.Marshal(userJSON)
203
+		//		var res ResultTwo
204
+		//		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
205
+		//			utils.ErrorLog("解析失败:%v", err)
206
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
207
+		//			return
208
+		//		}
209
+		//		Iinfos, _ := json.Marshal(res.Output.Iinfo)
210
+		//		Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
211
+		//		infoStr := string(Iinfos)
212
+		//		idetinfoStr := string(Idetinfos)
213
+		//
214
+		//		if res.Infcode == 0 {
215
+		//			his := models.VMHisPatient{
216
+		//				Status:      1,
217
+		//				Ctime:       time.Now().Unix(),
218
+		//				Mtime:       time.Now().Unix(),
219
+		//				PsnNo:       res.Output.Baseinfo.PsnNo,
220
+		//				PsnCertType: res.Output.Baseinfo.PsnCertType,
221
+		//				Certno:      res.Output.Baseinfo.Certno,
222
+		//				PsnName:     res.Output.Baseinfo.PsnName,
223
+		//				Gend:        res.Output.Baseinfo.Gend,
224
+		//				Naty:        res.Output.Baseinfo.Naty,
225
+		//				Brdy:        res.Output.Baseinfo.Brdy,
226
+		//				Age:         res.Output.Baseinfo.Age,
227
+		//				Iinfo:       infoStr,
228
+		//				Idetinfo:    idetinfoStr,
229
+		//				UserOrgId:   adminUser.CurrentOrgId,
230
+		//				IsReturn:    1,
231
+		//				IdCardType:  id_card_type,
232
+		//			}
233
+		//
234
+		//			patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
235
+		//			if err == gorm.ErrRecordNotFound {
236
+		//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
237
+		//				return
238
+		//
239
+		//			} else if err != nil {
240
+		//				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
241
+		//				return
242
+		//
243
+		//			} else {
244
+		//				c.ServeSuccessJSON(map[string]interface{}{
245
+		//					"patient": patient,
246
+		//					"his":     his,
247
+		//					"number":  basNumber,
248
+		//				})
249
+		//			}
250
+		//		} else {
251
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
252
+		//			return
253
+		//		}
254
+		//
255
+		//	}
256
+		//
257
+		//	break
258
+		//case 2:
259
+		//	SFZStr, err := GetSFZBaseInfo()
260
+		//	if err != nil {
261
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
262
+		//		return
263
+		//
264
+		//	} else {
265
+		//
266
+		//		id_card_str := strings.Split(SFZStr, "^")
267
+		//		id_card_number := id_card_str[0]
268
+		//		//appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
269
+		//		//
270
+		//		//api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
271
+		//		//resp, requestErr := http.Get(api)
272
+		//		//if requestErr != nil {
273
+		//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
274
+		//		//	return
275
+		//		//}
276
+		//		//defer resp.Body.Close()
277
+		//		//body, ioErr := ioutil.ReadAll(resp.Body)
278
+		//		//if ioErr != nil {
279
+		//		//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
280
+		//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
281
+		//		//	return
282
+		//		//}
283
+		//		//var respJSON map[string]interface{}
284
+		//		//
285
+		//		//if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
286
+		//		//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
287
+		//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
288
+		//		//	return
289
+		//		//}
290
+		//		//
291
+		//		//userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
292
+		//		//userJSONBytes, _ := json.Marshal(userJSON)
293
+		//		//var res ResultTwo
294
+		//		//if err := json.Unmarshal(userJSONBytes, &res); err != nil {
295
+		//		//	utils.ErrorLog("解析失败:%v", err)
296
+		//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
297
+		//		//	return
298
+		//		//}
299
+		//		//Iinfos, _ := json.Marshal(res.Output.Iinfo)
300
+		//		//Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
301
+		//		//infoStr := string(Iinfos)
302
+		//		//idetinfoStr := string(Idetinfos)
303
+		//		//
304
+		//		//if res.Infcode == 0 {
305
+		//		//	his := models.VMHisPatient{
306
+		//		//		Status:      1,
307
+		//		//		Ctime:       time.Now().Unix(),
308
+		//		//		Mtime:       time.Now().Unix(),
309
+		//		//		PsnNo:       res.Output.Baseinfo.PsnNo,
310
+		//		//		PsnCertType: res.Output.Baseinfo.PsnCertType,
311
+		//		//		Certno:      res.Output.Baseinfo.Certno,
312
+		//		//		PsnName:     res.Output.Baseinfo.PsnName,
313
+		//		//		Gend:        res.Output.Baseinfo.Gend,
314
+		//		//		Naty:        res.Output.Baseinfo.Naty,
315
+		//		//		Brdy:        res.Output.Baseinfo.Brdy,
316
+		//		//		Age:         res.Output.Baseinfo.Age,
317
+		//		//		Iinfo:       infoStr,
318
+		//		//		Idetinfo:    idetinfoStr,
319
+		//		//		UserOrgId:   adminUser.CurrentOrgId,
320
+		//		//		IsReturn:    1,
321
+		//		//		IdCardType:  id_card_type,
322
+		//		//	}
323
+		//
324
+		//		patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
325
+		//		if err == gorm.ErrRecordNotFound {
326
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
327
+		//			return
328
+		//
329
+		//		} else if err != nil {
330
+		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
331
+		//			return
332
+		//
333
+		//		} else {
334
+		//			c.ServeSuccessJSON(map[string]interface{}{
335
+		//				"patient": patient,
336
+		//				"number":  id_card_number,
337
+		//			})
338
+		//		}
339
+		//	}
340
+		//	break
341
+		//case 3:
342
+		//
343
+		//	break
344
+		//
345
+		//}
347 346
 	}
348 347
 }
349 348
 func GetBasBaseInfo() (jsonStr string, err error) {
@@ -388,6 +387,7 @@ func CardInit() int {
388 387
 	if err != nil {
389 388
 		fmt.Println("SSCard的运算结果为:", ret)
390 389
 	}
390
+	fmt.Println(err)
391 391
 	result := int(ret)
392 392
 	return result
393 393
 }