张保健 10 months ago
parent
commit
44a95fb429

+ 1 - 1
controllers/base_api_controller.go View File

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	_"IC/service"
5
 	"IC/enums"
4
 	"IC/enums"
5
+	_ "IC/service"
6
 	"github.com/astaxie/beego"
6
 	"github.com/astaxie/beego"
7
 )
7
 )
8
 
8
 

+ 27 - 0
controllers/lis.go View File

35
 
35
 
36
 }
36
 }
37
 
37
 
38
+// 普宁锦熹血液透析中心Lis同步
39
+func (c *LisController) SyncPljx() {
40
+	service.SyncLisPljx(10599)
41
+	c.ServeSuccessJSON(map[string]interface{}{
42
+		"resultList": "12345",
43
+	})
44
+	return
45
+}
46
+
47
+// 遵化仁爱医院Lis同步
48
+func (c *LisController) SyncZhraLis() {
49
+	service.SyncTszhraLis()
50
+	c.ServeSuccessJSON(map[string]interface{}{
51
+		"resultList": "12345",
52
+	})
53
+	return
54
+}
55
+
56
+// 北京南诚中西医结合医院Lis同步
57
+func (c *LisController) SyncBjncLis() {
58
+	service.SyncBjncLis()
59
+	c.ServeSuccessJSON(map[string]interface{}{
60
+		"resultList": "12345",
61
+	})
62
+	return
63
+}
64
+
38
 // 广州康允LIS同步
65
 // 广州康允LIS同步
39
 func (c *LisController) SyncGzky() {
66
 func (c *LisController) SyncGzky() {
40
 	service.SyncGzkyLis()
67
 	service.SyncGzkyLis()

+ 4 - 1
main.go View File

16
 
16
 
17
 func main() {
17
 func main() {
18
 	service.BeginAutoSyncLis()
18
 	service.BeginAutoSyncLis()
19
-
19
+	//service.SyncStsyLis() //  汕头三优  打开程序马上运行LIS同步
20
+	//service.SyncLisSgyhs() //  韶关源和盛  打开程序马上运行LIS同步
21
+	//service.SyncLisPljx(10599) //  揭阳景熹透析中心  打开程序马上运行LIS同步
22
+	service.SyncTszhraLis() // 遵化仁爱医院  打开程序马上运行LIS同步
20
 	beego.Run()
23
 	beego.Run()
21
 }
24
 }

+ 136 - 139
models/wfnfm_model.go View File

1
 package models
1
 package models
2
 
2
 
3
-
4
 type EmrBloodDialyRecord struct {
3
 type EmrBloodDialyRecord struct {
5
-	ReqNo                 string          `gorm:"column:REQ_NO" json:"REQ_NO" form:"REQ_NO"`
6
-	Patientname           string          `gorm:"column:PATIENTNAME" json:"PATIENTNAME" form:"PATIENTNAME"`
7
-	Idcard             	  string          `gorm:"column:IDCARD" json:"IDCARD" form:"IDCARD"`
8
-	Hospitalcode          string          `gorm:"column:HOSPITALCODE" json:"HOSPITALCODE" form:"HOSPITALCODE"`
9
-	Hospitalname          string          `gorm:"column:HOSPITALNAME" json:"HOSPITALNAME" form:"HOSPITALNAME"`
10
-	AdmissionId           string          `gorm:"column:ADMISSION_ID" json:"ADMISSION_ID" form:"ADMISSION_ID"`
11
-	SexCode               string          `gorm:"column:SEX_CODE" json:"SEX_CODE" form:"SEX_CODE"`
12
-	SexName               string          `gorm:"column:SEX_NAME" json:"SEX_NAME" form:"SEX_NAME"`
13
-	Age               	  int64           `gorm:"column:AGE" json:"AGE" form:"AGE"`
14
-	AgeMonth              int64           `gorm:"column:AGE_MONTH" json:"AGE_MONTH" form:"AGE_MONTH"`
15
-	SickbedNum            string          `gorm:"column:SICKBED_NUM" json:"SICKBED_NUM" form:"SICKBED_NUM"`
16
-	BdDate                string          `gorm:"column:BD_DATE" json:"BD_DATE" form:"BD_DATE"`
17
-	BdMatno               string          `gorm:"column:BD_MATNO" json:"BD_MATNO" form:"BD_MATNO"`
18
-	Temperature           float64         `gorm:"column:TEMPERATURE" json:"TEMPERATURE" form:"TEMPERATURE"`
19
-	PulseRate             float64           `gorm:"column:PULSE_RATE" json:"PULSE_RATE" form:"PULSE_RATE"`
20
-	BreathingRate         float64           `gorm:"column:BREATHING_RATE" json:"BREATHING_RATE" form:"BREATHING_RATE"`
21
-	PressureH             float64           `gorm:"column:PRESSURE_H" json:"PRESSURE_H" form:"PRESSURE_H"`
22
-	PressureL             float64           `gorm:"column:PRESSURE_L" json:"PRESSURE_L" form:"PRESSURE_L"`
23
-	UfvLimit              float64           `gorm:"column:UFV_LIMIT" json:"UFV_LIMIT" form:"UFV_LIMIT"`
24
-	Anticoagulant         string          `gorm:"column:ANTICOAGULANT" json:"ANTICOAGULANT" form:"ANTICOAGULANT"`
25
-	FirstAnticoagulant    float64           `gorm:"column:FIRST_ANTICOAGULANT" json:"FIRST_ANTICOAGULANT" form:"FIRST_ANTICOAGULANT"`
26
-	BdCruor               string          `gorm:"column:BD_CRUOR" json:"BD_CRUOR" form:"BD_CRUOR"`
27
-	BdCruorName           string          `gorm:"column:BD_CRUOR_NAME" json:"BD_CRUOR_NAME" form:"BD_CRUOR_NAME"`
28
-	BdMachine             string          `gorm:"column:BD_MACHINE" json:"BD_MACHINE" form:"BD_MACHINE"`
29
-	BdTimes               int64           `gorm:"column:BD_TIMES" json:"BD_TIMES" form:"BD_TIMES"`
30
-	BdHours               int64           `gorm:"column:BD_HOURS" json:"BD_HOURS" form:"BD_HOURS"`
31
-	BdType                int64          `gorm:"column:BD_TYPE" json:"BD_TYPE" form:"BD_TYPE"`
32
-	BdTypeName            string          `gorm:"column:BD_TYPE_NAME" json:"BD_TYPE_NAME" form:"BD_TYPE_NAME"`
33
-	BdT                   float64         `gorm:"column:BD_T" json:"BD_T" form:"BD_T"`
34
-	AnticoagulantTotal    float64           `gorm:"column:ANTICOAGULANT_TOTAL" json:"ANTICOAGULANT_TOTAL" form:"ANTICOAGULANT_TOTAL"`
35
-	AnticoagulantKeep     float64           `gorm:"column:ANTICOAGULANT_KEEP" json:"ANTICOAGULANT_KEEP" form:"ANTICOAGULANT_KEEP"`
36
-	BdCruorContiton       string          `gorm:"column:BD_CRUOR_CONTITON" json:"BD_CRUOR_CONTITON" form:"BD_CRUOR_CONTITON"`
37
-	PatientWeight         float64         `gorm:"column:PATIENT_WEIGHT" json:"PATIENT_WEIGHT" form:"PATIENT_WEIGHT"`
38
-	WeightBf              float64         `gorm:"column:WEIGHT_BF" json:"WEIGHT_BF" form:"WEIGHT_BF"`
39
-	WeightAf              float64         `gorm:"column:WEIGHT_AF" json:"WEIGHT_AF" form:"WEIGHT_AF"`
40
-	WeightBalan           float64         `gorm:"column:WEIGHT_BALAN" json:"WEIGHT_BALAN" form:"WEIGHT_BALAN"`
41
-	RecipeCa              int64           `gorm:"column:RECIPE_CA" json:"RECIPE_CA" form:"RECIPE_CA"`
42
-	RecipeK               int64           `gorm:"column:RECIPE_K" json:"RECIPE_K" form:"RECIPE_K"`
43
-	Compli                string          `gorm:"column:COMPLI" json:"COMPLI" form:"COMPLI"`
44
-	DiaAf                 string          `gorm:"column:DIA_AF" json:"DIA_AF" form:"DIA_AF"`
45
-	Comfort               string          `gorm:"column:COMFORT" json:"COMFORT" form:"COMFORT"`
46
-	ComfortName           string          `gorm:"column:COMFORT_NAME" json:"COMFORT_NAME" form:"COMFORT_NAME"`
47
-	Vascular              string          `gorm:"column:VASCULAR" json:"VASCULAR" form:"VASCULAR"`
48
-	Notes                 string          `gorm:"column:NOTES" json:"NOTES" form:"NOTES"`
49
-	OperName              string          `gorm:"column:OPER_NAME" json:"OPER_NAME" form:"OPER_NAME"`
50
-	CheckName             string          `gorm:"column:CHECK_NAME" json:"CHECK_NAME" form:"CHECK_NAME"`
51
-	PrimaryName           string          `gorm:"column:PRIMARY_NAME" json:"PRIMARY_NAME" form:"PRIMARY_NAME"`
52
-	DoctorName            string          `gorm:"column:DOCTOR_NAME" json:"DOCTOR_NAME" form:"DOCTOR_NAME"`
53
-	Orglevel              string          `gorm:"column:ORGLEVEL" json:"ORGLEVEL" form:"ORGLEVEL"`
54
-	Submitdate            string       	  `gorm:"column:SUBMITDATE" json:"SUBMITDATE" form:"SUBMITDATE"`
55
-	Recordstate           string          `gorm:"column:RECORDSTATE" json:"RECORDSTATE" form:"RECORDSTATE"`
56
-	Fectchdate            string       	  `gorm:"column:FECTCHDATE" json:"FECTCHDATE" form:"FECTCHDATE"`
57
-	OrganizationCode      string          `gorm:"column:ORGANIZATION_CODE" json:"ORGANIZATION_CODE" form:"ORGANIZATION_CODE"`
58
-	OrganizationName      string          `gorm:"column:ORGANIZATION_NAME" json:"ORGANIZATION_NAME" form:"ORGANIZATION_NAME"`
59
-	DistrictCode          string          `gorm:"column:DISTRICT_CODE" json:"DISTRICT_CODE" form:"DISTRICT_CODE"`
60
-	DistrictName          string          `gorm:"column:DISTRICT_NAME" json:"DISTRICT_NAME" form:"DISTRICT_NAME"`
61
-	Uploadmark            string          `gorm:"column:UPLOADMARK" json:"UPLOADMARK" form:"UPLOADMARK"`
62
-	Recordid              string          `gorm:"column:RECORDID" json:"RECORDID" form:"RECORDID"`
63
-	Businessyear          int64           `gorm:"column:BUSINESSYEAR" json:"BUSINESSYEAR" form:"BUSINESSYEAR"`
4
+	ReqNo              string  `gorm:"column:REQ_NO" json:"REQ_NO" form:"REQ_NO"`
5
+	Patientname        string  `gorm:"column:PATIENTNAME" json:"PATIENTNAME" form:"PATIENTNAME"`
6
+	Idcard             string  `gorm:"column:IDCARD" json:"IDCARD" form:"IDCARD"`
7
+	Hospitalcode       string  `gorm:"column:HOSPITALCODE" json:"HOSPITALCODE" form:"HOSPITALCODE"`
8
+	Hospitalname       string  `gorm:"column:HOSPITALNAME" json:"HOSPITALNAME" form:"HOSPITALNAME"`
9
+	AdmissionId        string  `gorm:"column:ADMISSION_ID" json:"ADMISSION_ID" form:"ADMISSION_ID"`
10
+	SexCode            string  `gorm:"column:SEX_CODE" json:"SEX_CODE" form:"SEX_CODE"`
11
+	SexName            string  `gorm:"column:SEX_NAME" json:"SEX_NAME" form:"SEX_NAME"`
12
+	Age                int64   `gorm:"column:AGE" json:"AGE" form:"AGE"`
13
+	AgeMonth           int64   `gorm:"column:AGE_MONTH" json:"AGE_MONTH" form:"AGE_MONTH"`
14
+	SickbedNum         string  `gorm:"column:SICKBED_NUM" json:"SICKBED_NUM" form:"SICKBED_NUM"`
15
+	BdDate             string  `gorm:"column:BD_DATE" json:"BD_DATE" form:"BD_DATE"`
16
+	BdMatno            string  `gorm:"column:BD_MATNO" json:"BD_MATNO" form:"BD_MATNO"`
17
+	Temperature        float64 `gorm:"column:TEMPERATURE" json:"TEMPERATURE" form:"TEMPERATURE"`
18
+	PulseRate          float64 `gorm:"column:PULSE_RATE" json:"PULSE_RATE" form:"PULSE_RATE"`
19
+	BreathingRate      float64 `gorm:"column:BREATHING_RATE" json:"BREATHING_RATE" form:"BREATHING_RATE"`
20
+	PressureH          float64 `gorm:"column:PRESSURE_H" json:"PRESSURE_H" form:"PRESSURE_H"`
21
+	PressureL          float64 `gorm:"column:PRESSURE_L" json:"PRESSURE_L" form:"PRESSURE_L"`
22
+	UfvLimit           float64 `gorm:"column:UFV_LIMIT" json:"UFV_LIMIT" form:"UFV_LIMIT"`
23
+	Anticoagulant      string  `gorm:"column:ANTICOAGULANT" json:"ANTICOAGULANT" form:"ANTICOAGULANT"`
24
+	FirstAnticoagulant float64 `gorm:"column:FIRST_ANTICOAGULANT" json:"FIRST_ANTICOAGULANT" form:"FIRST_ANTICOAGULANT"`
25
+	BdCruor            string  `gorm:"column:BD_CRUOR" json:"BD_CRUOR" form:"BD_CRUOR"`
26
+	BdCruorName        string  `gorm:"column:BD_CRUOR_NAME" json:"BD_CRUOR_NAME" form:"BD_CRUOR_NAME"`
27
+	BdMachine          string  `gorm:"column:BD_MACHINE" json:"BD_MACHINE" form:"BD_MACHINE"`
28
+	BdTimes            int64   `gorm:"column:BD_TIMES" json:"BD_TIMES" form:"BD_TIMES"`
29
+	BdHours            int64   `gorm:"column:BD_HOURS" json:"BD_HOURS" form:"BD_HOURS"`
30
+	BdType             int64   `gorm:"column:BD_TYPE" json:"BD_TYPE" form:"BD_TYPE"`
31
+	BdTypeName         string  `gorm:"column:BD_TYPE_NAME" json:"BD_TYPE_NAME" form:"BD_TYPE_NAME"`
32
+	BdT                float64 `gorm:"column:BD_T" json:"BD_T" form:"BD_T"`
33
+	AnticoagulantTotal float64 `gorm:"column:ANTICOAGULANT_TOTAL" json:"ANTICOAGULANT_TOTAL" form:"ANTICOAGULANT_TOTAL"`
34
+	AnticoagulantKeep  float64 `gorm:"column:ANTICOAGULANT_KEEP" json:"ANTICOAGULANT_KEEP" form:"ANTICOAGULANT_KEEP"`
35
+	BdCruorContiton    string  `gorm:"column:BD_CRUOR_CONTITON" json:"BD_CRUOR_CONTITON" form:"BD_CRUOR_CONTITON"`
36
+	PatientWeight      float64 `gorm:"column:PATIENT_WEIGHT" json:"PATIENT_WEIGHT" form:"PATIENT_WEIGHT"`
37
+	WeightBf           float64 `gorm:"column:WEIGHT_BF" json:"WEIGHT_BF" form:"WEIGHT_BF"`
38
+	WeightAf           float64 `gorm:"column:WEIGHT_AF" json:"WEIGHT_AF" form:"WEIGHT_AF"`
39
+	WeightBalan        float64 `gorm:"column:WEIGHT_BALAN" json:"WEIGHT_BALAN" form:"WEIGHT_BALAN"`
40
+	RecipeCa           int64   `gorm:"column:RECIPE_CA" json:"RECIPE_CA" form:"RECIPE_CA"`
41
+	RecipeK            int64   `gorm:"column:RECIPE_K" json:"RECIPE_K" form:"RECIPE_K"`
42
+	Compli             string  `gorm:"column:COMPLI" json:"COMPLI" form:"COMPLI"`
43
+	DiaAf              string  `gorm:"column:DIA_AF" json:"DIA_AF" form:"DIA_AF"`
44
+	Comfort            string  `gorm:"column:COMFORT" json:"COMFORT" form:"COMFORT"`
45
+	ComfortName        string  `gorm:"column:COMFORT_NAME" json:"COMFORT_NAME" form:"COMFORT_NAME"`
46
+	Vascular           string  `gorm:"column:VASCULAR" json:"VASCULAR" form:"VASCULAR"`
47
+	Notes              string  `gorm:"column:NOTES" json:"NOTES" form:"NOTES"`
48
+	OperName           string  `gorm:"column:OPER_NAME" json:"OPER_NAME" form:"OPER_NAME"`
49
+	CheckName          string  `gorm:"column:CHECK_NAME" json:"CHECK_NAME" form:"CHECK_NAME"`
50
+	PrimaryName        string  `gorm:"column:PRIMARY_NAME" json:"PRIMARY_NAME" form:"PRIMARY_NAME"`
51
+	DoctorName         string  `gorm:"column:DOCTOR_NAME" json:"DOCTOR_NAME" form:"DOCTOR_NAME"`
52
+	Orglevel           string  `gorm:"column:ORGLEVEL" json:"ORGLEVEL" form:"ORGLEVEL"`
53
+	Submitdate         string  `gorm:"column:SUBMITDATE" json:"SUBMITDATE" form:"SUBMITDATE"`
54
+	Recordstate        string  `gorm:"column:RECORDSTATE" json:"RECORDSTATE" form:"RECORDSTATE"`
55
+	Fectchdate         string  `gorm:"column:FECTCHDATE" json:"FECTCHDATE" form:"FECTCHDATE"`
56
+	OrganizationCode   string  `gorm:"column:ORGANIZATION_CODE" json:"ORGANIZATION_CODE" form:"ORGANIZATION_CODE"`
57
+	OrganizationName   string  `gorm:"column:ORGANIZATION_NAME" json:"ORGANIZATION_NAME" form:"ORGANIZATION_NAME"`
58
+	DistrictCode       string  `gorm:"column:DISTRICT_CODE" json:"DISTRICT_CODE" form:"DISTRICT_CODE"`
59
+	DistrictName       string  `gorm:"column:DISTRICT_NAME" json:"DISTRICT_NAME" form:"DISTRICT_NAME"`
60
+	Uploadmark         string  `gorm:"column:UPLOADMARK" json:"UPLOADMARK" form:"UPLOADMARK"`
61
+	Recordid           string  `gorm:"column:RECORDID" json:"RECORDID" form:"RECORDID"`
62
+	Businessyear       int64   `gorm:"column:BUSINESSYEAR" json:"BUSINESSYEAR" form:"BUSINESSYEAR"`
64
 }
63
 }
65
 
64
 
66
 func (EmrBloodDialyRecord) TableName() string {
65
 func (EmrBloodDialyRecord) TableName() string {
68
 }
67
 }
69
 
68
 
70
 type EmrBloodDialyDetail struct {
69
 type EmrBloodDialyDetail struct {
71
-	Id                    string          `gorm:"column:ID" json:"ID" form:"ID"`
72
-	ReqNo                 string          `gorm:"column:REQ_NO" json:"REQ_NO" form:"REQ_NO"`
73
-	Patientname           string          `gorm:"column:PATIENTNAME" json:"PATIENTNAME" form:"PATIENTNAME"`
74
-	Idcard             	  string          `gorm:"column:IDCARD" json:"IDCARD" form:"IDCARD"`
75
-	Hospitalcode          string          `gorm:"column:HOSPITALCODE" json:"HOSPITALCODE" form:"HOSPITALCODE"`
76
-	Hospitalname          string          `gorm:"column:HOSPITALNAME" json:"HOSPITALNAME" form:"HOSPITALNAME"`
77
-	BdDate                string       	  `gorm:"column:BD_DATE" json:"BD_DATE" form:"BD_DATE"`
78
-	BdBp                  string          `gorm:"column:BD_BP" json:"BD_BP" form:"BD_BP"`
79
-	BdT                   float64         `gorm:"column:BD_T" json:"BD_T" form:"BD_T"`
80
-	BdRate          	  float64         `gorm:"column:BD_RATE" json:"BD_RATE" form:"BD_RATE"`
81
-	BdFlow          	  float64         `gorm:"column:BD_FLOW" json:"BD_FLOW" form:"BD_FLOW"`
82
-	BdVbp                 float64         `gorm:"column:BD_VBP" json:"BD_VBP" form:"BD_VBP"`
83
-	BdTmp                 float64         `gorm:"column:BD_TMP" json:"BD_TMP" form:"BD_TMP"`
84
-	BdUfvLimit            float64         `gorm:"column:BD_UFV_LIMIT" json:"BD_UFV_LIMIT" form:"BD_UFV_LIMIT"`
85
-	Orglevel              string          `gorm:"column:ORGLEVEL" json:"ORGLEVEL" form:"ORGLEVEL"`
86
-	Submitdate            string       	  `gorm:"column:SUBMITDATE" json:"SUBMITDATE" form:"SUBMITDATE"`
87
-	Recordstate           string          `gorm:"column:RECORDSTATE" json:"RECORDSTATE" form:"RECORDSTATE"`
88
-	Fectchdate            string       	  `gorm:"column:FECTCHDATE" json:"FECTCHDATE" form:"FECTCHDATE"`
89
-	OrganizationCode      string          `gorm:"column:ORGANIZATION_CODE" json:"ORGANIZATION_CODE" form:"ORGANIZATION_CODE"`
90
-	OrganizationName      string          `gorm:"column:ORGANIZATION_NAME" json:"ORGANIZATION_NAME" form:"ORGANIZATION_NAME"`
91
-	DistrictCode          string          `gorm:"column:DISTRICT_CODE" json:"DISTRICT_CODE" form:"DISTRICT_CODE"`
92
-	DistrictName          string          `gorm:"column:DISTRICT_NAME" json:"DISTRICT_NAME" form:"DISTRICT_NAME"`
93
-	Uploadmark            string          `gorm:"column:UPLOADMARK" json:"UPLOADMARK" form:"UPLOADMARK"`
94
-	Recordid              string          `gorm:"column:RECORDID" json:"RECORDID" form:"RECORDID"`
95
-	Businessyear          int64           `gorm:"column:BUSINESSYEAR" json:"BUSINESSYEAR" form:"BUSINESSYEAR"`
96
-	
70
+	Id               string  `gorm:"column:ID" json:"ID" form:"ID"`
71
+	ReqNo            string  `gorm:"column:REQ_NO" json:"REQ_NO" form:"REQ_NO"`
72
+	Patientname      string  `gorm:"column:PATIENTNAME" json:"PATIENTNAME" form:"PATIENTNAME"`
73
+	Idcard           string  `gorm:"column:IDCARD" json:"IDCARD" form:"IDCARD"`
74
+	Hospitalcode     string  `gorm:"column:HOSPITALCODE" json:"HOSPITALCODE" form:"HOSPITALCODE"`
75
+	Hospitalname     string  `gorm:"column:HOSPITALNAME" json:"HOSPITALNAME" form:"HOSPITALNAME"`
76
+	BdDate           string  `gorm:"column:BD_DATE" json:"BD_DATE" form:"BD_DATE"`
77
+	BdBp             string  `gorm:"column:BD_BP" json:"BD_BP" form:"BD_BP"`
78
+	BdT              float64 `gorm:"column:BD_T" json:"BD_T" form:"BD_T"`
79
+	BdRate           float64 `gorm:"column:BD_RATE" json:"BD_RATE" form:"BD_RATE"`
80
+	BdFlow           float64 `gorm:"column:BD_FLOW" json:"BD_FLOW" form:"BD_FLOW"`
81
+	BdVbp            float64 `gorm:"column:BD_VBP" json:"BD_VBP" form:"BD_VBP"`
82
+	BdTmp            float64 `gorm:"column:BD_TMP" json:"BD_TMP" form:"BD_TMP"`
83
+	BdUfvLimit       float64 `gorm:"column:BD_UFV_LIMIT" json:"BD_UFV_LIMIT" form:"BD_UFV_LIMIT"`
84
+	Orglevel         string  `gorm:"column:ORGLEVEL" json:"ORGLEVEL" form:"ORGLEVEL"`
85
+	Submitdate       string  `gorm:"column:SUBMITDATE" json:"SUBMITDATE" form:"SUBMITDATE"`
86
+	Recordstate      string  `gorm:"column:RECORDSTATE" json:"RECORDSTATE" form:"RECORDSTATE"`
87
+	Fectchdate       string  `gorm:"column:FECTCHDATE" json:"FECTCHDATE" form:"FECTCHDATE"`
88
+	OrganizationCode string  `gorm:"column:ORGANIZATION_CODE" json:"ORGANIZATION_CODE" form:"ORGANIZATION_CODE"`
89
+	OrganizationName string  `gorm:"column:ORGANIZATION_NAME" json:"ORGANIZATION_NAME" form:"ORGANIZATION_NAME"`
90
+	DistrictCode     string  `gorm:"column:DISTRICT_CODE" json:"DISTRICT_CODE" form:"DISTRICT_CODE"`
91
+	DistrictName     string  `gorm:"column:DISTRICT_NAME" json:"DISTRICT_NAME" form:"DISTRICT_NAME"`
92
+	Uploadmark       string  `gorm:"column:UPLOADMARK" json:"UPLOADMARK" form:"UPLOADMARK"`
93
+	Recordid         string  `gorm:"column:RECORDID" json:"RECORDID" form:"RECORDID"`
94
+	Businessyear     int64   `gorm:"column:BUSINESSYEAR" json:"BUSINESSYEAR" form:"BUSINESSYEAR"`
97
 }
95
 }
98
 
96
 
99
 func (EmrBloodDialyDetail) TableName() string {
97
 func (EmrBloodDialyDetail) TableName() string {
101
 }
99
 }
102
 
100
 
103
 type EmrBloodDialyOrder struct {
101
 type EmrBloodDialyOrder struct {
104
-	Id                    string          `gorm:"column:ID" json:"ID" form:"ID"`
105
-	ReqNo                 string          `gorm:"column:REQ_NO" json:"REQ_NO" form:"REQ_NO"`
106
-	OrderType             string          `gorm:"column:ORDER_TYPE" json:"ORDER_TYPE" form:"ORDER_TYPE"`
107
-	OrderDate             string	      `gorm:"column:ORDER_DATE" json:"ORDER_DATE" form:"ORDER_DATE"`
108
-	OrderName             string          `gorm:"column:ORDER_NAME" json:"ORDER_NAME" form:"ORDER_NAME"`
109
-	Dosage                string          `gorm:"column:DOSAGE" json:"DOSAGE" form:"DOSAGE"`
110
-	Usage                 string          `gorm:"column:USAGE" json:"USAGE" form:"USAGE"`
111
-	ExecDate              string          `gorm:"column:EXEC_DATE" json:"EXEC_DATE" form:"EXEC_DATE"`
112
-	DoctorName            string          `gorm:"column:DOCTOR_NAME" json:"DOCTOR_NAME" form:"DOCTOR_NAME"`
113
-	NurseName             string          `gorm:"column:NURSE_NAME" json:"NURSE_NAME" form:"NURSE_NAME"`
114
-	Orglevel              string          `gorm:"column:ORGLEVEL" json:"ORGLEVEL" form:"ORGLEVEL"`
115
-	Submitdate            string       	  `gorm:"column:SUBMITDATE" json:"SUBMITDATE" form:"SUBMITDATE"`
116
-	Recordstate           string          `gorm:"column:RECORDSTATE" json:"RECORDSTATE" form:"RECORDSTATE"`
117
-	Fectchdate            string          `gorm:"column:FECTCHDATE" json:"FECTCHDATE" form:"FECTCHDATE"`
118
-	OrganizationCode      string          `gorm:"column:ORGANIZATION_CODE" json:"ORGANIZATION_CODE" form:"ORGANIZATION_CODE"`
119
-	OrganizationName      string          `gorm:"column:ORGANIZATION_NAME" json:"ORGANIZATION_NAME" form:"ORGANIZATION_NAME"`
120
-	DistrictCode          string          `gorm:"column:DISTRICT_CODE" json:"DISTRICT_CODE" form:"DISTRICT_CODE"`
121
-	DistrictName          string          `gorm:"column:DISTRICT_NAME" json:"DISTRICT_NAME" form:"DISTRICT_NAME"`
122
-	Uploadmark            string          `gorm:"column:UPLOADMARK" json:"UPLOADMARK" form:"UPLOADMARK"`
123
-	Recordid              string          `gorm:"column:RECORDID" json:"RECORDID" form:"RECORDID"`
124
-	Businessyear          int64           `gorm:"column:BUSINESSYEAR" json:"BUSINESSYEAR" form:"BUSINESSYEAR"`
125
-	
102
+	Id               string `gorm:"column:ID" json:"ID" form:"ID"`
103
+	ReqNo            string `gorm:"column:REQ_NO" json:"REQ_NO" form:"REQ_NO"`
104
+	OrderType        string `gorm:"column:ORDER_TYPE" json:"ORDER_TYPE" form:"ORDER_TYPE"`
105
+	OrderDate        string `gorm:"column:ORDER_DATE" json:"ORDER_DATE" form:"ORDER_DATE"`
106
+	OrderName        string `gorm:"column:ORDER_NAME" json:"ORDER_NAME" form:"ORDER_NAME"`
107
+	Dosage           string `gorm:"column:DOSAGE" json:"DOSAGE" form:"DOSAGE"`
108
+	Usage            string `gorm:"column:USAGE" json:"USAGE" form:"USAGE"`
109
+	ExecDate         string `gorm:"column:EXEC_DATE" json:"EXEC_DATE" form:"EXEC_DATE"`
110
+	DoctorName       string `gorm:"column:DOCTOR_NAME" json:"DOCTOR_NAME" form:"DOCTOR_NAME"`
111
+	NurseName        string `gorm:"column:NURSE_NAME" json:"NURSE_NAME" form:"NURSE_NAME"`
112
+	Orglevel         string `gorm:"column:ORGLEVEL" json:"ORGLEVEL" form:"ORGLEVEL"`
113
+	Submitdate       string `gorm:"column:SUBMITDATE" json:"SUBMITDATE" form:"SUBMITDATE"`
114
+	Recordstate      string `gorm:"column:RECORDSTATE" json:"RECORDSTATE" form:"RECORDSTATE"`
115
+	Fectchdate       string `gorm:"column:FECTCHDATE" json:"FECTCHDATE" form:"FECTCHDATE"`
116
+	OrganizationCode string `gorm:"column:ORGANIZATION_CODE" json:"ORGANIZATION_CODE" form:"ORGANIZATION_CODE"`
117
+	OrganizationName string `gorm:"column:ORGANIZATION_NAME" json:"ORGANIZATION_NAME" form:"ORGANIZATION_NAME"`
118
+	DistrictCode     string `gorm:"column:DISTRICT_CODE" json:"DISTRICT_CODE" form:"DISTRICT_CODE"`
119
+	DistrictName     string `gorm:"column:DISTRICT_NAME" json:"DISTRICT_NAME" form:"DISTRICT_NAME"`
120
+	Uploadmark       string `gorm:"column:UPLOADMARK" json:"UPLOADMARK" form:"UPLOADMARK"`
121
+	Recordid         string `gorm:"column:RECORDID" json:"RECORDID" form:"RECORDID"`
122
+	Businessyear     int64  `gorm:"column:BUSINESSYEAR" json:"BUSINESSYEAR" form:"BUSINESSYEAR"`
126
 }
123
 }
127
 
124
 
128
 func (EmrBloodDialyOrder) TableName() string {
125
 func (EmrBloodDialyOrder) TableName() string {
130
 }
127
 }
131
 
128
 
132
 type DialysisOrder struct {
129
 type DialysisOrder struct {
133
-	ID                         int64         `gorm:"column:id" json:"id"`
134
-	DialysisDate               int64         `gorm:"column:dialysis_date" json:"dialysis_date"`
135
-	UserOrgId                  int64         `gorm:"column:user_org_id" json:"user_org_id"`
136
-	PatientId                  int64         `gorm:"column:patient_id" json:"patient_id"`
137
-	PrescriptionId             int64         `gorm:"column:prescription_id" json:"prescription_id"`
138
-	Stage                      int64         `gorm:"column:stage" json:"stage"`
139
-	Remark                     string        `gorm:"column:remark" json:"remark"`
140
-	BedID                      int64         `gorm:"column:bed_id" json:"bed_id"`
141
-	StartNurse                 int64         `gorm:"column:start_nurse" json:"start_nurse"`
142
-	FinishNurse                int64         `gorm:"column:finish_nurse" json:"finish_nurse"`
143
-	Status                     int64         `gorm:"column:status" json:"status"`
144
-	CreatedTime                int64         `gorm:"column:created_time" json:"created_time"`
145
-	UpdatedTime                int64         `gorm:"column:updated_time" json:"updated_time"`
146
-	StartTime                  int64         `gorm:"column:start_time" json:"start_time"`
147
-	EndTime                    int64         `gorm:"column:end_time" json:"end_time"`
148
-	PunctureNurse              int64         `gorm:"column:puncture_nurse" json:"puncture_nurse"`
149
-	Creator                    int64         `gorm:"column:creator" json:"creator"`
150
-	Modifier                   int64         `gorm:"column:modifier" json:"modifier"`
151
-	FinishCreator              int64         `gorm:"column:finish_creator" json:"finish_creator"`
152
-	FinishModifier             int64         `gorm:"column:finish_modifier" json:"finish_modifier"`
153
-	SchedualType               int64         `gorm:"column:schedual_type" json:"schedual_type"`
154
-	WashpipeNurse              int64         `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
155
-	ChangeNurse                int64         `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
156
-	DifficultPunctureNurse     int64         `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
157
-	NewFistulaNurse            int64         `gorm:"column:new_fistula_nurse" json:"new_fistula_nurse" form:"new_fistula_nurse"`
158
-	ZoneId                     int64         `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
159
-	PuncturePointHaematoma     int64         `gorm:"column:puncture_point_haematoma" json:"puncture_point_haematoma" form:"puncture_point_haematoma"`
160
-	BloodAccessInternalFistula string        `gorm:"column:blood_access_internal_fistula" json:"blood_access_internal_fistula" form:"blood_access_internal_fistula"`
161
-	Catheter                   string        `gorm:"column:catheter" json:"catheter" form:"catheter"`
162
-	Cruor                      string        `gorm:"column:cruor" json:"cruor" form:"cruor"`
130
+	ID                         int64  `gorm:"column:id" json:"id"`
131
+	DialysisDate               int64  `gorm:"column:dialysis_date" json:"dialysis_date"`
132
+	UserOrgId                  int64  `gorm:"column:user_org_id" json:"user_org_id"`
133
+	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id"`
134
+	PrescriptionId             int64  `gorm:"column:prescription_id" json:"prescription_id"`
135
+	Stage                      int64  `gorm:"column:stage" json:"stage"`
136
+	Remark                     string `gorm:"column:remark" json:"remark"`
137
+	BedID                      int64  `gorm:"column:bed_id" json:"bed_id"`
138
+	StartNurse                 int64  `gorm:"column:start_nurse" json:"start_nurse"`
139
+	FinishNurse                int64  `gorm:"column:finish_nurse" json:"finish_nurse"`
140
+	Status                     int64  `gorm:"column:status" json:"status"`
141
+	CreatedTime                int64  `gorm:"column:created_time" json:"created_time"`
142
+	UpdatedTime                int64  `gorm:"column:updated_time" json:"updated_time"`
143
+	StartTime                  int64  `gorm:"column:start_time" json:"start_time"`
144
+	EndTime                    int64  `gorm:"column:end_time" json:"end_time"`
145
+	PunctureNurse              int64  `gorm:"column:puncture_nurse" json:"puncture_nurse"`
146
+	Creator                    int64  `gorm:"column:creator" json:"creator"`
147
+	Modifier                   int64  `gorm:"column:modifier" json:"modifier"`
148
+	FinishCreator              int64  `gorm:"column:finish_creator" json:"finish_creator"`
149
+	FinishModifier             int64  `gorm:"column:finish_modifier" json:"finish_modifier"`
150
+	SchedualType               int64  `gorm:"column:schedual_type" json:"schedual_type"`
151
+	WashpipeNurse              int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
152
+	ChangeNurse                int64  `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
153
+	DifficultPunctureNurse     int64  `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
154
+	NewFistulaNurse            int64  `gorm:"column:new_fistula_nurse" json:"new_fistula_nurse" form:"new_fistula_nurse"`
155
+	ZoneId                     int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
156
+	PuncturePointHaematoma     int64  `gorm:"column:puncture_point_haematoma" json:"puncture_point_haematoma" form:"puncture_point_haematoma"`
157
+	BloodAccessInternalFistula string `gorm:"column:blood_access_internal_fistula" json:"blood_access_internal_fistula" form:"blood_access_internal_fistula"`
158
+	Catheter                   string `gorm:"column:catheter" json:"catheter" form:"catheter"`
159
+	Cruor                      string `gorm:"column:cruor" json:"cruor" form:"cruor"`
163
 }
160
 }
164
 
161
 
165
 func (DialysisOrder) TableName() string {
162
 func (DialysisOrder) TableName() string {
518
 
515
 
519
 func (MonitoringRecord) TableName() string {
516
 func (MonitoringRecord) TableName() string {
520
 	return "xt_monitoring_record"
517
 	return "xt_monitoring_record"
521
-}
518
+}

+ 3 - 0
routers/router.go View File

36
 	beego.Router("/api/lis/tscyvip", &controllers.LisController{}, "get:SyncTscyVipLis")
36
 	beego.Router("/api/lis/tscyvip", &controllers.LisController{}, "get:SyncTscyVipLis")
37
 	beego.Router("/api/lis/syncgzky", &controllers.LisController{}, "get:SyncGzky")
37
 	beego.Router("/api/lis/syncgzky", &controllers.LisController{}, "get:SyncGzky")
38
 	beego.Router("/api/lis/syncszwz", &controllers.LisController{}, "get:SyncSzwz")
38
 	beego.Router("/api/lis/syncszwz", &controllers.LisController{}, "get:SyncSzwz")
39
+	beego.Router("/api/lis/syncpljx", &controllers.LisController{}, "get:SyncPljx")
40
+	beego.Router("/api/lis/syncbjnc", &controllers.LisController{}, "get:SyncBjncLis")
41
+	beego.Router("/api/lis/synczhra", &controllers.LisController{}, "get:SyncZhraLis")
39
 }
42
 }

+ 65 - 35
service/cron.go View File

6
 	"encoding/json"
6
 	"encoding/json"
7
 	_ "fmt"
7
 	_ "fmt"
8
 	_ "github.com/jinzhu/gorm"
8
 	_ "github.com/jinzhu/gorm"
9
-	"github.com/robfig/cron"
9
+	"github.com/robfig/cron/v3"
10
 	_ "strings"
10
 	_ "strings"
11
 	"time"
11
 	"time"
12
 )
12
 )
