Browse Source

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

csx 1 year ago
parent
commit
d5daf83c14
4 changed files with 306 additions and 145 deletions
  1. 15 15
      controllers/coordinate/coordinate_controller.go
  2. 7 1
      enums/error_code.go
  3. 65 0
      models/his_models.go
  4. 219 129
      service/coordinate_service.go

+ 15 - 15
controllers/coordinate/coordinate_controller.go View File

@@ -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"
7 4
 	"encoding/json"
8 5
 	"fmt"
9 6
 	"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"
@@ -99,7 +99,7 @@ func (c *CoordinateController) SettleAccount() {
99 99
 		recordDateTime := theTime.Unix()
100 100
 		patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
101 101
 		if patientPrescription.ID == 0 {
102
-			patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
102
+			patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwoTen(org_id, patient.ID, recordDateTime)
103 103
 		}
104 104
 		departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
105 105
 		doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
@@ -108,7 +108,7 @@ func (c *CoordinateController) SettleAccount() {
108 108
 		var prescriptions []*models.HisPrescription
109 109
 
110 110
 		if settle_accounts_type == 1 { //日结
111
-			prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, patient_id, recordDateTime, 2)
111
+			prescriptions, _ = service.GetUnSettleHisPrescriptionFiveTen(org_id, patient_id, recordDateTime, 2)
112 112
 		} else { //月结
113 113
 
114 114
 			start_time_str := c.GetString("start_time")
@@ -164,7 +164,7 @@ func (c *CoordinateController) SettleAccount() {
164 164
 						Cut:              fmt.Sprintf("%.4f", subItem.PrescribingNumber),
165 165
 						FeedetlSn:        subItem.FeedetlSn,
166 166
 						Price:            fmt.Sprintf("%.2f", subItem.Price),
167
-						MedListCodg:      subItem.Drug.MedicalInsuranceNumber,
167
+						MedListCodg:      subItem.BaseDrugLib.MedicalInsuranceNumber,
168 168
 						Type:             1,
169 169
 					}
170 170
 					customs = append(customs, cus)
@@ -217,7 +217,7 @@ func (c *CoordinateController) SettleAccount() {
217 217
 		for _, item := range diagnosis_ids {
218 218
 			id, _ := strconv.ParseInt(item, 10, 64)
219 219
 			diagnosisConfig, _ := service.FindDiagnoseById(id)
220
-			config = append(config, diagnosisConfig)
220
+			config = append(config, &diagnosisConfig)
221 221
 		}
222 222
 		for index, item := range config {
223 223
 			var diag models.Diag
@@ -252,13 +252,13 @@ func (c *CoordinateController) SettleAccount() {
252 252
 				infoItem.Rownr = strconv.FormatInt(int64(index+1), 10)
253 253
 				infoItem.Vaf11 = "2"
254 254
 				infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
255
-				infoItem.Bbx01 = subItem.Drug.MedicalInsuranceNumber
255
+				infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber
256 256
 				infoItem.Bda01 = "1"
257 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
258
+				if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
259
+					infoItem.Vaf22 = subItem.BaseDrugLib.DrugName + " " + subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
260 260
 				}
261
-				infoItem.Vaf14 = subItem.Drug.DrugName
261
+				infoItem.Vaf14 = subItem.BaseDrugLib.DrugName
262 262
 				infoItem.Bdi01 = ef.Code
263 263
 				infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10)
264 264
 				infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
@@ -419,7 +419,7 @@ func (c *CoordinateController) SettleAccount() {
419 419
 				Number:                 strconv.FormatInt(int64(res.Result[0].Vaa07), 10),
420 420
 				PhoneNumber:            patient.Phone,
421 421
 			}
422
-			service.UpdateHisPatientStatus(&his)
422
+			service.UpdateHisPatientStatusTwo(&his)
423 423
 			service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
424 424
 			tm := time.Unix(time.Now().Unix(), 0)
425 425
 
@@ -499,10 +499,10 @@ func (c *CoordinateController) SettleAccount() {
499 499
 			his.SickType = sick_type
500 500
 			his.RegisterType = reg_type
501 501
 			his.MedicalTreatmentType = reg_type
502
-			service.UpdataHisPateintTwo(&his)
502
+			service.UpdataHisPateintTwoTen(&his)
503 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)
504
+			err = service.UpDateHisPrescriptionInfoNumberTen(org_id, patient_id, order.Number, recordDateTime, his.ID)
505
+			err = service.UpdataOrderStatusThreeTen(strconv.FormatInt(int64(chrgBchno), 10), org_id)
506 506
 
507 507
 			c.ServeSuccessJSON(map[string]interface{}{
508 508
 				"msg": "医嘱保存成功",

+ 7 - 1
enums/error_code.go View File

@@ -259,6 +259,9 @@ const ( // ErrorCode
259 259
 	ErrorCodeHisPatientParamWrong = 300004
260 260
 
261 261
 	ErrorCodeOrderParamWrong = 300005
262
+
263
+	ErrorCodeHisPatientNoRegException = 4000000
264
+	ErrorCodeCreateOrderException     = 20068
262 265
 )
263 266
 
264 267
 var ErrCodeMsgs = map[int]string{
@@ -498,7 +501,10 @@ var ErrCodeMsgs = map[int]string{
498 501
 	ErrorCodeHospitalExistDataException: "该患者已经入院,请选办理出院结算后再进行办理入院操作",
499 502
 	ErrorCodeHisPatientParamWrong:       "订单正在结算、请先结算完成",
500 503
 
501
-	ErrorCodeOrderParamWrong: "该就诊号存在已结算记录,请先退费后再进行退号操作",
504
+	ErrorCodeOrderParamWrong:          "该就诊号存在已结算记录,请先退费后再进行退号操作",
505
+	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
506
+
507
+	ErrorCodeCreateOrderException: "记账失败",
502 508
 }
503 509
 
504 510
 type SGJError struct {

+ 65 - 0
models/his_models.go View File

@@ -331,6 +331,7 @@ type HisPrescription struct {
331 331
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
332 332
 	HisAdditionalCharge    []*HisAdditionalCharge    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
333 333
 	VMHisPrescriptionInfo  HisPrescriptionInfo       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"info"`
334
+	MedType                string                    `gorm:"column:med_type" json:"med_type" form:"med_type"`
334 335
 }
335 336
 
336 337
 func (HisPrescription) TableName() string {
@@ -513,6 +514,7 @@ type HisPrescriptionProject struct {
513 514
 	TeamId             int64            `gorm:"column:team_id" json:"team_id" form:"team_id"`
514 515
 	XtHisProjectTeam   XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
515 516
 	IsCheckTeam        int64            `gorm:"-" json:"is_check_team" form:"is_check_team"`
517
+	ExecutionTime      int64            `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
516 518
 }
517 519
 
518 520
 func (HisPrescriptionProject) TableName() string {
@@ -1625,3 +1627,66 @@ type HisHospitalCheckRecordTwo struct {
1625 1627
 func (HisHospitalCheckRecordTwo) TableName() string {
1626 1628
 	return "his_hospital_check_record"
1627 1629
 }
1630
+
1631
+type NewCustomTwo struct {
1632
+	DetItemFeeSumamt string
1633
+	Cut              string
1634
+	FeedetlSn        string
1635
+	Price            string
1636
+	MedListCodg      string
1637
+	Type             int64
1638
+	AdviceId         int64
1639
+	ProjectId        int64
1640
+	ItemId           int64
1641
+}
1642
+
1643
+type UploadInfo struct {
1644
+	Bce02a   string `json:"bce02a"`
1645
+	Bck01c   string `json:"bck01c"`
1646
+	Diag     []*Diag
1647
+	Fasong   string `json:"fasong"`
1648
+	PresInfo []*PresInfo
1649
+	Vaa01    int `json:"vaa01"`
1650
+	Vaa07    int `json:"vaa07"`
1651
+}
1652
+
1653
+type Diag struct {
1654
+	Bak02 string `json:"bak02"`
1655
+	Vao06 string `json:"vao06"`
1656
+}
1657
+
1658
+type PresDetail struct {
1659
+	Item  []*Item
1660
+	Vaf59 string `json:"vaf59"`
1661
+}
1662
+
1663
+type PresInfo struct {
1664
+	Cbm06      string `json:"cbm06"`
1665
+	Cbm07      string `json:"cbm07"`
1666
+	Cbmid      string `json:"cbmid"`
1667
+	PresDetail []*PresDetail
1668
+}
1669
+
1670
+type Item struct {
1671
+	Bbx01  string `json:"bbx01"`
1672
+	Bby01  string `json:"bby01"`
1673
+	Bck01b string `json:"bck01b"`
1674
+	Bck01d string `json:"bck01d"`
1675
+	Bda01  string `json:"bda01"`
1676
+	Bdi01  string `json:"bdi01"`
1677
+	Rownr  string `json:"rownr"`
1678
+	Vaf11  string `json:"vaf11"`
1679
+	Vaf14  string `json:"vaf14"`
1680
+	Vaf15  string `json:"vaf15"`
1681
+	Vaf17  string `json:"vaf17"`
1682
+	Vaf18  int    `json:"vaf18"`
1683
+	Vaf19  string `json:"vaf19"`
1684
+	Vaf20  string `json:"vaf20"`
1685
+	Vaf21  string `json:"vaf21"`
1686
+	Vaf22  string `json:"vaf22"`
1687
+	Vaf32  string `json:"vaf32"`
1688
+	Vaf35  string `json:"vaf35"`
1689
+	Vaf36  string `json:"vaf36"`
1690
+	Vaf58  string `json:"vaf58"`
1691
+	Vaf61  string `json:"vaf61"`
1692
+}

+ 219 - 129
service/coordinate_service.go View File

@@ -5,26 +5,64 @@ import (
5 5
 	"encoding/json"
6 6
 	"fmt"
7 7
 	"gdyb/models"
8
+	"github.com/jinzhu/gorm"
8 9
 	"io/ioutil"
9 10
 	"net/http"
11
+	"time"
10 12
 )
11 13
 
12
-func SavePatientMessageInfo() (string, string) {
14
+func UpdateHisPatientStatusTwo(his *models.VMHisPatient) {
15
+	writeDb.Save(&his)
16
+}
17
+
18
+func GetUnSettleHisPrescriptionFiveTen(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
19
+	err = readDb.Model(&models.HisPrescription{}).
20
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
21
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
22
+		}).
23
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
24
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
25
+		}).
26
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
27
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
28
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
29
+		return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3  AND order_status <> 2  ", org_id)
30
+	}).
31
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 and order_status <> 5  AND p_type = ?", org_id, record_date, patient_id, p_type).
32
+		Find(&prescription).Error
33
+	return
34
+}
35
+
36
+func GetUnSettleMonthHisPrescription(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
37
+	err = readDb.Model(&models.HisPrescription{}).
38
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
39
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
40
+		}).
41
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
42
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
43
+		}).
44
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
45
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
46
+		}).
47
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 5 AND p_type <> 1", org_id, start_date, end_date, patient_id).
48
+		Find(&prescription).Error
49
+	return
50
+}
51
+
52
+func GetHisOrderFour(patient_id string, infoSeq string, docId string) (order models.HisOrder, err error) {
53
+	if len(docId) > 0 {
54
+		err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND setl_id = ? AND status = 1", infoSeq, patient_id, docId).First(&order).Error
55
+	} else {
56
+		err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND status = 1 ", infoSeq, patient_id).First(&order).Error
57
+	}
58
+	return
59
+}
60
+
61
+func GetHisPatientForCoordinate(id_card_no string) (string, string) {
13 62
 
14 63
 	//input := make(map[string]interface{})
15 64
 	inputData := make(map[string]interface{})
16
-	inputData["patType"] = "1"                  // 就诊凭证编号
17
-	inputData["patIdNo"] = "441701195808152845" // 开始时间
18
-	inputData["patName"] = "罗秀云"                // 人员姓名
19
-
20
-	inputData["patMobile"] = "13535547901" // 人员姓名
21
-	inputData["patSex"] = "M"              // 人员姓名
22
-	inputData["patMarriage"] = "1"         // 人员姓名
23
-	inputData["birthday"] = "1992-10-23"   // 人员姓名
24
-	inputData["patAddress"] = "11111"      // 人员姓名
25
-	inputData["thirdPartyID"] = "16"       // 人员姓名
26
-	inputData["patAge"] = "11"             // 人员姓名
27
-	//input["req"] = inputData
65
+	inputData["idcard"] = id_card_no // 就诊凭证编号
28 66
 
29 67
 	var inputLog string
30 68
 	bytesData, err := json.Marshal(inputData)
@@ -36,7 +74,7 @@ func SavePatientMessageInfo() (string, string) {
36 74
 	}
37 75
 	reader := bytes.NewReader(bytesData)
38 76
 	var url string
39
-	gdyb_url := "http://218.104.146.179:9091/esb/listener/savePatientMessageInfo"
77
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/getPatientType"
40 78
 	url = gdyb_url
41 79
 
42 80
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
@@ -65,44 +103,75 @@ func SavePatientMessageInfo() (string, string) {
65 103
 	return str, inputLog
66 104
 
67 105
 }
68
-
69
-func SaveReg(reg models.Reg) (string, string) {
106
+func UploadPrescriptionForCoordinate(info models.UploadInfo) (string, string) {
70 107
 
71 108
 	//input := make(map[string]interface{})
72 109
 	inputData := make(map[string]interface{})
73 110
 
74
-	inputData["deptId"] = reg.DeptId // 就诊凭证编号
75
-	inputData["clinicUnitId"] = ""   // 开始时间
76
-	inputData["healthCardNo"] = ""   // 人员姓名
77
-
78
-	inputData["patientId"] = reg.PatientId     // 人员姓名
79
-	inputData["patientName"] = reg.PatientName // 人员姓名
80
-	inputData["idCardNo"] = ""                 // 人员姓名
81
-	inputData["phone"] = ""                    // 人员姓名
82
-	inputData["doctorId"] = reg.DoctorId       // 人员姓名
83
-	inputData["doctorLevelCode"] = ""          // 人员姓名
84
-	inputData["regDate"] = reg.RegDate         // 人员姓名
85
-
86
-	inputData["shiftCode"] = "" // 人员姓名
87
-	inputData["startTime"] = "" // 人员姓名
88
-	inputData["endTime"] = ""   // 人员姓名
111
+	diags := make([]map[string]interface{}, 0)
112
+	//diags := make([]map[string]interface{}, 0)
89 113
 
90
-	inputData["scheduleId"] = "" // 人员姓名
91
-	inputData["periodId"] = ""   // 人员姓名
114
+	presInfos := make([]map[string]interface{}, 0)
92 115
 
93
-	inputData["svObjectId"] = ""     // 人员姓名
94
-	inputData["diseaseId"] = ""      // 人员姓名
95
-	inputData["regFee"] = reg.RegFee // 人员姓名
116
+	for _, item := range info.Diag {
117
+		inputDataDiag := make(map[string]interface{})
118
+		inputDataDiag["vao06"] = item.Vao06
119
+		inputDataDiag["bak02"] = item.Bak02
120
+		diags = append(diags, inputDataDiag)
121
+	}
96 122
 
97
-	inputData["treatFee"] = reg.TreatFee     // 人员姓名
98
-	inputData["operatorId"] = reg.OperatorId // 人员姓名
99
-	inputData["remark"] = ""                 // 人员姓名
123
+	for _, item := range info.PresInfo {
124
+		inputDataPresInfo := make(map[string]interface{})
125
+		inputDataPresInfo["cbm06"] = item.Cbm06
126
+		inputDataPresInfo["cbm07"] = item.Cbm06
127
+		inputDataPresInfo["cbmid"] = item.Cbmid
128
+		presDetails := make([]map[string]interface{}, 0)
129
+
130
+		for _, subItem := range item.PresDetail {
131
+			inputDataPresDetail := make(map[string]interface{})
132
+			inputDataPresDetail["vaf59"] = subItem.Vaf59
133
+			Items := make([]map[string]interface{}, 0)
134
+			for _, subSubItem := range subItem.Item {
135
+				inputDataItem := make(map[string]interface{})
136
+				inputDataItem["bbx01"] = subSubItem.Bbx01
137
+				inputDataItem["bda01"] = subSubItem.Bda01
138
+				inputDataItem["bby01"] = subSubItem.Bby01
139
+				inputDataItem["bck01b"] = subSubItem.Bck01b
140
+				inputDataItem["bck01d"] = subSubItem.Bck01d
141
+				inputDataItem["bdi01"] = subSubItem.Bdi01
142
+				inputDataItem["rownr"] = subSubItem.Rownr
143
+				inputDataItem["vaf11"] = subSubItem.Vaf11
144
+				inputDataItem["vaf14"] = subSubItem.Vaf14
145
+				inputDataItem["vaf15"] = subSubItem.Vaf15
146
+				inputDataItem["vaf17"] = subSubItem.Vaf17
147
+				inputDataItem["vaf18"] = subSubItem.Vaf18
148
+				inputDataItem["vaf19"] = subSubItem.Vaf19
149
+				inputDataItem["vaf20"] = subSubItem.Vaf20
150
+				inputDataItem["vaf21"] = subSubItem.Vaf21
151
+				inputDataItem["vaf22"] = subSubItem.Vaf22
152
+				inputDataItem["vaf32"] = subSubItem.Vaf32
153
+				inputDataItem["vaf35"] = subSubItem.Vaf35
154
+				inputDataItem["vaf36"] = subSubItem.Vaf36
155
+				inputDataItem["vaf58"] = subSubItem.Vaf58
156
+				inputDataItem["vaf61"] = subSubItem.Vaf61
157
+				Items = append(Items, inputDataItem)
158
+
159
+			}
160
+			inputDataPresDetail["item"] = Items
161
+			presDetails = append(presDetails, inputDataPresDetail)
162
+		}
163
+		inputDataPresInfo["presDetail"] = presDetails
164
+		presInfos = append(presInfos, inputDataPresInfo)
165
+	}
100 166
 
101
-	inputData["orderType"] = ""  // 人员姓名
102
-	inputData["clinicCode"] = "" // 人员姓名
103
-	inputData["infoSeq"] = ""    // 人员姓名
167
+	inputData["vaa01"] = info.Vaa01   // 就诊凭证编号
168
+	inputData["Fasong"] = info.Fasong // 就诊凭证编号
169
+	inputData["vaa07"] = info.Vaa07   // 就诊凭证编号
170
+	inputData["bck01c"] = info.Bck01c // 就诊凭证编号
171
+	inputData["bce02a"] = "1001"      // 就诊凭证编号
104 172
 
105
-	//input["Request"] = inputData
173
+	inputData["diag"] = diags         // 就诊凭证编号
174
+	inputData["presInfo"] = presInfos // 就诊凭证编号
106 175
 
107 176
 	var inputLog string
108 177
 	bytesData, err := json.Marshal(inputData)
@@ -114,7 +183,7 @@ func SaveReg(reg models.Reg) (string, string) {
114 183
 	}
115 184
 	reader := bytes.NewReader(bytesData)
116 185
 	var url string
117
-	gdyb_url := "http://218.104.146.179:9091/esb/listener/saveReg"
186
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/sendPretreat"
118 187
 	url = gdyb_url
119 188
 
120 189
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
@@ -143,60 +212,76 @@ func SaveReg(reg models.Reg) (string, string) {
143 212
 	return str, inputLog
144 213
 
145 214
 }
146
-func GetWaitPayDetail() (string, string) {
215
+
216
+func UploadPrescriptionForCoordinateHospital(info models.UploadInfo) (string, string) {
147 217
 
148 218
 	//input := make(map[string]interface{})
149 219
 	inputData := make(map[string]interface{})
150 220
 
151
-	inputData["clinicSeq"] = "30445"              // 就诊凭证编号
152
-	inputData["prescriptionId"] = ""              // 开始时间
153
-	inputData["patientId"] = "701822660170096645" // 人员姓名
221
+	diags := make([]map[string]interface{}, 0)
222
+	//diags := make([]map[string]interface{}, 0)
154 223
 
155
-	var inputLog string
156
-	bytesData, err := json.Marshal(inputData)
157
-	inputLog = string(bytesData)
158
-	fmt.Println(string(bytesData))
159
-	if err != nil {
160
-		fmt.Println(err.Error())
161
-		return err.Error(), ""
162
-	}
163
-	reader := bytes.NewReader(bytesData)
164
-	var url string
165
-	gdyb_url := "http://218.104.146.179:9091/esb/listener/getWaitPayDetail"
166
-	url = gdyb_url
224
+	presInfos := make([]map[string]interface{}, 0)
167 225
 
168
-	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
169
-	request, err := http.NewRequest("POST", url, reader)
170
-	if err != nil {
171
-		fmt.Println(err.Error())
172
-		return err.Error(), ""
226
+	for _, item := range info.Diag {
227
+		inputDataDiag := make(map[string]interface{})
228
+		inputDataDiag["vao06"] = item.Vao06
229
+		inputDataDiag["bak02"] = item.Bak02
230
+		diags = append(diags, inputDataDiag)
173 231
 	}
174 232
 
175
-	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
176
-	request.Header.Set("code", "Xmrjyy")
177
-
178
-	client := http.Client{}
179
-	resp, err := client.Do(request)
180
-	if err != nil {
181
-		fmt.Println(err.Error())
182
-		return err.Error(), ""
233
+	for _, item := range info.PresInfo {
234
+		inputDataPresInfo := make(map[string]interface{})
235
+		inputDataPresInfo["cbm06"] = item.Cbm06
236
+		inputDataPresInfo["cbm07"] = item.Cbm06
237
+		inputDataPresInfo["cbmid"] = item.Cbmid
238
+		presDetails := make([]map[string]interface{}, 0)
239
+
240
+		for _, subItem := range item.PresDetail {
241
+			inputDataPresDetail := make(map[string]interface{})
242
+			inputDataPresDetail["vaf59"] = subItem.Vaf59
243
+			Items := make([]map[string]interface{}, 0)
244
+			for _, subSubItem := range subItem.Item {
245
+				inputDataItem := make(map[string]interface{})
246
+				inputDataItem["bbx01"] = subSubItem.Bbx01
247
+				inputDataItem["bda01"] = subSubItem.Bda01
248
+				inputDataItem["bby01"] = subSubItem.Bby01
249
+				inputDataItem["bck01b"] = subSubItem.Bck01b
250
+				inputDataItem["bck01d"] = subSubItem.Bck01d
251
+				inputDataItem["bdi01"] = subSubItem.Bdi01
252
+				inputDataItem["rownr"] = subSubItem.Rownr
253
+				inputDataItem["vaf11"] = subSubItem.Vaf11
254
+				inputDataItem["vaf14"] = subSubItem.Vaf14
255
+				inputDataItem["vaf15"] = subSubItem.Vaf15
256
+				inputDataItem["vaf17"] = subSubItem.Vaf17
257
+				inputDataItem["vaf18"] = subSubItem.Vaf18
258
+				inputDataItem["vaf19"] = subSubItem.Vaf19
259
+				inputDataItem["vaf20"] = subSubItem.Vaf20
260
+				inputDataItem["vaf21"] = subSubItem.Vaf21
261
+				inputDataItem["vaf22"] = subSubItem.Vaf22
262
+				inputDataItem["vaf32"] = subSubItem.Vaf32
263
+				inputDataItem["vaf35"] = subSubItem.Vaf35
264
+				inputDataItem["vaf36"] = subSubItem.Vaf36
265
+				inputDataItem["vaf58"] = subSubItem.Vaf58
266
+				inputDataItem["vaf61"] = subSubItem.Vaf61
267
+				Items = append(Items, inputDataItem)
268
+
269
+			}
270
+			inputDataPresDetail["item"] = Items
271
+			presDetails = append(presDetails, inputDataPresDetail)
272
+		}
273
+		inputDataPresInfo["presDetail"] = presDetails
274
+		presInfos = append(presInfos, inputDataPresInfo)
183 275
 	}
184
-	respBytes, err := ioutil.ReadAll(resp.Body)
185
-	if err != nil {
186
-		fmt.Println(err.Error())
187
-		return err.Error(), ""
188
-	}
189
-	fmt.Println(string(respBytes))
190
-	str := string(respBytes)
191
-	return str, inputLog
192 276
 
193
-}
194
-func OpKeepAccounts() (string, string) {
277
+	inputData["vaa01"] = info.Vaa01   // 就诊凭证编号
278
+	inputData["Fasong"] = info.Fasong // 就诊凭证编号
279
+	inputData["vaa07"] = info.Vaa07   // 就诊凭证编号
280
+	inputData["bck01c"] = info.Bck01c // 就诊凭证编号
281
+	inputData["bce02a"] = "1001"      // 就诊凭证编号
195 282
 
196
-	inputData := make(map[string]interface{})
197
-	inputData["inNo"] = "30445"             // 就诊凭证编号
198
-	inputData["itemCode"] = "240300013-000" // 开始时间
199
-	inputData["num"] = "1"                  // 人员姓名
283
+	inputData["diag"] = diags         // 就诊凭证编号
284
+	inputData["presInfo"] = presInfos // 就诊凭证编号
200 285
 
201 286
 	var inputLog string
202 287
 	bytesData, err := json.Marshal(inputData)
@@ -208,7 +293,7 @@ func OpKeepAccounts() (string, string) {
208 293
 	}
209 294
 	reader := bytes.NewReader(bytesData)
210 295
 	var url string
211
-	gdyb_url := "http://218.104.146.179:9091/esb/listener/opKeepAccounts"
296
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/saveOrdInfoIp"
212 297
 	url = gdyb_url
213 298
 
214 299
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
@@ -237,53 +322,58 @@ func OpKeepAccounts() (string, string) {
237 322
 	return str, inputLog
238 323
 
239 324
 }
240
-func OpCancelKeepAccounts() (string, string) {
241 325
 
242
-	input := make(map[string]interface{})
243
-	inputData := make(map[string]interface{})
326
+func UpDatePrescriptionNumberForCoordinate(user_org_id int64, ids []int64, number string) (err error) {
327
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix(), "order_status": 6}).Error
328
+	return
329
+}
244 330
 
245
-	inputData["docId"] = ""    // 就诊凭证编号
246
-	inputData["operCode"] = "" // 开始时间
247
-	inputData["operName"] = "" // 人员姓名
331
+func FindPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
332
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).First(&info).Error
333
+	return
248 334
 
249
-	input["req"] = inputData
335
+}
250 336
 
251
-	var inputLog string
252
-	bytesData, err := json.Marshal(input)
253
-	inputLog = string(bytesData)
254
-	fmt.Println(string(bytesData))
255
-	if err != nil {
256
-		fmt.Println(err.Error())
257
-		return err.Error(), ""
258
-	}
259
-	reader := bytes.NewReader(bytesData)
260
-	var url string
261
-	gdyb_url := "http://218.104.146.179:9091/esb/listener/opCancelKeepAccounts"
262
-	url = gdyb_url
337
+func FindLastPatientPrescriptionInfoTwoTen(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
338
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date < ? AND patient_id = ?", org_id, record_date, patient_id).Order("record_date desc").First(&info).Error
339
+	return
340
+}
263 341
 
264
-	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
265
-	request, err := http.NewRequest("POST", url, reader)
266
-	if err != nil {
267
-		fmt.Println(err.Error())
268
-		return err.Error(), ""
269
-	}
342
+func GetUnSettleHisPrescriptionFive(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
343
+	err = readDb.Model(&models.HisPrescription{}).
344
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
345
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
346
+		}).
347
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
348
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
349
+		}).
350
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
351
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
352
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
353
+		return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3  AND order_status <> 2  ", org_id)
354
+	}).
355
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 and order_status <> 5  AND p_type = ?", org_id, record_date, patient_id, p_type).
356
+		Find(&prescription).Error
357
+	return
358
+}
270 359
 
