|
@@ -40,23 +40,64 @@ var (
|
|
|
"26": "物理治疗器械",
|
|
|
"46": "骨科手术器械",
|
|
|
}
|
|
|
+ rangeRelation = map[string]string{
|
|
|
+ "6801": "无源手术器械",
|
|
|
+ "6831": "X射线附属及辅助设备",
|
|
|
+ "6812": "妇产科、辅助生殖和避孕器械",
|
|
|
+ "6813": "妇产科手术器械",
|
|
|
+ "6810": "骨科手术器械",
|
|
|
+ "6824": "光治疗设备",
|
|
|
+ "6854": "呼吸、麻醉和急救器械",
|
|
|
+ "6856": "呼吸、麻醉和急救器械",
|
|
|
+ "6806": "口腔科器械",
|
|
|
+ "6855": "口腔科器械",
|
|
|
+ "6863": "口腔科器械",
|
|
|
+ "6840": "临床检验器械",
|
|
|
+ "6841": "临床检验器械",
|
|
|
+ "6803": "神经和心血管手术器械",
|
|
|
+ "6807": "神经和心血管手术器械",
|
|
|
+ "6877": "神经和心血管手术器械-心血管介入器械",
|
|
|
+ "6845": "输血、透析和体外循环器械",
|
|
|
+ "6805": "无源手术器械",
|
|
|
+ "6809": "无源手术器械",
|
|
|
+ "6808": "无源手术器械",
|
|
|
+ "6816": "无源手术器械",
|
|
|
+ "6846": "无源植入器械",
|
|
|
+ "6826": "物理治疗器械",
|
|
|
+ "6804": "眼科器械",
|
|
|
+ "6857": "医疗器械消毒灭菌器械",
|
|
|
+ "6822": "医用成像器械",
|
|
|
+ "6828": "医用成像器械",
|
|
|
+ "6833": "医用成像器械",
|
|
|
+ "6870": "医用软件",
|
|
|
+ "6834": "医用射线防护设备",
|
|
|
+ "6820": "医用诊察和监护器械",
|
|
|
+ "6821": "医用诊察和监护器械",
|
|
|
+ "6827": "中医器械",
|
|
|
+ "6815": "注射、穿刺器械",
|
|
|
+ "6864": "注输、护理和防护器械",
|
|
|
+ }
|
|
|
productTemp = map[string]string{}
|
|
|
companyTemp = map[string]string{}
|
|
|
YlqxCodeName = map[string]string{}
|
|
|
YlqxNameCode = map[string]string{}
|
|
|
|
|
|
- rangeReg1 = regexp.MustCompile("(\\d{2}|\\d{4})-(\\d{2}|\\d{1})([\\s -::]+)?([\u4e00-\u9fa5()、()/\\s ]+)")
|
|
|
- rangeReg2 = regexp.MustCompile("\\d{2}([\\s -::]+)?([\u4e00-\u9fa5()、()/\\s ]+)")
|
|
|
-
|
|
|
- rangeClean1 = regexp.MustCompile("[\\s ]+")
|
|
|
- rangeClean2 = regexp.MustCompile("(生产范围).*")
|
|
|
+ ScRangeReg1 = regexp.MustCompile("(\\d{2}|\\d{4})-(\\d{2}|\\d{1})([\\s -::]+)?([\u4e00-\u9fa5()、()/\\s ]+)")
|
|
|
+ ScRangeReg2 = regexp.MustCompile("\\d{2}([\\s -::]+)?([\u4e00-\u9fa5()、()/\\s ]+)")
|
|
|
+ ScRangeClean1 = regexp.MustCompile("[\\s ]+")
|
|
|
+ ScRangeClean2 = regexp.MustCompile("(生产范围).*")
|
|
|
+ JyRangeReg1 = regexp.MustCompile("(6801|6831|6812|6813|6810|6824|6854|6856|6806|6855|6863|6840|6841|6803|6807|6877|6845|6805|6809|6808|6816|6846|6826|6804|6857|6822|6828|6833|6870|6834|6820|6821|6827|6815|6864)")
|
|
|
+ SpecRangeReg = regexp.MustCompile("(检测试剂|试剂盒|抗体试剂|保存试剂|提取试剂)")
|
|
|
)
|
|
|
|
|
|
func confirmYlqxInfoClass() {
|
|
|
loadYlqxInfo()
|
|
|
- //confirmFirst()
|
|
|
- //confirmSecond()
|
|
|
+ confirmFirst()
|
|
|
+ confirmSecond()
|
|
|
confirmThird()
|
|
|
+ confirmFourth()
|
|
|
+ confirmFifth()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//加载医疗器械代码
|
|
@@ -74,7 +115,7 @@ func loadYlqxInfo() {
|
|
|
//医疗分类打标记
|
|
|
func confirmFirst() {
|
|
|
isok := 0
|
|
|
- dataArr, _ := Sour_Mgo.Find("nmpa_product_new", nil, nil, bson.M{"product_name": 1})
|
|
|
+ dataArr, _ := Save_Mgo.Find("nmpa_product_new", nil, nil, bson.M{"product_name": 1})
|
|
|
for _, v := range dataArr {
|
|
|
product_class_1 := qu.ObjToString(v["product_class_1"])
|
|
|
if product_class_1 != "" {
|
|
@@ -84,8 +125,8 @@ func confirmFirst() {
|
|
|
product_name := qu.ObjToString(v["product_name"])
|
|
|
if code := YlqxNameCode[product_name]; code != "" {
|
|
|
isok++
|
|
|
- update := calculationYlqxCode(code)
|
|
|
- Sour_Mgo.UpdateById("nmpa_product_new", tmpid, map[string]interface{}{
|
|
|
+ _, update := calculationYlqxCode(code)
|
|
|
+ Save_Mgo.UpdateById("nmpa_product_new", tmpid, map[string]interface{}{
|
|
|
"$set": update,
|
|
|
})
|
|
|
}
|
|
@@ -93,7 +134,7 @@ func confirmFirst() {
|
|
|
log.Debug("is over ... ", isok)
|
|
|
time.Sleep(time.Second * 2)
|
|
|
}
|
|
|
-func calculationYlqxCode(yl_code string) map[string]interface{} {
|
|
|
+func calculationYlqxCode(yl_code string) (bool, map[string]interface{}) {
|
|
|
update := map[string]interface{}{}
|
|
|
if len(yl_code) == 2 {
|
|
|
update["product_class_1"] = YlqxCodeName[yl_code]
|
|
@@ -110,14 +151,14 @@ func calculationYlqxCode(yl_code string) map[string]interface{} {
|
|
|
update["product_class_3"] = YlqxCodeName[yl_code[:7]]
|
|
|
update["product_class_4"] = YlqxCodeName[yl_code]
|
|
|
} else {
|
|
|
-
|
|
|
+ return false, update
|
|
|
}
|
|
|
- return update
|
|
|
+ return true, update
|
|
|
}
|
|
|
func confirmSecond() {
|
|
|
codeReg := regexp.MustCompile("20\\d{3}(\\d{2})")
|
|
|
isok := 0
|
|
|
- dataArr, _ := Sour_Mgo.Find("nmpa_product_new", nil, nil, bson.M{"reg_no": 1, "classify": 1})
|
|
|
+ dataArr, _ := Save_Mgo.Find("nmpa_product_new", nil, nil, bson.M{"reg_no": 1, "classify": 1})
|
|
|
for _, v := range dataArr {
|
|
|
tmpid := BsonTOStringId(v["_id"])
|
|
|
reg_no := qu.ObjToString(v["reg_no"])
|
|
@@ -129,7 +170,7 @@ func confirmSecond() {
|
|
|
name := codeRelation[code]
|
|
|
if name != "" {
|
|
|
isok++
|
|
|
- Sour_Mgo.UpdateById("nmpa_product_new", tmpid, map[string]interface{}{
|
|
|
+ Save_Mgo.UpdateById("nmpa_product_new", tmpid, map[string]interface{}{
|
|
|
"$set": bson.M{"product_class_1": name},
|
|
|
})
|
|
|
}
|
|
@@ -141,86 +182,221 @@ func confirmSecond() {
|
|
|
}
|
|
|
func confirmThird() {
|
|
|
isok := 0
|
|
|
- dataArr, _ := Sour_Mgo.Find("nmpa_product_new", nil, nil, bson.M{
|
|
|
+ dataArr, _ := Save_Mgo.Find("nmpa_product_new", nil, nil, bson.M{"product_name": 1, "product_class_1": 1})
|
|
|
+ for _, v := range dataArr {
|
|
|
+ tmpid := BsonTOStringId(v["_id"])
|
|
|
+ product_name := qu.ObjToString(v["product_name"])
|
|
|
+ product_class_1 := qu.ObjToString(v["product_class_1"])
|
|
|
+ if product_class_1 == "" && strings.Contains(product_name, "试剂") {
|
|
|
+ Save_Mgo.UpdateById("nmpa_product_new", tmpid, map[string]interface{}{
|
|
|
+ "$set": bson.M{"product_class_1": "体外诊断试剂"},
|
|
|
+ })
|
|
|
+ isok++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.Debug("is over ... ", isok)
|
|
|
+}
|
|
|
+func confirmFourth() {
|
|
|
+ isok := 0
|
|
|
+ dataArr, _ := Save_Mgo.Find("nmpa_product_new", nil, nil, bson.M{
|
|
|
"reg_company": 1,
|
|
|
"product_name": 1,
|
|
|
"product_class_1": 1,
|
|
|
"product_class_2": 1,
|
|
|
})
|
|
|
for _, v := range dataArr {
|
|
|
- product_name := qu.ObjToString(v["product_name"])
|
|
|
+ tmpid := BsonTOStringId(v["_id"])
|
|
|
+ old_name := qu.ObjToString(v["product_name"])
|
|
|
reg_company := qu.ObjToString(v["reg_company"])
|
|
|
- product_class_1 := qu.ObjToString(v["product_class_1"])
|
|
|
- product_class_2 := qu.ObjToString(v["product_class_2"])
|
|
|
- if product_class_2 != "" {
|
|
|
+ old_class_1 := qu.ObjToString(v["product_class_1"])
|
|
|
+ old_class_2 := qu.ObjToString(v["product_class_2"])
|
|
|
+ if old_class_2 != "" {
|
|
|
continue
|
|
|
}
|
|
|
- infos := calculationYlqxRange(reg_company, product_class_1)
|
|
|
- isTure := 0
|
|
|
- if len(infos) == 1 {
|
|
|
- isTure = 1
|
|
|
+ resArr := calculationYlqxScRange(reg_company, old_class_1, old_name)
|
|
|
+ b, res := checkYlqxResultRight(resArr, old_class_1)
|
|
|
+ if b && res != nil && tmpid != "" {
|
|
|
+ isok++
|
|
|
+ Save_Mgo.UpdateById("nmpa_product_new", tmpid, map[string]interface{}{
|
|
|
+ "$set": res,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.Debug("is over ... ", isok)
|
|
|
+ time.Sleep(time.Second * 2)
|
|
|
+}
|
|
|
+func confirmFifth() {
|
|
|
+ isok := 0
|
|
|
+ dataArr, _ := Save_Mgo.Find("nmpa_product_new", nil, nil, bson.M{
|
|
|
+ "reg_company": 1,
|
|
|
+ "product_name": 1,
|
|
|
+ "product_class_1": 1,
|
|
|
+ "product_class_2": 1,
|
|
|
+ })
|
|
|
+ for _, v := range dataArr {
|
|
|
+ tmpid := BsonTOStringId(v["_id"])
|
|
|
+ old_name := qu.ObjToString(v["product_name"])
|
|
|
+ reg_company := qu.ObjToString(v["reg_company"])
|
|
|
+ old_class_1 := qu.ObjToString(v["product_class_1"])
|
|
|
+ old_class_2 := qu.ObjToString(v["product_class_2"])
|
|
|
+ if old_class_2 != "" {
|
|
|
+ continue
|
|
|
}
|
|
|
- if len(infos) > 0 {
|
|
|
+ resArr := calculationYlqxJyRange(reg_company, old_class_1, old_name)
|
|
|
+ b, res := checkYlqxResultRight(resArr, old_class_1)
|
|
|
+ if b && res != nil && tmpid != "" {
|
|
|
isok++
|
|
|
- Sour_Mgo.Save("nmpa_product_ylqx_log", map[string]interface{}{
|
|
|
- "product_name": product_name,
|
|
|
- "product_class_1": product_class_1,
|
|
|
- "log": infos,
|
|
|
- "isTure": isTure,
|
|
|
+ Save_Mgo.UpdateById("nmpa_product_new", tmpid, map[string]interface{}{
|
|
|
+ "$set": res,
|
|
|
})
|
|
|
}
|
|
|
+ //Sour_Mgo.Save("123456", map[string]interface{}{
|
|
|
+ // "_id": v["_id"],
|
|
|
+ // "name": old_name,
|
|
|
+ // "class": old_class_1,
|
|
|
+ // "res": res,
|
|
|
+ //})
|
|
|
}
|
|
|
log.Debug("is over ... ", isok)
|
|
|
time.Sleep(time.Second * 2)
|
|
|
}
|
|
|
-func calculationYlqxRange(company string, old_class_1 string) []map[string]interface{} {
|
|
|
- dataArr, _ := Sour_Mgo.Find("nmpa_company_new", bson.M{"company": company}, nil, bson.M{"product_range": 1})
|
|
|
+func calculationYlqxScRange(company string, old_class string, old_name string) []map[string]interface{} {
|
|
|
+ dataArr, _ := Save_Mgo.Find("nmpa_company_new", bson.M{"company": company}, nil, bson.M{"product_range": 1})
|
|
|
infos := []map[string]interface{}{}
|
|
|
- temp := map[string]string{}
|
|
|
for _, v := range dataArr {
|
|
|
product_range := qu.ObjToString(v["product_range"])
|
|
|
- matchArr1 := rangeReg1.FindAllString(product_range, -1)
|
|
|
+ matchArr1 := ScRangeReg1.FindAllString(product_range, -1)
|
|
|
if len(matchArr1) > 0 {
|
|
|
for _, v1 := range matchArr1 {
|
|
|
- name := rangeReg1.ReplaceAllString(v1, "${4}")
|
|
|
- name = rangeClean1.ReplaceAllString(name, "")
|
|
|
- name = rangeClean2.ReplaceAllString(name, "")
|
|
|
- if temp[name] == "" {
|
|
|
- temp[name] = name
|
|
|
- log := calculationYlqxCode(YlqxNameCode[name])
|
|
|
- infos = append(infos, map[string]interface{}{
|
|
|
- name: log,
|
|
|
- })
|
|
|
+ name := ScRangeReg1.ReplaceAllString(v1, "${4}")
|
|
|
+ name = ScRangeClean1.ReplaceAllString(name, "")
|
|
|
+ name = ScRangeClean2.ReplaceAllString(name, "")
|
|
|
+ b, res := calculationYlqxCode(YlqxNameCode[name])
|
|
|
+ //根据结果校验一下,是否有效合理
|
|
|
+ if b && checkYlqxInfoRight(res, old_class, old_name) {
|
|
|
+ infos = append(infos, res)
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- matchArr2 := rangeReg2.FindAllString(product_range, -1)
|
|
|
+ matchArr2 := ScRangeReg2.FindAllString(product_range, -1)
|
|
|
for _, v1 := range matchArr2 {
|
|
|
if strings.Contains(v1, "分类目录") {
|
|
|
continue
|
|
|
}
|
|
|
- name := rangeReg2.ReplaceAllString(v1, "${2}")
|
|
|
- name = rangeClean1.ReplaceAllString(name, "")
|
|
|
- name = rangeClean2.ReplaceAllString(name, "")
|
|
|
- if temp[name] == "" {
|
|
|
- temp[name] = name
|
|
|
- log := calculationYlqxCode(YlqxNameCode[name])
|
|
|
- infos = append(infos, map[string]interface{}{
|
|
|
- name: log,
|
|
|
- })
|
|
|
+ name := ScRangeReg2.ReplaceAllString(v1, "${2}")
|
|
|
+ name = ScRangeClean1.ReplaceAllString(name, "")
|
|
|
+ name = ScRangeClean2.ReplaceAllString(name, "")
|
|
|
+ b, res := calculationYlqxCode(YlqxNameCode[name])
|
|
|
+ //根据结果校验一下,是否有效合理
|
|
|
+ if b && checkYlqxInfoRight(res, old_class, old_name) {
|
|
|
+ infos = append(infos, res)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //进行有效结果去重
|
|
|
+ new_infos := []map[string]interface{}{}
|
|
|
+ temp := map[string]string{}
|
|
|
+ for _, v := range infos {
|
|
|
+ c1, c2 := qu.ObjToString(v["product_class_1"]), qu.ObjToString(v["product_class_2"])
|
|
|
+ c3, c4 := qu.ObjToString(v["product_class_3"]), qu.ObjToString(v["product_class_4"])
|
|
|
+ key := c1 + "~" + c2 + "~" + c3 + "~" + c4 + "~"
|
|
|
+ if temp[key] == "" {
|
|
|
+ new_infos = append(new_infos, v)
|
|
|
+ temp[key] = key
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new_infos
|
|
|
return infos
|
|
|
}
|
|
|
+func calculationYlqxJyRange(company string, old_class string, old_name string) []map[string]interface{} {
|
|
|
+ dataArr, _ := Save_Mgo.Find("nmpa_company_new", bson.M{"company": company}, nil, bson.M{"business_range": 1})
|
|
|
+ infos := []map[string]interface{}{}
|
|
|
+ for _, v := range dataArr {
|
|
|
+ business_range := qu.ObjToString(v["business_range"])
|
|
|
+ matchArr := JyRangeReg1.FindAllString(business_range, -1)
|
|
|
+ if len(matchArr) > 0 {
|
|
|
+ for _, v1 := range matchArr {
|
|
|
+ name := rangeRelation[v1]
|
|
|
+ b, res := calculationYlqxCode(YlqxNameCode[name])
|
|
|
+ //根据结果校验一下,是否有效合理
|
|
|
+ if b && checkYlqxInfoRight(res, old_class, old_name) {
|
|
|
+ infos = append(infos, res)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //进行有效结果去重
|
|
|
+ new_infos := []map[string]interface{}{}
|
|
|
+ temp := map[string]string{}
|
|
|
+ for _, v := range infos {
|
|
|
+ c1, c2 := qu.ObjToString(v["product_class_1"]), qu.ObjToString(v["product_class_2"])
|
|
|
+ c3, c4 := qu.ObjToString(v["product_class_3"]), qu.ObjToString(v["product_class_4"])
|
|
|
+ key := c1 + "~" + c2 + "~" + c3 + "~" + c4 + "~"
|
|
|
+ if temp[key] == "" {
|
|
|
+ new_infos = append(new_infos, v)
|
|
|
+ temp[key] = key
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new_infos
|
|
|
+}
|
|
|
+func checkYlqxInfoRight(res map[string]interface{}, class string, name string) bool {
|
|
|
+ if class != "" {
|
|
|
+ if qu.ObjToString(res["product_class_1"]) != class {
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ if qu.ObjToString(res["product_class_2"]) == "" {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if SpecRangeReg.MatchString(name) {
|
|
|
+ if qu.ObjToString(res["product_class_1"]) != "体外诊断试剂" {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
+}
|
|
|
+func checkYlqxResultRight(resArr []map[string]interface{}, old_class string) (bool, map[string]interface{}) {
|
|
|
+ if len(resArr) == 0 {
|
|
|
+ return false, map[string]interface{}{}
|
|
|
+ }
|
|
|
+ if len(resArr) == 1 {
|
|
|
+ return true, resArr[0]
|
|
|
+ }
|
|
|
+ if old_class != "" {
|
|
|
+ return false, map[string]interface{}{}
|
|
|
+ }
|
|
|
+ infos := map[string]int{}
|
|
|
+ for _, v := range resArr {
|
|
|
+ key := qu.ObjToString(v["product_class_1"])
|
|
|
+ num := qu.IntAll(infos[key])
|
|
|
+ infos[key] = num + 1
|
|
|
+ }
|
|
|
+ new_class := ""
|
|
|
+ count := 0
|
|
|
+ for k, v := range infos {
|
|
|
+ if v > count {
|
|
|
+ new_class = k
|
|
|
+ count = v
|
|
|
+ } else if v == count {
|
|
|
+ new_class = ""
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if new_class != "" {
|
|
|
+ return true, map[string]interface{}{"product_class_1": new_class}
|
|
|
+ }
|
|
|
+ return false, map[string]interface{}{}
|
|
|
+}
|
|
|
|
|
|
//拆分合并医疗产品与企业信息
|
|
|
func splitMergeMedicalInfo(coll string) {
|
|
|
- sess := Sour_Mgo.GetMgoConn()
|
|
|
- defer Sour_Mgo.DestoryMongoConn(sess)
|
|
|
+ sess := Old_Mgo.GetMgoConn()
|
|
|
+ defer Old_Mgo.DestoryMongoConn(sess)
|
|
|
q, total := map[string]interface{}{}, 0
|
|
|
- it := sess.DB(Sour_Mgo.DbName).C(coll).Find(&q).Sort("_id").Iter()
|
|
|
+ it := sess.DB(Old_Mgo.DbName).C(coll).Find(&q).Sort("_id").Iter()
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
if total%10000 == 0 {
|
|
|
log.Debug("cur index ", total)
|