29
 	utils.InfoLog("开启自动检验检查同步定时任务")
29
 	utils.InfoLog("开启自动检验检查同步定时任务")
30
 	createLisSyncCronJob := newWithSeconds()
30
 	createLisSyncCronJob := newWithSeconds()
31
 
31
 
32
-	specys := "0 0 */1 * * ?" // 每天凌晨3点同步 唐山朝阳医院
33
-	createLisSyncCronJob.AddFunc(specys, func() {
34
-		SyncTscyLis()
35
-	})
36
-
37
-	specys1 := "0 10 */2 * * ?" // 每两个小时同步长沙南雅医院
38
-	createLisSyncCronJob.AddFunc(specys1, func() {
39
-		SyncCsnyLis()
40
-	})
41
-
42
-	spec := "0 50 1 * * ?" // 每天凌晨1点同步 监利大院的
43
-	createLisSyncCronJob.AddFunc(spec, func() {
44
-		SyncHbdyLis()
45
-	})
46
-
47
-	spec2 := "0 50 2 * * ?" // 每天凌晨2点同步 龙岗二院
48
-	createLisSyncCronJob.AddFunc(spec2, func() {
49
-		SyncLisLgty()
50
-	})
51
-
52
-	spec3 := "0 50 3 * * ?" // 每天凌晨2点同步 广州暨华血液透析中心
53
-	createLisSyncCronJob.AddFunc(spec3, func() {
54
-		SyncLisGzjhtx()
55
-	})
56
-
57
-	spec4 := "0 20 3 * * ?" // 每天凌晨同步 石狮盛誉血液透析中心
58
-	createLisSyncCronJob.AddFunc(spec4, func() {
59
-		SyncSYData2()
60
-	})
61
-
62
-	spec5 := "0 20 4 * * ?" // 每天凌晨同步 石狮盛誉血液透析中心
63
-	createLisSyncCronJob.AddFunc(spec5, func() {
64
-		SyncTscyVipLis()
65
-	})
32
+	//specys := "0 0 */1 * * ?" // 每天凌晨3点同步 唐山朝阳医院
33
+	//createLisSyncCronJob.AddFunc(specys, func() {
34
+	//	SyncTscyLis()
35
+	//})
36
+	//
37
+	//specys1 := "0 10 */2 * * ?" // 每两个小时同步长沙南雅医院
38
+	//createLisSyncCronJob.AddFunc(specys1, func() {
39
+	//	SyncCsnyLis()
40
+	//})
41
+	//
42
+	//spec := "0 50 1 * * ?" // 每天凌晨1点同步 监利大院的
43
+	//createLisSyncCronJob.AddFunc(spec, func() {
44
+	//	SyncHbdyLis()
45
+	//})
46
+	//
47
+	//spec2 := "0 50 2 * * ?" // 每天凌晨2点同步 龙岗二院
48
+	//createLisSyncCronJob.AddFunc(spec2, func() {
49
+	//	SyncLisLgty()
50
+	//})
51
+	//
52
+	//spec3 := "0 50 3 * * ?" // 每天凌晨2点同步 广州暨华血液透析中心
53
+	//createLisSyncCronJob.AddFunc(spec3, func() {
54
+	//	SyncLisGzjhtx()
55
+	//})
56
+	//
57
+	//spec4 := "0 20 3 * * ?" // 每天凌晨同步 石狮盛誉血液透析中心
58
+	//createLisSyncCronJob.AddFunc(spec4, func() {
59
+	//	SyncSYData2()
60
+	//})
61
+	//
62
+	//spec5 := "0 20 4 * * ?" // 每天凌晨同步 石狮盛誉血液透析中心
63
+	//createLisSyncCronJob.AddFunc(spec5, func() {
64
+	//	SyncTscyVipLis()
65
+	//})
66
 
66
 
67
 	//spec6 := "0 20 1 * * ?" // 每天凌晨同步 广州康允透析中心LIS对接,本地部署的
67
 	//spec6 := "0 20 1 * * ?" // 每天凌晨同步 广州康允透析中心LIS对接,本地部署的
68
 	//createLisSyncCronJob.AddFunc(spec6, func() {
68
 	//createLisSyncCronJob.AddFunc(spec6, func() {
69
 	//	SyncGzkyLis()
69
 	//	SyncGzkyLis()
70
 	//})
70
 	//})
71
 
71
 
72
+	//spec7 := "0 40 1 * * ?" // 每天凌晨同步 广州康允透析中心LIS对接,本地部署的
73
+	//createLisSyncCronJob.AddFunc(spec7, func() {
74
+	//	SyncLisSzwz()
75
+	//})
76
+
77
+	//spec8 := "0 20 */2 * * ?" // 每个小时同步一次 汕头三优透析中心LIS对接,本地部署的
78
+	//createLisSyncCronJob.AddFunc(spec8, func() {
79
+	//	SyncStsyLis()
80
+	//})
81
+
82
+	//spec9 := "0 57 * * * ?" // 每个小时同步一次 遵化仁爱医院LIS对接,本地部署的
83
+	//createLisSyncCronJob.AddFunc(spec9, func() {
84
+	//	SyncTszhraLis()
85
+	//})
86
+
87
+	//spec10 := "0 20 * * * ?" // 每个小时同步一次 韶关始兴源和盛LIS对接,本地部署的
88
+	//createLisSyncCronJob.AddFunc(spec10, func() {
89
+	//	SyncLisSgyhs()
90
+	//})
91
+
92
+	//spec11 := "0 20 */2 * * ?" // 每个小时同步一次 揭阳景熹LIS对接,本地部署的
93
+	//createLisSyncCronJob.AddFunc(spec11, func() {
94
+	//	SyncLisPljx(10597)
95
+	//})
96
+	//
97
+	//spec12 := "0 40 */2 * * ?" // 每个小时同步一次 普宁景熹LIS对接,本地部署的
98
+	//createLisSyncCronJob.AddFunc(spec12, func() {
99
+	//	SyncLisPljx(10599)
100
+	//})
101
+
72
 	createLisSyncCronJob.Start()
102
 	createLisSyncCronJob.Start()
73
 }
103
 }
74
 
104
 

+ 105 - 108
service/csny_service.go View File

7
 	"bytes"
7
 	"bytes"
8
 	"encoding/json"
8
 	"encoding/json"
9
 	_ "encoding/json"
9
 	_ "encoding/json"
10
-	_"encoding/xml"
10
+	_ "encoding/xml"
11
 	"fmt"
11
 	"fmt"
12
-	"net/http"
13
-	"io/ioutil"
14
 	_ "github.com/jinzhu/gorm"
12
 	_ "github.com/jinzhu/gorm"
13
+	"io/ioutil"
14
+	"net/http"
15
 
15
 
16
 	"strconv"
16
 	"strconv"
17
 	"strings"
17
 	"strings"
28
 	if syncLastInfo.ID > 0 {
28
 	if syncLastInfo.ID > 0 {
29
 		sync_time = syncLastInfo.SyncTime
29
 		sync_time = syncLastInfo.SyncTime
30
 	} else {
30
 	} else {
31
-		sync_time = 1651334400  // 2022-05-01 00:00:00
31
+		sync_time = 1651334400 // 2022-05-01 00:00:00
32
 	}
32
 	}
33
 
33
 
34
-	sync_time_temp := time.Unix(sync_time,0)
34
+	sync_time_temp := time.Unix(sync_time, 0)
35
 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
35
 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
36
 	// 第二步:获取所有患者的病历号
36
 	// 第二步:获取所有患者的病历号
37
 
37
 
43
 				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
43
 				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
44
 				// utils.InfoLog("VipStr:%v", VipStr)
44
 				// utils.InfoLog("VipStr:%v", VipStr)
45
 
45
 
46
-				result, _ := CsnyGetLab(patient.IdCardNo,syncTimeStr)
46
+				result, _ := CsnyGetLab(patient.IdCardNo, syncTimeStr)
47
 				utils.InfoLog("result:%v", result)