271
-	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
272
-	request.Header.Set("code", "Xmrjyy")
360
+func UpdataHisPateintTwoTen(his *models.VMHisPatient) {
361
+	writeDb.Save(&his)
362
+}
273 363
 
274
-	client := http.Client{}
275
-	resp, err := client.Do(request)
276
-	if err != nil {
277
-		fmt.Println(err.Error())
278
-		return err.Error(), ""
279
-	}
280
-	respBytes, err := ioutil.ReadAll(resp.Body)
281
-	if err != nil {
282
-		fmt.Println(err.Error())
283
-		return err.Error(), ""
284
-	}
285
-	fmt.Println(string(respBytes))
286
-	str := string(respBytes)
287
-	return str, inputLog
364
+func UpDateHisPrescriptionInfoNumberTen(user_org_id int64, id int64, number string, record_time int64, his_patient_id int64) (err error) {
365
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND his_patient_id = ? AND record_date = ?", user_org_id, his_patient_id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
366
+
367
+	return
368
+}
369
+
370
+func UpdataOrderStatusThreeTen(number string, user_org_id int64) (err error) {
371
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 5, "mtime": time.Now().Unix()}).Error
372
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 5, "mtime": time.Now().Unix()}).Error
373
+	return
374
+}
288 375
 
376
+func GetExecutionFrequencyByName(name string, org_id int64) (ef models.ExecutionFrequencyDic, err error) {
377
+	err = readDb.Model(&models.ExecutionFrequencyDic{}).Where("org_id = ? AND name = ?", org_id, name).First(&ef).Error
378
+	return
289 379
 }