Răsfoiți Sursa

医院整合~备份~完毕

zhengkun 3 ani în urmă
părinte
comite
0b246dd30d

+ 17 - 4
fieldproject_medical/data_preparation/src/class/initcode.go

@@ -41,13 +41,26 @@ func initLevel() {
 
 //加载类型代码表~type
 func initType() {
-	data_type := MysqlTool.Find("code_medical_institution_type", nil, "name,code", "", -1, -1)
+	data_type := MysqlTool.Find("code_medical_institution_type", nil, "", "", -1, -1)
 	for _, v := range *data_type {
-		name := qu.ObjToString(v["name"])
 		code := qu.ObjToString(v["code"])
-		Medical_Type_Code[name] = code
+		pcode := qu.ObjToString(v["pcode"])
+		name := qu.ObjToString(v["name"])
+		key := ""
+		if qu.IntAll(v["level"]) == 1 {
+			key = name + "~"
+		} else if qu.IntAll(v["level"]) == 2 {
+			data := *MysqlTool.FindOne("code_medical_institution_type", map[string]interface{}{
+				"code": pcode,
+			}, "name", "")
+			pname := qu.ObjToString(data["name"])
+			key = pname + "~" + name
+		} else {
+
+		}
+		Medical_Type_Code[key] = code
 	}
-	log.Debug("医疗类型表~", len(Medical_Type_Code))
+	log.Debug("医疗类型表~", len(Medical_Type_Code))
 }
 
 //加载科室代码表

+ 11 - 8
fieldproject_medical/data_preparation/src/hospital/hospital_sql.go

@@ -62,15 +62,18 @@ func createBaseInfo(tmp map[string]interface{}) string {
 	data_info["mi_name"] = name
 	data_info["introduce"] = qu.ObjToString(tmp["introduce"])
 	//代码标准化
-	new_level, new_type, new_bustype := codificationOfInfo(qu.ObjToString(tmp["level"]), qu.ObjToString(tmp["type"]), qu.ObjToString(tmp["business_type"]))
+	new_level, new_type, new_bustype, new_sdequipment := codificationOfInfo(qu.ObjToString(tmp["level"]), qu.ObjToString(tmp["type"]), qu.ObjToString(tmp["business_type"]))
 	data_info["level_code"] = new_level
 	data_info["mi_type_code"] = new_type
 	data_info["business_type"] = new_bustype
+	data_info["sdequipment_code"] = new_sdequipment
+
 	data_info["address"] = qu.ObjToString(tmp["address"])
 	data_info["equipment"] = qu.ObjToString(tmp["equipment"])
 	beds := qu.IntAll(tmp["beds"])
 	visit_perday := qu.IntAll(tmp["visit_perday"])
 	doctorsnum := qu.IntAll(tmp["doctorsnum"])
+	staffnum := qu.IntAll(tmp["staffnum"])
 	if beds > 0 {
 		data_info["beds"] = beds
 	}
@@ -80,6 +83,9 @@ func createBaseInfo(tmp map[string]interface{}) string {
 	if doctorsnum > 0 {
 		data_info["doctorsnum"] = doctorsnum
 	}
+	if staffnum > 0 {
+		data_info["staffnum"] = staffnum
+	}
 	data_info["tel"] = qu.ObjToString(tmp["tel"])
 	data_info["fax_number"] = qu.ObjToString(tmp["fax_number"])
 	data_info["website"] = qu.ObjToString(tmp["website"])
@@ -145,10 +151,6 @@ func createDepartsInfo(tmp map[string]interface{}, level string) {
 		data["company_id"] = qu.ObjToString(tmp["company_id"])
 
 		data["departname_code"] = depart_code
-		//equipment_code 设备代码~需要构建
-		equipment_code := level + depart_code
-		data["equipment_code"] = equipment_code
-
 		data["departname_class1"] = qu.ObjToString(v["departclass1"])
 		data["departname_class2"] = qu.ObjToString(v["departclass2"])
 		data["introduce"] = qu.ObjToString(v["depart_introduce"])
@@ -168,11 +170,12 @@ func createDepartsInfo(tmp map[string]interface{}, level string) {
 }
 
 //等级,类型,性质代码化
-func codificationOfInfo(med_level string, med_type string, med_bustype string) (string, string, int) {
+func codificationOfInfo(med_level string, med_type string, med_bustype string) (string, string, int, string) {
 	new_level := class.Medical_Level_Code[med_level]
-	new_type := class.Medical_Type_Code[med_type]
 	new_bustype := class.Medical_BusType_Code[med_bustype]
-	return new_level, new_type, new_bustype
+	new_type := class.Medical_Type_Code[med_type]
+	new_sdequipment := new_level[:2] + new_type
+	return new_level, new_type, new_bustype, new_sdequipment
 }
 
 //区域代码

+ 21 - 11
fieldproject_medical/data_preparation/src/hospital/hospital_ways.go

@@ -228,12 +228,17 @@ func cleanHospitalType(tmp map[string]interface{}, update *map[string]interface{
 	if med_type != "" {
 		is_exists, type_1, type_2 = relevanceType(med_type, hospital, false)
 	}
-	if !is_exists && med_bus_type != "" {
-		arr := strings.Split(med_bus_type, "/")
-		if len(arr) == 2 {
-			_, type_1, type_2 = relevanceType(arr[1], hospital, true)
+	if !is_exists {
+		new_text := ""
+		if med_bus_type != "" {
+			arr := strings.Split(med_bus_type, "/")
+			if len(arr) == 2 {
+				new_text = arr[1]
+			}
 		}
+		is_exists, type_1, type_2 = relevanceType(new_text, hospital, true)
 	}
+
 	new_type := type_1 + "~" + type_2
 	if med_type != new_type {
 		(*update)["type"] = new_type
@@ -241,13 +246,16 @@ func cleanHospitalType(tmp map[string]interface{}, update *map[string]interface{
 	}
 }
 
-//type 类型规则划分
+//type 类型规则划分  is_extra 是否额外字段补充
 func relevanceType(name string, hospital string, is_extra bool) (bool, string, string) {
-	is_exists := false
-	type_1, type_2 := confrimFromFieldHospitalRule(name, hospital, false)
-	if type_1 == "其它" && !is_extra {
-		type_1, type_2 = confrimFromFieldHospitalRule(hospital, hospital, true)
+	type_1, type_2 := "其它", ""
+	if name != "" {
+		type_1, type_2 = confrimFromFieldHospitalRule(name, hospital, true)
 	}
+	if type_1 == "其它" && is_extra {
+		type_1, type_2 = confrimFromFieldHospitalRule(hospital, hospital, false)
+	}
+	is_exists := false
 	if type_1 != "其它" {
 		is_exists = true
 	}
@@ -255,7 +263,7 @@ func relevanceType(name string, hospital string, is_extra bool) (bool, string, s
 }
 
 //规则一
-func confrimFromFieldHospitalRule(name string, hospital string, is_hospital bool) (string, string) {
+func confrimFromFieldHospitalRule(name string, hospital string, is_check bool) (string, string) {
 	type_1, type_2 := "其它", ""
 L:
 	for _, v := range class.Medical_RuleType {
@@ -282,7 +290,9 @@ L:
 							}
 						}
 					}
-					if type_2 == "其它" && !is_hospital {
+
+					//医院校验补充~二级
+					if type_2 == "其它" && is_check {
 						if exclude != "" && regexp.MustCompile(exclude).MatchString(hospital) {
 							break L
 						}

+ 1 - 1
fieldproject_medical/data_preparation/src/main.go

@@ -16,7 +16,7 @@ func main() {
 	//hospital.RunBuildHospitalInfo()
 	//hospital.RunCleanHospitalInfo()
 	//hospital.RunMergeHospitalInfo()
-	//暂时需要线上补充~确定company_id
+	//暂时需要线上补充~数据
 	//hospital.RunRepairHospitalInfo()
 	//导入信息~医疗六张表
 	//hospital.ExportHospitalInfoToMysql()

+ 23 - 1
fieldproject_medical/data_preparation/src/repair/repairclass.go

@@ -7,18 +7,40 @@ import (
 
 //修复体外诊断试剂的code  207表
 func repairTwzdsjCode() {
+	//加载新版本分类目录
 	sess := class.Save_Mgo.GetMgoConn()
 	defer class.Save_Mgo.DestoryMongoConn(sess)
 	q := map[string]interface{}{}
 	it := sess.DB(class.Save_Mgo.DbName).C("zktest_mysql_product_info").Find(&q).Select(map[string]interface{}{
-		"product_code": 1,
+		"product_class1": 1,
+		"product_class2": 1,
+		"product_class3": 1,
+		"product_class4": 1,
 	}).Sort("_id").Iter()
 	total := 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
 		if total%10000 == 0 {
 			log.Debug("cur index ", total)
 		}
+		//new_dict := map[string]interface{}{
+		//	"product_class1": "",
+		//	"product_class2": "",
+		//	"product_class3": "",
+		//	"product_class4": "",
+		//	"product_code":   "",
+		//}
+		//
+		////刷数据
+		//product_class1 := qu.ObjToString(tmp["product_class1"])
+		//product_class2 := qu.ObjToString(tmp["product_class2"])
+		//product_class3 := qu.ObjToString(tmp["product_class3"])
+		//product_class4 := qu.ObjToString(tmp["product_class4"])
+		//
+		//if product_class1 != "" {
+		//
+		//}
 
+		//code_medical_equipment_product
 		tmp = make(map[string]interface{})
 	}