47
 				utils.InfoLog("result:%v", result)
48
 				var fjtfLab LabCsnyResult
48
 				var fjtfLab LabCsnyResult
49
 				if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
49
 				if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
53
 
53
 
54
 				if len(fjtfLab.Result) > 0 {
54
 				if len(fjtfLab.Result) > 0 {
55
 					// 根据获取的头部lab01获取检查结果
55
 					// 根据获取的头部lab01获取检查结果
56
-	
56
+
57
 					for _, info := range fjtfLab.Result {
57
 					for _, info := range fjtfLab.Result {
58
 						lacResult, _ := CsnyGetLac(info.Lab01)
58
 						lacResult, _ := CsnyGetLac(info.Lab01)
59
 						utils.InfoLog("lacResult:%v", lacResult)
59
 						utils.InfoLog("lacResult:%v", lacResult)
62
 							utils.ErrorLog("解析失败:%v", err)
62
 							utils.ErrorLog("解析失败:%v", err)
63
 						}
63
 						}
64
 						fmt.Println(fjtfLac)
64
 						fmt.Println(fjtfLac)
65
-						for _,cinfo := range fjtfLac.Result{
65
+						for _, cinfo := range fjtfLac.Result {
66
 							project_id := int64(0)
66
 							project_id := int64(0)
67
 							item_id := int64(0)
67
 							item_id := int64(0)
68
 							if len(cinfo.Bbx05a) > 0 {
68
 							if len(cinfo.Bbx05a) > 0 {
72
 								project_id, _ = GetCsnyProjectID(org_id, cinfo.Bbx05)
72
 								project_id, _ = GetCsnyProjectID(org_id, cinfo.Bbx05)
73
 								item_id, _ = GetCsnyItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
73
 								item_id, _ = GetCsnyItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
74
 							}
74
 							}
75
-						
76
 
75
 
77
 							tx := writeMiddleDb.Begin()
76
 							tx := writeMiddleDb.Begin()
78
 							var inspection models.MiddleInspection
77
 							var inspection models.MiddleInspection
79
 							var inspection_reference models.MiddleInspectionReference
78
 							var inspection_reference models.MiddleInspectionReference
80
 
79
 
81
-
82
 							loc, _ := time.LoadLocation("Local")
80
 							loc, _ := time.LoadLocation("Local")
83
 							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
81
 							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
84
 							record_date := theTime.Unix()
82
 							record_date := theTime.Unix()
85
 
83
 
86
-						if record_date == 0 {
87
-							record_date = time.Now().Unix()
88
-						}
89
-
90
-						inspect_date := time.Unix(record_date, 0).Format("2006-01-02 15:04")
91
-						var total int
92
-						var RangeOptions string
93
-						var RangeMin string
94
-						var RangeMax string
95
-
96
-						// // 判断检查类型
97
-						ItemType := 1
98
-						Range := strings.Split(cinfo.Lac15, "-")
99
-						if len(Range) > 1 {
100
-							RangeMin = cinfo.Lac13
101
-							RangeMax = cinfo.Lac14
102
-							ItemType = 1
103
-						} else {
104
-							ItemType = 2
105
-							RangeOptions = cinfo.Lac15
106
-						}
84
+							if record_date == 0 {
85
+								record_date = time.Now().Unix()
86
+							}
107
 
87
 
108
-						err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
109
-						// if inspection_reference.ID > 0 {
110
-						// 	ItemType = int64(inspection_reference.RangeType)
111
-						// }
112
-						
113
-						if total <= 0 {
114
-							inspection_reference.OrgId = org_id
115
-							if len(cinfo.Bbx05a) > 0 {
116
-								inspection_reference.ProjectName = cinfo.Bbx05a 
117
-								inspection_reference.Project = cinfo.Bbx05a
88
+							inspect_date := time.Unix(record_date, 0).Format("2006-01-02 15:04")
89
+							var total int
90
+							var RangeOptions string
91
+							var RangeMin string
92
+							var RangeMax string
93
+
94
+							// // 判断检查类型
95
+							ItemType := 1
96
+							Range := strings.Split(cinfo.Lac15, "-")
97
+							if len(Range) > 1 {
98
+								RangeMin = cinfo.Lac13
99
+								RangeMax = cinfo.Lac14
100
+								ItemType = 1
118
 							} else {
101
 							} else {
119
-								inspection_reference.ProjectName = cinfo.Bbx05
120
-								inspection_reference.Project = cinfo.Bbx05
102
+								ItemType = 2
103
+								RangeOptions = cinfo.Lac15
121
 							}
104
 							}
122
-							inspection_reference.ProjectId = project_id
123
-							inspection_reference.ItemName = cinfo.Bbx05
124
-							inspection_reference.ItemId = item_id
125
-							inspection_reference.RangeType = ItemType
126
-							inspection_reference.RangeMin = RangeMin
127
-							inspection_reference.RangeMax = RangeMax
128
-							// inspection_reference.RangeValue = RangeValue
129
-							inspection_reference.RangeOptions = RangeOptions
130
-							inspection_reference.Unit = cinfo.Bdg02
131
-							inspection_reference.Status = 1
132
-							inspection_reference.CreatedTime = time.Now().Unix()
133
-							inspection_reference.UpdatedTime = time.Now().Unix()
134
-							inspection_reference.InspectDate = inspect_date
135
-							inspection_reference.UTime = inspect_date
136
-							err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
137
-							if err != nil {
138
-								tx.Rollback()
105
+
106
+							err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
107
+							// if inspection_reference.ID > 0 {
108
+							// 	ItemType = int64(inspection_reference.RangeType)
109
+							// }
110
+
111
+							if total <= 0 {
112
+								inspection_reference.OrgId = org_id
113
+								if len(cinfo.Bbx05a) > 0 {
114
+									inspection_reference.ProjectName = cinfo.Bbx05a
115
+									inspection_reference.Project = cinfo.Bbx05a
116
+								} else {
117
+									inspection_reference.ProjectName = cinfo.Bbx05
118
+									inspection_reference.Project = cinfo.Bbx05
119
+								}
120
+								inspection_reference.ProjectId = project_id
121
+								inspection_reference.ItemName = cinfo.Bbx05
122
+								inspection_reference.ItemId = item_id
123
+								inspection_reference.RangeType = ItemType
124
+								inspection_reference.RangeMin = RangeMin
125
+								inspection_reference.RangeMax = RangeMax
126
+								// inspection_reference.RangeValue = RangeValue
127
+								inspection_reference.RangeOptions = RangeOptions
128
+								inspection_reference.Unit = cinfo.Bdg02
129
+								inspection_reference.Status = 1
130
+								inspection_reference.CreatedTime = time.Now().Unix()
131
+								inspection_reference.UpdatedTime = time.Now().Unix()
132
+								inspection_reference.InspectDate = inspect_date
133
+								inspection_reference.UTime = inspect_date
134
+								err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
135
+								if err != nil {
136
+									tx.Rollback()
137
+								}
139
 							}
138
 							}
140
-						}
141
 
139
 
142
-						var itotal int
143
-						err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, record_date, patient_id).Find(&inspection).Count(&itotal).Error
144
-						if itotal <= 0 {
145
-							inspection.PatientId = patient_id
146
-							inspection.OrgId = org_id
147
-							inspection.ProjectId = project_id
148
-							inspection.ItemName = inspection_reference.ItemName
149
-							inspection.ProjectName = inspection_reference.ProjectName
150
-							inspection.InspectType = ItemType
151
-							inspection.ItemId = item_id
152
-							inspection.InspectValue = cinfo.Lac10
153
-							inspection.InspectDate = inspect_date
154
-							inspection.RecordDate = record_date
155
-							inspection.InspectTips =  cinfo.Lac11
156
-							inspection.Status = 1
157
-							inspection.CreatedTime = time.Now().Unix()
158
-							inspection.UpdatedTime = time.Now().Unix()
159
-							inspection.UTime = inspect_date
160
-							inspection.HisUserId = strconv.FormatInt(patient_id, 10)
161
-							err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
162
-							if err != nil {
163
-								tx.Rollback()
140
+							var itotal int
141
+							err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, record_date, patient_id).Find(&inspection).Count(&itotal).Error
142
+							if itotal <= 0 {
143
+								inspection.PatientId = patient_id
144
+								inspection.OrgId = org_id
145
+								inspection.ProjectId = project_id
146
+								inspection.ItemName = inspection_reference.ItemName
147
+								inspection.ProjectName = inspection_reference.ProjectName
148
+								inspection.InspectType = ItemType
149
+								inspection.ItemId = item_id
150
+								inspection.InspectValue = cinfo.Lac10
151
+								inspection.InspectDate = inspect_date
152
+								inspection.RecordDate = record_date
153
+								inspection.InspectTips = cinfo.Lac11
154
+								inspection.Status = 1
155
+								inspection.CreatedTime = time.Now().Unix()
156
+								inspection.UpdatedTime = time.Now().Unix()
157
+								inspection.UTime = inspect_date
158
+								inspection.HisUserId = strconv.FormatInt(patient_id, 10)
159
+								err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
160
+								if err != nil {
161
+									tx.Rollback()
162
+								}
164
 							}
163
 							}
165
-						}
166
 
164
 
167
-						tx.Commit()
168
-						
165
+							tx.Commit()
166
+
167
+						}
169
 					}
168
 					}
170
 				}
169
 				}
171
-				}
172
 			} else {
170
 			} else {
173
 				continue
171
 				continue
174
 			}
172
 			}
197
 type LabCsnyResult struct {
195
 type LabCsnyResult struct {
198
 	Msg    string `json:"msg"`
196
 	Msg    string `json:"msg"`
199
 	Result []struct {
197
 	Result []struct {
200
-		Lab01	int64		`json:"lab01"`
201
-		Lab58	string   	`json:"lab58"`
198
+		Lab01 int64  `json:"lab01"`
199
+		Lab58 string `json:"lab58"`
202
 	} `json:"result"`
200
 	} `json:"result"`
203
 	Code string `json:"code"`
201
 	Code string `json:"code"`
204
 }
202
 }
247
 type LacCsnyResult struct {
245
 type LacCsnyResult struct {
248
 	Msg    string `json:"msg"`
246
 	Msg    string `json:"msg"`
249
 	Result []struct {
247
 	Result []struct {
250
-		Lab01	int64		`json:"labo1"`
251
-		Bbx05	string   	`json:"BBX05"`
252
-		Bbx05a	string   	`json:"BBX05A"`
253
-		Bfc03	string   	`json:"BFC03"`
254
-		Bdg02	string   	`json:"BDG02"`
255
-		Lac10	string   	`json:"LAC10"`
256
-		Lac11	string   	`json:"LAC11"`
257
-		Lac13	string   	`json:"LAC13"`
258
-		Lac14	string   	`json:"LAC14"`
259
-		Lac15	string   	`json:"LAC15"`
260
-		Lac25	string   	`json:"LAC25"`
248
+		Lab01  int64  `json:"labo1"`
249
+		Bbx05  string `json:"BBX05"`
250
+		Bbx05a string `json:"BBX05A"`
251
+		Bfc03  string `json:"BFC03"`
252
+		Bdg02  string `json:"BDG02"`
253
+		Lac10  string `json:"LAC10"`
254
+		Lac11  string `json:"LAC11"`
255
+		Lac13  string `json:"LAC13"`
256
+		Lac14  string `json:"LAC14"`
257
+		Lac15  string `json:"LAC15"`
258
+		Lac25  string `json:"LAC25"`
261
 	} `json:"result"`
259
 	} `json:"result"`
262
 	Code string `json:"code"`
260
 	Code string `json:"code"`
263
 }
261
 }
319
 }
317
 }
320
 
318
 
321
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
319
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
322
-func GetCsnyItemID(org_id int64,project_name string,item_name string,project_id int64) (item_id int64 ,err error) {
320
+func GetCsnyItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
323
 	var inspection_reference models.MiddleInspectionReference
321
 	var inspection_reference models.MiddleInspectionReference
324
-	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ? and item_name = ?", org_id,project_name,item_name).First(&inspection_reference).Error
322
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
325
 	if inspection_reference.ID > 0 {
323
 	if inspection_reference.ID > 0 {
326
-		return inspection_reference.ItemId,err
324
+		return inspection_reference.ItemId, err
327
 	} else {
325
 	} else {
328
-		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ? ", org_id,project_id).Select("max(item_id) as item_id").First(&inspection_reference).Error
329
-		utils.InfoLog("inspection_reference: %v",inspection_reference)
326
+		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ? ", org_id, project_id).Select("max(item_id) as item_id").First(&inspection_reference).Error
327
+		utils.InfoLog("inspection_reference: %v", inspection_reference)
330
 		if inspection_reference.ItemId > 0 {
328
 		if inspection_reference.ItemId > 0 {
331
-			return inspection_reference.ItemId + 1,err
329
+			return inspection_reference.ItemId + 1, err
332
 		} else {
330
 		} else {
333
-			return project_id * 100 + 1 ,err
331
+			return project_id*100 + 1, err
334
 		}
332
 		}
335
 	}
333
 	}
336
 }
334
 }
337
 
335
 
338
-
339
 func SyncToCsnytx() {
336
 func SyncToCsnytx() {
340
 	utils.TraceLog("检验检查同步任务开始执行")
337
 	utils.TraceLog("检验检查同步任务开始执行")
341
 	org_id := int64(10340)
338
 	org_id := int64(10340)

+ 3 - 4
service/db.go View File

40
 var blDb *gorm.DB
40
 var blDb *gorm.DB
41
 var shDb *gorm.DB
41
 var shDb *gorm.DB
42
 
42
 
43
-
44
 func CreateSqlServiceDB(Host string, Port string, User string, Pass string, Name string) (mssqlDb *gorm.DB, err error) {
43
 func CreateSqlServiceDB(Host string, Port string, User string, Pass string, Name string) (mssqlDb *gorm.DB, err error) {
45
 	//rdb := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", User, Pass, Host, Port, Name)
44
 	//rdb := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", User, Pass, Host, Port, Name)
46
 	mssqlstring := fmt.Sprintf("server=%s;port=%s;database=%s;user id=%s;password=%s;encrypt=disable", Host, Port, Name, User, Pass)
45
 	mssqlstring := fmt.Sprintf("server=%s;port=%s;database=%s;user id=%s;password=%s;encrypt=disable", Host, Port, Name, User, Pass)
260
 	return writeDb
259
 	return writeDb
261
 }
260
 }
262
 
261
 
263
-// func RemoteReadDB() *gorm.DB {
264
-// 	return readRemoteDb
265
-// }
262
+//	func RemoteReadDB() *gorm.DB {
263
+//		return readRemoteDb
264
+//	}
266
 func UserWriteDB() *gorm.DB {
265
 func UserWriteDB() *gorm.DB {
267
 	return writeUserDb
266
 	return writeUserDb
268
 }
267
 }

+ 105 - 108
service/fjtf_service.go View File

7
 	"bytes"
7
 	"bytes"
8
 	"encoding/json"
8
 	"encoding/json"
9
 	_ "encoding/json"
9
 	_ "encoding/json"
10
-	_"encoding/xml"
10
+	_ "encoding/xml"
11
 	"fmt"
11
 	"fmt"
12
-	"net/http"
13
-	"io/ioutil"
14
 	_ "github.com/jinzhu/gorm"
12
 	_ "github.com/jinzhu/gorm"
13
+	"io/ioutil"
14
+	"net/http"
15
 
15
 
16
 	"strconv"
16
 	"strconv"
17
 	"strings"
17
 	"strings"
28
 	if syncLastInfo.ID > 0 {
28
 	if syncLastInfo.ID > 0 {
29
 		sync_time = syncLastInfo.SyncTime
29
 		sync_time = syncLastInfo.SyncTime
30
 	} else {
30
 	} else {
31
-		sync_time = 1651334400  // 2022-05-01 00:00:00
31
+		sync_time = 1651334400 // 2022-05-01 00:00:00
32
 	}
32
 	}
33
 
33
 
34
-	sync_time_temp := time.Unix(sync_time,0)
34
+	sync_time_temp := time.Unix(sync_time, 0)
35
 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
35
 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
36
 	// 第二步:获取所有患者的病历号
36
 	// 第二步:获取所有患者的病历号
37
 
37
 
43
 				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
43
 				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
44
 				// utils.InfoLog("VipStr:%v", VipStr)
44
 				// utils.InfoLog("VipStr:%v", VipStr)
45
 
45
 
46
-				result, _ := FjtjGetLab(patient.IdCardNo,syncTimeStr)
46
+				result, _ := FjtjGetLab(patient.IdCardNo, syncTimeStr)
47
 				var fjtfLab LabResult
47
 				var fjtfLab LabResult
48
 				if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
48
 				if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
49
 					utils.ErrorLog("解析失败:%v", err)
49
 					utils.ErrorLog("解析失败:%v", err)
52
 
52
 
53
 				if len(fjtfLab.Result) > 0 {
53
 				if len(fjtfLab.Result) > 0 {
54
 					// 根据获取的头部lab01获取检查结果
54
 					// 根据获取的头部lab01获取检查结果
55
-	
55
+
56
 					for _, info := range fjtfLab.Result {
56
 					for _, info := range fjtfLab.Result {
57
 						lacResult, _ := FjtjGetLac(info.Lab01)
57
 						lacResult, _ := FjtjGetLac(info.Lab01)
58
 						var fjtfLac LacResult
58
 						var fjtfLac LacResult
60
 							utils.ErrorLog("解析失败:%v", err)
60
 							utils.ErrorLog("解析失败:%v", err)
61
 						}
61
 						}
62
 						fmt.Println(fjtfLac)
62
 						fmt.Println(fjtfLac)
63
-						for _,cinfo := range fjtfLac.Result{
63
+						for _, cinfo := range fjtfLac.Result {
64
 							project_id := int64(0)
64
 							project_id := int64(0)
65
 							item_id := int64(0)
65
 							item_id := int64(0)
66
 							if len(cinfo.Bbx05a) > 0 {
66
 							if len(cinfo.Bbx05a) > 0 {
70
 								project_id, _ = GetfjtfProjectID(org_id, cinfo.Bbx05)
70
 								project_id, _ = GetfjtfProjectID(org_id, cinfo.Bbx05)
71
 								item_id, _ = GetFjtfItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
71
 								item_id, _ = GetFjtfItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
72
 							}
72
 							}
73
-						
74
 
73
 
75
 							tx := writeMiddleDb.Begin()
74
 							tx := writeMiddleDb.Begin()
76
 							var inspection models.MiddleInspection
75
 							var inspection models.MiddleInspection
77
 							var inspection_reference models.MiddleInspectionReference
76
 							var inspection_reference models.MiddleInspectionReference
78
 
77
 
79
-
80
 							loc, _ := time.LoadLocation("Local")
78
 							loc, _ := time.LoadLocation("Local")
81
 							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
79
 							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
82
 							record_date := theTime.Unix()
80
 							record_date := theTime.Unix()
83
 
81
 
84
-						if record_date == 0 {
85
-							record_date = time.Now().Unix()
86
-						}
87
-
88
-						inspect_date := time.Unix(record_date, 0).Format("2006-01-02 15:04")
89
-						var total int
90
-						var RangeOptions string
91
-						var RangeMin string
92
-						var RangeMax string
93
-
94
-						// // 判断检查类型
95
-						ItemType := 1
96
-						Range := strings.Split(cinfo.Lac15, "-")
97
-						if len(Range) > 1 {
98
-							RangeMin = cinfo.Lac13
99
-							RangeMax = cinfo.Lac14
100
-							ItemType = 1
101
-						} else {
102
-							ItemType = 2
103
-							RangeOptions = cinfo.Lac15
104
-						}
82
+							if record_date == 0 {
83
+								record_date = time.Now().Unix()
84
+							}
105
 
85
 
106
-						err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
107
-						// if inspection_reference.ID > 0 {
108
-						// 	ItemType = int64(inspection_reference.RangeType)
109
-						// }
110
-						
111
-						if total <= 0 {
112
-							inspection_reference.OrgId = org_id
113
-							if len(cinfo.Bbx05a) > 0 {
114
-								inspection_reference.ProjectName = cinfo.Bbx05a 
115
-								inspection_reference.Project = cinfo.Bbx05a
86
+							inspect_date := time.Unix(record_date, 0).Format("2006-01-02 15:04")
87
+							var total int
88
+							var RangeOptions string
89
+							var RangeMin string
90
+							var RangeMax string
91
+
92
+							// // 判断检查类型
93
+							ItemType := 1
94
+							Range := strings.Split(cinfo.Lac15, "-")
95
+							if len(Range) > 1 {
96
+								RangeMin = cinfo.Lac13
97
+								RangeMax = cinfo.Lac14
98
+								ItemType = 1
116
 							} else {
99
 							} else {
117
-								inspection_reference.ProjectName = cinfo.Bbx05
118
-								inspection_reference.Project = cinfo.Bbx05
100
+								ItemType = 2
101
+								RangeOptions = cinfo.Lac15
119
 							}
102
 							}
120
-							inspection_reference.ProjectId = project_id
121
-							inspection_reference.ItemName = cinfo.Bbx05
122
-							inspection_reference.ItemId = item_id
123
-							inspection_reference.RangeType = ItemType
124
-							inspection_reference.RangeMin = RangeMin
125
-							inspection_reference.RangeMax = RangeMax
126
-							// inspection_reference.RangeValue = RangeValue
127
-							inspection_reference.RangeOptions = RangeOptions
128
-							inspection_reference.Unit = cinfo.Bdg02
129
-							inspection_reference.Status = 1
130
-							inspection_reference.CreatedTime = time.Now().Unix()
131
-							inspection_reference.UpdatedTime = time.Now().Unix()
132
-							inspection_reference.InspectDate = inspect_date
133
-							inspection_reference.UTime = inspect_date
134
-							err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
135
-							if err != nil {
136
-								tx.Rollback()
103
+
104
+							err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
105
+							// if inspection_reference.ID > 0 {
106
+							// 	ItemType = int64(inspection_reference.RangeType)
107
+							// }
108
+
109
+							if total <= 0 {
110
+								inspection_reference.OrgId = org_id
111
+								if len(cinfo.Bbx05a) > 0 {
112
+									inspection_reference.ProjectName = cinfo.Bbx05a
113
+									inspection_reference.Project = cinfo.Bbx05a
114
+								} else {
115
+									inspection_reference.ProjectName = cinfo.Bbx05
116
+									inspection_reference.Project = cinfo.Bbx05
117
+								}
118
+								inspection_reference.ProjectId = project_id
119
+								inspection_reference.ItemName = cinfo.Bbx05
120
+								inspection_reference.ItemId = item_id
121
+								inspection_reference.RangeType = ItemType
122
+								inspection_reference.RangeMin = RangeMin
123
+								inspection_reference.RangeMax = RangeMax
124
+								// inspection_reference.RangeValue = RangeValue
125
+								inspection_reference.RangeOptions = RangeOptions
126
+								inspection_reference.Unit = cinfo.Bdg02
127
+								inspection_reference.Status = 1
128
+								inspection_reference.CreatedTime = time.Now().Unix()
129
+								inspection_reference.UpdatedTime = time.Now().Unix()
130
+								inspection_reference.InspectDate = inspect_date
131
+								inspection_reference.UTime = inspect_date
132
+								err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
133
+								if err != nil {
134
+									tx.Rollback()
135
+								}
137
 							}
136
 							}
138
-						}
139
 
137
 
140
-						var itotal int
141
-						err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, record_date, patient_id).Find(&inspection).Count(&itotal).Error
142
-						if itotal <= 0 {
143
-							inspection.PatientId = patient_id
144
-							inspection.OrgId = org_id
145
-							inspection.ProjectId = project_id
146
-							inspection.ItemName = inspection_reference.ItemName
147
-							inspection.ProjectName = inspection_reference.ProjectName
148
-							inspection.InspectType = ItemType
149
-							inspection.ItemId = item_id
150
-							inspection.InspectValue = cinfo.Lac10
151
-							inspection.InspectDate = inspect_date
152
-							inspection.RecordDate = record_date
153
-							inspection.InspectTips =  cinfo.Lac11
154
-							inspection.Status = 1
155
-							inspection.CreatedTime = time.Now().Unix()
156
-							inspection.UpdatedTime = time.Now().Unix()
157
-							inspection.UTime = inspect_date
158
-							inspection.HisUserId = strconv.FormatInt(patient_id, 10)
159
-							err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
160
-							if err != nil {
161
-								tx.Rollback()
138
+							var itotal int
139
+							err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, record_date, patient_id).Find(&inspection).Count(&itotal).Error
140
+							if itotal <= 0 {
141
+								inspection.PatientId = patient_id
142
+								inspection.OrgId = org_id
143
+								inspection.ProjectId = project_id
144
+								inspection.ItemName = inspection_reference.ItemName
145
+								inspection.ProjectName = inspection_reference.ProjectName
146
+								inspection.InspectType = ItemType
147
+								inspection.ItemId = item_id
148
+								inspection.InspectValue = cinfo.Lac10
149
+								inspection.InspectDate = inspect_date
150
+								inspection.RecordDate = record_date
151
+								inspection.InspectTips = cinfo.Lac11
152
+								inspection.Status = 1
153
+								inspection.CreatedTime = time.Now().Unix()
154
+								inspection.UpdatedTime = time.Now().Unix()
155
+								inspection.UTime = inspect_date
156
+								inspection.HisUserId = strconv.FormatInt(patient_id, 10)
157
+								err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
158
+								if err != nil {
159
+									tx.Rollback()
160
+								}
162
 							}
161
 							}
163
-						}
164
 
162
 
165
-						tx.Commit()
166
-						
163
+							tx.Commit()
164
+
165
+						}
167
 					}
166
 					}
168
 				}
