Browse Source

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

csx 3 years ago
parent
commit
6af602c1bd
2 changed files with 51 additions and 1 deletions
  1. 35 1
      controllers/zh/zh_his_api_controller.go
  2. 16 0
      service/zh_his_service.go

+ 35 - 1
controllers/zh/zh_his_api_controller.go View File

@@ -1138,7 +1138,7 @@ func (c *ZHHisApiController) GetSettleInfo() {
1138 1138
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
1139 1139
 	roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
1140 1140
 	order, _ := service.GetHisOrderByID(order_id)
1141
-	allTotal := fmt.Sprintf("%.4f", order.MedfeeSumamt)
1141
+
1142 1142
 	var rf []*ResultFive
1143 1143
 	json.Unmarshal([]byte(record.Iinfo), &rf)
1144 1144
 	chrg_bchno := order.Number
@@ -1157,6 +1157,40 @@ func (c *ZHHisApiController) GetSettleInfo() {
1157 1157
 	}
1158 1158
 	var result string
1159 1159
 	var src_resquest string
1160
+
1161
+	timeLayout := "2006-01-02"
1162
+	loc, _ := time.LoadLocation("Local")
1163
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record.InHosptialTime, loc)
1164
+	if err != nil {
1165
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1166
+		return
1167
+	}
1168
+	recordStartDateTime := theTime.Unix()
1169
+
1170
+	theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", record.OutHosptialTime, loc)
1171
+	if err != nil {
1172
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1173
+		return
1174
+	}
1175
+	recordEndDateTime := theTimeEnd.Unix()
1176
+
1177
+	prescriptions, _ := service.GetZHSettleMonthHisPrescription(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordStartDateTime, recordEndDateTime)
1178
+
1179
+	var total float64
1180
+	for _, item := range prescriptions {
1181
+		if item.Type == 1 { //药品
1182
+			for _, subItem := range item.HisDoctorAdviceInfo {
1183
+				total = total + (subItem.Price * subItem.PrescribingNumber)
1184
+			}
1185
+		}
1186
+		if item.Type == 2 { //项目
1187
+			for _, subItem := range item.HisPrescriptionProject {
1188
+				cnt, _ := strconv.ParseFloat(subItem.Count, 64)
1189
+				total = total + (subItem.Price * cnt)
1190
+			}
1191
+		}
1192
+	}
1193
+	allTotal := fmt.Sprintf("%.2f", total)
1160 1194
 	result, src_resquest = service.ZHGdyb2304(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
1161 1195
 	//saveLog()
1162 1196
 	saveLog(result, src_resquest, "2304", "住院结算")

+ 16 - 0
service/zh_his_service.go View File

@@ -1092,3 +1092,19 @@ func UpDatePrescriptionOrderStatusTwo(patient_id int64, record_date int64, org_i
1092 1092
 //
1093 1093
 //	err = readDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND ")
1094 1094
 //}
1095
+
1096
+func GetZHSettleMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
1097
+	err = readDb.Model(&models.HisPrescription{}).
1098
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
1099
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
1100
+		}).
1101
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1102
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
1103
+		}).
1104
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1105
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
1106
+		}).
1107
+		Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
1108
+		Find(&prescription).Error
1109
+	return
1110
+}