167
 				}
169
-				}
170
 			} else {
168
 			} else {
171
 				continue
169
 				continue
172
 			}
170
 			}
195
 type LabResult struct {
193
 type LabResult struct {
196
 	Msg    string `json:"msg"`
194
 	Msg    string `json:"msg"`
197
 	Result []struct {
195
 	Result []struct {
198
-		Lab01	int64		`json:"lab01"`
199
-		Lab58	string   	`json:"lab58"`
196
+		Lab01 int64  `json:"lab01"`
197
+		Lab58 string `json:"lab58"`
200
 	} `json:"result"`
198
 	} `json:"result"`
201
 	Code string `json:"code"`
199
 	Code string `json:"code"`
202
 }
200
 }
245
 type LacResult struct {
243
 type LacResult struct {
246
 	Msg    string `json:"msg"`
244
 	Msg    string `json:"msg"`
247
 	Result []struct {
245
 	Result []struct {
248
-		Lab01	int64		`json:"labo1"`
249
-		Bbx05	string   	`json:"BBX05"`
250
-		Bbx05a	string   	`json:"BBX05A"`
251
-		Bfc03	string   	`json:"BFC03"`
252
-		Bdg02	string   	`json:"BDG02"`
253
-		Lac10	string   	`json:"LAC10"`
254
-		Lac11	string   	`json:"LAC11"`
255
-		Lac13	string   	`json:"LAC13"`
256
-		Lac14	string   	`json:"LAC14"`
257
-		Lac15	string   	`json:"LAC15"`
258
-		Lac25	string   	`json:"LAC25"`
246
+		Lab01  int64  `json:"labo1"`
247
+		Bbx05  string `json:"BBX05"`
248
+		Bbx05a string `json:"BBX05A"`
249
+		Bfc03  string `json:"BFC03"`
250
+		Bdg02  string `json:"BDG02"`
251
+		Lac10  string `json:"LAC10"`
252
+		Lac11  string `json:"LAC11"`
253
+		Lac13  string `json:"LAC13"`
254
+		Lac14  string `json:"LAC14"`
255
+		Lac15  string `json:"LAC15"`
256
+		Lac25  string `json:"LAC25"`
259
 	} `json:"result"`
257
 	} `json:"result"`
260
 	Code string `json:"code"`
258
 	Code string `json:"code"`
261
 }
259
 }
317
 }
315
 }
318
 
316
 
319
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
317
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
320
-func GetFjtfItemID(org_id int64,project_name string,item_name string,project_id int64) (item_id int64 ,err error) {
318
+func GetFjtfItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
321
 	var inspection_reference models.MiddleInspectionReference
319
 	var inspection_reference models.MiddleInspectionReference
322
-	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ? and item_name = ?", org_id,project_name,item_name).First(&inspection_reference).Error
320
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
323
 	if inspection_reference.ID > 0 {
321
 	if inspection_reference.ID > 0 {
324
-		return inspection_reference.ItemId,err
322
+		return inspection_reference.ItemId, err
325
 	} else {
323
 	} else {
326
-		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ? ", org_id,project_id).Select("max(item_id) as item_id").First(&inspection_reference).Error
327
-		utils.InfoLog("inspection_reference: %v",inspection_reference)
324
+		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ? ", org_id, project_id).Select("max(item_id) as item_id").First(&inspection_reference).Error
325
+		utils.InfoLog("inspection_reference: %v", inspection_reference)
328
 		if inspection_reference.ItemId > 0 {
326
 		if inspection_reference.ItemId > 0 {
329
-			return inspection_reference.ItemId + 1,err
327
+			return inspection_reference.ItemId + 1, err
330
 		} else {
328
 		} else {
331
-			return project_id * 100 + 1 ,err
329
+			return project_id*100 + 1, err
332
 		}
330
 		}
333
 	}
331
 	}
334
 }
332
 }
335
 
333
 
336
-
337
 func SyncToFjtftx() {
334
 func SyncToFjtftx() {
338
 	utils.TraceLog("检验检查同步任务开始执行")
335
 	utils.TraceLog("检验检查同步任务开始执行")
339
 	org_id := int64(10330)
336
 	org_id := int64(10330)

+ 30 - 31
service/gzjhtxzx_service.go View File

13
 )
13
 )
14
 
14
 
15
 type RequestResultGzjh struct {
15
 type RequestResultGzjh struct {
16
-	Msg    string `json:"msg"`
16
+	Msg        string `json:"msg"`
17
 	ResultGzjh []struct {
17
 	ResultGzjh []struct {
18
 		AdviceId               int64   `json:"医嘱ID"`
18
 		AdviceId               int64   `json:"医嘱ID"`
19
 		OtherId                int64   `json:"相关ID"`
19
 		OtherId                int64   `json:"相关ID"`
100
 }
100
 }
101
 
101
 
102
 type ADStringGzjh struct {
102
 type ADStringGzjh struct {
103
-	XMLName    xml.Name     `xml:"string" json:"string"`
103
+	XMLName    xml.Name         `xml:"string" json:"string"`
104
 	NewDataSet rpnewDataSetGzjh `xml:"NewDataSet" json:"NewDataSetGzjh"`
104
 	NewDataSet rpnewDataSetGzjh `xml:"NewDataSet" json:"NewDataSetGzjh"`
105
 }
105
 }
106
 
106
 
118
 }
118
 }
119
 
119
 
120
 type ReportListXml struct {
120
 type ReportListXml struct {
121
-	XMLName 		xml.Name `xml:"GetReportList"`
122
-	Key				string `xml:"Key"`
123
-	BeginDateTime	string `xml:"BeginDateTime"`
124
-	EndDateTime		string `xml:"EndDateTime"`
125
-	TypeDateTime	string `xml:"TypeDateTime"`
126
-	AgainFlag		string `xml:"AgainFlag"`
121
+	XMLName       xml.Name `xml:"GetReportList"`
122
+	Key           string   `xml:"Key"`
123
+	BeginDateTime string   `xml:"BeginDateTime"`
124
+	EndDateTime   string   `xml:"EndDateTime"`
125
+	TypeDateTime  string   `xml:"TypeDateTime"`
126
+	AgainFlag     string   `xml:"AgainFlag"`
127
 }
127
 }
128
 
128
 
129
 // 获取机构一段时间内检验检查列表
129
 // 获取机构一段时间内检验检查列表
131
 	Domain := "http://183.63.151.26:8081/AdWebService_new/ADReportWebService.asmx/GetReportList"
131
 	Domain := "http://183.63.151.26:8081/AdWebService_new/ADReportWebService.asmx/GetReportList"
132
 	var xmlKey ADStringGzjh
132
 	var xmlKey ADStringGzjh
133
 	reportPost := httplib.Post(Domain)
133
 	reportPost := httplib.Post(Domain)
134
-	reportPost.Param("Key",Key)
135
-	reportPost.Param("BeginDateTime",BeginDateTime)
136
-	reportPost.Param("EndDateTime",EndDateTime)
137
-	reportPost.Param("TypeDateTime",TypeDateTime)
138
-	reportPost.Param("AgainFlag",AgainFlag)
139
-	reportPost.Header("Content-Type", "application/xml")  
140
-	
141
-	xmlString,_ := reportPost.String()
134
+	reportPost.Param("Key", Key)
135
+	reportPost.Param("BeginDateTime", BeginDateTime)
136
+	reportPost.Param("EndDateTime", EndDateTime)
137
+	reportPost.Param("TypeDateTime", TypeDateTime)
138
+	reportPost.Param("AgainFlag", AgainFlag)
139
+	reportPost.Header("Content-Type", "application/xml")
140
+
141
+	xmlString, _ := reportPost.String()
142
 	xmlString = strings.Replace(xmlString, "&lt;", "<", -1)
142
 	xmlString = strings.Replace(xmlString, "&lt;", "<", -1)
143
 	xmlString = strings.Replace(xmlString, "&gt;", ">", -1)
143
 	xmlString = strings.Replace(xmlString, "&gt;", ">", -1)
144
 	xml.Unmarshal([]byte(xmlString), &xmlKey)
144
 	xml.Unmarshal([]byte(xmlString), &xmlKey)
146
 }
146
 }
147
 
147
 
148
 type adkCheckGzjh struct {
148
 type adkCheckGzjh struct {
149
-	ApplyId     string      	`json:"applyid"`
150
-	ReportNo    string      	`json:"reportno"`
151
-	PatName     string      	`json:"patname"`
152
-	Sex         string      	`json:"sex"`
153
-	Age         string      	`json:"age"`
154
-	DptName     string      	`json:"dptname"`
155
-	Testtype    string      	`json:"testtype"`
156
-	Testcode    string      	`json:"testcode"`
157
-	ExecuteTime string      	`json:"receivetime"`
158
-	Checktime   string      	`json:"checktime"`
159
-	Checkcode   string      	`json:"checkcode"`
149
+	ApplyId     string          `json:"applyid"`
150
+	ReportNo    string          `json:"reportno"`
151
+	PatName     string          `json:"patname"`
152
+	Sex         string          `json:"sex"`
153
+	Age         string          `json:"age"`
154
+	DptName     string          `json:"dptname"`
155
+	Testtype    string          `json:"testtype"`
156
+	Testcode    string          `json:"testcode"`
157
+	ExecuteTime string          `json:"receivetime"`
158
+	Checktime   string          `json:"checktime"`
159
+	Checkcode   string          `json:"checkcode"`
160
 	Result      []adkResultGzjh `json:"result"`
160
 	Result      []adkResultGzjh `json:"result"`
161
 }
161
 }
162
 
162
 
164
 	Domain := "http://183.63.151.26:8081/AdWebService_new/ADReportWebService.asmx/GetJSONReportItemListById"
164
 	Domain := "http://183.63.151.26:8081/AdWebService_new/ADReportWebService.asmx/GetJSONReportItemListById"
165
 
165
 
166
 	reportPost := httplib.Post(Domain)
166
 	reportPost := httplib.Post(Domain)
167
-	reportPost.Param("Key",key)
168
-	reportPost.Param("id",id)
169
-	reportPost.Header("Content-Type", "application/xml")  
167
+	reportPost.Param("Key", key)
168
+	reportPost.Param("id", id)
169
+	reportPost.Header("Content-Type", "application/xml")
170
 	xmlKey := XmlKey{}
170
 	xmlKey := XmlKey{}
171
 	reportPost.ToXML(&xmlKey)
171
 	reportPost.ToXML(&xmlKey)
172
 	var checkJSON []adkCheckGzjh
172
 	var checkJSON []adkCheckGzjh
482
 	return nil, err
482
 	return nil, err
483
 }
483
 }
484
 
484
 
485
-
486
 // 根据姓名获取patient_id
485
 // 根据姓名获取patient_id
487
 func GetPatientGzjhListGzjh(org_id int64, schedulesTime int64) (schedules []*models.DialysisSchedule, err error) {
486
 func GetPatientGzjhListGzjh(org_id int64, schedulesTime int64) (schedules []*models.DialysisSchedule, err error) {
488
 	err = readDb.Model(&models.DialysisSchedule{}).Where("user_org_id = ? and status = 1 and  schedule_date = ?", org_id, schedulesTime).Preload("Patients", "status = 1").Find(&schedules).Error
487
 	err = readDb.Model(&models.DialysisSchedule{}).Where("user_org_id = ? and status = 1 and  schedule_date = ?", org_id, schedulesTime).Preload("Patients", "status = 1").Find(&schedules).Error

+ 304 - 0
service/pljx_service.go View File

1
+package service
2
+
3
+import (
4
+	"IC/models"
5
+	"IC/utils"
6
+	"github.com/jinzhu/gorm"
7
+	"strings"
8
+	"time"
9
+)
10
+
11
+type pljxLisReportResult struct {
12
+	Itemcode             string `gorm:"column:itemcode" json:"itemcode"`
13
+	Itemname             string `gorm:"column:itemname" json:"itemname"`
14
+	Result               string `gorm:"column:result" json:"result"`
15
+	Unit                 string `gorm:"column:unit" json:"unit"`
16
+	Refrange             string `gorm:"column:refrange" json:"refrange"`
17
+	Ts                   string `gorm:"column:ts" json:"ts"`
18
+	Repdate              string `gorm:"column:repdate" json:"repdate"`
19
+	Name                 string `gorm:"column:name" json:"name"`
20
+	DockingapplyitemName string `gorm:"column:DockingApplyItemName" json:"DockingApplyItemName"`
21
+	Sex                  string `gorm:"column:sex" json:"sex"`
22
+	Age                  string `gorm:"column:age" json:"age"`
23
+}
24
+
25
+func (pljxLisReportResult) TableName() string {
26
+	return "v_cm_result"
27
+}
28
+
29
+func GetPljxLisReport(rdb *gorm.DB, synctime string) (record []*pljxLisReportResult, err error) {
30
+	err = rdb.Model(&pljxLisReportResult{}).Where("repdate >= ?", synctime).Find(&record).Error
31
+	return
32
+}
33
+
34
+// 普宁锦熹血液透析中心Lis同步
35
+func SyncLisPljx(org_id int64) (err error) {
36
+	org := &models.DataUploadConfig{
37
+		OrgId:  org_id,
38
+		DbHost: "localhost",
39
+		DbPort: "1433",
40
+		DbPass: "1Q2W3e4r!@#$",
41
+		DbUser: "kyy",
42
+		DbName: "hyDB",
43
+	}
44
+	if org_id == 10599 {
45
+		org.DbName = "hy_pndb"
46
+	}
47
+
48
+	orgDb, err := CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
49
+	if err != nil {
50
+		utils.ErrorLog("创建数据库连接失败:%v", err)
51
+		return
52
+	}
53
+
54
+	// 第一步:获取上一次同步的时间点
55
+	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
56
+	var sync_time int64
57
+	if syncLastInfo.ID > 0 {
58
+		sync_time = syncLastInfo.SyncTime
59
+	} else {
60
+		sync_time = 1698768000 // 2023-01-01
61
+	}
62
+
63
+	SyncTime := time.Unix(sync_time, 0)
64
+	syncTimeStr := SyncTime.Format("2006-01-02 15:04:05")
65
+
66
+	// 第二步:获取时间内所有检验结果
67
+	pljxLisResult, _ := GetPljxLisReport(orgDb, syncTimeStr)
68
+	if len(pljxLisResult) > 0 {
69
+		for _, Result := range pljxLisResult {
70
+			utils.InfoLog("Report:%v", Result)
71
+			patient, _ := GetUserInfoByName(org_id, Result.Name)
72
+			if patient.ID > 0 {
73
+				project_id, _ := GetPljxProjectID(org_id, Result.DockingapplyitemName, Result.Itemname)
74
+				item_id, _ := GetPljxItemID(org_id, Result.DockingapplyitemName, Result.Itemname, project_id)
75
+				tx := writeMiddleDb.Begin()
76
+				var inspection models.MiddleInspection
77
+				var inspection_reference models.MiddleInspectionReference
78
+
79
+				tempTime := strings.Split(Result.Repdate, "T")
80
+				tempTime1 := strings.Split(tempTime[1], "Z")
81
+				tempRecord := tempTime[0] + " " + tempTime1[0]
82
+
83
+				recordTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", tempRecord)
84
+				inspect_date := recordTime.Format("2006-01-02 15:04")
85
+				recordTimeStr, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", inspect_date)
86
+				recordTimeInt := recordTimeStr.Unix()
87
+
88
+				//tempTime := strings.Split(Result.Time, "T")
89
+				//tempTime1 := strings.Split(tempTime[1], "+")
90
+				//tempRecord := tempTime[0] + " " + tempTime1[0]
91
+				//recordTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", tempRecord)
92
+				//inspect_date := recordTime.Format("2006-01-02 15:04")
93
+				//recordTimeStr, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", inspect_date)
94
+				//recordTimeInt := recordTimeStr.Unix()
95
+
96
+				var total int
97
+				var RangeOptions string
98
+				var RangeMin string
99
+				var RangeMax string
100
+				var ItemType int
101
+
102
+				Range := strings.Split(Result.Refrange, "-")
103
+				if len(Range) > 1 {
104
+					Range1 := strings.Split(Range[0], "[")
105
+					if len(Range1) > 1 {
106
+						Range2 := strings.Split(Range[1], "]")
107
+						RangeMin = Range1[1]
108
+						RangeMax = Range2[0]
109
+						ItemType = 1
110
+					} else {
111
+						ItemType = 2
112
+						RangeMin = Result.Refrange
113
+					}
114
+				} else {
115
+					ItemType = 2
116
+					RangeMin = Result.Refrange
117
+				}
118
+				RangeOptions = Result.Ts
119
+
120
+				err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
121
+				if total <= 0 {
122
+					inspection_reference.OrgId = org_id
123
+					inspection_reference.ProjectName = Result.DockingapplyitemName
124
+					inspection_reference.Project = Result.DockingapplyitemName
125
+					inspection_reference.ProjectId = project_id
126
+					inspection_reference.ItemName = Result.Itemname
127
+					inspection_reference.ItemNameAddition = Result.Itemcode
128
+					inspection_reference.ItemId = item_id
129
+					inspection_reference.RangeType = ItemType
130
+					inspection_reference.RangeMin = RangeMin
131
+					inspection_reference.RangeMax = RangeMax
132
+					inspection_reference.Unit = Result.Unit
133
+					inspection_reference.Status = 1
134
+					inspection_reference.CreatedTime = time.Now().Unix()
135
+					inspection_reference.UpdatedTime = time.Now().Unix()
136
+					inspection_reference.InspectDate = tempRecord
137
+					inspection_reference.UTime = tempRecord
138
+					err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
139
+					if err != nil {
140
+						tx.Rollback()
141
+					}
142
+				}
143
+				var itotal int
144
+				err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, recordTimeStr, patient.ID).Find(&inspection).Count(&itotal).Error
145
+				if itotal <= 0 {
146
+					// inspection.InspectValue = strings.Replace(LisInfo.Testresult, "&gt;", ">", -1)
147
+					// inspection.InspectValue = strings.Replace(LiLisInfo.Testresult, "&lt;", "<", -1)
148
+					inspection.PatientId = patient.ID
149
+					inspection.OrgId = org_id
150
+					inspection.ProjectId = project_id
151
+					inspection.ItemName = inspection_reference.ItemName
152
+					inspection.ProjectName = inspection_reference.ProjectName
153
+					inspection.InspectType = ItemType
154
+					inspection.ItemId = item_id
155
+					inspection.InspectValue = Result.Result
156
+					inspection.InspectDate = inspect_date
157
+					inspection.RecordDate = recordTimeInt
158
+					inspection.InspectTips = RangeOptions
159
+					inspection.Status = 1
160
+					inspection.CreatedTime = time.Now().Unix()
161
+					inspection.UpdatedTime = time.Now().Unix()
162
+					// inspection.UTime = record_date.Format(timeLayout)
163
+					// inspection.HisUserId = strconv.FormatInt(patient_id, 10)
164
+					inspection.SysProjectId = inspection_reference.XtProjectId
165
+					inspection.SysItemId = inspection_reference.XtItemId
166
+					err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
167
+					if err != nil {
168
+						tx.Rollback()
169
+					}
170
+				}
171
+				tx.Commit()
172
+
173
+			} else {
174
+				continue
175
+			}
176
+		}
177
+		var syncInfo models.MiddleSyncInfo
178
+		syncInfo.OrgId = org_id
179
+		syncInfo.SyncTime = time.Now().Unix()
180
+		syncInfo.SyncResultType = 1
181
+		syncInfo.SyncRsultRemark = "同步成功"
182
+		syncInfo.SyncTotalNum = 0
183
+		syncInfo.SyncSuccessNum = 0
184
+		syncInfo.SyncInfo = ""
185
+		syncInfo.CreateTime = time.Now().Unix()
186
+		syncInfo.UpdateTime = time.Now().Unix()
187
+
188
+		cwderr := CreateSyncInfo(&syncInfo)
189
+		if cwderr != nil {
190
+			utils.ErrorLog("创建同步信息失败:%v", cwderr)
191
+			return
192
+		}
193
+	}
194
+	SyncToPljx(org_id)
195
+	return
196
+}
197
+
198
+// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
199
+func GetPljxProjectID(org_id int64, project_name string, item_name string) (project_id int64, err error) {
200
+	var inspection_reference models.MiddleInspectionReference
201
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? and item_name = ? ", org_id, project_name, item_name).First(&inspection_reference).Error
202
+	if inspection_reference.ID > 0 {
203
+		return inspection_reference.ProjectId, err
204
+	} else {
205
+		err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? ", org_id, project_name).First(&inspection_reference).Error
206
+		if inspection_reference.ID > 0 {
207
+			return inspection_reference.ProjectId, err
208
+		} else {
209
+			err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
210
+			if inspection_reference.ProjectId > 0 {
211
+				return inspection_reference.ProjectId + 1, err
212
+			} else {
213
+				if org_id == 10597 {
214
+					return 1059901, err
215
+				} else {
216
+					return 1059701, err
217
+				}
218
+			}
219
+		}
220
+	}
221
+}
222
+
223
+// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
224
+func GetPljxItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
225
+	var inspection_reference models.MiddleInspectionReference
226
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
227
+	if inspection_reference.ID > 0 {
228
+		return inspection_reference.ItemId, err
229
+	} else {
230
+		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ? ", org_id, project_id).Select("max(item_id) as item_id").First(&inspection_reference).Error
231
+		if inspection_reference.ItemId > 0 {
232
+			return inspection_reference.ItemId + 1, err
233
+		} else {
234
+			return project_id*100 + 1, err
235
+		}
236
+	}
237
+}
238
+
239
+func SyncToPljx(org_id int64) {
240
+	utils.TraceLog("检验检查同步任务开始执行")
241
+	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
242
+	inspections, _ := GetSyncInspectionByOrgId(org_id)
243
+
244
+	// 第二步:将数据同步到业务库
245
+	if len(inspection_references) > 0 {
246
+		for _, inspection_reference := range inspection_references {
247
+			SyncInspectionReference(&inspection_reference)
248
+		}
249
+	}
250
+
251
+	if len(inspections) > 0 {
252
+		for _, inspection := range inspections {
253
+			SyncInspection(&inspection)
254
+		}
255
+	}
256
+
257
+	//if len(inspections) > 0 {
258
+	//	for _, inspection := range inspections {
259
+	//		if inspection.SysProjectId > 0 && inspection.SysItemId > 0 {
260
+	//			SyncPljxInspection(&inspection)
261
+	//		}
262
+	//	}
263
+	//}
264
+	utils.SuccessLog("检验检查同步任务完成")
265
+}
266
+
267
+// 从机构将数据同步到中间库
268
+func SyncPljxInspection(data *models.MiddleInspection) error {
269
+	tx := writeDb.Begin()
270
+	var inspection models.Inspection
271
+	var total int
272
+	err = readDb.Model(&models.Inspection{}).Where("org_id = ? and project_id = ? and item_id = ? and patient_id =? and inspect_date=?  and status = 1", data.OrgId, data.ProjectId, data.ItemId, data.PatientId, data.RecordDate).Find(&inspection).Count(&total).Error
273
+	if total <= 0 {
274
+		inspection.OrgId = data.OrgId
275
+		inspection.PatientId = data.PatientId
276
+		inspection.ProjectName = data.ProjectName
277
+		// inspection.Project = data.ProjectName
278
+		inspection.ProjectId = data.SysProjectId
279
+		inspection.ItemName = data.ItemName
280
+		inspection.ItemId = data.SysItemId
281
+		inspection.InspectType = int64(data.InspectType)
282
+		inspection.InspectValue = data.InspectValue
283
+		inspection.InspectTips = data.InspectTips
284
+		inspection.InspectDate = data.RecordDate
285
+		inspection.Status = 1
286
+		inspection.CreatedTime = time.Now().Unix()
287
+		inspection.UpdatedTime = time.Now().Unix()
288
+
289
+		err := tx.Model(&models.Inspection{}).Create(&inspection).Error
290
+		if err != nil {
291
+			tx.Rollback()
292
+		}
293
+
294
+		data.IsSync = 1
295
+		data.SyncId = inspection.ID
296
+		data.UpdatedTime = time.Now().Unix()
297
+		ierr := writeMiddleDb.Save(&data).Error
298
+		if ierr != nil {
299
+			tx.Rollback()
300
+		}
301
+	}
302
+	tx.Commit()
303
+	return err
304
+}

+ 11 - 18
service/sccdkfyy_service.go View File

46
 	sync_time_temp := time.Unix(sync_time, 0)
46
 	sync_time_temp := time.Unix(sync_time, 0)
47
 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
47
 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
48
 
48
 
49
-
50
 	// 第二步:获取时间内所有检验结果
49
 	// 第二步:获取时间内所有检验结果
51
 	sccdLis, _ := GetScdckfyyLis(orgDb, syncTimeStr)
50
 	sccdLis, _ := GetScdckfyyLis(orgDb, syncTimeStr)
52
 
51
 
57
 				continue
56
 				continue
58
 			}
57
 			}
59
 			// result 里查询
58
 			// result 里查询
60
-			antiRresult,_ := GetScCdkfyyAnti(orgDb,item.TestOrderNo)
61
-			if len(antiRresult) > 0  {
62
-				for _,anti := range antiRresult {
63
-					LgthScdckfyySync(anti,item, org_id, printInfo.ID)
59
+			antiRresult, _ := GetScCdkfyyAnti(orgDb, item.TestOrderNo)
60
+			if len(antiRresult) > 0 {
61
+				for _, anti := range antiRresult {
62
+					LgthScdckfyySync(anti, item, org_id, printInfo.ID)
64
 				}
63
 				}
65
 			}
64
 			}
66
 		}
65
 		}
154
 	return
153
 	return
155
 }
154
 }
156
 
155
 
157
-
158
 func SyncToScdckfyytx() {
156
 func SyncToScdckfyytx() {
159
 	utils.TraceLog("检验检查同步任务开始执行")
157
 	utils.TraceLog("检验检查同步任务开始执行")
160
 	org_id := int64(10551)
158
 	org_id := int64(10551)
178
 	utils.SuccessLog("检验检查同步任务完成")
176
 	utils.SuccessLog("检验检查同步任务完成")
179
 }
177
 }
180
 
178
 
181
-
182
 // 从机构将数据同步到中间库
179
 // 从机构将数据同步到中间库
183
 func LgthScdckfyySync(result *models.VYunjingPatientLabAnti, checkItem *models.VYunjingPatientLabItems, org_id int64, patient_id int64) (*models.MiddleInspectionReference, error) {
180
 func LgthScdckfyySync(result *models.VYunjingPatientLabAnti, checkItem *models.VYunjingPatientLabItems, org_id int64, patient_id int64) (*models.MiddleInspectionReference, error) {
184
 	tx := writeMiddleDb.Begin()
181
 	tx := writeMiddleDb.Begin()
194
 		recordDateStr = time.Now().Format("2006-01-02 15:04")
191
 		recordDateStr = time.Now().Format("2006-01-02 15:04")
195
 	}
192
 	}
196
 
193
 
197
-	
198
-
199
 	record_date_str, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", recordDateStr)
194
 	record_date_str, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", recordDateStr)
200
 	utils.InfoLog("record_date_str: %v", record_date_str)
195
 	utils.InfoLog("record_date_str: %v", record_date_str)
201
 	record_date := record_date_str.Unix()
196
 	record_date := record_date_str.Unix()
220
 		RangeOptions = result.ReferRange
215
 		RangeOptions = result.ReferRange
221
 	}
216
 	}
222
 
217
 
223
-	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_name = ? and item_name = ? and status = 1", org_id,checkItem.ItemTypeName,result.AntiName).Find(&inspection_reference).Count(&total).Error
218
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_name = ? and item_name = ? and status = 1", org_id, checkItem.ItemTypeName, result.AntiName).Find(&inspection_reference).Count(&total).Error
224
 	if inspection_reference.ID > 0 {
219
 	if inspection_reference.ID > 0 {
225
 		ItemType = inspection_reference.RangeType
220
 		ItemType = inspection_reference.RangeType
226
 	}
221
 	}
227
 	if total <= 0 {
222
 	if total <= 0 {
228
 		//  如果配置表里没有相关配置,则创建project_id,item_id和相关配置信息
223
 		//  如果配置表里没有相关配置,则创建project_id,item_id和相关配置信息
229
-		project_id, _ := GetSccdkfyyProjectID(org_id,checkItem.ItemTypeName)
230
-		item_id,_ := GetSccdkfyyItemID(org_id, checkItem.ItemTypeName, result.AntiName, project_id)
224
+		project_id, _ := GetSccdkfyyProjectID(org_id, checkItem.ItemTypeName)
225
+		item_id, _ := GetSccdkfyyItemID(org_id, checkItem.ItemTypeName, result.AntiName, project_id)
231
 
226
 
232
 		inspection_reference.OrgId = org_id
227
 		inspection_reference.OrgId = org_id
233
 		inspection_reference.ProjectName = checkItem.ItemTypeName
228
 		inspection_reference.ProjectName = checkItem.ItemTypeName
289
 	return
284
 	return
290
 }
285
 }
291
 
286
 
292
-
293
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
287
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
294
 func GetSccdkfyyItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
288
 func GetSccdkfyyItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
295
 	var inspection_reference models.MiddleInspectionReference
289
 	var inspection_reference models.MiddleInspectionReference
307
 	}
301
 	}
308
 }
302
 }
309
 
303
 
310
-
311
 // 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
304
 // 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
312
 func GetSccdkfyyProjectID(org_id int64, project_name string) (project_id int64, err error) {
305
 func GetSccdkfyyProjectID(org_id int64, project_name string) (project_id int64, err error) {
313
 	var inspection_reference models.MiddleInspectionReference
306
 	var inspection_reference models.MiddleInspectionReference
324
 	}
317
 	}
325
 }
318
 }
326
 
319
 
327
-func GetScCdkfyyResult(rdb *gorm.DB, serialNo string,parItemNo string) (record []*models.PlugPlugresult, err error) {
328
-	err = rdb.Model(&models.PlugPlugresult{}).Where("serialNo = ? and parItemNo = ?", serialNo,parItemNo).Find(&record).Error
320
+func GetScCdkfyyResult(rdb *gorm.DB, serialNo string, parItemNo string) (record []*models.PlugPlugresult, err error) {
321
+	err = rdb.Model(&models.PlugPlugresult{}).Where("serialNo = ? and parItemNo = ?", serialNo, parItemNo).Find(&record).Error
329
 	return
322
 	return
330
 }
323
 }
331
 
324
 
334
 	return
327
 	return
335
 }
328
 }
336
 
329
 
337
-func GetScCdkfyyCase(rdb *gorm.DB, startId int64,endId int64, hisuserid string) (record []*models.PlugPlugcase, err error) {
338
-	err = rdb.Model(&models.PlugPlugcase{}).Where("ID >= ? and ID <= ? and mainIndex = ?", startId,endId, hisuserid).Find(&record).Error
330
+func GetScCdkfyyCase(rdb *gorm.DB, startId int64, endId int64, hisuserid string) (record []*models.PlugPlugcase, err error) {
331
+	err = rdb.Model(&models.PlugPlugcase{}).Where("ID >= ? and ID <= ? and mainIndex = ?", startId, endId, hisuserid).Find(&record).Error
339
 	return
332
 	return
340
 }
333
 }
341
 
334
 

+ 245 - 0
service/sgyhs_service.go View File

1
+package service
2
+
3
+import (
4
+	"IC/models"
5
+	"IC/utils"
6
+	"github.com/jinzhu/gorm"
7
+	"strings"
8
+	"time"
9
+)
10
+
11
+type sgyhsLisReportResult struct {
12
+	Itemcode             string `gorm:"column:itemcode" json:"itemcode"`
13
+	Itemname             string `gorm:"column:itemname" json:"itemname"`
14
+	Result               string `gorm:"column:result" json:"result"`
15
+	Unit                 string `gorm:"column:unit" json:"unit"`
16
+	Refrange             string `gorm:"column:refrange" json:"refrange"`
17
+	Ts                   string `gorm:"column:ts" json:"ts"`
18
+	Repdate              string `gorm:"column:repdate" json:"repdate"`
19
+	Name                 string `gorm:"column:name" json:"name"`
20
+	DockingapplyitemName string `gorm:"column:DockingApplyItemName" json:"DockingApplyItemName"`
21
+	Sex                  string `gorm:"column:sex" json:"sex"`
22
+	Age                  string `gorm:"column:age" json:"age"`
23
+}
24
+
25
+func (sgyhsLisReportResult) TableName() string {
26
+	return "v_cm_result"
27
+}
28
+
29
+func GetSgyhsLisReport(rdb *gorm.DB, synctime string) (record []*sgyhsLisReportResult, err error) {
30
+	err = rdb.Model(&sgyhsLisReportResult{}).Where("repdate >= ?", synctime).Find(&record).Error
31
+	return
32
+}
33
+
34
+// 韶关始兴源和圣血液透析中心Lis同步
35
+func SyncLisSgyhs() (err error) {
36
+	org_id := int64(10571)
37
+	org := &models.DataUploadConfig{
38
+		OrgId:  org_id,
39
+		DbHost: "192.168.3.75",
40
+		DbPort: "1433",
41
+		DbPass: "hy@123456.",
42
+		DbUser: "sa",
43
+		DbName: "hyDB",
44
+	}
45
+
46
+	orgDb, err := CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
47
+	if err != nil {
48
+		utils.ErrorLog("创建数据库连接失败:%v", err)
49
+		return
50
+	}
51
+
52
+	// 第一步:获取上一次同步的时间点
53
+	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
54
+	var sync_time int64
55
+	if syncLastInfo.ID > 0 {
56
+		sync_time = syncLastInfo.SyncTime
57
+	} else {
58
+		sync_time = 1698768000 // 2023-01-01
59
+	}
60
+
61
+	SyncTime := time.Unix(sync_time, 0)
62
+	syncTimeStr := SyncTime.Format("2006-01-02 15:04:05")
63
+
64
+	utils.InfoLog("syncTimeStr:%v", syncTimeStr)
65
+
66
+	// 第二步:获取时间内所有检验结果
67
+	sgyhsLisResult, _ := GetSgyhsLisReport(orgDb, syncTimeStr)
68
+	if len(sgyhsLisResult) > 0 {
69
+		for _, Result := range sgyhsLisResult {
70
+			utils.InfoLog("Report:%v", Result)
71
+			if Result.Name == "陈永中" {
72
+				Result.Name = "陈永忠"
73
+			}
74
+			patient, _ := GetUserInfoByName(org_id, Result.Name)
75
+			if patient.ID > 0 {
76
+				project_id, _ := GetSgyhsProjectID(org_id, Result.DockingapplyitemName)
77
+				item_id, _ := GetSgyhsItemID(org_id, Result.DockingapplyitemName, Result.Itemname, project_id)
78
+				tx := writeMiddleDb.Begin()
79
+				var inspection models.MiddleInspection
80
+				var inspection_reference models.MiddleInspectionReference
81
+
82
+				tempTime := strings.Split(Result.Repdate, "T")
83
+				tempTime1 := strings.Split(tempTime[1], "Z")
84
+				tempRecord := tempTime[0] + " " + tempTime1[0]
85
+				recordTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", tempRecord)
86
+				inspect_date := recordTime.Format("2006-01-02 15:04")
87
+				recordTimeStr, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", inspect_date)
88
+				recordTimeInt := recordTimeStr.Unix()
89
+
90
+				var total int
91
+				var RangeOptions string
92
+				var RangeMin string
93
+				var RangeMax string
94
+				var ItemType int
95
+
96
+				Range := strings.Split(Result.Refrange, "-")
97
+				if len(Range) > 1 {
98
+					Range1 := strings.Split(Range[0], "[")
99
+					if len(Range1) > 1 {
100
+						Range2 := strings.Split(Range[1], "]")
101
+						RangeMin = Range1[1]
102
+						RangeMax = Range2[0]
103
+						ItemType = 1
104
+					} else {
105
+						ItemType = 2
106
+						RangeMin = Result.Refrange
107
+					}
108
+				} else {
109
+					ItemType = 2
110
+					RangeMin = Result.Refrange
111
+				}
112
+				RangeOptions = Result.Ts
113
+
114
+				err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
115
+				if total <= 0 {
116
+					inspection_reference.OrgId = org_id
117
+					inspection_reference.ProjectName = Result.DockingapplyitemName
118
+					inspection_reference.Project = Result.DockingapplyitemName
119
+					inspection_reference.ProjectId = project_id
120
+					inspection_reference.ItemName = Result.Itemname
121
+					inspection_reference.ItemNameAddition = Result.Itemcode
122
+					inspection_reference.ItemId = item_id
123
+					inspection_reference.RangeType = ItemType
124
+					inspection_reference.RangeMin = RangeMin
125
+					inspection_reference.RangeMax = RangeMax
126
+					inspection_reference.Unit = Result.Unit
127
+					inspection_reference.Status = 1
128
+					inspection_reference.CreatedTime = time.Now().Unix()
129
+					inspection_reference.UpdatedTime = time.Now().Unix()
130
+					inspection_reference.InspectDate = tempRecord
131
+					inspection_reference.UTime = tempRecord
132
+					err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
133
+					if err != nil {
134
+						tx.Rollback()
135
+					}
136
+				}
137
+				var itotal int
138
+				err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, recordTimeStr, patient.ID).Find(&inspection).Count(&itotal).Error
139
+				if itotal <= 0 {
140
+					// inspection.InspectValue = strings.Replace(LisInfo.Testresult, "&gt;", ">", -1)
141
+					// inspection.InspectValue = strings.Replace(LiLisInfo.Testresult, "&lt;", "<", -1)
142
+					inspection.PatientId = patient.ID
143
+					inspection.OrgId = org_id
144
+					inspection.ProjectId = project_id
145
+					inspection.ItemName = inspection_reference.ItemName
146
+					inspection.ProjectName = inspection_reference.ProjectName
147
+					inspection.InspectType = ItemType
148
+					inspection.ItemId = item_id
149
+					inspection.InspectValue = Result.Result
150
+					inspection.InspectDate = inspect_date
151
+					inspection.RecordDate = recordTimeInt
152
+					inspection.InspectTips = RangeOptions
153
+					inspection.Status = 1
154
+					inspection.CreatedTime = time.Now().Unix()
155
+					inspection.UpdatedTime = time.Now().Unix()
156
+					// inspection.UTime = record_date.Format(timeLayout)
157
+					// inspection.HisUserId = strconv.FormatInt(patient_id, 10)
158
+					inspection.SysProjectId = inspection_reference.XtProjectId
159
+					inspection.SysItemId = inspection_reference.XtItemId
160
+					err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
161
+					if err != nil {
162
+						tx.Rollback()
163
+					}
164
+				}
165
+				tx.Commit()
166
+
167
+			} else {
168
+				continue
169
+			}
170
+		}
171
+		var syncInfo models.MiddleSyncInfo
172
+		syncInfo.OrgId = org_id
173
+		syncInfo.SyncTime = time.Now().Unix()
174
+		syncInfo.SyncResultType = 1
175
+		syncInfo.SyncRsultRemark = "同步成功"
176
+		syncInfo.SyncTotalNum = 0
177
+		syncInfo.SyncSuccessNum = 0
178
+		syncInfo.SyncInfo = ""
179
+		syncInfo.CreateTime = time.Now().Unix()
180
+		syncInfo.UpdateTime = time.Now().Unix()
181
+
182
+		cwderr := CreateSyncInfo(&syncInfo)
183
+		if cwderr != nil {
184
+			utils.ErrorLog("创建同步信息失败:%v", cwderr)
185
+			return
186
+		}
187
+	}
188
+
189
+	SyncToSgyhs()
190
+	return
191
+}
192
+
193
+// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
194
+func GetSgyhsProjectID(org_id int64, project_name string) (project_id int64, err error) {
195
+	var inspection_reference models.MiddleInspectionReference
196
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?  ", org_id, project_name).First(&inspection_reference).Error
197
+	if inspection_reference.ID > 0 {
198
+		return inspection_reference.ProjectId, err
199
+	} else {
200
+		err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
201
+		if inspection_reference.ProjectId > 0 {
202
+			return inspection_reference.ProjectId + 1, err
203
+		} else {
204
+			return 1057101, err
205
+		}
206
+	}
207
+}
208
+
209
+// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
210
+func GetSgyhsItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
211
+	var inspection_reference models.MiddleInspectionReference
212
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
213
+	if inspection_reference.ID > 0 {
214
+		return inspection_reference.ItemId, err
215
+	} else {
216
+		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ? ", org_id, project_id).Select("max(item_id) as item_id").First(&inspection_reference).Error
217
+		if inspection_reference.ItemId > 0 {
218
+			return inspection_reference.ItemId + 1, err
219
+		} else {
220
+			return project_id*100 + 1, err
221
+		}
222
+	}
223
+}
224
+
225
+func SyncToSgyhs() {
226
+	utils.TraceLog("检验检查同步任务开始执行")
227
+	org_id := int64(10571)
228
+	// 第一步:跟进org_id 去中间库查出需要同步的数据
229
+	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
230
+	inspections, _ := GetSyncInspectionByOrgId(org_id)
231
+
232
+	// 第二步:将数据同步到业务库
233
+	if len(inspection_references) > 0 {
234
+		for _, inspection_reference := range inspection_references {
235
+			SyncInspectionReference(&inspection_reference)
236
+		}
237
+	}
238
+
239
+	if len(inspections) > 0 {
240
+		for _, inspection := range inspections {
241
+			SyncInspection(&inspection)
242
+		}
243
+	}
244
+	utils.SuccessLog("检验检查同步任务完成")
245
+}

+ 17 - 15
service/sy_service.go View File

220
 				continue
220
 				continue
221
 			}
221
 			}
222
 		}
222
 		}
223
-	}
224
-	var syncInfo models.MiddleSyncInfo
225
-	syncInfo.OrgId = org_id
226
-	syncInfo.SyncTime = time.Now().Unix()
227
-	syncInfo.SyncResultType = 1
228
-	syncInfo.SyncRsultRemark = "同步成功"
229
-	syncInfo.SyncTotalNum = 0
230
-	syncInfo.SyncSuccessNum = 0
231
-	syncInfo.SyncInfo = ""
232
-	syncInfo.CreateTime = time.Now().Unix()
233
-	syncInfo.UpdateTime = time.Now().Unix()
234
 
223
 
235
-	cwderr := CreateSyncInfo(&syncInfo)
236
-	if cwderr != nil {
237
-		utils.ErrorLog("创建同步信息失败:%v", cwderr)
238
-		return
224
+		var syncInfo models.MiddleSyncInfo
225
+		syncInfo.OrgId = org_id
226
+		syncInfo.SyncTime = time.Now().Unix()
227
+		syncInfo.SyncResultType = 1
228
+		syncInfo.SyncRsultRemark = "同步成功"
229
+		syncInfo.SyncTotalNum = 0
230
+		syncInfo.SyncSuccessNum = 0
231
+		syncInfo.SyncInfo = ""
232
+		syncInfo.CreateTime = time.Now().Unix()
233
+		syncInfo.UpdateTime = time.Now().Unix()
234
+
235
+		cwderr := CreateSyncInfo(&syncInfo)
236
+		if cwderr != nil {
237
+			utils.ErrorLog("创建同步信息失败:%v", cwderr)
238
+			return
239
+		}
239
 	}
240
 	}
241
+
240
 	SyncToStsytx()
242
 	SyncToStsytx()
241
 	return
243
 	return
242
 }
244
 }

+ 41 - 45
service/szbl_service.go View File

4
 	"IC/models"
4
 	"IC/models"
5
 	"IC/utils"
5
 	"IC/utils"
6
 	"fmt"
6
 	"fmt"
7
-	_"regexp"
7
+	"github.com/jinzhu/gorm"
8
+	_ "regexp"
8
 	"strconv"
9
 	"strconv"
9
 	"strings"
10
 	"strings"
10
 	"time"
11
 	"time"
11
-	_"unicode"
12
-	"github.com/jinzhu/gorm"
12
+	_ "unicode"
13
 )
13
 )
14
 
14
 
15
-
16
-
17
 type SZBLJYJC struct {
15
 type SZBLJYJC struct {
18
-	FName                  string `gorm:"column:name" json:"name" form:"name"`
19
-	FCompoundItemName      string `gorm:"column:DockingApplyItemName" json:"DockingApplyItemName" form:"DockingApplyItemName"`
20
-	FReference             string `gorm:"column:refrange" json:"refrange" form:"refrange"`
21
-	FSingleItemName        string `gorm:"column:itemname" json:"itemname" form:"itemname"`
22
-	FRecordTime            string `gorm:"column:recordTime" json:"recordTime" form:"recordTime"`
23
-	FCheckTime             string `gorm:"column:repdate" json:"repdate" form:"repdate"`
24
-	FResult                string `gorm:"column:result" json:"result" form:"result"`
25
-	FUnit                  string `gorm:"column:unit" json:"unit" form:"unit"`
16
+	FName             string `gorm:"column:name" json:"name" form:"name"`
17
+	FCompoundItemName string `gorm:"column:DockingApplyItemName" json:"DockingApplyItemName" form:"DockingApplyItemName"`
18
+	FReference        string `gorm:"column:refrange" json:"refrange" form:"refrange"`
19
+	FSingleItemName   string `gorm:"column:itemname" json:"itemname" form:"itemname"`
20
+	FRecordTime       string `gorm:"column:recordTime" json:"recordTime" form:"recordTime"`
21
+	FCheckTime        string `gorm:"column:repdate" json:"repdate" form:"repdate"`
22
+	FResult           string `gorm:"column:result" json:"result" form:"result"`
23
+	FUnit             string `gorm:"column:unit" json:"unit" form:"unit"`
26
 }
24
 }
27
 
25
 
28
 func (SZBLJYJC) TableName() string {
26
 func (SZBLJYJC) TableName() string {
29
 	return "v_cm_result"
27
 	return "v_cm_result"
30
 }
28
 }
31
 
29
 
32
-//获取lis返回检验检查结果数据
30
+// 获取lis返回检验检查结果数据
33
 func GetSZBLResultDataInsertDB(org_id int64) (result []*SZBLJYJC) {
31
 func GetSZBLResultDataInsertDB(org_id int64) (result []*SZBLJYJC) {
34
 
32
 
35
 	org := &models.DataUploadConfig{
33
 	org := &models.DataUploadConfig{
53
 			return
51
 			return
54
 		}
52
 		}
55
 
53
 
56
-	record, _ := GetLastSyncResultRecord(org_id)
57
-	fmt.Println(record)
58
-	var sync_time int64
59
-	if record.ID > 0 {
60
-		sync_time = record.Ctime
61
-	} else {
62
-		sync_time = 1627747200
63
-	}
54
+		record, _ := GetLastSyncResultRecord(org_id)
55
+		fmt.Println(record)
56
+		var sync_time int64
57
+		if record.ID > 0 {
58
+			sync_time = record.Ctime
59
+		} else {
60
+			sync_time = 1627747200
61
+		}
64
 
62
 
65
-	sync_time_temp := time.Unix(sync_time,0)
66
-	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
63
+		sync_time_temp := time.Unix(sync_time, 0)
64
+		syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
67
 
65
 
68
-		list, err := GetSZBLResultRecord(orgDb,syncTimeStr)
66
+		list, err := GetSZBLResultRecord(orgDb, syncTimeStr)
69
 		if err == nil {
67
 		if err == nil {
70
 			// fmt.Println(list)
68
 			// fmt.Println(list)
71
 
69
 
81
 				}
79
 				}
82
 
80
 
83
 				project_id := int64(0)
81
 				project_id := int64(0)
84
-				
82
+
85
 				project_id, _ = GetSzbljhProjectID(org_id, item.FCompoundItemName)
83
 				project_id, _ = GetSzbljhProjectID(org_id, item.FCompoundItemName)
86
-				
87
-				
88
 
84
 
89
 				item_id, _ := GetSzblItemID(org_id, item.FCompoundItemName, item.FSingleItemName, project_id)
85
 				item_id, _ := GetSzblItemID(org_id, item.FCompoundItemName, item.FSingleItemName, project_id)
90
 
86
 
101
 				recordDateStr = timstr[0] + " " + timstem[0]
97
 				recordDateStr = timstr[0] + " " + timstem[0]
102
 				// recordDateStr = item.FCheckTime
98
 				// recordDateStr = item.FCheckTime
103
 				fmt.Println(recordDateStr)
99
 				fmt.Println(recordDateStr)
104
-				date ,_ :=  utils.ParseTimeStringToTime("2006-01-02 15:04:05",recordDateStr)
100
+				date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", recordDateStr)
105
 				fmt.Println(date)
101
 				fmt.Println(date)
106
 				record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
102
 				record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
107
 				fmt.Println(record_date)
103
 				fmt.Println(record_date)
108
-			
104
+
109
 				// ftimstr := strings.Split(item.FCheckTime, "T")
105
 				// ftimstr := strings.Split(item.FCheckTime, "T")
110
 				// ftimstem := strings.Split(timstr[1], "Z")
106
 				// ftimstem := strings.Split(timstr[1], "Z")
111
 
107
 
203
 			writeMiddleDb.Save(&info)
199
 			writeMiddleDb.Save(&info)
204
 		}
200
 		}
205
 
201
 
206
-	// 第一步:跟进org_id 去中间库查出需要同步的数据
207
-	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
208
-	inspections, _ := GetSyncInspectionByOrgId(org_id)
202
+		// 第一步:跟进org_id 去中间库查出需要同步的数据
203
+		inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
204
+		inspections, _ := GetSyncInspectionByOrgId(org_id)
209
 
205
 
210
-	// 第二步:将数据同步到业务库
211
-	if len(inspection_references) > 0 {
212
-		for _, inspection_reference := range inspection_references {
213
-			SyncInspectionReference(&inspection_reference)
206
+		// 第二步:将数据同步到业务库
207
+		if len(inspection_references) > 0 {
208
+			for _, inspection_reference := range inspection_references {
209
+				SyncInspectionReference(&inspection_reference)
210
+			}
214
 		}
211
 		}
215
-	}
216
 
212
 
217
-	if len(inspections) > 0 {
218
-		for _, inspection := range inspections {
219
-			SyncInspection(&inspection)
213
+		if len(inspections) > 0 {
214
+			for _, inspection := range inspections {
215
+				SyncInspection(&inspection)
216
+			}
220
 		}
217
 		}
221
 	}
218
 	}
222
-}
223
-return
219
+	return
224
 
220
 
225
 }
221
 }
226
 
222
 
227
-func GetSZBLResultRecord(rdb *gorm.DB,synctime string) (record []*SZBLJYJC, err error) {
228
-	err = rdb.Model(&SZBLJYJC{}).Where("repdate >= ?",synctime).Find(&record).Error
223
+func GetSZBLResultRecord(rdb *gorm.DB, synctime string) (record []*SZBLJYJC, err error) {
224
+	err = rdb.Model(&SZBLJYJC{}).Where("repdate >= ?", synctime).Find(&record).Error
229
 	return
225
 	return
230
 }
226
 }
231
 
227
 

+ 191 - 16
service/szwz_service.go View File

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
+	"IC/models"
4
 	"IC/utils"
5
 	"IC/utils"
5
-	_ "IC/utils"
6
-	_ "encoding/json"
7
-	"fmt"
8
-	oracle "github.com/godoes/gorm-oracle"
9
-	_ "github.com/godror/godror"
6
+	oracle "github.com/dzwvip/gorm-oracle"
10
 	"gorm.io/gorm"
7
 	"gorm.io/gorm"
11
-	_ "strconv"
8
+	"strings"
12
 	"time"
9
 	"time"
13
 )
10
 )
14
 
11
 
17
 	Repname        string `gorm:"column:REPNAME" json:"REPNAME"`
14
 	Repname        string `gorm:"column:REPNAME" json:"REPNAME"`
18
 	NAME           string `gorm:"column:NAME" json:"NAME"`
15
 	NAME           string `gorm:"column:NAME" json:"NAME"`
19
 	Appdeptname    string `gorm:"column:APPDEPTNAME" json:"APPDEPTNAME"`
16
 	Appdeptname    string `gorm:"column:APPDEPTNAME" json:"APPDEPTNAME"`
20
-	Fisrtaudittime string `gorm:"column:FISRTAUDITTIME" json:"FISRTAUDITTIME"`
17
+	Firstaudittime string `gorm:"column:FIRSTAUDITTIME" json:"FIRSTAUDITTIME"`
21
 }
18
 }
22
 
19
 
23
 func (wzLisReport) TableName() string {
20
 func (wzLisReport) TableName() string {
42
 }
39
 }
43
 
40
 
44
 func GetSzwzyLisReport(rdb *gorm.DB, synctime string) (record []*wzLisReport, err error) {
41
 func GetSzwzyLisReport(rdb *gorm.DB, synctime string) (record []*wzLisReport, err error) {
45
-	err = rdb.Model(&wzLisReport{}).Where("FISRTAUDITTIME >= ? and APPDEPTNAME = '肾病科'", synctime).Find(&record).Error
42
+	err = rdb.Model(&wzLisReport{}).Where("FIRSTAUDITTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')  and APPDEPTNAME = '肾病科'", synctime).Find(&record).Error
46
 	return
43
 	return
47
 }
44
 }
48
 
45
 
55
 func SyncLisSzwz() (err error) {
52
 func SyncLisSzwz() (err error) {
56
 
53
 
57
 	org_id := int64(10580)
54
 	org_id := int64(10580)
58
-	// oracle://user:password@127.0.0.1:1521/service
59
-	url := oracle.BuildUrl("172.9.200.3", 1521, "JKY", "BSLIS52", "zhsoft", nil)
60
-	orgDb, err := gorm.Open(oracle.Open(url), &gorm.Config{})
55
+
56
+	orgDb, err := gorm.Open(oracle.Open("oracle://BSLIS52:zhsoft@172.9.200.3:1521/JYK"), &gorm.Config{})
57
+
61
 	if err != nil {
58
 	if err != nil {
62
-		utils.ErrorLog("创建数据库连接失败:%v", err)
63
-		return
59
+		utils.InfoLog("syncTimeStr:%v", err)
64
 	}
60
 	}
65
 
61
 
66
 	// 第一步:获取上一次同步的时间点
62
 	// 第一步:获取上一次同步的时间点
75
 	SyncTime := time.Unix(sync_time, 0)
71
 	SyncTime := time.Unix(sync_time, 0)
76
 	syncTimeStr := SyncTime.Format("2006-01-02 15:04:05")
72
 	syncTimeStr := SyncTime.Format("2006-01-02 15:04:05")
77
 
73
 
78
-	fmt.Println(SyncTime)
74
+	utils.InfoLog("syncTimeStr:%v", syncTimeStr)
79
 
75
 
80
 	// 第二步:获取时间内所有检验结果
76
 	// 第二步:获取时间内所有检验结果
81
 	szwzLisReport, _ := GetSzwzyLisReport(orgDb, syncTimeStr)
77
 	szwzLisReport, _ := GetSzwzyLisReport(orgDb, syncTimeStr)
82
 	if len(szwzLisReport) > 0 {
78
 	if len(szwzLisReport) > 0 {
83
 		for _, Report := range szwzLisReport {
79
 		for _, Report := range szwzLisReport {
84
 			utils.InfoLog("Report:%v", Report)
80
 			utils.InfoLog("Report:%v", Report)
85
-			utils.InfoLog("患者姓名:%v", Report.NAME)
86
 			if len(Report.Repname) <= 0 {
81
 			if len(Report.Repname) <= 0 {
87
 				Report.Repname = "未知"
82
 				Report.Repname = "未知"
88
 			}
83
 			}
92
 				szwzLisReportResult, _ := GetSzwzyLisReportResule(orgDb, Report.Repno)
87
 				szwzLisReportResult, _ := GetSzwzyLisReportResule(orgDb, Report.Repno)
93
 				if len(szwzLisReportResult) > 0 {
88
 				if len(szwzLisReportResult) > 0 {
94
 					for _, Result := range szwzLisReportResult {
89
 					for _, Result := range szwzLisReportResult {
95
-						utils.InfoLog("Result:%v", Result)
90
+						project_id, _ := GetSzwzProjectID(org_id, Report.Repname)
91
+						item_id, _ := GetSzwzItemID(org_id, Report.Repname, Result.Itemcname, project_id)
92
+						tx := writeMiddleDb.Begin()
93
+						var inspection models.MiddleInspection
94
+						var inspection_reference models.MiddleInspectionReference
95
+						tempTime := strings.Split(Result.Time, "T")
96
+						tempTime1 := strings.Split(tempTime[1], "+")
97
+						tempRecord := tempTime[0] + " " + tempTime1[0]
98
+						recordTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", tempRecord)
99
+						inspect_date := recordTime.Format("2006-01-02 15:04")
100
+						recordTimeStr, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", inspect_date)
101
+						recordTimeInt := recordTimeStr.Unix()
102
+
103
+						var total int
104
+						var RangeOptions string
105
+						var RangeMin string
106
+						var RangeMax string
107
+						var ItemType int
108
+
109
+						RangeMin = Result.Refmin
110
+						RangeMax = Result.Refmax
111
+						ItemType = 1
112
+						RangeOptions = Result.Prompt
113
+
114
+						err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
115
+						if total <= 0 {
116
+							inspection_reference.OrgId = org_id
117
+							inspection_reference.ProjectName = Report.Repname
118
+							inspection_reference.Project = Report.Repname
119
+							inspection_reference.ProjectId = project_id
120
+							inspection_reference.ItemName = Result.Itemcname
121
+							inspection_reference.ItemNameAddition = Result.Itemename
122
+							inspection_reference.ItemId = item_id
123
+							inspection_reference.RangeType = ItemType
124
+							inspection_reference.RangeMin = RangeMin
125
+							inspection_reference.RangeMax = RangeMax
126
+							inspection_reference.Unit = Result.Unit
127
+							inspection_reference.Status = 1
128
+							inspection_reference.CreatedTime = time.Now().Unix()
129
+							inspection_reference.UpdatedTime = time.Now().Unix()
130
+							inspection_reference.InspectDate = tempRecord
131
+							inspection_reference.UTime = tempRecord
132
+							err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
133
+							if err != nil {
134
+								tx.Rollback()
135
+							}
136
+						}
137
+						var itotal int
138
+						err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, recordTimeStr, patient.ID).Find(&inspection).Count(&itotal).Error
139
+						if itotal <= 0 {
140
+							// inspection.InspectValue = strings.Replace(LisInfo.Testresult, "&gt;", ">", -1)
141
+							// inspection.InspectValue = strings.Replace(LiLisInfo.Testresult, "&lt;", "<", -1)
142
+							inspection.PatientId = patient.ID
143
+							inspection.OrgId = org_id
144
+							inspection.ProjectId = project_id
145
+							inspection.ItemName = inspection_reference.ItemName
146
+							inspection.ProjectName = inspection_reference.ProjectName
147
+							inspection.InspectType = ItemType
148
+							inspection.ItemId = item_id
149
+							inspection.InspectValue = Result.Result
150
+							inspection.InspectDate = inspect_date
151
+							inspection.RecordDate = recordTimeInt
152
+							inspection.InspectTips = RangeOptions
153
+							inspection.Status = 1
154
+							inspection.CreatedTime = time.Now().Unix()
155
+							inspection.UpdatedTime = time.Now().Unix()
156
+							// inspection.UTime = record_date.Format(timeLayout)
157
+							// inspection.HisUserId = strconv.FormatInt(patient_id, 10)
158
+							inspection.SysProjectId = inspection_reference.XtProjectId
159
+							inspection.SysItemId = inspection_reference.XtItemId
160
+							err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
161
+							if err != nil {
162
+								tx.Rollback()
163
+							}
164
+						}
165
+						tx.Commit()
96
 					}
166
 					}
97
 				}
167
 				}
168
+			} else {
169
+				continue
170
+			}
171
+		}
172
+	}
173
+	var syncInfo models.MiddleSyncInfo
174
+	syncInfo.OrgId = org_id
175
+	syncInfo.SyncTime = time.Now().Unix()
176
+	syncInfo.SyncResultType = 1
177
+	syncInfo.SyncRsultRemark = "同步成功"
178
+	syncInfo.SyncTotalNum = 0
179
+	syncInfo.SyncSuccessNum = 0
180
+	syncInfo.SyncInfo = ""
181
+	syncInfo.CreateTime = time.Now().Unix()
182
+	syncInfo.UpdateTime = time.Now().Unix()
183
+
184
+	cwderr := CreateSyncInfo(&syncInfo)
185
+	if cwderr != nil {
186
+		utils.ErrorLog("创建同步信息失败:%v", cwderr)
187
+		return
188
+	}
189
+	SyncToSzwz()
190
+	return
191
+}
192
+
193
+// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
194
+func GetSzwzProjectID(org_id int64, project_name string) (project_id int64, err error) {
195
+	var inspection_reference models.MiddleInspectionReference
196
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?  ", org_id, project_name).First(&inspection_reference).Error
197
+	if inspection_reference.ID > 0 {
198
+		return inspection_reference.ProjectId, err
199
+	} else {
200
+		err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
201
+		if inspection_reference.ProjectId > 0 {
202
+			return inspection_reference.ProjectId + 1, err
203
+		} else {
204
+			return 1058001, err
205
+		}
206
+	}
207
+}
208
+
209
+// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
210
+func GetSzwzItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
211
+	var inspection_reference models.MiddleInspectionReference
212
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
213
+	if inspection_reference.ID > 0 {
214
+		return inspection_reference.ItemId, err
215
+	} else {
216
+		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ? ", org_id, project_id).Select("max(item_id) as item_id").First(&inspection_reference).Error
217
+		if inspection_reference.ItemId > 0 {
218
+			return inspection_reference.ItemId + 1, err
219
+		} else {
220
+			return project_id*100 + 1, err
221
+		}
222
+	}
223
+}
224
+
225
+func SyncToSzwz() {
226
+	utils.TraceLog("检验检查同步任务开始执行")
227
+	org_id := int64(10580)
228
+	inspections, _ := GetSyncInspectionByOrgId(org_id)
229
+
230
+	if len(inspections) > 0 {
231
+		for _, inspection := range inspections {
232
+			if inspection.SysProjectId > 0 && inspection.SysItemId > 0 {
233
+				SyncSzwzInspection(&inspection)
98
 			}
234
 			}
99
 		}
235
 		}
100
 	}
236
 	}
237
+	utils.SuccessLog("检验检查同步任务完成")
238
+}
239
+
240
+// 从机构将数据同步到中间库
241
+func SyncSzwzInspection(data *models.MiddleInspection) error {
242
+	tx := writeDb.Begin()
243
+	var inspection models.Inspection
244
+	var total int
245
+	err = readDb.Model(&models.Inspection{}).Where("org_id = ? and project_id = ? and item_id = ? and patient_id =? and inspect_date=?  and status = 1", data.OrgId, data.ProjectId, data.ItemId, data.PatientId, data.RecordDate).Find(&inspection).Count(&total).Error
246
+	if total <= 0 {
247
+		inspection.OrgId = data.OrgId
248
+		inspection.PatientId = data.PatientId
249
+		inspection.ProjectName = data.ProjectName
250
+		// inspection.Project = data.ProjectName
251
+		inspection.ProjectId = data.SysProjectId
252
+		inspection.ItemName = data.ItemName
253
+		inspection.ItemId = data.SysItemId
254
+		inspection.InspectType = int64(data.InspectType)
255
+		inspection.InspectValue = data.InspectValue
256
+		inspection.InspectTips = data.InspectTips
257
+		inspection.InspectDate = data.RecordDate
258
+		inspection.Status = 1
259
+		inspection.CreatedTime = time.Now().Unix()
260
+		inspection.UpdatedTime = time.Now().Unix()
261
+
262
+		err := tx.Model(&models.Inspection{}).Create(&inspection).Error
263
+		if err != nil {
264
+			tx.Rollback()
265
+		}
266
+
267
+		data.IsSync = 1
268
+		data.SyncId = inspection.ID
269
+		data.UpdatedTime = time.Now().Unix()
270
+		ierr := writeMiddleDb.Save(&data).Error
271
+		if ierr != nil {
272
+			tx.Rollback()
273
+		}
274
+	}
275
+	tx.Commit()
101
 	return err
276
 	return err
102
 }
277
 }

+ 256 - 0
service/tszhra_service.go View File

1
+package service
2
+
3
+import (
4
+	"IC/models"
5
+	"IC/utils"
6
+	_ "encoding/json"
7
+	_ "fmt"
8
+	"github.com/jinzhu/gorm"
9
+	"strings"
10
+	"time"
11
+)
12
+
13
+type zhraLis struct {
14
+	UserCardId   string `json:"user_card_id"`
15
+	PatientName  string `json:"patient_name"`
16
+	ProjectId    string `json:"project_id"`
17
+	ProjectName  string `json:"project_name"`
18
+	InspectDate  string `json:"inspect_date"`
19
+	ItemId       string `json:"item_id"`
20
+	ItemName     string `json:"item_name"`
21
+	ItemType     string `json:"item_type"`
22
+	ItemValue    string `json:"item_value"`
23
+	RangeMin     string `json:"range_min"`
24
+	RangeMax     string `json:"range_max"`
25
+	RangeValue   string `json:"range_value"`
26
+	RangeOptions string `json:"range_options"`
27
+	Unit         string `json:"unit"`
28
+	State        string `json:"state"`
29
+	CTime        string `json:"c_time"`
30
+	UTime        string `json:"u_time"`
31
+}
32
+
33
+func (zhraLis) TableName() string {
34
+	return "V_LIS_XTJK"
35
+}
36
+
37
+func GetTszhraLis(rdb *gorm.DB, synctime string, user_card_id string) (record []*zhraLis, err error) {
38
+	err = rdb.Model(&zhraLis{}).Where("c_time >= ? and user_card_id = ?", synctime, user_card_id).Find(&record).Error
39
+	return
40
+}
41
+
42
+// 根据机构ID和患者身份证号码获取患者信息
43
+func GetUserInIdcardNoByOrg(org_id int64) (patients []*models.Patients, err error) {
44
+	err = readDb.Model(&models.Patients{}).Where("user_org_id = ? and status = 1 ", org_id).Find(&patients).Error
45
+	return
46
+}
47
+
48
+// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
49
+func GetZhraProjectID(org_id int64, project_name string, item_name string) (project_id int64, err error) {
50
+	var inspection_reference models.MiddleInspectionReference
51
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? and item_name = ? ", org_id, project_name, item_name).First(&inspection_reference).Error
52
+	if inspection_reference.ID > 0 {
53
+		return inspection_reference.ProjectId, err
54
+	} else {
55
+		err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? ", org_id, project_name).First(&inspection_reference).Error
56
+		if inspection_reference.ID > 0 {
57
+			return inspection_reference.ProjectId, err
58
+		} else {
59
+			err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
60
+			if inspection_reference.ProjectId > 0 {
61
+				return inspection_reference.ProjectId + 1, err
62
+			} else {
63
+				return 1058501, err
64
+			}
65
+		}
66
+	}
67
+}
68
+
69
+// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
70
+func GetZhraItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
71
+	var inspection_reference models.MiddleInspectionReference
72
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
73
+	if inspection_reference.ID > 0 {
74
+		return inspection_reference.ItemId, err
75
+	} else {
76
+		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ? ", org_id, project_id).Select("max(item_id) as item_id").First(&inspection_reference).Error
77
+		if inspection_reference.ItemId > 0 {
78
+			return inspection_reference.ItemId + 1, err
79
+		} else {
80
+			return project_id*100 + 1, err
81
+		}
82
+	}
83
+}
84
+
85
+// 唐山遵化仁爱医院Lis同步
86
+func SyncTszhraLis() (err error) {
87
+	org_id := int64(10585)
88
+
89
+	org := &models.DataUploadConfig{
90
+		OrgId:  org_id,
91
+		DbHost: "192.168.100.100",
92
+		DbPort: "1433",
93
+		DbPass: "xytx",
94
+		DbUser: "xytx",
95
+		DbName: "BLis",
96
+	}
97
+
98
+	orgDb, err := CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
99
+	if err != nil {
100
+		utils.ErrorLog("创建数据库连接失败:%v", err)
101
+		return
102
+	}
103
+
104
+	// 第一步:获取上一次同步的时间点
105
+	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
106
+	var sync_time int64
107
+	if syncLastInfo.ID > 0 {
108
+		sync_time = syncLastInfo.SyncTime + 86400
109
+	} else {
110
+		sync_time = 1672502400 // 2023-01-01
111
+	}
112
+	// 第二步:获取时间内所有检验结果
113
+	sync_time_temp := time.Unix(sync_time, 0)
114
+	startTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
115
+
116
+	patients, _ := GetUserInIdcardNoByOrg(org_id)
117
+
118
+	if len(patients) > 0 {
119
+		for _, patient := range patients {
120
+			userCardId := patient.IdCardNo
121
+			// 根据姓名获取患者ID
122
+			zhraLis, _ := GetTszhraLis(orgDb, startTimeStr, userCardId)
123
+			if len(zhraLis) > 0 {
124
+				for _, LisInfo := range zhraLis {
125
+					project_id, _ := GetZhraProjectID(org_id, LisInfo.ProjectName, LisInfo.ItemName)
126
+					item_id, _ := GetZhraItemID(org_id, LisInfo.ProjectName, LisInfo.ItemName, project_id)
127
+					tx := writeMiddleDb.Begin()
128
+					var inspection models.MiddleInspection
129
+					var inspection_reference models.MiddleInspectionReference
130
+
131
+					timeLayout := "2006-01-02 15:04"
132
+					loc, _ := time.LoadLocation("Local")
133
+
134
+					tempRecord := LisInfo.CTime
135
+
136
+					recordTime, _ := time.ParseInLocation("2006-01-02 15:04:05", tempRecord, loc)
137
+					recordTimeInt := recordTime.Unix()
138
+					recordTimeStr := time.Unix(recordTimeInt, 0).Format(timeLayout)
139
+
140
+					var total int
141
+					var RangeOptions string
142
+					var RangeMin string
143
+					var RangeMax string
144
+					var ItemType int
145
+					Range := strings.Split(LisInfo.RangeValue, "--")
146
+					if len(Range) > 1 {
147
+						RangeMin = Range[0]
148
+						RangeMax = Range[1]
149
+						ItemType = 1
150
+					} else {
151
+						ItemType = 2
152
+						RangeOptions = LisInfo.RangeValue
153
+					}
154
+
155
+					err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
156
+					if total <= 0 {
157
+						inspection_reference.OrgId = org_id
158
+						inspection_reference.ProjectName = LisInfo.ProjectName
159
+						inspection_reference.Project = LisInfo.ProjectName
160
+						inspection_reference.ProjectId = project_id
161
+						inspection_reference.ItemName = LisInfo.ItemName
162
+						// inspection_reference.ItemNameAddition = strconv.FormatInt(info.ItemId, 10)
163
+						inspection_reference.ItemId = item_id
164
+						inspection_reference.RangeType = ItemType
165
+						inspection_reference.RangeMin = RangeMin
166
+						inspection_reference.RangeMax = RangeMax
167
+						// inspection_reference.RangeValue = RangeValue
168
+						inspection_reference.RangeOptions = RangeOptions
169
+						inspection_reference.Unit = LisInfo.Unit
170
+						inspection_reference.Status = 1
171
+						inspection_reference.CreatedTime = time.Now().Unix()
172
+						inspection_reference.UpdatedTime = time.Now().Unix()
173
+						inspection_reference.InspectDate = recordTimeStr
174
+						inspection_reference.UTime = recordTimeStr
175
+						err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
176
+						if err != nil {
177
+							tx.Rollback()
178
+						}
179
+					}
180
+					var itotal int
181
+					err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, recordTimeStr, patient.ID).Find(&inspection).Count(&itotal).Error
182
+					if itotal <= 0 {
183
+						// inspection.InspectValue = strings.Replace(LisInfo.Testresult, "&gt;", ">", -1)
184
+						// inspection.InspectValue = strings.Replace(LiLisInfo.Testresult, "&lt;", "<", -1)
185
+						inspection.PatientId = patient.ID
186
+						inspection.OrgId = org_id
187
+						inspection.ProjectId = project_id
188
+						inspection.ItemName = inspection_reference.ItemName
189
+						inspection.ProjectName = inspection_reference.ProjectName
190
+						inspection.InspectType = ItemType
191
+						inspection.ItemId = item_id
192
+						inspection.InspectValue = LisInfo.ItemValue
193
+						inspection.InspectDate = recordTimeStr
194
+						inspection.RecordDate = recordTimeInt
195
+						// inspection.InspectTips = report.Resultstate
196
+						inspection.Status = 1
197
+						inspection.CreatedTime = time.Now().Unix()
198
+						inspection.UpdatedTime = time.Now().Unix()
199
+						// inspection.UTime = record_date.Format(timeLayout)
200
+						// inspection.HisUserId = strconv.FormatInt(patient_id, 10)
201
+						err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
202
+						if err != nil {
203
+							tx.Rollback()
204
+						}
205
+					}
206
+					tx.Commit()
207
+				}
208
+			} else {
209
+				continue
210
+			}
211
+		}
212
+
213
+		var syncInfo models.MiddleSyncInfo
214
+		syncInfo.OrgId = org_id
215
+		syncInfo.SyncTime = time.Now().Unix()
216
+		syncInfo.SyncResultType = 1
217
+		syncInfo.SyncRsultRemark = "同步成功"
218
+		syncInfo.SyncTotalNum = 0
219
+		syncInfo.SyncSuccessNum = 0
220
+		syncInfo.SyncInfo = ""
221
+		syncInfo.CreateTime = time.Now().Unix()
222
+		syncInfo.UpdateTime = time.Now().Unix()
223
+
224
+		cwderr := CreateSyncInfo(&syncInfo)
225
+		if cwderr != nil {
226
+			utils.ErrorLog("创建同步信息失败:%v", cwderr)
227
+			return
228
+		}
229
+	}
230
+	SyncTotszhrayy()
231
+	return
232
+}
233
+
234
+func SyncTotszhrayy() {
235
+
236
+	utils.TraceLog("检验检查同步任务开始执行")
237
+	org_id := int64(10585)
238
+
239
+	// 第一步:跟进org_id 去中间库查出需要同步的数据
240
+	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
241
+	inspections, _ := GetSyncInspectionByOrgId(org_id)
242
+
243
+	// 第二步:将数据同步到业务库
244
+	if len(inspection_references) > 0 {
245
+		for _, inspection_reference := range inspection_references {
246
+			SyncInspectionReference(&inspection_reference)
247
+		}
248
+	}
249
+
250
+	if len(inspections) > 0 {
251
+		for _, inspection := range inspections {
252
+			SyncInspection(&inspection)
253
+		}
254
+	}
255
+	utils.SuccessLog("检验检查同步任务完成")
256
+}

+ 193 - 201
service/wfnfm_service.go View File

4
 	"IC/models"
4
 	"IC/models"
5
 	"IC/utils"
5
 	"IC/utils"
6
 	_ "IC/utils"
6
 	_ "IC/utils"
7
-	_"bytes"
8
-	_"encoding/json"
7
+	_ "bytes"
9
 	_ "encoding/json"
8
 	_ "encoding/json"
10
-	_"encoding/xml"
11
-	_"fmt"
12
-	_"net/http"
13
-	_"io/ioutil"
9
+	_ "encoding/xml"
10
+	_ "fmt"
11
+	"github.com/jinzhu/gorm"
14
 	_ "github.com/jinzhu/gorm"
12
 	_ "github.com/jinzhu/gorm"
13
+	_ "io/ioutil"
14
+	_ "net/http"
15
 	"strconv"
15
 	"strconv"
16
-	_"strings"
16
+	_ "strings"
17
 	"time"
17
 	"time"
18
-	"github.com/jinzhu/gorm"
19
 )
18
 )
20
 
19
 
21
 type AdminUserList struct {
20
 type AdminUserList struct {
42
 	return order, err
41
 	return order, err
43
 }
42
 }
44
 
43
 
45
-//透析处方
44
+// 透析处方
46
 func FindPatientPrescribeById(orgID int64, patientsId int64, recordDate int64) (patient models.DialysisPrescription, err error) {
45
 func FindPatientPrescribeById(orgID int64, patientsId int64, recordDate int64) (patient models.DialysisPrescription, err error) {
47
 	err = readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id=? and status=1 and  record_date = ? ", patientsId, orgID, recordDate).First(&patient).Error
46
 	err = readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id=? and status=1 and  record_date = ? ", patientsId, orgID, recordDate).First(&patient).Error
48
 	return
47
 	return
49
 }
48
 }
50
 
49
 
51
-//透前评估
50
+// 透前评估
52
 func FindPredialysisEvaluationById(orgID int64, patientsId int64, recordDate int64) (patient models.PredialysisEvaluation, err error) {
51
 func FindPredialysisEvaluationById(orgID int64, patientsId int64, recordDate int64) (patient models.PredialysisEvaluation, err error) {
53
 	err = readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id=? and status=1 and assessment_date = ?", patientsId, orgID, recordDate).First(&patient).Error
52
 	err = readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id=? and status=1 and assessment_date = ?", patientsId, orgID, recordDate).First(&patient).Error
54
 	return
53
 	return
55
 }
54
 }
56
 
55
 
57
-//透后评估
56
+// 透后评估
58
 func FindAssessmentAfterDislysisById(orgID int64, patientsId int64, recordDate int64) (patient models.AssessmentAfterDislysis, err error) {
57
 func FindAssessmentAfterDislysisById(orgID int64, patientsId int64, recordDate int64) (patient models.AssessmentAfterDislysis, err error) {
59
 	err = readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id=? and status=1 and assessment_date =?", patientsId, orgID, recordDate).First(&patient).Error
58
 	err = readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id=? and status=1 and assessment_date =?", patientsId, orgID, recordDate).First(&patient).Error
60
 	return
59
 	return
61
 }
60
 }
62
 
61
 
63
-//透析监测
62
+// 透析监测
64
 func FindAllMonitorRecord(orgID int64, patientsId int64, recordDate int64) (record []*models.MonitoringRecord, err error) {
63
 func FindAllMonitorRecord(orgID int64, patientsId int64, recordDate int64) (record []*models.MonitoringRecord, err error) {
65
 	err = readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id=? and status=1 and monitoring_date = ?", patientsId, orgID, recordDate).Order("operate_time ASC").Find(&record).Error
64
 	err = readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id=? and status=1 and monitoring_date = ?", patientsId, orgID, recordDate).Order("operate_time ASC").Find(&record).Error
66
 	return
65
 	return
67
 }
66
 }
68
 
67
 
69
-//临时医嘱
70
-func FindDoctorAdviceOrderById(orgID int64,patientId int64, recordDate int64) (patient []*models.DoctorAdvice, err error) {
68
+// 临时医嘱
69
+func FindDoctorAdviceOrderById(orgID int64, patientId int64, recordDate int64) (patient []*models.DoctorAdvice, err error) {
71
 	err = readDb.Model(&models.DoctorAdvice{}).
70
 	err = readDb.Model(&models.DoctorAdvice{}).
72
-		Where("user_org_id=? and status=1 and record_date = ? and advice_type = 2 and patient_id = ?", orgID, recordDate,patientId).
71
+		Where("user_org_id=? and status=1 and record_date = ? and advice_type = 2 and patient_id = ?", orgID, recordDate, patientId).
73
 		Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno, IF(parent_id > 0, parent_id, id) as advice_order").Order("start_time asc, groupno desc, advice_order desc, id asc").
72
 		Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno, IF(parent_id > 0, parent_id, id) as advice_order").Order("start_time asc, groupno desc, advice_order desc, id asc").
74
 		Find(&patient).Error
73
 		Find(&patient).Error
75
 	return
74
 	return
76
 }
75
 }
77
 
76
 
78
-
79
 func BatchCreateRecord(ps *models.EmrBloodDialyRecord, rdb *gorm.DB) (err error) {
77
 func BatchCreateRecord(ps *models.EmrBloodDialyRecord, rdb *gorm.DB) (err error) {
80
 	err = rdb.Create(&ps).Error
78
 	err = rdb.Create(&ps).Error
81
 	return err
79
 	return err
92
 }
90
 }
93
 
91
 
94
 // 潍坊内分泌医院 同步健康数据上报
92
 // 潍坊内分泌医院 同步健康数据上报
95
-func  EmrBloodDiaylOrder() {
93
+func EmrBloodDiaylOrder() {
96
 	org := &models.DataUploadConfig{
94
 	org := &models.DataUploadConfig{
97
-		DbHost:         "127.0.0.1",
98
-		DbPort:         "1433",
99
-		DbPass:         "Aa123456",
100
-		DbUser:         "xtzk",
101
-		DbName:         "wfnfm",
95
+		DbHost: "127.0.0.1",
96
+		DbPort: "1433",
97
+		DbPass: "Aa123456",
98
+		DbUser: "xtzk",
99
+		DbName: "wfnfm",
102
 	}
100
 	}
103
 
101
 
104
 	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
102
 	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
124
 				timeLayout := "2006-01-02 15:04:05"
122
 				timeLayout := "2006-01-02 15:04:05"
125
 				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
123
 				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
126
 				timenow := timeStringToTime.Unix()
124
 				timenow := timeStringToTime.Unix()
127
-				orders,_ := GetAllPatientByOrgID(10414,timenow)
125
+				orders, _ := GetAllPatientByOrgID(10414, timenow)
128
 				if len(orders) > 0 {
126
 				if len(orders) > 0 {
129
 					for _, order := range orders {
127
 					for _, order := range orders {
130
 
128
 
131
 						//查询病人信息
129
 						//查询病人信息
132
 						patients, _ := GetPatientInformation(order.PatientId, 10414)
130
 						patients, _ := GetPatientInformation(order.PatientId, 10414)
133
 
131
 
134
-						Records, _ := FindDoctorAdviceOrderById(10414,order.PatientId,timenow)
132
+						Records, _ := FindDoctorAdviceOrderById(10414, order.PatientId, timenow)
135
 						if len(Records) > 0 {
133
 						if len(Records) > 0 {
136
-							for _,record := range Records {
134
+							for _, record := range Records {
137
 								emrDetail := &models.EmrBloodDialyOrder{
135
 								emrDetail := &models.EmrBloodDialyOrder{
138
-									ReqNo 				: patients.DialysisNo,
139
-									OrderType 			: "1",
140
-									OrderDate 			: time.Unix(record.StartTime, 0).Format("2006-01-02 15:04:05"),
141
-									OrderName 			: record.AdviceName,
142
-									Dosage 				: strconv.FormatFloat(record.PrescribingNumber, 'f', 1, 32)+record.PrescribingNumberUnit,
143
-									Usage 				: record.DeliveryWay,
144
-									ExecDate 			: time.Unix(record.ExecutionTime, 0).Format("2006-01-02 15:04:05"),
145
-									Orglevel 			: "二级",
146
-									Submitdate 			: time.Unix(record.CreatedTime, 0).Format("2006-01-02 15:04:05"),
147
-									Recordstate 		: "0",
148
-									Fectchdate 			: time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
149
-									OrganizationCode 	: "",
150
-									OrganizationName 	: "",
151
-									DistrictCode 		: "370724",
152
-									DistrictName 		: "临朐县",
153
-									Uploadmark 			: "0",
136
+									ReqNo:            patients.DialysisNo,
137
+									OrderType:        "1",
138
+									OrderDate:        time.Unix(record.StartTime, 0).Format("2006-01-02 15:04:05"),
139
+									OrderName:        record.AdviceName,
140
+									Dosage:           strconv.FormatFloat(record.PrescribingNumber, 'f', 1, 32) + record.PrescribingNumberUnit,
141
+									Usage:            record.DeliveryWay,
142
+									ExecDate:         time.Unix(record.ExecutionTime, 0).Format("2006-01-02 15:04:05"),
143
+									Orglevel:         "二级",
144
+									Submitdate:       time.Unix(record.CreatedTime, 0).Format("2006-01-02 15:04:05"),
145
+									Recordstate:      "0",
146
+									Fectchdate:       time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
147
+									OrganizationCode: "",
148
+									OrganizationName: "",
149
+									DistrictCode:     "370724",
150
+									DistrictName:     "临朐县",
151
+									Uploadmark:       "0",
154
 								}
152
 								}
155
 								for _, admin := range adminUser {
153
 								for _, admin := range adminUser {
156
 									if record.AdviceDoctor == admin.Id {
154
 									if record.AdviceDoctor == admin.Id {
157
 										emrDetail.DoctorName = admin.Name
155
 										emrDetail.DoctorName = admin.Name
158
 									}
156
 									}
159
-									if record.ExecutionStaff == admin.Id{
157
+									if record.ExecutionStaff == admin.Id {
160
 										emrDetail.NurseName = admin.Name
158
 										emrDetail.NurseName = admin.Name
161
 									}
159
 									}
162
 								}
160
 								}
163
 
161
 
164
-								currentYear := time.Now().Year()        //当前年
162
+								currentYear := time.Now().Year() //当前年
165
 								emrDetail.Businessyear = int64(currentYear)
163
 								emrDetail.Businessyear = int64(currentYear)
166
-								BatchCreateOrder(emrDetail,orgDb)
164
+								BatchCreateOrder(emrDetail, orgDb)
167
 							}
165
 							}
168
 						}
166
 						}
169
 					}
167
 					}
188
 			}
186
 			}
189
 		}
187
 		}
190
 
188
 
191
-		
192
-		
193
-		
194
 		// 第四步:关闭数据库连接
189
 		// 第四步:关闭数据库连接
195
 		CloseDB(orgDb)
190
 		CloseDB(orgDb)
196
 	}
191
 	}
197
 }
192
 }
198
 
193
 
199
 // 潍坊内分泌医院 同步健康数据上报
194
 // 潍坊内分泌医院 同步健康数据上报
200
-func  EmrBloodDiaylDetail() {
195
+func EmrBloodDiaylDetail() {
201
 	org := &models.DataUploadConfig{
196
 	org := &models.DataUploadConfig{
202
-		DbHost:         "localhost",
203
-		DbPort:         "1433",
204
-		DbPass:         "Aa123456",
205
-		DbUser:         "xtzk",
206
-		DbName:         "wfnfm",
197
+		DbHost: "localhost",
198
+		DbPort: "1433",
199
+		DbPass: "Aa123456",
200
+		DbUser: "xtzk",
201
+		DbName: "wfnfm",
207
 	}
202
 	}
208
 
203
 
209
 	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
204
 	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
220
 		} else {
215
 		} else {
221
 			sync_time = 1664553600
216
 			sync_time = 1664553600
222
 		}
217
 		}
223
-	
218
+
224
 		nowTimes := time.Now().Unix()
219
 		nowTimes := time.Now().Unix()
225
 		if sync_time < nowTimes {
220
 		if sync_time < nowTimes {
226
 			for i := sync_time; i < nowTimes; i = i + 86400 {
221
 			for i := sync_time; i < nowTimes; i = i + 86400 {
229
 				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
224
 				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
230
 				timenow := timeStringToTime.Unix()
225
 				timenow := timeStringToTime.Unix()
231
 
226
 
232
-				orders,_ := GetAllPatientByOrgID(10414,timenow)
227
+				orders, _ := GetAllPatientByOrgID(10414, timenow)
233
 				if len(orders) > 0 {
228
 				if len(orders) > 0 {
234
 					for _, order := range orders {
229
 					for _, order := range orders {
235
 
230
 
238
 
233
 
239
 						Records, _ := FindAllMonitorRecord(10414, order.PatientId, timenow)
234
 						Records, _ := FindAllMonitorRecord(10414, order.PatientId, timenow)
240
 						if len(Records) > 0 {
235
 						if len(Records) > 0 {
241
-							for _,record := range Records {
236
+							for _, record := range Records {
242
 								emrDetail := &models.EmrBloodDialyDetail{
237
 								emrDetail := &models.EmrBloodDialyDetail{
243
-									ReqNo 				: patients.DialysisNo,
244
-									Patientname 		: patients.Name,
245
-									Idcard 				: patients.IdCardNo,
246
-									Hospitalcode 		: "MA3R6UFL9",
247
-									Hospitalname 		: "潍坊内分泌与代谢病医院",
248
-									BdDate				: time.Unix(record.MonitoringDate, 0).Format("2006-01-02") + " " + record.MonitoringTime ,
249
-									BdBp				: strconv.FormatFloat(record.SystolicBloodPressure, 'f', 1, 32) + "/" + strconv.FormatFloat(record.DiastolicBloodPressure, 'f', 1, 32),
250
-									BdT					: record.DialysateTemperature,
251
-									BdRate 				: record.PulseFrequency,
252
-									BdFlow 				: record.BloodFlowVolume,
253
-									BdVbp 				: record.VenousPressure,
254
-									BdTmp 				: record.TransmembranePressure,
255
-									BdUfvLimit 			: record.UltrafiltrationVolume,
256
-									Orglevel 			: "二级",
257
-									Submitdate 			: time.Unix(record.CreatedTime, 0).Format("2006-01-02 15:04:05"),
258
-									Recordstate 		: "0",
259
-									Fectchdate 			: time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
260
-									OrganizationCode 	: "",
261
-									OrganizationName 	: "",
262
-									DistrictCode 		: "370724",
263
-									DistrictName 		: "临朐县",
264
-									Uploadmark 			: "0",
238
+									ReqNo:            patients.DialysisNo,
239
+									Patientname:      patients.Name,
240
+									Idcard:           patients.IdCardNo,
241
+									Hospitalcode:     "MA3R6UFL9",
242
+									Hospitalname:     "潍坊内分泌与代谢病医院",
243
+									BdDate:           time.Unix(record.MonitoringDate, 0).Format("2006-01-02") + " " + record.MonitoringTime,
244
+									BdBp:             strconv.FormatFloat(record.SystolicBloodPressure, 'f', 1, 32) + "/" + strconv.FormatFloat(record.DiastolicBloodPressure, 'f', 1, 32),
245
+									BdT:              record.DialysateTemperature,
246
+									BdRate:           record.PulseFrequency,
247
+									BdFlow:           record.BloodFlowVolume,
248
+									BdVbp:            record.VenousPressure,
249
+									BdTmp:            record.TransmembranePressure,
250
+									BdUfvLimit:       record.UltrafiltrationVolume,
251
+									Orglevel:         "二级",
252
+									Submitdate:       time.Unix(record.CreatedTime, 0).Format("2006-01-02 15:04:05"),
253
+									Recordstate:      "0",
254
+									Fectchdate:       time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
255
+									OrganizationCode: "",
256
+									OrganizationName: "",
257
+									DistrictCode:     "370724",
258
+									DistrictName:     "临朐县",
259
+									Uploadmark:       "0",
265
 								}
260
 								}
266
-								currentYear := time.Now().Year()        //当前年
261
+								currentYear := time.Now().Year() //当前年
267
 								emrDetail.Businessyear = int64(currentYear)
262
 								emrDetail.Businessyear = int64(currentYear)
268
-								BatchCreateDetail(emrDetail,orgDb)
263
+								BatchCreateDetail(emrDetail, orgDb)
269
 							}
264
 							}
270
 						}
265
 						}
271
 					}
266
 					}
272
 					var syncInfo models.MiddleSyncInfo
267
 					var syncInfo models.MiddleSyncInfo
273
 					syncInfo.OrgId = 1041402
268
 					syncInfo.OrgId = 1041402
274
-	
269
+
275
 					syncInfo.SyncTime = i
270
 					syncInfo.SyncTime = i
276
 					syncInfo.SyncResultType = 1
271
 					syncInfo.SyncResultType = 1
277
 					syncInfo.SyncRsultRemark = "同步成功"
272
 					syncInfo.SyncRsultRemark = "同步成功"
280
 					syncInfo.SyncInfo = ""
275
 					syncInfo.SyncInfo = ""
281
 					syncInfo.CreateTime = time.Now().Unix()
276
 					syncInfo.CreateTime = time.Now().Unix()
282
 					syncInfo.UpdateTime = time.Now().Unix()
277
 					syncInfo.UpdateTime = time.Now().Unix()
283
-	
278
+
284
 					cwderr := CreateSyncInfo(&syncInfo)
279
 					cwderr := CreateSyncInfo(&syncInfo)
285
 					if cwderr != nil {
280
 					if cwderr != nil {
286
 						utils.ErrorLog("创建同步信息失败:%v", cwderr)
281
 						utils.ErrorLog("创建同步信息失败:%v", cwderr)
295
 }
290
 }
296
 
291
 
297
 // 潍坊内分泌医院 同步健康数据上报
292
 // 潍坊内分泌医院 同步健康数据上报
298
-func  EmrBloodDiaylRecord() {
293
+func EmrBloodDiaylRecord() {
299
 	org := &models.DataUploadConfig{
294
 	org := &models.DataUploadConfig{
300
-		DbHost:         "localhost",
301
-		DbPort:         "1433",
302
-		DbPass:         "Aa123456",
303
-		DbUser:         "xtzk",
304
-		DbName:         "wfnfm",
295
+		DbHost: "localhost",
296
+		DbPort: "1433",
297
+		DbPass: "Aa123456",
298
+		DbUser: "xtzk",
299
+		DbName: "wfnfm",
305
 	}
300
 	}
306
 
301
 
307
 	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
302
 	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
320
 		} else {
315
 		} else {
321
 			sync_time = 1664553600
316
 			sync_time = 1664553600
322
 		}
317
 		}
323
-	
318
+
324
 		nowTimes := time.Now().Unix()
319
 		nowTimes := time.Now().Unix()
325
 		if sync_time < nowTimes {
320
 		if sync_time < nowTimes {
326
 			for i := sync_time; i < nowTimes; i = i + 86400 {
321
 			for i := sync_time; i < nowTimes; i = i + 86400 {
327
 				tempsyncTimes := time.Unix(i, 0).Format("2006-01-02")
322
 				tempsyncTimes := time.Unix(i, 0).Format("2006-01-02")
328
 				timeLayout := "2006-01-02 15:04:05"
323
 				timeLayout := "2006-01-02 15:04:05"
329
-			
324
+
330
 				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
325
 				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
331
 				timenow := timeStringToTime.Unix()
326
 				timenow := timeStringToTime.Unix()
332
 
327
 
333
-				orders,_ := GetAllPatientByOrgID(10414,timenow)
328
+				orders, _ := GetAllPatientByOrgID(10414, timenow)
334
 				if len(orders) > 0 {
329
 				if len(orders) > 0 {
335
 					for _, order := range orders {
330
 					for _, order := range orders {
336
 
331
 
344
 						AssessmentAfterDislysis, _ := FindAssessmentAfterDislysisById(10414, order.PatientId, timenow)
339
 						AssessmentAfterDislysis, _ := FindAssessmentAfterDislysisById(10414, order.PatientId, timenow)
345
 
340
 
346
 						emrRecord := &models.EmrBloodDialyRecord{
341
 						emrRecord := &models.EmrBloodDialyRecord{
347
-							ReqNo 				: patients.DialysisNo,
348
-							Patientname 		: patients.Name,
349
-							Idcard 				: patients.IdCardNo,
350
-							Hospitalcode 		: "MA3R6UFL9",
351
-							Hospitalname 		: "潍坊内分泌与代谢病医院",
352
-							AdmissionId 		: patients.IdCardNo,
353
-							BdDate 				: time.Unix(order.DialysisDate, 0).Format("2006-01-02"),
354
-							BdMatno 			: dialysisPrescription.DialyzerPerfusionApparatus,
355
-							Temperature 		: PredialysisEvaluation.Temperature,
356
-							PulseRate 			: PredialysisEvaluation.PulseFrequency,
357
-							BreathingRate 		: PredialysisEvaluation.BreathingRate,
358
-							PressureH 			: PredialysisEvaluation.SystolicBloodPressure,
359
-							PressureL 			: PredialysisEvaluation.DiastolicBloodPressure,
360
-							UfvLimit 			: dialysisPrescription.DewaterAmount*1000,
361
-							FirstAnticoagulant 	: dialysisPrescription.AnticoagulantShouji,
362
-							BdHours 			: AssessmentAfterDislysis.ActualTreatmentHour,
363
-							BdType 				: dialysisPrescription.ModeId,
364
-							BdT 				: 36.5,
365
-							AnticoagulantTotal 	: dialysisPrescription.AnticoagulantZongliang,
366
-							BdCruorContiton 	: "2",
367
-							PatientWeight		: PredialysisEvaluation.DryWeight,
368
-							WeightBf 			: PredialysisEvaluation.WeightBefore,
369
-							WeightAf 			: AssessmentAfterDislysis.WeightAfter,
370
-							WeightBalan 		: PredialysisEvaluation.WeightBefore - PredialysisEvaluation.WeightBefore,
371
-							Vascular 			: "2",
372
-							Orglevel 			: "二级",
373
-							Submitdate 			: time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
374
-							Recordstate 		: "0",
375
-							Fectchdate 			: time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
376
-							OrganizationCode 	: "",
377
-							OrganizationName 	: "",
378
-							DistrictCode 		: "370724",
379
-							DistrictName 		: "临朐县",
380
-							Uploadmark 			: "0",
342
+							ReqNo:              patients.DialysisNo,
343
+							Patientname:        patients.Name,
344
+							Idcard:             patients.IdCardNo,
345
+							Hospitalcode:       "MA3R6UFL9",
346
+							Hospitalname:       "潍坊内分泌与代谢病医院",
347
+							AdmissionId:        patients.IdCardNo,
348
+							BdDate:             time.Unix(order.DialysisDate, 0).Format("2006-01-02"),
349
+							BdMatno:            dialysisPrescription.DialyzerPerfusionApparatus,
350
+							Temperature:        PredialysisEvaluation.Temperature,
351
+							PulseRate:          PredialysisEvaluation.PulseFrequency,
352
+							BreathingRate:      PredialysisEvaluation.BreathingRate,
353
+							PressureH:          PredialysisEvaluation.SystolicBloodPressure,
354
+							PressureL:          PredialysisEvaluation.DiastolicBloodPressure,
355
+							UfvLimit:           dialysisPrescription.DewaterAmount * 1000,
356
+							FirstAnticoagulant: dialysisPrescription.AnticoagulantShouji,
357
+							BdHours:            AssessmentAfterDislysis.ActualTreatmentHour,
358
+							BdType:             dialysisPrescription.ModeId,
359
+							BdT:                36.5,
360
+							AnticoagulantTotal: dialysisPrescription.AnticoagulantZongliang,
361
+							BdCruorContiton:    "2",
362
+							PatientWeight:      PredialysisEvaluation.DryWeight,
363
+							WeightBf:           PredialysisEvaluation.WeightBefore,
364
+							WeightAf:           AssessmentAfterDislysis.WeightAfter,
365
+							WeightBalan:        PredialysisEvaluation.WeightBefore - PredialysisEvaluation.WeightBefore,
366
+							Vascular:           "2",
367
+							Orglevel:           "二级",
368
+							Submitdate:         time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
369
+							Recordstate:        "0",
370
+							Fectchdate:         time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
371
+							OrganizationCode:   "",
372
+							OrganizationName:   "",
373
+							DistrictCode:       "370724",
374
+							DistrictName:       "临朐县",
375
+							Uploadmark:         "0",
381
 						}
376
 						}
382
 
377
 
383
 						for _, admin := range adminUser {
378
 						for _, admin := range adminUser {
384
 							if dialysisPrescription.Creater == admin.Id {
379
 							if dialysisPrescription.Creater == admin.Id {
385
 								emrRecord.DoctorName = admin.Name
380
 								emrRecord.DoctorName = admin.Name
386
 							}
381
 							}
387
-							if order.StartNurse == admin.Id{
382
+							if order.StartNurse == admin.Id {
388
 								emrRecord.OperName = admin.Name
383
 								emrRecord.OperName = admin.Name
389
 								emrRecord.PrimaryName = admin.Name
384
 								emrRecord.PrimaryName = admin.Name
390
 							}
385
 							}
391
 						}
386
 						}
392
 
387
 
393
-						if(patients.Gender == 1){
388
+						if patients.Gender == 1 {
394
 							emrRecord.SexCode = "1"
389
 							emrRecord.SexCode = "1"
395
 							emrRecord.SexName = "男"
390
 							emrRecord.SexName = "男"
396
 						}
391
 						}
397
-						if(patients.Gender == 2){
392
+						if patients.Gender == 2 {
398
 							emrRecord.SexCode = "2"
393
 							emrRecord.SexCode = "2"
399
 							emrRecord.SexName = "女"
394
 							emrRecord.SexName = "女"
400
 						}
395
 						}
401
 
396
 
402
-						currentYear := time.Now().Year()        //当前年
397
+						currentYear := time.Now().Year() //当前年
403
 						birthYear := time.Unix(patients.Birthday, 0).Year()
398
 						birthYear := time.Unix(patients.Birthday, 0).Year()
404
 						emrRecord.Businessyear = int64(currentYear)
399
 						emrRecord.Businessyear = int64(currentYear)
405
 						emrRecord.Age = int64(currentYear) - int64(birthYear)
400
 						emrRecord.Age = int64(currentYear) - int64(birthYear)
406
 						switch dialysisPrescription.Anticoagulant {
401
 						switch dialysisPrescription.Anticoagulant {
407
-							case 1:
408
-								emrRecord.Anticoagulant = "无肝素"
409
-								break
410
-							case 2:
411
-								emrRecord.Anticoagulant = "普通肝素"
412
-								break
413
-							case 3:
414
-								emrRecord.Anticoagulant = "低分子肝素"
415
-								break
416
-							case 4:
417
-								emrRecord.Anticoagulant = "阿加曲班"
418
-								break
419
-							case 5:
420
-								emrRecord.Anticoagulant = "枸橼酸钠"
421
-								break
422
-							case 6:
423
-								emrRecord.Anticoagulant = "低分子肝素钙"
424
-								break
425
-							case 7:
426
-								emrRecord.Anticoagulant = "低分子肝素钠"
427
-								break
402
+						case 1:
403
+							emrRecord.Anticoagulant = "无肝素"
404
+							break
405
+						case 2:
406
+							emrRecord.Anticoagulant = "普通肝素"
407
+							break
408
+						case 3:
409
+							emrRecord.Anticoagulant = "低分子肝素"
410
+							break
411
+						case 4:
412
+							emrRecord.Anticoagulant = "阿加曲班"
413
+							break
414
+						case 5:
415
+							emrRecord.Anticoagulant = "枸橼酸钠"
416
+							break
417
+						case 6:
418
+							emrRecord.Anticoagulant = "低分子肝素钙"
419
+							break
420
+						case 7:
421
+							emrRecord.Anticoagulant = "低分子肝素钠"
422
+							break
428
 						}
423
 						}
429
 
424
 
430
 						switch dialysisPrescription.ModeId {
425
 						switch dialysisPrescription.ModeId {
431
-							case 1:
432
-								emrRecord.BdTypeName = "HD"
433
-								break
434
-							case 2:
435
-								emrRecord.BdTypeName = "HDF"
436
-								break
437
-							case 3:
438
-								emrRecord.BdTypeName = "HD+HP"
439
-								break
440
-							case 4:
441
-								emrRecord.BdTypeName = "HP"
442
-								break
443
-							case 5:
444
-								emrRecord.BdTypeName = "HF"
445
-								break
446
-							case 6:
447
-								emrRecord.BdTypeName = "SCUF"
448
-								break
449
-							case 7:
450
-								emrRecord.BdTypeName = "IUF"
451
-								break
452
-							case 8:
453
-								emrRecord.BdTypeName = "HFHD"
454
-								break
455
-							case 9:
456
-								emrRecord.BdTypeName = "HFHD+HP"
457
-								break
458
-							case 10:
459
-								emrRecord.BdTypeName = "PHF"
460
-								break
461
-							case 11:
462
-								emrRecord.BdTypeName = "HFR"
463
-								break
464
-							case 12:
465
-								emrRecord.BdTypeName = "HDF+HP"
466
-								break
467
-							default:
468
-								emrRecord.BdTypeName = "HD"
469
-								break
426
+						case 1:
427
+							emrRecord.BdTypeName = "HD"
428
+							break
429
+						case 2:
430
+							emrRecord.BdTypeName = "HDF"
431
+							break
432
+						case 3:
433
+							emrRecord.BdTypeName = "HD+HP"
434
+							break
435
+						case 4:
436
+							emrRecord.BdTypeName = "HP"
437
+							break
438
+						case 5:
439
+							emrRecord.BdTypeName = "HF"
440
+							break
441
+						case 6:
442
+							emrRecord.BdTypeName = "SCUF"
443
+							break
444
+						case 7:
445
+							emrRecord.BdTypeName = "IUF"
446
+							break
447
+						case 8:
448
+							emrRecord.BdTypeName = "HFHD"
449
+							break
450
+						case 9:
451
+							emrRecord.BdTypeName = "HFHD+HP"
452
+							break
453
+						case 10:
454
+							emrRecord.BdTypeName = "PHF"
455
+							break
456
+						case 11:
457
+							emrRecord.BdTypeName = "HFR"
458
+							break
459
+						case 12:
460
+							emrRecord.BdTypeName = "HDF+HP"
461
+							break
462
+						default:
463
+							emrRecord.BdTypeName = "HD"
464
+							break
470
 						}
465
 						}
471
 
466
 
472
-						if AssessmentAfterDislysis.Cruor == "透析器-0度" || len(AssessmentAfterDislysis.Cruor) <= 0{
467
+						if AssessmentAfterDislysis.Cruor == "透析器-0度" || len(AssessmentAfterDislysis.Cruor) <= 0 {
473
 							emrRecord.BdCruor = "2"
468
 							emrRecord.BdCruor = "2"
474
 							emrRecord.BdCruorName = "无凝血"
469
 							emrRecord.BdCruorName = "无凝血"
475
 						} else {
470
 						} else {
477
 							emrRecord.BdCruorName = "有凝血"
472
 							emrRecord.BdCruorName = "有凝血"
478
 						}
473
 						}
479
 
474
 
480
-						BatchCreateRecord(emrRecord,orgDb)
475
+						BatchCreateRecord(emrRecord, orgDb)
481
 					}
476
 					}
482
-				
477
+
483
 					var syncInfo models.MiddleSyncInfo
478
 					var syncInfo models.MiddleSyncInfo
484
 					syncInfo.OrgId = 1041403
479
 					syncInfo.OrgId = 1041403
485
-		
480
+
486
 					syncInfo.SyncTime = i
481
 					syncInfo.SyncTime = i
487
 					syncInfo.SyncResultType = 1
482
 					syncInfo.SyncResultType = 1
488
 					syncInfo.SyncRsultRemark = "同步成功"
483
 					syncInfo.SyncRsultRemark = "同步成功"
491
 					syncInfo.SyncInfo = ""
486
 					syncInfo.SyncInfo = ""
492
 					syncInfo.CreateTime = time.Now().Unix()
487
 					syncInfo.CreateTime = time.Now().Unix()
493
 					syncInfo.UpdateTime = time.Now().Unix()
488
 					syncInfo.UpdateTime = time.Now().Unix()
494
-		
489
+
495
 					cwderr := CreateSyncInfo(&syncInfo)
490
 					cwderr := CreateSyncInfo(&syncInfo)
496
 					if cwderr != nil {
491
 					if cwderr != nil {
497
 						utils.ErrorLog("创建同步信息失败:%v", cwderr)
492
 						utils.ErrorLog("创建同步信息失败:%v", cwderr)
539
 
534
 
540
 // 				if len(fjtfLab.Result) > 0 {
535
 // 				if len(fjtfLab.Result) > 0 {
541
 // 					// 根据获取的头部lab01获取检查结果
536
 // 					// 根据获取的头部lab01获取检查结果
542
-	
537
+
543
 // 					for _, info := range fjtfLab.Result {
538
 // 					for _, info := range fjtfLab.Result {
544
 // 						lacResult, _ := FjtjGetLac(info.Lab01)
539
 // 						lacResult, _ := FjtjGetLac(info.Lab01)
545
 // 						var fjtfLac LacResult
540
 // 						var fjtfLac LacResult
557
 // 								project_id, _ = GetfjtfProjectID(org_id, cinfo.Bbx05)
552
 // 								project_id, _ = GetfjtfProjectID(org_id, cinfo.Bbx05)
558
 // 								item_id, _ = GetFjtfItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
553
 // 								item_id, _ = GetFjtfItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
559
 // 							}
554
 // 							}
560
-						
561
 
555
 
562
 // 							tx := writeMiddleDb.Begin()
556
 // 							tx := writeMiddleDb.Begin()
563
 // 							var inspection models.MiddleInspection
557
 // 							var inspection models.MiddleInspection
564
 // 							var inspection_reference models.MiddleInspectionReference
558
 // 							var inspection_reference models.MiddleInspectionReference
565
 
559
 
566
-
567
 // 							loc, _ := time.LoadLocation("Local")
560
 // 							loc, _ := time.LoadLocation("Local")
568
 // 							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
561
 // 							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
569
 // 							record_date := theTime.Unix()
562
 // 							record_date := theTime.Unix()
594
 // 						// if inspection_reference.ID > 0 {
587
 // 						// if inspection_reference.ID > 0 {
595
 // 						// 	ItemType = int64(inspection_reference.RangeType)
588
 // 						// 	ItemType = int64(inspection_reference.RangeType)
596
 // 						// }
589
 // 						// }
597
-						
590
+
598
 // 						if total <= 0 {
591
 // 						if total <= 0 {
599
 // 							inspection_reference.OrgId = org_id
592
 // 							inspection_reference.OrgId = org_id
600
 // 							if len(cinfo.Bbx05a) > 0 {
593
 // 							if len(cinfo.Bbx05a) > 0 {
601
-// 								inspection_reference.ProjectName = cinfo.Bbx05a 
594
+// 								inspection_reference.ProjectName = cinfo.Bbx05a
602
 // 								inspection_reference.Project = cinfo.Bbx05a
595
 // 								inspection_reference.Project = cinfo.Bbx05a
603
 // 							} else {
596
 // 							} else {
604
 // 								inspection_reference.ProjectName = cinfo.Bbx05
597
 // 								inspection_reference.ProjectName = cinfo.Bbx05
650
 // 						}
643
 // 						}
651
 
644
 
652
 // 						tx.Commit()
645
 // 						tx.Commit()
653
-						
646
+
654
 // 					}
647
 // 					}
655
 // 				}
648
 // 				}
656
 // 				}
649
 // 				}
820
 // 	}
813
 // 	}
821
 // }
814
 // }
822
 
815
 
823
-
824
 // func SyncToFjtftx() {
816
 // func SyncToFjtftx() {
825
 // 	utils.TraceLog("检验检查同步任务开始执行")
817
 // 	utils.TraceLog("检验检查同步任务开始执行")
826
 // 	org_id := int64(10330)
818
 // 	org_id := int64(10330)

+ 10 - 12
tests/default_test.go View File

1
 package test
1
 package test
2
 
2
 
3
 import (
3
 import (
4
+	_ "IC/routers"
4
 	"net/http"
5
 	"net/http"
5
 	"net/http/httptest"
6
 	"net/http/httptest"
6
-	"testing"
7
-	"runtime"
8
 	"path/filepath"
7
 	"path/filepath"
9
-	_ "IC/routers"
8
+	"runtime"
9
+	"testing"
10
 
10
 
11
 	"github.com/astaxie/beego"
11
 	"github.com/astaxie/beego"
12
 	. "github.com/smartystreets/goconvey/convey"
12
 	. "github.com/smartystreets/goconvey/convey"
14
 
14
 
15
 func init() {
15
 func init() {
16
 	_, file, _, _ := runtime.Caller(1)
16
 	_, file, _, _ := runtime.Caller(1)
17
-	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
17
+	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
18
 	beego.TestBeegoInit(apppath)
18
 	beego.TestBeegoInit(apppath)
19
 }
19
 }
20
 
20
 
21
-
22
 // TestBeego is a sample to run an endpoint test
21
 // TestBeego is a sample to run an endpoint test
23
 func TestBeego(t *testing.T) {
22
 func TestBeego(t *testing.T) {
24
 	r, _ := http.NewRequest("GET", "/", nil)
23
 	r, _ := http.NewRequest("GET", "/", nil)
28
 	beego.Trace("testing", "TestBeego", "Code[%d]\n%s", w.Code, w.Body.String())
27
 	beego.Trace("testing", "TestBeego", "Code[%d]\n%s", w.Code, w.Body.String())
29
 
28
 
30
 	Convey("Subject: Test Station Endpoint\n", t, func() {
29
 	Convey("Subject: Test Station Endpoint\n", t, func() {
31
-	        Convey("Status Code Should Be 200", func() {
32
-	                So(w.Code, ShouldEqual, 200)
33
-	        })
34
-	        Convey("The Result Should Not Be Empty", func() {
35
-	                So(w.Body.Len(), ShouldBeGreaterThan, 0)
36
-	        })
30
+		Convey("Status Code Should Be 200", func() {
31
+			So(w.Code, ShouldEqual, 200)
32
+		})
33
+		Convey("The Result Should Not Be Empty", func() {
34
+			So(w.Body.Len(), ShouldBeGreaterThan, 0)
35
+		})
37
 	})
36
 	})
38
 }
37
 }
39
-

+ 4 - 4
utils/tools.go View File

72
 	return ""
72
 	return ""
73
 }
73
 }
74
 
74
 
75
-//Signature sha1签名
75
+// Signature sha1签名
76
 func Signature(params ...string) string {
76
 func Signature(params ...string) string {
77
 	sort.Strings(params)
77
 	sort.Strings(params)
78
 	h := sha1.New()
78
 	h := sha1.New()
82
 	return fmt.Sprintf("%x", h.Sum(nil))
82
 	return fmt.Sprintf("%x", h.Sum(nil))
83
 }
83
 }
84
 
84
 
85
-//RandomStr 随机生成字符串
85
+// RandomStr 随机生成字符串
86
 func RandomStr(length int) string {
86
 func RandomStr(length int) string {
87
 	str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
87
 	str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
88
 	bytes := []byte(str)
88
 	bytes := []byte(str)
94
 	return string(result)
94
 	return string(result)
95
 }
95
 }
96
 
96
 
97
-//GetCurrTs return current timestamps
97
+// GetCurrTs return current timestamps
98
 func GetCurrTs() int64 {
98
 func GetCurrTs() int64 {
99
 	return time.Now().Unix()
99
 	return time.Now().Unix()
100
 }
100
 }
154
 	Signature string `json:"signature"`
154
 	Signature string `json:"signature"`
155
 }
155
 }
156
 
156
 
157
-//GetAJTConfig jsapi_ticket config
157
+// GetAJTConfig jsapi_ticket config
158
 func GetAJTConfig(jsapiTicket, uri string) (jSapiConfig, error) {
158
 func GetAJTConfig(jsapiTicket, uri string) (jSapiConfig, error) {
159
 	var config jSapiConfig
159
 	var config jSapiConfig
160
 	nonceStr := RandomStr(16)
160
 	nonceStr := RandomStr(16)