张保健 11 miesięcy temu
rodzic
commit
6645cbc1b0

+ 42 - 9
controllers/lis.go Wyświetl plik

@@ -20,12 +20,12 @@ type LisController struct {
20 20
 
21 21
 func (c *LisController) Schedule() {
22 22
 	for i := 762429; i > 0; i-- {
23
-		schedule,err := service.GetScheduless(int64(i))
23
+		schedule, err := service.GetScheduless(int64(i))
24 24
 		fmt.Println(schedule.ID)
25 25
 		if err == nil {
26
-			service.UpdateSchedule(schedule.ID,schedule.Status)
26
+			service.UpdateSchedule(schedule.ID, schedule.Status)
27 27
 		}
28
-		
28
+
29 29
 	}
30 30
 
31 31
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -35,26 +35,43 @@ func (c *LisController) Schedule() {
35 35
 
36 36
 }
37 37
 
38
+func (c *LisController) SyncTest() {
39
+	// 获取备份库里所有的医嘱信息
40
+	// service.EmrBloodDiaylOrder()
41
+	// service.EmrBloodDiaylDetail()
42
+	service.SyncScpaLis()
43
+	c.ServeSuccessJSON(map[string]interface{}{
44
+		"resultList": "12345",
45
+	})
46
+	return
47
+}
48
+
38 49
 func (c *LisController) SyncSzblLis() {
39 50
 	// 获取备份库里所有的医嘱信息
40
-	
41
-	service.GetSZBLResultDataInsertDB(10138)
51
+	service.GetSZBLResultDataInsertDB(10278)
42 52
 	c.ServeSuccessJSON(map[string]interface{}{
43 53
 		"resultList": "12345",
44 54
 	})
45 55
 	return
56
+}
46 57
 
58
+// 唐山朝阳医院LIS
59
+func (c *LisController) SyncTscyLis() {
60
+	service.SyncTscyLis()
61
+	c.ServeSuccessJSON(map[string]interface{}{
62
+		"resultList": "12345",
63
+	})
64
+	return
47 65
 }
48 66
 
49 67
 func (c *LisController) SyncShLis() {
50 68
 	// 获取备份库里所有的医嘱信息
51
-	
69
+
52 70
 	service.GetSHResultDataInsertDB(10215)
53 71
 	c.ServeSuccessJSON(map[string]interface{}{
54 72
 		"resultList": "12345",
55 73
 	})
56 74
 	return
57
-
58 75
 }
59 76
 
60 77
 func (c *LisController) SyncAdvice() {
@@ -450,9 +467,25 @@ func (c *LisController) SyncBlResultLis() {
450 467
 	})
451 468
 }
452 469
 
453
-//肇庆三鹤
470
+// 肇庆三鹤
454 471
 func (c *LisController) SyncZQSHResultLis() {
455
-	service.GetResultDataInsertDB(10215)
472
+	service.GetSHResultDataInsertDB(10215)
473
+	c.ServeSuccessJSON(map[string]interface{}{
474
+		"resultList": "同步成功",
475
+	})
476
+}
477
+
478
+// 福建天福
479
+func (c *LisController) SyncFjtfLis() {
480
+	service.SyncFjtfLis()
481
+	c.ServeSuccessJSON(map[string]interface{}{
482
+		"resultList": "同步成功",
483
+	})
484
+}
485
+
486
+// 长沙南雅
487
+func (c *LisController) SyncCsnyLis() {
488
+	service.SyncCsnyLis()
456 489
 	c.ServeSuccessJSON(map[string]interface{}{
457 490
 		"resultList": "同步成功",
458 491
 	})

+ 1 - 1
main.go Wyświetl plik

@@ -18,7 +18,7 @@ func main() {
18 18
 	service.BeginAutoSyncLis()
19 19
 	//service.GetDataInsertDB(10138)
20 20
 	//service.GetResultDataInsertDB(10138)
21
-	//service.GetSHResultDataInsertDB(10215)
21
+	// service.GetSHResultDataInsertDB(10215)
22 22
 	// service.Synctfyz()
23 23
 	// service.GetSHResultDataInsertDB(10215)
24 24
 	beego.Run()

+ 1 - 0
models/lis_model.go Wyświetl plik

@@ -139,6 +139,7 @@ type Patients struct {
139 139
 	Name            string `gorm:"column:name" json:"name" form:"name"`
140 140
 	ContactName     string `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
141 141
 	Gender          int64  `gorm:"column:gender" json:"gender" form:"gender"`
142
+	Birthday        int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
142 143
 }
143 144
 
144 145
 func (Patients) TableName() string {

+ 521 - 0
models/wfnfm_model.go Wyświetl plik

@@ -0,0 +1,521 @@
1
+package models
2
+
3
+
4
+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"`
64
+}
65
+
66
+func (EmrBloodDialyRecord) TableName() string {
67
+	return "EMR_BLOOD_DIALY_RECORD"
68
+}
69
+
70
+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
+	
97
+}
98
+
99
+func (EmrBloodDialyDetail) TableName() string {
100
+	return "EMR_BLOOD_DIALY_DETAIL"
101
+}
102
+
103
+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
+	
126
+}
127
+
128
+func (EmrBloodDialyOrder) TableName() string {
129
+	return "EMR_BLOOD_DIALY_ORDER"
130
+}
131
+
132
+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"`
163
+}
164
+
165
+func (DialysisOrder) TableName() string {
166
+	return "xt_dialysis_order"
167
+}
168
+
169
+type DialysisPrescription struct {
170
+	ID                        int64   `gorm:"column:id" json:"id"`
171
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id"`
172
+	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id"`
173
+	Dialyzer                  int64   `gorm:"column:dialyzer" json:"dialyzer"`
174
+	MachineType               string  `gorm:"column:machine_type" json:"machine_type"`
175
+	DewaterAmount             float64 `gorm:"column:dewater_amount" json:"dewater_amount"`
176
+	PrescriptionDewatering    float64 `gorm:"column:prescription_dewatering" json:"prescription_dewatering"`
177
+	Anticoagulant             int64   `gorm:"column:anticoagulant" json:"anticoagulant"`
178
+	AnticoagulantShouji       float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji"`
179
+	AnticoagulantWeichi       float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi"`
180
+	AnticoagulantZongliang    float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang"`
181
+	AnticoagulantGaimingcheng string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng"`
182
+	AnticoagulantGaijiliang   string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang"`
183
+	ModeId                    int64   `gorm:"column:mode_id" json:"mode_id"`
184
+	DialysisDuration          float64 `gorm:"column:dialysis_duration" json:"dialysis_duration"`
185
+	ReplacementTotal          float64 `gorm:"column:replacement_total" json:"replacement_total"`
186
+	ReplacementWay            int64   `gorm:"column:replacement_way" json:"replacement_way"`
187
+	HemodialysisMachine       int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine"`
188
+	BloodFilter               int64   `gorm:"column:blood_filter" json:"blood_filter"`
189
+	PerfusionApparatus        int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus"`
190
+	//DryWeight                 float64 `gorm:"column:dry_weight" json:"dry_weight"`
191
+	VascularAccessMode         int64         `gorm:"column:vascular_access_mode" json:"vascular_access_mode"`
192
+	VascularAccess             int64         `gorm:"column:vascular_access" json:"vascular_access"`
193
+	BloodFlowVolume            float64       `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
194
+	DialysateFlow              float64       `gorm:"column:dialysate_flow" json:"dialysate_flow"`
195
+	DisplaceLiqui              float64       `gorm:"column:displace_liqui" json:"displace_liqui"`
196
+	Kalium                     float64       `gorm:"column:kalium" json:"kalium"`
197
+	Sodium                     float64       `gorm:"column:sodium" json:"sodium"`
198
+	Calcium                    float64       `gorm:"column:calcium" json:"calcium"`
199
+	Bicarbonate                float64       `gorm:"column:bicarbonate" json:"bicarbonate"`
200
+	Glucose                    float64       `gorm:"column:glucose" json:"glucose"`
201
+	DialysateTemperature       float64       `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
202
+	Conductivity               float64       `gorm:"column:conductivity" json:"conductivity"`
203
+	PrescriptionDoctor         int64         `gorm:"column:prescription_doctor" json:"prescription_doctor"`
204
+	Remark                     string        `gorm:"column:remark" json:"remark"`
205
+	Status                     int64         `gorm:"column:status" json:"status"`
206
+	CreatedTime                int64         `gorm:"column:created_time" json:"created_time"`
207
+	UpdatedTime                int64         `gorm:"column:updated_time" json:"updated_time"`
208
+	RecordDate                 int64         `gorm:"column:record_date" json:"record_date"`
209
+	RecordId                   int64         `gorm:"column:record_id" json:"record_id"`
210
+	Creater                    int64         `gorm:"column:creater" json:"creater"`
211
+	Modifier                   int64         `gorm:"column:modifier" json:"modifier"`
212
+	DialysisDurationHour       int64         `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour"`
213
+	DialysisDurationMinute     int64         `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute"`
214
+	DialysateFormulation       int64         `gorm:"column:dialysate_formulation" json:"dialysate_formulation"`
215
+	TargetUltrafiltration      float64       `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration"`
216
+	DialyzerPerfusionApparatus string        `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
217
+	BodyFluid                  int64         `gorm:"column:body_fluid" json:"body_fluid"`
218
+	SpecialMedicine            int64         `gorm:"column:special_medicine" json:"special_medicine"`
219
+	SpecialMedicineOther       string        `gorm:"column:special_medicine_other" json:"special_medicine_other"`
220
+	DisplaceLiquiPart          int64         `gorm:"column:displace_liqui_part" json:"displace_liqui_part"`
221
+	DisplaceLiquiValue         float64       `gorm:"column:displace_liqui_value" json:"displace_liqui_value"`
222
+	BloodAccess                int64         `gorm:"column:blood_access" json:"blood_access"`
223
+	Ultrafiltration            float64       `gorm:"column:ultrafiltration" json:"ultrafiltration"`
224
+	BodyFluidOther             string        `gorm:"column:body_fluid_other" json:"body_fluid_other"`
225
+	Niprocart                  int64         `gorm:"column:niprocart" json:"niprocart"`
226
+	Jms                        int64         `gorm:"column:jms" json:"jms"`
227
+	FistulaNeedleSet           int64         `gorm:"column:fistula_needle_set" json:"fistula_needle_set"`
228
+	FistulaNeedleSet16         int64         `gorm:"column:fistula_needle_set_16" json:"fistula_needle_set_16"`
229
+	Hemoperfusion              int64         `gorm:"column:hemoperfusion" json:"hemoperfusion"`
230
+	DialyserSterilised         int64         `gorm:"column:dialyser_sterilised" json:"dialyser_sterilised"`
231
+	Filtryzer                  int64         `gorm:"column:filtryzer" json:"filtryzer"`
232
+	TargetKtv                  float64       `gorm:"column:target_ktv" json:"target_ktv"`
233
+	Dialyzers                  int64         `gorm:"column:dialyzers" json:"dialyzers"`
234
+	Injector                   int64         `gorm:"column:injector" json:"injector"`
235
+	Bloodlines                 int64         `gorm:"column:bloodlines" json:"bloodlines"`
236
+	TubingHemodialysis         int64         `gorm:"column:tubing_hemodialysis" json:"tubing_hemodialysis"`
237
+	Package                    int64         `gorm:"column:package" json:"package"`
238
+	ALiquid                    int64         `gorm:"column:a_liquid" json:"a_liquid"`
239
+	UserAdminRole              UserAdminRole `json:"role" gorm:"foreignkey:AdminUserId;AssociationForeignKey:Creater;"`
240
+	PreImpulse                 float64       `gorm:"column:pre_impulse" json:"pre_impulse" form:"pre_impulse"`
241
+	AnticoagulantStopTimeMin   int64         `gorm:"column:anticoagulant_stop_time_min" json:"anticoagulant_stop_time_min" form:"anticoagulant_stop_time_min"`
242
+	AnticoagulantStopTimeHour  int64         `gorm:"column:anticoagulant_stop_time_hour" json:"anticoagulant_stop_time_hour" form:"anticoagulant_stop_time_hour"`
243
+	Blood                      string        `gorm:"column:blood" json:"blood"`
244
+	DialysisDialyszers         string        `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
245
+	DialysisIrrigation         string        `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
246
+	AntioxidantCommodityName   string        `gorm:"column:antioxidant_commodity_name" json:"antioxidant_commodity_name" form:"antioxidant_commodity_name"`
247
+	DisplaceSpeed              string        `gorm:"column:displace_speed" json:"displace_speed" form:"displace_speed"`
248
+	Illness                    int64         `gorm:"column:illness" json:"illness" form:"illness"`
249
+	Amylaceum                  string        `gorm:"column:amylaceum" json:"amylaceum" form:"amylaceum"`
250
+	SingleTime                 string        `gorm:"column:single_time" json:"single_time" form:"single_time"`
251
+	SingleWater                string        `gorm:"column:single_water" json:"single_water" form:"single_water"`
252
+	ReplacementFlow            string        `gorm:"column:replacement_flow" json:"replacement_flow" form:"replacement_flow"`
253
+	PlasmaSeparator            string        `gorm:"column:plasma_separator" json:"plasma_separator" form:"plasma_separator"`
254
+	BilirubinAdsorptionColumn  string        `gorm:"column:bilirubin_adsorption_column" json:"bilirubin_adsorption_column" form:"bilirubin_adsorption_column"`
255
+	OxygenUptake               int64         `gorm:"column:oxygen_uptake" json:"oxygen_uptake" form:"oxygen_uptake"`
256
+	OxygenFlow                 string        `gorm:"column:oxygen_flow" json:"oxygen_flow" form:"oxygen_flow"`
257
+	OxygenTime                 string        `gorm:"column:oxygen_time" json:"oxygen_time" form:"oxygen_time"`
258
+	HemodialysisPipelines      string        `gorm:"column:hemodialysis_pipelines" json:"hemodialysis_pipelines" form:"hemodialysis_pipelines"`
259
+	HemodialysisPipelinesCount float64       `gorm:"column:hemodialysis_pipelines_count" json:"hemodialysis_pipelines_count" form:"hemodialysis_pipelines_count"`
260
+	PunctureNeedle             string        `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
261
+	PunctureNeedleCount        float64       `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
262
+	Epo                        string        `gorm:"column:epo" json:"epo" form:"epo"`
263
+	EpoCount                   float64       `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
264
+	MaxUltrafiltrationRate     float64       `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
265
+}
266
+
267
+func (DialysisPrescription) TableName() string {
268
+	return "xt_dialysis_prescription"
269
+}
270
+
271
+type PredialysisEvaluation struct {
272
+	ID                          int64   `gorm:"column:id" json:"id"`
273
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id"`
274
+	PatientId                   int64   `gorm:"column:patient_id" json:"patient_id"`
275
+	AssessmentDate              int64   `gorm:"column:assessment_date" json:"assessment_date"`
276
+	DialysisOrderId             int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
277
+	Temperature                 float64 `gorm:"column:temperature" json:"temperature"`
278
+	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
279
+	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
280
+	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
281
+	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
282
+	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
283
+	DryWeight                   float64 `gorm:"column:dry_weight" json:"dry_weight"`
284
+	WeightAfterLastTransparency float64 `gorm:"column:weight_after_last_transparency" json:"weight_after_last_transparency"`
285
+	WeighingWay                 string  `gorm:"column:weighing_way" json:"weighing_way"`
286
+	WeighingBefore              float64 `gorm:"column:weighing_before" json:"weighing_before"`
287
+	AdditionalWeight            float64 `gorm:"column:additional_weight" json:"additional_weight"`
288
+	WeightBefore                float64 `gorm:"column:weight_before" json:"weight_before"`
289
+	WeightGain                  float64 `gorm:"column:weight_gain" json:"weight_gain"`
290
+	PreloadedDewatering         float64 `gorm:"column:preloaded_dewatering" json:"preloaded_dewatering"`
291
+	UltrafiltrationAmount       float64 `gorm:"column:ultrafiltration_amount" json:"ultrafiltration_amount"`
292
+	DialysisInterphase          string  `gorm:"column:dialysis_interphase" json:"dialysis_interphase"`
293
+	LastPostDialysis            string  `gorm:"column:last_post_dialysis" json:"last_post_dialysis"`
294
+	SymptomBeforeDialysis       string  `gorm:"column:symptom_before_dialysis" json:"symptom_before_dialysis"`
295
+	InternalFistula             string  `gorm:"column:internal_fistula" json:"internal_fistula"`
296
+	InternalFistulaSkin         string  `gorm:"column:internal_fistula_skin" json:"internal_fistula_skin"`
297
+	Catheter                    string  `gorm:"column:catheter" json:"catheter"`
298
+	CatheterBend                int     `gorm:"column:catheter_bend" json:"catheter_bend"`
299
+	Complication                string  `gorm:"column:complication" json:"complication"`
300
+	Evaluator                   int64   `gorm:"column:evaluator" json:"evaluator"`
301
+	Creater                     int64   `gorm:"column:creater" json:"creater"`
302
+	Remark                      string  `gorm:"column:remark" json:"remark"`
303
+	Status                      int64   `gorm:"column:status" json:"status"`
304
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time"`
305
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time"`
306
+	Modifier                    int64   `gorm:"column:modifier" json:"modifier"`
307
+	BloodAccessPartId           string  `gorm:"column:blood_access_part_id" json:"blood_access_part_id"`
308
+	BloodAccessPartOperaId      int64   `gorm:"column:blood_access_part_opera_id" json:"blood_access_part_opera_id"`
309
+	IsHemorrhage                int64   `gorm:"column:is_hemorrhage" json:"is_hemorrhage"`
310
+	Hemorrhage                  string  `gorm:"column:hemorrhage" json:"hemorrhage"`
311
+	HemorrhageOther             string  `gorm:"column:hemorrhage_other" json:"hemorrhage_other"`
312
+	PunctureMethod              string  `gorm:"column:puncture_method" json:"puncture_method"`
313
+	BloodAccessInternalFistula  string  `gorm:"column:blood_access_internal_fistula" json:"blood_access_internal_fistula"`
314
+	InternalFistulaOther        string  `gorm:"column:internal_fistula_other" json:"internal_fistula_other"`
315
+
316
+	BloodAccessNoise               int64   `gorm:"column:blood_access_noise" json:"blood_access_noise"`
317
+	PunctureWay                    string  `gorm:"column:puncture_way" json:"puncture_way"`
318
+	VenousCatheterization          int64   `gorm:"column:venous_catheterization" json:"venous_catheterization"`
319
+	VenousCatheterizationPart      int64   `gorm:"column:venous_catheterization_part" json:"venous_catheterization_part"`
320
+	VenousCatheterizationPartOther string  `gorm:"column:venous_catheterization_part_other" json:"venous_catheterization_part_other"`
321
+	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii"`
322
+	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment"`
323
+	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other"`
324
+	DialysisCount                  string  `gorm:"column:dialysis_count" json:"dialysis_count"`
325
+	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
326
+	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time"`
327
+	MachineType                    string  `gorm:"column:machine_type" json:"machine_type"`
328
+	IsInfect                       int64   `gorm:"column:is_infect" json:"is_infect"`
329
+	Exposed                        float64 `gorm:"column:exposed" json:"exposed"`
330
+	Skin                           string  `gorm:"column:skin" json:"skin"`
331
+	SkinOther                      string  `gorm:"column:skin_other" json:"skin_other"`
332
+	InfectOther                    string  `gorm:"column:infect_other" json:"infect_other"`
333
+	DuctusArantiiOther             string  `gorm:"column:ductus_arantii_other" json:"ductus_arantii_other"`
334
+	PunctureNeedle                 string  `gorm:"column:puncture_needle" json:"puncture_needle"`
335
+	LastPostDialysisOther          string  `gorm:"column:last_post_dialysis_other" json:"last_post_dialysis_other"`
336
+	SymptomBeforeDialysisOther     string  `gorm:"column:symptom_before_dialysis_other" json:"symptom_before_dialysis_other"`
337
+	DialysisInterphaseOther        string  `gorm:"column:dialysis_interphase_other" json:"dialysis_interphase_other"`
338
+	HumorExcessiveSymptom          string  `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom"`
339
+	Phinholing                     string  `gorm:"column:pinholing" json:"pinholing" form:"pinholing"`
340
+	CatheterSuture                 string  `gorm:"column:catheter_suture" json:"catheter_suture" form:"catheter_suture"`
341
+	CatheterSutureOther            string  `gorm:"column:catheter_suture_other" json:"catheter_suture_other" form:"catheter_suture_other"`
342
+	UrineVolume                    float64 `gorm:"column:urine_volume" json:"urine_volume" form:"urine_volume"`
343
+	Edema                          string  `gorm:"column:edema" json:"edema" form:"edema"`
344
+	SpecialTreatment               string  `gorm:"column:special_treatment" json:"special_treatment" form:"special_treatment"`
345
+	CatheterMaintenance            string  `gorm:"column:catheter_maintenance" json:"catheter_maintenance" form:"catheter_maintenance"`
346
+	ThromubusType                  int64   `gorm:"column:thromubus_type" json:"thromubus_type" form:"thromubus_type"`
347
+	ThrombusAv                     string  `gorm:"column:thrombus_av" json:"thrombus_av" form:"thrombus_av"`
348
+	ThromubusA                     string  `gorm:"column:thromubus_a" json:"thromubus_a" form:"thromubus_a"`
349
+	ThromubusV                     string  `gorm:"column:thromubus_v" json:"thromubus_v" form:"thromubus_v"`
350
+	Dehydration                    string  `gorm:"column:dehydration" json:"dehydration" form:"dehydration"`
351
+	PreDialysisDrugs               string  `gorm:"column:pre_dialysis_drugs" json:"pre_dialysis_drugs" form:"pre_dialysis_drugs"`
352
+	Period                         int64   `gorm:"column:period" json:"period" form:"period"`
353
+	EstimatedFoodIntake            string  `gorm:"column:estimated_food_intake" json:"estimated_food_intake" form:"estimated_food_intake"`
354
+	BloodPressureDuringDialysis    string  `gorm:"column:blood_pressure_during_dialysis" json:"blood_pressure_during_dialysis" form:"blood_pressure_during_dialysis"`
355
+	UreaBefor                      string  `gorm:"column:urea_befor" json:"urea_befor" form:"urea_befor"`
356
+	Suction                        string  `gorm:"column:suction" json:"suction" form:"suction"`
357
+}
358
+
359
+func (PredialysisEvaluation) TableName() string {
360
+	return "xt_assessment_before_dislysis"
361
+}
362
+
363
+type AssessmentAfterDislysis struct {
364
+	ID                     int64   `gorm:"column:id" json:"id"`
365
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id"`
366
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id"`
367
+	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date"`
368
+	DialysisOrderId        int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
369
+	Temperature            float64 `gorm:"column:temperature" json:"temperature"`
370
+	PulseFrequency         float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
371
+	BreathingRate          float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
372
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
373
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
374
+	BloodPressureType      int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
375
+	ActualUltrafiltration  float64 `gorm:"column:actual_ultrafiltration" json:"actual_ultrafiltration"`
376
+	ActualDisplacement     float64 `gorm:"column:actual_displacement" json:"actual_displacement"`
377
+	ActualTreatmentHour    int64   `gorm:"column:actual_treatment_hour" json:"actual_treatment_hour"`
378
+	ActualTreatmentMinute  int64   `gorm:"column:actual_treatment_minute" json:"actual_treatment_minute"`
379
+	WeighingWay            string  `gorm:"column:weighing_way" json:"weighing_way"`
380
+	WeightAfter            float64 `gorm:"column:weight_after" json:"weight_after"`
381
+	AdditionalWeight       float64 `gorm:"column:additional_weight" json:"additional_weight"`
382
+	WeightLoss             float64 `gorm:"column:weight_loss" json:"weight_loss"`
383
+	Cruor                  string  `gorm:"column:cruor" json:"cruor"`
384
+	SymptomAfterDialysis   string  `gorm:"column:symptom_after_dialysis" json:"symptom_after_dialysis"`
385
+	InternalFistula        string  `gorm:"column:internal_fistula" json:"internal_fistula"`
386
+	// InternalFistulaSkin             string  `gorm:"column:internal_fistula_skin" json:"internal_fistula_skin"`
387
+	Catheter string `gorm:"column:catheter" json:"catheter"`
388
+	// CatheterBend                    int     `gorm:"column:catheter_bend" json:"catheter_bend"`
389
+	Complication                    string  `gorm:"column:complication" json:"complication"`
390
+	Evaluator                       int64   `gorm:"column:evaluator" json:"evaluator"`
391
+	Remark                          string  `gorm:"column:remark" json:"remark"`
392
+	DialysisIntakes                 float64 `gorm:"column:dialysis_intakes" json:"dialysis_intakes"`
393
+	DialysisIntakesFeed             int64   `gorm:"column:dialysis_intakes_feed" json:"dialysis_intakes_feed"`
394
+	DialysisIntakesTransfusion      int64   `gorm:"column:dialysis_intakes_transfusion" json:"dialysis_intakes_transfusion"`
395
+	DialysisIntakesBloodTransfusion int64   `gorm:"column:dialysis_intakes_blood_transfusion" json:"dialysis_intakes_blood_transfusion"`
396
+	DialysisIntakesWashpipe         int64   `gorm:"column:dialysis_intakes_washpipe" json:"dialysis_intakes_washpipe"`
397
+	Status                          int64   `gorm:"column:status" json:"status"`
398
+	CreatedTime                     int64   `gorm:"column:created_time" json:"created_time"`
399
+	UpdatedTime                     int64   `gorm:"column:updated_time" json:"updated_time"`
400
+	Creater                         int64   `gorm:"column:creater" json:"creater"`
401
+	Modifier                        int64   `gorm:"column:modifier" json:"modifier"`
402
+	BloodAccessPartId               int64   `gorm:"column:blood_access_part_id" json:"blood_access_part_id"`
403
+	BloodAccessPartOperaId          int64   `gorm:"column:blood_access_part_opera_id" json:"blood_access_part_opera_id"`
404
+	PuncturePointOozingBlood        int64   `gorm:"column:puncture_point_oozing_blood" json:"puncture_point_oozing_blood"`
405
+	PuncturePointHaematoma          int64   `gorm:"column:puncture_point_haematoma" json:"puncture_point_haematoma"`
406
+	InternalFistulaTremorAc         int64   `gorm:"column:internal_fistula_tremor_ac" json:"internal_fistula_tremor_ac"`
407
+	PatientGose                     int64   `gorm:"column:patient_gose" json:"patient_gose"`
408
+	InpatientDepartment             string  `gorm:"column:inpatient_department" json:"inpatient_department"`
409
+	ObservationContent              string  `gorm:"column:observation_content" json:"observation_content"`
410
+	ObservationContentOther         string  `gorm:"column:observation_content_other" json:"observation_content_other"`
411
+	DryWeight                       float64 `gorm:"column:dry_weight" json:"dry_weight"`
412
+	DialysisProcess                 int64   `gorm:"column:dialysis_process" json:"dialysis_process"`
413
+	InAdvanceMinute                 float64 `gorm:"column:in_advance_minute" json:"in_advance_minute"`
414
+	InAdvanceReason                 string  `gorm:"column:in_advance_reason" json:"in_advance_reason"`
415
+	HemostasisMinute                int64   `gorm:"column:hemostasis_minute" json:"hemostasis_minute"`
416
+	HemostasisOpera                 int64   `gorm:"column:hemostasis_opera" json:"hemostasis_opera"`
417
+	TremorNoise                     int64   `gorm:"column:tremor_noise" json:"tremor_noise"`
418
+	DisequilibriumSyndrome          int64   `gorm:"column:disequilibrium_syndrome" json:"disequilibrium_syndrome"`
419
+	DisequilibriumSyndromeOption    string  `gorm:"column:disequilibrium_syndrome_option" json:"disequilibrium_syndrome_option"`
420
+	ArterialTube                    int64   `gorm:"column:arterial_tube" json:"arterial_tube"`
421
+	IntravenousTube                 int64   `gorm:"column:intravenous_tube" json:"intravenous_tube"`
422
+	Dialyzer                        int64   `gorm:"column:dialyzer" json:"dialyzer"`
423
+	InAdvanceReasonOther            string  `gorm:"column:in_advance_reason_other" json:"in_advance_reason_other"`
424
+	AssessmentTime                  int64   `gorm:"column:assessment_time" json:"assessment_time"`
425
+	AssessmentDoctor                int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
426
+	IsEat                           int64   `gorm:"column:is_eat" json:"is_eat"`
427
+	DialysisIntakesUnit             int64   `gorm:"column:dialysis_intakes_unit" json:"dialysis_intakes_unit"`
428
+	CvcA                            float64 `gorm:"column:cvc_a" json:"cvc_a" form:"cvc_a"`
429
+	CvcV                            float64 `gorm:"column:cvc_v" json:"cvc_v" form:"cvc_v"`
430
+	ReturnBlood                     int64   `gorm:"column:return_blood" json:"return_blood" form:"return_blood"`
431
+	RehydrationVolume               int64   `gorm:"column:rehydration_volume" json:"rehydration_volume" form:"rehydration_volume"`
432
+	DialysisDuring                  int64   `gorm:"column:dialysis_during" json:"dialysis_during" form:"dialysis_during"`
433
+	StrokeVolume                    int64   `gorm:"column:stroke_volume" json:"stroke_volume" form:"stroke_volume"`
434
+	Channel                         int64   `gorm:"column:channel" json:"channel" form:"channel"`
435
+	BloodFlow                       int64   `gorm:"column:blood_flow" json:"blood_flow" form:"blood_flow"`
436
+	SealingFluidDispose             string  `gorm:"column:sealing_fluid_dispose" json:"sealing_fluid_dispose" form:"sealing_fluid_dispose"`
437
+	SealingFluidSpecial             string  `gorm:"column:sealing_fluid_special" json:"sealing_fluid_special" form:"sealing_fluid_special"`
438
+	DosageOfAnticoagulants          float64 `gorm:"column:dosage_of_anticoagulants" json:"dosage_of_anticoagulants" form:"dosage_of_anticoagulants"`
439
+	SupineSystolicBloodPressure     string  `gorm:"column:supine_systolic_blood_pressure" json:"supine_systolic_blood_pressure" form:"supine_systolic_blood_pressure"`
440
+	SettingPressure                 string  `gorm:"column:setting_pressure" json:"setting_pressure" form:"setting_pressure"`
441
+	SupineDiastolicBloodPressure    string  `gorm:"column:supine_diastolic_blood_pressure" json:"supine_diastolic_blood_pressure" form:"supine_diastolic_blood_pressure"`
442
+	DiastolicPressure               string  `gorm:"column:diastolic_pressure" json:"diastolic_pressure" form:"diastolic_pressure"`
443
+	OtherComplication               string  `gorm:"column:other_complication" json:"other_complication" form:"other_complication"`
444
+	Ktv                             string  `gorm:"column:ktv" json:"ktv" form:"ktv"`
445
+	Urr                             string  `gorm:"column:urr" json:"urr" form:"urr"`
446
+	Hypertenison                    int64   `gorm:"column:hypertenison" json:"hypertenison" form:"hypertenison"`
447
+	Hypopiesia                      int64   `gorm:"column:hypopiesia" json:"hypopiesia" form:"hypopiesia"`
448
+	LeaveOfficeMethod               int64   `gorm:"column:leave_office_method" json:"leave_office_method" form:"leave_office_method"`
449
+	Lapse                           int64   `gorm:"column:lapse" json:"lapse" form:"lapse"`
450
+	Consciousness                   int64   `gorm:"column:consciousness" json:"consciousness" form:"consciousness"`
451
+	Fallrisk                        int64   `gorm:"column:fallrisk" json:"fallrisk" form:"fallrisk"`
452
+	MachineRun                      string  `gorm:"column:machine_run" json:"machine_run" form:"machine_run"`
453
+	AfterUrea                       string  `gorm:"column:after_urea" json:"after_urea" form:"after_urea"`
454
+	PipCoagulation                  string  `gorm:"column:pip_coagulation" json:"pip_coagulation" form:"pip_coagulation"`
455
+}
456
+
457
+func (AssessmentAfterDislysis) TableName() string {
458
+	return "xt_assessment_after_dislysis"
459
+}
460
+
461
+type MonitoringRecord struct {
462
+	ID                          int64   `gorm:"column:id" json:"id"`
463
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id"`
464
+	PatientId                   int64   `gorm:"column:patient_id" json:"patient_id"`
465
+	DialysisOrderId             int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
466
+	MonitoringDate              int64   `gorm:"column:monitoring_date" json:"monitoring_date"`
467
+	OperateTime                 int64   `gorm:"column:operate_time" json:"operate_time"`
468
+	MonitoringTime              string  `gorm:"column:monitoring_time" json:"monitoring_time"`
469
+	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
470
+	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
471
+	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
472
+	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
473
+	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
474
+	Pic                         string  `gorm:"column:pic" json:"pic"`
475
+	BloodFlowVolume             float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
476
+	VenousPressure              float64 `gorm:"column:venous_pressure" json:"venous_pressure"`
477
+	VenousPressureType          int64   `gorm:"column:venous_pressure_type" json:"venous_pressure_type"`
478
+	ArterialPressure            float64 `gorm:"column:arterial_pressure" json:"arterial_pressure"`
479
+	ArterialPressureType        int64   `gorm:"column:arterial_pressure_type" json:"arterial_pressure_type"`
480
+	TransmembranePressure       float64 `gorm:"column:transmembrane_pressure" json:"transmembrane_pressure"`
481
+	TransmembranePressureType   int64   `gorm:"column:transmembrane_pressure_type" json:"transmembrane_pressure_type"`
482
+	UltrafiltrationRate         float64 `gorm:"column:ultrafiltration_rate" json:"ultrafiltration_rate"`
483
+	UltrafiltrationVolume       float64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume"`
484
+	SodiumConcentration         float64 `gorm:"column:sodium_concentration" json:"sodium_concentration"`
485
+	DialysateTemperature        float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
486
+	Temperature                 float64 `gorm:"column:temperature" json:"temperature"`
487
+	ReplacementRate             float64 `gorm:"column:replacement_rate" json:"replacement_rate"`
488
+	DisplacementQuantity        float64 `gorm:"column:displacement_quantity" json:"displacement_quantity"`
489
+	Ktv                         float64 `gorm:"column:ktv" json:"ktv"`
490
+	Symptom                     string  `gorm:"column:symptom" json:"symptom"`
491
+	Dispose                     string  `gorm:"column:dispose" json:"dispose"`
492
+	Result                      string  `gorm:"column:result" json:"result"`
493
+	MonitoringNurse             int64   `gorm:"column:monitoring_nurse" json:"monitoring_nurse"`
494
+	Status                      int64   `gorm:"column:status" json:"status"`
495
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time"`
496
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time"`
497
+	Conductivity                float64 `gorm:"column:conductivity" json:"conductivity"`
498
+	DisplacementFlowQuantity    float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
499
+	BloodOxygenSaturation       string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
500
+	Creator                     int64   `gorm:"column:creator" json:"creator" form:"creator"`
501
+	Modify                      int64   `gorm:"column:modify" json:"modify" form:"modify"`
502
+	Heparin                     float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
503
+	DialysateFlow               float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
504
+	Urr                         string  `gorm:"column:urr" json:"urr"`
505
+	BloodSugar                  float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
506
+	MonitorAnticoagulant        int64   `gorm:"column:monitor_anticoagulant" json:"monitor_anticoagulant" form:"monitor_anticoagulant"`
507
+	MonitorAnticoagulantValue   string  `gorm:"column:monitor_anticoagulant_value" json:"monitor_anticoagulant_value" form:"monitor_anticoagulant_value"`
508
+	BloodPressureMonitoringSite int64   `gorm:"column:blood_pressure_monitoring_site" json:"blood_pressure_monitoring_site" form:"blood_pressure_monitoring_site"`
509
+	Complication                int64   `gorm:"column:complication" json:"complication" form:"complication"`
510
+	AccumulatedBloodVolume      float64 `gorm:"column:accumulated_blood_volume" json:"accumulated_blood_volume" form:"accumulated_blood_volume"`
511
+	BloodTemperature            float64 `gorm:"column:blood_temperature" json:"blood_temperature" form:"blood_temperature"`
512
+	UreaMonitoring              float64 `gorm:"column:urea_monitoring" json:"urea_monitoring" form:"urea_monitoring"`
513
+	BloodThickness              float64 `gorm:"column:blood_thickness" json:"blood_thickness" form:"blood_thickness"`
514
+	BloodMonitor                float64 `gorm:"column:blood_monitor" json:"blood_monitor" form:"blood_monitor"`
515
+	HeparinAmount               float64 `gorm:"column:heparin_amount" json:"heparin_amount" form:"heparin_amount"`
516
+	Dehydration                 float64 `gorm:"column:dehydration" json:"dehydration" form:"dehydration"`
517
+}
518
+
519
+func (MonitoringRecord) TableName() string {
520
+	return "xt_monitoring_record"
521
+}

+ 4 - 0
routers/router.go Wyświetl plik

@@ -17,6 +17,9 @@ func init() {
17 17
 	beego.Router("/api/lis/gzjhlissync", &controllers.LisController{}, "get:SyncGzjhLis")
18 18
 	beego.Router("/api/lis/hbdyyzsync", &controllers.LisController{}, "get:SyncHbJldyyz")
19 19
 	beego.Router("/api/lis/hbdylissync", &controllers.LisController{}, "get:SyncHbJldyLis")
20
+	beego.Router("/api/lis/tscylissync", &controllers.LisController{}, "get:SyncTscyLis")
21
+	beego.Router("/api/lis/fjtflissync", &controllers.LisController{}, "get:SyncFjtfLis")
22
+	beego.Router("/api/lis/csnylissync", &controllers.LisController{}, "get:SyncCsnyLis")
20 23
 
21 24
 	//百霖lis
22 25
 	beego.Router("/api/lis/bltest", &controllers.LisController{}, "get:SyncBlLis")
@@ -25,5 +28,6 @@ func init() {
25 28
 
26 29
 	beego.Router("/api/syncshLis", &controllers.LisController{}, "get:SyncShLis")
27 30
 	beego.Router("/api/syncszblis", &controllers.LisController{}, "get:SyncSzblLis")
31
+	beego.Router("/api/test", &controllers.LisController{}, "get:SyncScpaLis")
28 32
 
29 33
 }

+ 18 - 49
service/cron.go Wyświetl plik

@@ -15,44 +15,7 @@ import (
15 15
 // var createLisSyncCronJob *cron.Cron
16 16
 
17 17
 func init() {
18
-	// utils.InfoLog("开启自动检验检查同步定时任务")
19
-	// createLisSyncCronJob = cron.New()
20
-	// spec := "0 0 1 * * ?" // 每天凌晨1点同步
21
-	// createLisSyncCronJob.AddFunc(spec, func() {
22
-	// 	AutoSyncLis()
23
-	// })
24
-
25
-	//speclg := "0 0 2 * * ?" // 每天凌晨2点同步 龙岗二院
26
-	//createLisSyncCronJob.AddFunc(speclg, func() {
27
-	//	SyncLisLgty()
28
-	//})
29
-	//
30
-	//specys := "0 0 3 * * ?" // 每天凌晨3点同步 沅胜血透
31
-	//createLisSyncCronJob.AddFunc(specys, func() {
32
-	//	SyncHbdyLis()
33
-	//})
34
-
35
-	// utils.InfoLog("3333333")
36
-	// specgzjh := "1 * * * * ?" // 每1分钟同步 广州暨华HIS医嘱
37
-	// createLisSyncCronJob.AddFunc(specgzjh, func() {
38
-	// 	utils.InfoLog("1111111111")
39
-	// 	SyncGzjhyz()
40
-	// })
41 18
 
42
-	//specgzjhlis := "0 30 3 * * ?" // 每天凌晨3点30同步 广州暨华
43
-	//createLisSyncCronJob.AddFunc(specgzjhlis, func() {
44
-	//	SyncGzjhLis()
45
-	//})
46
-	//
47
-	// specszbllis := "0 0 4 * * ?" // 每天凌晨4点00同步 深圳百霖
48
-	// createLisSyncCronJob.AddFunc(specszbllis, func() {
49
-	// 	SyncSZblLis()
50
-	// })
51
-
52
-	// specszbllisResult := "0 30 4 * * ?" // 每天凌晨4点30同步 深圳百霖
53
-	// createLisSyncCronJob.AddFunc(specszbllisResult, func() {
54
-	// 	SyncSZblLisResult()
55
-	// })
56 19
 }
57 20
 
58 21
 // 返回一个支持至 秒 级别的 cron
@@ -66,21 +29,27 @@ func BeginAutoSyncLis() {
66 29
 	utils.InfoLog("开启自动检验检查同步定时任务")
67 30
 	createLisSyncCronJob := newWithSeconds()
68 31
 
69
-	specgzjh := "0 */1 * * * ?" // 每1分钟同步 广州暨华HIS医嘱
70
-	createLisSyncCronJob.AddFunc(specgzjh, func() {
71
-		// SyncGzjhyz()
72
-		Synctfyz()
73
-	})
32
+	// specgzjh := "0 */1 * * * ?" // 每1分钟同步 广州暨华HIS医嘱
33
+	// createLisSyncCronJob.AddFunc(specgzjh, func() {
34
+	// 	// SyncGzjhyz()
35
+	// 	Synctfyz()
36
+	// })
74 37
 
75
-	specys := "0 0 3 * * ?" // 每天凌晨3点同步 湖北监利
38
+	specys := "0 0 */1 * * ?" // 每天凌晨3点同步 唐山朝阳医院
76 39
 	createLisSyncCronJob.AddFunc(specys, func() {
77
-		GetSZBLResultDataInsertDB(10138)
40
+		SyncScpaLis()
41
+	})
42
+
43
+	specys1 := "0 10 */2 * * ?" // 每两个小时同步长沙南雅医院
44
+	createLisSyncCronJob.AddFunc(specys1, func() {
45
+		// SyncCsnyLis()
46
+	})
47
+
48
+	spec := "0 50 1 * * ?" // 每天凌晨1点同步 监利大院的
49
+	createLisSyncCronJob.AddFunc(spec, func() {
50
+		// SyncHbdyLis()
78 51
 	})
79 52
 
80
-	// spec := "0 0 1 * * ?" // 每天凌晨1点同步 中能建的
81
-	// createLisSyncCronJob.AddFunc(spec, func() {
82
-	// 	AutoSyncLis()
83
-	// })
84 53
 	createLisSyncCronJob.Start()
85 54
 }
86 55
 
@@ -158,7 +127,7 @@ func AutoSyncLis() {
158 127
 				}
159 128
 				// utils.InfoLog("同步信息详情:%v",syncInfo)
160 129
 				continue
161
-			}
130
+			} 
162 131
 
163 132
 			// 第四部:将同步过来的数据插入到中间库对应的表
164 133
 			syncSuccessNum := 0

+ 360 - 0
service/csny_service.go Wyświetl plik

@@ -0,0 +1,360 @@
1
+package service
2
+
3
+import (
4
+	"IC/models"
5
+	"IC/utils"
6
+	_ "IC/utils"
7
+	"bytes"
8
+	"encoding/json"
9
+	_ "encoding/json"
10
+	_"encoding/xml"
11
+	"fmt"
12
+	"net/http"
13
+	"io/ioutil"
14
+	_ "github.com/jinzhu/gorm"
15
+
16
+	"strconv"
17
+	"strings"
18
+	"time"
19
+)
20
+
21
+// 福建天福医院透析中心Lis同步
22
+func SyncCsnyLis() (err error) {
23
+	org_id := int64(10340)
24
+
25
+	// 第一步:获取上一次同步的时间点
26
+	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
27
+	var sync_time int64
28
+	if syncLastInfo.ID > 0 {
29
+		sync_time = syncLastInfo.SyncTime
30
+	} else {
31
+		sync_time = 1651334400  // 2022-05-01 00:00:00
32
+	}
33
+
34
+	sync_time_temp := time.Unix(sync_time,0)
35
+	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
36
+	// 第二步:获取所有患者的病历号
37
+
38
+	patientList, _ := GetPatientGzjhByOrgId(org_id)
39
+	if len(patientList) > 0 {
40
+		for _, patient := range patientList {
41
+			if len(patient.IdCardNo) > 0 || len(patient.DialysisNo) > 0 {
42
+				patient_id := patient.ID
43
+				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
44
+				// utils.InfoLog("VipStr:%v", VipStr)
45
+
46
+				result, _ := CsnyGetLab(patient.IdCardNo,syncTimeStr)
47
+				utils.InfoLog("result:%v", result)
48
+				var fjtfLab LabCsnyResult
49
+				if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
50
+					utils.ErrorLog("解析失败:%v", err)
51
+				}
52
+				fmt.Println(fjtfLab)
53
+
54
+				if len(fjtfLab.Result) > 0 {
55
+					// 根据获取的头部lab01获取检查结果
56
+	
57
+					for _, info := range fjtfLab.Result {
58
+						lacResult, _ := CsnyGetLac(info.Lab01)
59
+						utils.InfoLog("lacResult:%v", lacResult)
60
+						var fjtfLac LacCsnyResult
61
+						if err := json.Unmarshal([]byte(lacResult), &fjtfLac); err != nil {
62
+							utils.ErrorLog("解析失败:%v", err)
63
+						}
64
+						fmt.Println(fjtfLac)
65
+						for _,cinfo := range fjtfLac.Result{
66
+							project_id := int64(0)
67
+							item_id := int64(0)
68
+							if len(cinfo.Bbx05a) > 0 {
69
+								project_id, _ = GetCsnyProjectID(org_id, cinfo.Bbx05a)
70
+								item_id, _ = GetCsnyItemID(org_id, cinfo.Bbx05a, cinfo.Bbx05, project_id)
71
+							} else {
72
+								project_id, _ = GetCsnyProjectID(org_id, cinfo.Bbx05)
73
+								item_id, _ = GetCsnyItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
74
+							}
75
+						
76
+
77
+							tx := writeMiddleDb.Begin()
78
+							var inspection models.MiddleInspection
79
+							var inspection_reference models.MiddleInspectionReference
80
+
81
+
82
+							loc, _ := time.LoadLocation("Local")
83
+							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
84
+							record_date := theTime.Unix()
85
+
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
+						}
107
+
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
118
+							} else {
119
+								inspection_reference.ProjectName = cinfo.Bbx05
120
+								inspection_reference.Project = cinfo.Bbx05
121
+							}
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()
139
+							}
140
+						}
141
+
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()
164
+							}
165
+						}
166
+
167
+						tx.Commit()
168
+						
169
+					}
170
+				}
171
+				}
172
+			} else {
173
+				continue
174
+			}
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
+	SyncToCsnytx()
194
+	return
195
+}
196
+
197
+type LabCsnyResult struct {
198
+	Msg    string `json:"msg"`
199
+	Result []struct {
200
+		Lab01	int64		`json:"lab01"`
201
+		Lab58	string   	`json:"lab58"`
202
+	} `json:"result"`
203
+	Code string `json:"code"`
204
+}
205
+
206
+func CsnyGetLab(id_card_no string, synctime string) (string, string) {
207
+	inputData := make(map[string]interface{})
208
+
209
+	inputData["vaa15"] = id_card_no
210
+	inputData["begintime"] = synctime
211
+
212
+	var inputLog string
213
+	bytesData, err := json.Marshal(inputData)
214
+	inputLog = string(bytesData)
215
+	fmt.Println(string(bytesData))
216
+	if err != nil {
217
+		fmt.Println(err.Error())
218
+		return err.Error(), ""
219
+	}
220
+	reader := bytes.NewReader(bytesData)
221
+	url := "http://218.104.146.179:9091/esb/listener/getLab1"
222
+
223
+	request, err := http.NewRequest("POST", url, reader)
224
+	if err != nil {
225
+		fmt.Println(err.Error())
226
+		return err.Error(), ""
227
+	}
228
+
229
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
230
+	request.Header.Set("code", "Xmrjyy")
231
+
232
+	client := http.Client{}
233
+	resp, err := client.Do(request)
234
+	if err != nil {
235
+		fmt.Println(err.Error())
236
+		return err.Error(), ""
237
+	}
238
+	respBytes, err := ioutil.ReadAll(resp.Body)
239
+	if err != nil {
240
+		fmt.Println(err.Error())
241
+		return err.Error(), ""
242
+	}
243
+	str := string(respBytes)
244
+	return str, inputLog
245
+}
246
+
247
+type LacCsnyResult struct {
248
+	Msg    string `json:"msg"`
249
+	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"`
261
+	} `json:"result"`
262
+	Code string `json:"code"`
263
+}
264
+
265
+func CsnyGetLac(lab01 int64) (string, string) {
266
+	inputData := make(map[string]interface{})
267
+
268
+	inputData["lab01"] = lab01
269
+
270
+	var inputLog string
271
+	bytesData, err := json.Marshal(inputData)
272
+	inputLog = string(bytesData)
273
+	fmt.Println(string(bytesData))
274
+	if err != nil {
275
+		fmt.Println(err.Error())
276
+		return err.Error(), ""
277
+	}
278
+	reader := bytes.NewReader(bytesData)
279
+	url := "http://218.104.146.179:9091/esb/listener/getLac1"
280
+
281
+	request, err := http.NewRequest("POST", url, reader)
282
+	if err != nil {
283
+		fmt.Println(err.Error())
284
+		return err.Error(), ""
285
+	}
286
+
287
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
288
+	request.Header.Set("code", "Xmrjyy")
289
+
290
+	client := http.Client{}
291
+	resp, err := client.Do(request)
292
+	if err != nil {
293
+		fmt.Println(err.Error())
294
+		return err.Error(), ""
295
+	}
296
+	respBytes, err := ioutil.ReadAll(resp.Body)
297
+	if err != nil {
298
+		fmt.Println(err.Error())
299
+		return err.Error(), ""
300
+	}
301
+	str := string(respBytes)
302
+	return str, inputLog
303
+}
304
+
305
+// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
306
+func GetCsnyProjectID(org_id int64, project_name string) (project_id int64, err error) {
307
+	var inspection_reference models.MiddleInspectionReference
308
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, project_name).First(&inspection_reference).Error
309
+	if inspection_reference.ID > 0 {
310
+		return inspection_reference.ProjectId, err
311
+	} else {
312
+		err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
313
+		if inspection_reference.ProjectId > 0 {
314
+			return inspection_reference.ProjectId + 1, err
315
+		} else {
316
+			return 340001, err
317
+		}
318
+	}
319
+}
320
+
321
+// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
322
+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
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
325
+	if inspection_reference.ID > 0 {
326
+		return inspection_reference.ItemId,err
327
+	} 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)
330
+		if inspection_reference.ItemId > 0 {
331
+			return inspection_reference.ItemId + 1,err
332
+		} else {
333
+			return project_id * 100 + 1 ,err
334
+		}
335
+	}
336
+}
337
+
338
+
339
+func SyncToCsnytx() {
340
+	utils.TraceLog("检验检查同步任务开始执行")
341
+	org_id := int64(10340)
342
+
343
+	// 第一步:跟进org_id 去中间库查出需要同步的数据
344
+	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
345
+	inspections, _ := GetSyncInspectionByOrgId(org_id)
346
+
347
+	// 第二步:将数据同步到业务库
348
+	if len(inspection_references) > 0 {
349
+		for _, inspection_reference := range inspection_references {
350
+			SyncInspectionReference(&inspection_reference)
351
+		}
352
+	}
353
+
354
+	if len(inspections) > 0 {
355
+		for _, inspection := range inspections {
356
+			SyncInspection(&inspection)
357
+		}
358
+	}
359
+	utils.SuccessLog("检验检查同步任务完成")
360
+}

+ 358 - 0
service/fjtf_service.go Wyświetl plik

@@ -0,0 +1,358 @@
1
+package service
2
+
3
+import (
4
+	"IC/models"
5
+	"IC/utils"
6
+	_ "IC/utils"
7
+	"bytes"
8
+	"encoding/json"
9
+	_ "encoding/json"
10
+	_"encoding/xml"
11
+	"fmt"
12
+	"net/http"
13
+	"io/ioutil"
14
+	_ "github.com/jinzhu/gorm"
15
+
16
+	"strconv"
17
+	"strings"
18
+	"time"
19
+)
20
+
21
+// 福建天福医院透析中心Lis同步
22
+func SyncFjtfLis() (err error) {
23
+	org_id := int64(10330)
24
+
25
+	// 第一步:获取上一次同步的时间点
26
+	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
27
+	var sync_time int64
28
+	if syncLastInfo.ID > 0 {
29
+		sync_time = syncLastInfo.SyncTime
30
+	} else {
31
+		sync_time = 1651334400  // 2022-05-01 00:00:00
32
+	}
33
+
34
+	sync_time_temp := time.Unix(sync_time,0)
35
+	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
36
+	// 第二步:获取所有患者的病历号
37
+
38
+	patientList, _ := GetPatientGzjhByOrgId(org_id)
39
+	if len(patientList) > 0 {
40
+		for _, patient := range patientList {
41
+			if len(patient.IdCardNo) > 0 || len(patient.DialysisNo) > 0 {
42
+				patient_id := patient.ID
43
+				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
44
+				// utils.InfoLog("VipStr:%v", VipStr)
45
+
46
+				result, _ := FjtjGetLab(patient.IdCardNo,syncTimeStr)
47
+				var fjtfLab LabResult
48
+				if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
49
+					utils.ErrorLog("解析失败:%v", err)
50
+				}
51
+				fmt.Println(fjtfLab)
52
+
53
+				if len(fjtfLab.Result) > 0 {
54
+					// 根据获取的头部lab01获取检查结果
55
+	
56
+					for _, info := range fjtfLab.Result {
57
+						lacResult, _ := FjtjGetLac(info.Lab01)
58
+						var fjtfLac LacResult
59
+						if err := json.Unmarshal([]byte(lacResult), &fjtfLac); err != nil {
60
+							utils.ErrorLog("解析失败:%v", err)
61
+						}
62
+						fmt.Println(fjtfLac)
63
+						for _,cinfo := range fjtfLac.Result{
64
+							project_id := int64(0)
65
+							item_id := int64(0)
66
+							if len(cinfo.Bbx05a) > 0 {
67
+								project_id, _ = GetfjtfProjectID(org_id, cinfo.Bbx05a)
68
+								item_id, _ = GetFjtfItemID(org_id, cinfo.Bbx05a, cinfo.Bbx05, project_id)
69
+							} else {
70
+								project_id, _ = GetfjtfProjectID(org_id, cinfo.Bbx05)
71
+								item_id, _ = GetFjtfItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
72
+							}
73
+						
74
+
75
+							tx := writeMiddleDb.Begin()
76
+							var inspection models.MiddleInspection
77
+							var inspection_reference models.MiddleInspectionReference
78
+
79
+
80
+							loc, _ := time.LoadLocation("Local")
81
+							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
82
+							record_date := theTime.Unix()
83
+
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
+						}
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
+							}
138
+						}
139
+
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
+							}
163
+						}
164
+
165
+						tx.Commit()
166
+						
167
+					}
168
+				}
169
+				}
170
+			} else {
171
+				continue
172
+			}
173
+		}
174
+	}
175
+	var syncInfo models.MiddleSyncInfo
176
+	syncInfo.OrgId = org_id
177
+	syncInfo.SyncTime = time.Now().Unix()
178
+	syncInfo.SyncResultType = 1
179
+	syncInfo.SyncRsultRemark = "同步成功"
180
+	syncInfo.SyncTotalNum = 0
181
+	syncInfo.SyncSuccessNum = 0
182
+	syncInfo.SyncInfo = ""
183
+	syncInfo.CreateTime = time.Now().Unix()
184
+	syncInfo.UpdateTime = time.Now().Unix()
185
+
186
+	cwderr := CreateSyncInfo(&syncInfo)
187
+	if cwderr != nil {
188
+		utils.ErrorLog("创建同步信息失败:%v", cwderr)
189
+		return
190
+	}
191
+	SyncToFjtftx()
192
+	return
193
+}
194
+
195
+type LabResult struct {
196
+	Msg    string `json:"msg"`
197
+	Result []struct {
198
+		Lab01	int64		`json:"lab01"`
199
+		Lab58	string   	`json:"lab58"`
200
+	} `json:"result"`
201
+	Code string `json:"code"`
202
+}
203
+
204
+func FjtjGetLab(id_card_no string, synctime string) (string, string) {
205
+	inputData := make(map[string]interface{})
206
+
207
+	inputData["vaa15"] = id_card_no
208
+	inputData["begintime"] = synctime
209
+
210
+	var inputLog string
211
+	bytesData, err := json.Marshal(inputData)
212
+	inputLog = string(bytesData)
213
+	fmt.Println(string(bytesData))
214
+	if err != nil {
215
+		fmt.Println(err.Error())
216
+		return err.Error(), ""
217
+	}
218
+	reader := bytes.NewReader(bytesData)
219
+	url := "http://hip.zptfyy.com/esb/listener/getLab1"
220
+
221
+	request, err := http.NewRequest("POST", url, reader)
222
+	if err != nil {
223
+		fmt.Println(err.Error())
224
+		return err.Error(), ""
225
+	}
226
+
227
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
228
+	request.Header.Set("code", "xt")
229
+
230
+	client := http.Client{}
231
+	resp, err := client.Do(request)
232
+	if err != nil {
233
+		fmt.Println(err.Error())
234
+		return err.Error(), ""
235
+	}
236
+	respBytes, err := ioutil.ReadAll(resp.Body)
237
+	if err != nil {
238
+		fmt.Println(err.Error())
239
+		return err.Error(), ""
240
+	}
241
+	str := string(respBytes)
242
+	return str, inputLog
243
+}
244
+
245
+type LacResult struct {
246
+	Msg    string `json:"msg"`
247
+	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"`
259
+	} `json:"result"`
260
+	Code string `json:"code"`
261
+}
262
+
263
+func FjtjGetLac(lab01 int64) (string, string) {
264
+	inputData := make(map[string]interface{})
265
+
266
+	inputData["lab01"] = lab01
267
+
268
+	var inputLog string
269
+	bytesData, err := json.Marshal(inputData)
270
+	inputLog = string(bytesData)
271
+	fmt.Println(string(bytesData))
272
+	if err != nil {
273
+		fmt.Println(err.Error())
274
+		return err.Error(), ""
275
+	}
276
+	reader := bytes.NewReader(bytesData)
277
+	url := "http://hip.zptfyy.com/esb/listener/getLac1"
278
+
279
+	request, err := http.NewRequest("POST", url, reader)
280
+	if err != nil {
281
+		fmt.Println(err.Error())
282
+		return err.Error(), ""
283
+	}
284
+
285
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
286
+	request.Header.Set("code", "xt")
287
+
288
+	client := http.Client{}
289
+	resp, err := client.Do(request)
290
+	if err != nil {
291
+		fmt.Println(err.Error())
292
+		return err.Error(), ""
293
+	}
294
+	respBytes, err := ioutil.ReadAll(resp.Body)
295
+	if err != nil {
296
+		fmt.Println(err.Error())
297
+		return err.Error(), ""
298
+	}
299
+	str := string(respBytes)
300
+	return str, inputLog
301
+}
302
+
303
+// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
304
+func GetfjtfProjectID(org_id int64, project_name string) (project_id int64, err error) {
305
+	var inspection_reference models.MiddleInspectionReference
306
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, project_name).First(&inspection_reference).Error
307
+	if inspection_reference.ID > 0 {
308
+		return inspection_reference.ProjectId, err
309
+	} else {
310
+		err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
311
+		if inspection_reference.ProjectId > 0 {
312
+			return inspection_reference.ProjectId + 1, err
313
+		} else {
314
+			return 330001, err
315
+		}
316
+	}
317
+}
318
+
319
+// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
320
+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
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
323
+	if inspection_reference.ID > 0 {
324
+		return inspection_reference.ItemId,err
325
+	} 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)
328
+		if inspection_reference.ItemId > 0 {
329
+			return inspection_reference.ItemId + 1,err
330
+		} else {
331
+			return project_id * 100 + 1 ,err
332
+		}
333
+	}
334
+}
335
+
336
+
337
+func SyncToFjtftx() {
338
+	utils.TraceLog("检验检查同步任务开始执行")
339
+	org_id := int64(10330)
340
+
341
+	// 第一步:跟进org_id 去中间库查出需要同步的数据
342
+	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
343
+	inspections, _ := GetSyncInspectionByOrgId(org_id)
344
+
345
+	// 第二步:将数据同步到业务库
346
+	if len(inspection_references) > 0 {
347
+		for _, inspection_reference := range inspection_references {
348
+			SyncInspectionReference(&inspection_reference)
349
+		}
350
+	}
351
+
352
+	if len(inspections) > 0 {
353
+		for _, inspection := range inspections {
354
+			SyncInspection(&inspection)
355
+		}
356
+	}
357
+	utils.SuccessLog("检验检查同步任务完成")
358
+}

+ 138 - 140
service/lgty_service.go Wyświetl plik

@@ -3,58 +3,57 @@ package service
3 3
 import (
4 4
 	"IC/models"
5 5
 	"IC/utils"
6
-	_"strconv"
7
-	"strings"
6
+	_ "IC/utils"
8 7
 	"encoding/json"
9
-	"time"
10
-	"net/url"
11
-	_"IC/utils"
12
-	_"fmt"
13
-	_"encoding/json"
14
-	_"github.com/jinzhu/gorm"
8
+	_ "encoding/json"
9
+	_ "fmt"
15 10
 	"github.com/astaxie/beego/httplib"
11
+	_ "github.com/jinzhu/gorm"
12
+	"net/url"
13
+	_ "strconv"
14
+	"strings"
15
+	"time"
16 16
 )
17 17
 
18
-
19 18
 // 龙岗二院Lis同步
20 19
 func SyncLisLgty() (err error) {
21 20
 	// 第一步:获取龙岗二院所有病人
22 21
 	org_id := int64(9598)
23
-	patientlist,patientError := GetUserInfoByOrgID(org_id)
22
+	patientlist, patientError := GetUserInfoByOrgID(org_id)
24 23
 	if patientError != nil {
25 24
 		utils.ErrorLog("获取龙岗二院患者信息失败:%v", patientError)
26 25
 		return
27 26
 	}
28 27
 
29 28
 	if len(patientlist) > 0 {
30
-		// 第二步:根据病人的住院号来查询上次同步时间	
31
-		for _ , patient := range patientlist {
32
-			if len(patient.AdmissionNumber) <= 0 {
33
-				continue
34
-			}
35
-			syncLastInfo,_ := GetSyncTimeByOrgID(org_id,patient.AdmissionNumber)
29
+		// 第二步:根据病人的住院号来查询上次同步时间
30
+		for _, patient := range patientlist {
31
+			//if len(patient.AdmissionNumber) <= 0 {
32
+			//	continue
33
+			//}
34
+			syncLastInfo, _ := GetSyncTimeByOrgID(org_id, patient.IdCardNo)
36 35
 			var sync_time int64
37 36
 			if syncLastInfo.ID > 0 {
38 37
 				sync_time = syncLastInfo.SyncTime
39 38
 			} else {
40
-				inspectionLastInfo,_ := GetInspectionLastInfoByOrgID(org_id,patient.AdmissionNumber)
39
+				inspectionLastInfo, _ := GetInspectionLastInfoByOrgID(org_id, patient.IdCardNo)
41 40
 				if inspectionLastInfo.ID > 0 {
42 41
 					sync_time = inspectionLastInfo.CreatedTime
43 42
 				} else {
44
-					sync_time = 0
43
+					sync_time = 1640966400
45 44
 				}
46 45
 			}
47 46
 
48
-			syncTimes := time.Unix(sync_time,0).Format("2006-01-02 15:04")
49
-			utils.InfoLog("syncTimes:%v",syncTimes)
47
+			syncTimes := time.Unix(sync_time, 0).Format("2006-01-02 15:04")
48
+			utils.InfoLog("syncTimes:%v", syncTimes)
50 49
 			nowTimes := time.Now().Format("2006-01-02 15:04")
51 50
 			// 第三步:跟进上次同步时间和指定的门诊号,获取上次同步到现在指定人的检验检查记录
52
-			lisHead,HeadString := GetHead(patient.AdmissionNumber,syncTimes,nowTimes)
51
+			lisHead, HeadString := GetHead(patient.IdCardNo, syncTimes, nowTimes)
53 52
 			var resultCount int64
54 53
 			// 第四步,将同步过来的头部信息存到中间库的检验检查操作表中
55 54
 			if len(lisHead) > 0 {
56 55
 				resultCount = 0
57
-				for _ , head := range lisHead {
56
+				for _, head := range lisHead {
58 57
 					// if len(head.Item) <= 0  {
59 58
 					// 	continue
60 59
 					// }
@@ -63,29 +62,29 @@ func SyncLisLgty() (err error) {
63 62
 							head.Item = "肾功三项"
64 63
 						}
65 64
 						middleReportHandle := models.MiddleReportHandle{
66
-							OrgId:			org_id,
67
-							HisUserId:		patient.AdmissionNumber,
68
-							ApplyNo:		head.ApplyNo,
69
-							ReportId:		head.ReportId,	
70
-							Name:			head.Name,	
71
-							Sex:			head.Sex,
72
-							Age:			head.Age,
73
-							Dept:			head.Dept,
74
-							PatientId:		head.PatientId,
75
-							RequestTime:	head.RequestTime,
76
-							ExecuteTime:	head.ExecuteTime,
77
-							ReceiveTime:	head.ReceiveTime,
78
-							Item:			head.Item,
79
-							CheckTime:		head.CheckTime,
80
-							PatientType:	head.PatientType,
81
-							CreatedTime:	time.Now().Unix(),
82
-							UpdatedTime:	time.Now().Unix(),
65
+							OrgId:       org_id,
66
+							HisUserId:   patient.AdmissionNumber,
67
+							ApplyNo:     head.ApplyNo,
68
+							ReportId:    head.ReportId,
69
+							Name:        head.Name,
70
+							Sex:         head.Sex,
71
+							Age:         head.Age,
72
+							Dept:        head.Dept,
73
+							PatientId:   patient.IdCardNo,
74
+							RequestTime: head.RequestTime,
75
+							ExecuteTime: head.ExecuteTime,
76
+							ReceiveTime: head.ReceiveTime,
77
+							Item:        head.Item,
78
+							CheckTime:   head.CheckTime,
79
+							PatientType: head.PatientType,
80
+							CreatedTime: time.Now().Unix(),
81
+							UpdatedTime: time.Now().Unix(),
83 82
 						}
84 83
 						handleerr := CreateReportHandle(&middleReportHandle)
85 84
 						if handleerr != nil {
86 85
 							utils.ErrorLog("创建检验检查操作数据失败:%v", handleerr)
87 86
 							return
88
-						} 
87
+						}
89 88
 						// // reportInfos,ReportString := GetReport(head.ReportId)
90 89
 						// HeadString = HeadString + " " + ReportString
91 90
 						// // 获取该项的检验检查project_id,如果没有,则创建一个
@@ -122,7 +121,7 @@ func SyncLisLgty() (err error) {
122 121
 				if cwderr != nil {
123 122
 					utils.ErrorLog("创建同步信息失败:%v", cwderr)
124 123
 					return
125
-				}	
124
+				}
126 125
 			} else {
127 126
 				// 未同步到检验检查头部信息
128 127
 				var syncInfo models.MiddleSyncInfo
@@ -139,82 +138,82 @@ func SyncLisLgty() (err error) {
139 138
 					utils.ErrorLog("创建同步信息失败:%v", serr)
140 139
 					return
141 140
 				}
142
-				continue 
141
+				continue
143 142
 			}
144
-			
143
+
145 144
 		}
146 145
 	}
147 146
 	// 第五步,查询检验检查操作表里状态为0的数据,并将该对应报告的检验检查详情数据请求回来并存入该条数据里的report_info字段
148 147
 	ReportInfoHandle(org_id)
149
-	return 
148
+	return
150 149
 }
151 150
 
152
-func ReportInfoHandle (org_id int64) {
153
-	// 1.从检验检查表中查询操作状态为0的数据 
154
-	report_handle_list,_ := GetReportHandleListyOrgID(org_id)
151
+func ReportInfoHandle(org_id int64) {
152
+	// 1.从检验检查表中查询操作状态为0的数据
153
+	report_handle_list, _ := GetReportHandleListyOrgID(org_id)
155 154
 	if len(report_handle_list) > 0 {
156
-		for _,report_handle := range report_handle_list {
155
+		for _, report_handle := range report_handle_list {
157 156
 			// 2. 根据report_id获取报告详情并进行相关处理
158
-			reportInfos,ReportString := GetReport(report_handle.ReportId)
157
+			reportInfos, ReportString := GetReport(report_handle.ReportId)
159 158
 			if len(reportInfos) > 0 {
160 159
 				report_info_item_num := len(reportInfos)
161 160
 				// 将检验检查详情,检验检查小项条数更新到操作表数据中
162 161
 				middleReportHandle := models.MiddleReportHandle{
163
-					ID:					report_handle.ID,
164
-					ReportInfo:			ReportString,
165
-					ReportInfoItemNum: 	int64(report_info_item_num),
166
-					UpdatedTime:		time.Now().Unix(),
162
+					ID:                report_handle.ID,
163
+					ReportInfo:        ReportString,
164
+					ReportInfoItemNum: int64(report_info_item_num),
165
+					UpdatedTime:       time.Now().Unix(),
167 166
 				}
168 167
 				err := UpdateReportHandleListyOrgID(&middleReportHandle)
169 168
 				if err != nil {
170 169
 					utils.ErrorLog("创建同步信息失败:%v", err)
171
-					return
170
+					//return
172 171
 				}
173 172
 				report_handle.ReportInfoItemNum = int64(report_info_item_num)
174
-				project_id,_ := GetProjectID(org_id,report_handle.Item)
175
-				patient,perr := GetUserInfoByAdmission(report_handle.HisUserId,org_id)
173
+				project_id, _ := GetProjectID(org_id, report_handle.Item)
174
+				patient, perr := GetUserInfoByAdmission(report_handle.PatientId, org_id)
176 175
 				if perr != nil {
177 176
 					utils.ErrorLog("查询病人信息失败:%v", perr)
178
-					return
177
+					//return
179 178
 				}
180 179
 				if len(reportInfos) > 0 {
181
-				// 将同步过来的检验检查数据存到中间库
182
-					for _,reportInfo := range reportInfos{
180
+					// 将同步过来的检验检查数据存到中间库
181
+					for _, reportInfo := range reportInfos {
183 182
 						if len(reportInfo.ItemName) <= 0 {
184 183
 							continue
185 184
 						}
186 185
 						// 获取该小项的检验检查item_id,如果没有,则创建一个
187
-						item_id,_ := GetItemID(org_id,report_handle.Item,reportInfo.ItemName,project_id)
188
-						_,_,syerr := LgthSync(&report_handle,reportInfo,project_id,item_id,org_id,patient.ID,patient.AdmissionNumber)
186
+						item_id, _ := GetItemID(org_id, report_handle.Item, reportInfo.ItemName, project_id)
187
+						_, _, syerr := LgthSync(&report_handle, reportInfo, project_id, item_id, org_id, patient.ID, patient.AdmissionNumber)
189 188
 						if syerr != nil {
190 189
 							utils.ErrorLog("创建同步信息失败:%v", syerr)
191 190
 							return
192 191
 						}
193 192
 					}
194 193
 				}
195
-			} 
194
+			}
196 195
 		}
197 196
 	}
198 197
 	SyncToLgey()
199 198
 }
200 199
 
201
-func  SyncToLgey() {
200
+func SyncToLgey() {
202 201
 	utils.TraceLog("检验检查同步任务开始执行")
203 202
 	org_id := int64(9598)
204 203
 
205 204
 	// 第一步:跟进org_id 去中间库查出需要同步的数据
206
-	inspection_references,_ := GetSyncInspectionReferenceByOrgId(org_id)
207
-	inspections,_ := GetSyncInspectionByOrgId(org_id)
205
+	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
206
+	inspections, _ := GetSyncInspectionByOrgId(org_id)
208 207
 
209 208
 	// 第二步:将数据同步到业务库
210 209
 	if len(inspection_references) > 0 {
211
-		for _,inspection_reference := range inspection_references {
210
+		for _, inspection_reference := range inspection_references {
212 211
 			SyncInspectionReference(&inspection_reference)
213 212
 		}
214 213
 	}
215 214
 
216 215
 	if len(inspections) > 0 {
217
-		for _,inspection := range inspections {
216
+		for _, inspection := range inspections {
218 217
 			SyncInspection(&inspection)
219 218
 		}
220 219
 	}
@@ -222,46 +221,45 @@ func  SyncToLgey() {
222 221
 }
223 222
 
224 223
 // 从机构将数据同步到中间库
225
-func LgthSync(Head *models.MiddleReportHandle,report ReportInfo,project_id int64,item_id int64,org_id int64,patient_id int64,his_user_id string)(*models.MiddleInspectionReference,*models.MiddleInspection,error) {
224
+func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int64, item_id int64, org_id int64, patient_id int64, his_user_id string) (*models.MiddleInspectionReference, *models.MiddleInspection, error) {
226 225
 	tx := writeMiddleDb.Begin()
227 226
 	var inspection models.MiddleInspection
228 227
 	var inspection_reference models.MiddleInspectionReference
229 228
 	recordDateStr := Head.CheckTime
229
+	utils.InfoLog("打印测试: %v", recordDateStr)
230 230
 
231
-	if len(Head.CheckTime) == 0 { 
231
+	if len(Head.CheckTime) == 0 {
232 232
 		recordDateStr = time.Now().Format("2006-01-02 15:04")
233 233
 	} else {
234
-		dateTempArrOne := strings.Split(recordDateStr,"T")
235
-		dateTempArrTwo := strings.Split(dateTempArrOne[1],".")
236
-		recordDateStr = dateTempArrOne[0] + " " + dateTempArrTwo[0]
234
+		//dateTempArrOne := strings.Split(recordDateStr, "T")
235
+		dateTempArrTwo := strings.Split(recordDateStr, ".")
236
+		recordDateStr = dateTempArrTwo[0]
237 237
 	}
238 238
 
239 239
 	record_date_str, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", recordDateStr)
240 240
 	record_date := record_date_str.Unix()
241
-	inspect_date := time.Unix(record_date,0).Format("2006-01-02 15:04")
241
+	inspect_date := time.Unix(record_date, 0).Format("2006-01-02 15:04")
242 242
 	// date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
243 243
 	// record_date,_ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
244 244
 	var total int
245 245
 	var itotal int
246
-	var RangeOptions string 
246
+	var RangeOptions string
247 247
 	var RangeMin string
248 248
 	var RangeMax string
249 249
 
250 250
 	// // 判断检查类型
251 251
 	ItemType := 1
252
-	Range := strings.Split(report.Reference,"~")
253
-	if len(Range) > 1   {
252
+	Range := strings.Split(report.Reference, "~")
253
+	if len(Range) > 1 {
254 254
 		RangeMin = Range[0]
255
-		RangeMax = Range[1] 
255
+		RangeMax = Range[1]
256 256
 		ItemType = 1
257 257
 	} else {
258 258
 		ItemType = 2
259 259
 		RangeOptions = report.Reference
260 260
 	}
261 261
 
262
-
263
-
264
-	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
262
+	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
265 263
 	if inspection_reference.ID > 0 {
266 264
 		ItemType = inspection_reference.RangeType
267 265
 	}
@@ -289,7 +287,7 @@ func LgthSync(Head *models.MiddleReportHandle,report ReportInfo,project_id int64
289 287
 		}
290 288
 	}
291 289
 
292
-	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
290
+	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
293 291
 	if itotal <= 0 {
294 292
 		inspection.PatientId = patient_id
295 293
 		inspection.OrgId = org_id
@@ -314,15 +312,15 @@ func LgthSync(Head *models.MiddleReportHandle,report ReportInfo,project_id int64
314 312
 		//处理检验检查操作表里同步条数和状态
315 313
 		cur_num := Head.ReportInfoItemHandleNum + 1
316 314
 		Head.ReportInfoItemHandleNum = cur_num
317
-		handleType := 2 
315
+		handleType := 2
318 316
 		if cur_num == Head.ReportInfoItemNum {
319 317
 			handleType = 1
320 318
 		}
321 319
 		middleReportHandle := models.MiddleReportHandle{
322
-			ID:							Head.ID,
323
-			ReportInfoItemHandleNum:	cur_num,
324
-			HandleType:					int64(handleType),
325
-			UpdatedTime:				time.Now().Unix(),
320
+			ID:                      Head.ID,
321
+			ReportInfoItemHandleNum: cur_num,
322
+			HandleType:              int64(handleType),
323
+			UpdatedTime:             time.Now().Unix(),
326 324
 		}
327 325
 		err = UpdateReportHandleListyOrgID(&middleReportHandle)
328 326
 		if err != nil {
@@ -331,109 +329,109 @@ func LgthSync(Head *models.MiddleReportHandle,report ReportInfo,project_id int64
331 329
 	}
332 330
 
333 331
 	tx.Commit()
334
-	return nil,nil,err
332
+	return nil, nil, err
335 333
 }
336 334
 
337 335
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
338
-func GetItemID(org_id int64,project_name string,item_name string,project_id int64) (item_id int64 ,err error) {
336
+func GetItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
339 337
 	var inspection_reference models.MiddleInspectionReference
340
-	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
338
+	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
341 339
 	if inspection_reference.ID > 0 {
342
-		return inspection_reference.ItemId,err
340
+		return inspection_reference.ItemId, err
343 341
 	} else {
344
-		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
345
-		utils.InfoLog("inspection_reference: %v",inspection_reference)
342
+		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
343
+		utils.InfoLog("inspection_reference: %v", inspection_reference)
346 344
 		if inspection_reference.ItemId > 0 {
347
-			return inspection_reference.ItemId + 1,err
345
+			return inspection_reference.ItemId + 1, err
348 346
 		} else {
349
-			return project_id * 1000 + 1 ,err
347
+			return project_id*1000 + 1, err
350 348
 		}
351 349
 	}
352 350
 }
353 351
 
354 352
 // 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
355
-func GetProjectID(org_id int64,project_name string) (project_id int64 ,err error) {
353
+func GetProjectID(org_id int64, project_name string) (project_id int64, err error) {
356 354
 	var inspection_reference models.MiddleInspectionReference
357
-	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id,project_name).First(&inspection_reference).Error
355
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, project_name).First(&inspection_reference).Error
358 356
 	if inspection_reference.ID > 0 {
359
-		return inspection_reference.ProjectId,err
357
+		return inspection_reference.ProjectId, err
360 358
 	} else {
361 359
 		err := readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
362
-		utils.InfoLog("inspection_reference: %v",inspection_reference)
360
+		utils.InfoLog("inspection_reference: %v", inspection_reference)
363 361
 		if inspection_reference.ProjectId > 0 {
364
-			return inspection_reference.ProjectId + 1,err
362
+			return inspection_reference.ProjectId + 1, err
365 363
 		} else {
366
-			return 18001,err
364
+			return 18001, err
367 365
 		}
368 366
 	}
369 367
 }
370 368
 
371 369
 // 根据机构ID获取该机构所有病人的admission_number (住院号)
372
-func GetUserInfoByOrgID(org_id int64) (patients []models.Patients ,err error) {
370
+func GetUserInfoByOrgID(org_id int64) (patients []models.Patients, err error) {
373 371
 	err = readDb.Model(&models.Patients{}).Where("user_org_id = ? and status = 1", org_id).Find(&patients).Error
374 372
 	return
375 373
 }
376 374
 
377 375
 // 根据机构ID获取该机构所有病人的admission_number (住院号)
378
-func GetUserInfoByAdmission(admission_number string,org_id int64) (patients models.Patients ,err error) {
379
-	err = readDb.Model(&models.Patients{}).Where("user_org_id = ? and admission_number = ?  and status = 1", org_id,admission_number).First(&patients).Error
376
+func GetUserInfoByAdmission(admission_number string, org_id int64) (patients models.Patients, err error) {
377
+	err = readDb.Model(&models.Patients{}).Where("user_org_id = ? and id_card_no = ?  and status = 1", org_id, admission_number).First(&patients).Error
380 378
 	return
381 379
 }
382 380
 
383 381
 type HeadInfo struct {
384
-	ApplyNo        	string  `json:"applyNo"`
385
-	ReportId        string	`json:"reportId"`
386
-	Name       		string	`json:"name"`
387
-	Sex       		string	`json:"sex"`
388
-	Age 			string	`json:"age"`
389
-	Dept 			string	`json:"dept"`
390
-	BedNo 			string	`json:"bedNo"`
391
-	PatientId 		string	`json:"patientId"`
392
-	PatientPid 		string	`json:"patientPid"`
393
-	SampleNo 		float64	`json:"sampleNo"`
394
-	RequestTime 	string	`json:"requestTime"`
395
-	ExecuteTime 	string	`json:"executeTime"`
396
-	ReceiveTime 	string	`json:"receiveTime"`
397
-	Item 			string	`json:"item"`
398
-	CheckTime 		string	`json:"checkTime"`
399
-	PatientType 	string	`json:"patientType"`
400
-	RequestTimes 	string	`json:"request_time"`
382
+	ApplyNo      string  `json:"applyNo"`
383
+	ReportId     string  `json:"reportId"`
384
+	Name         string  `json:"name"`
385
+	Sex          string  `json:"sex"`
386
+	Age          string  `json:"age"`
387
+	Dept         string  `json:"dept"`
388
+	BedNo        string  `json:"bedNo"`
389
+	PatientId    string  `json:"patientId"`
390
+	PatientPid   string  `json:"patientPid"`
391
+	SampleNo     float64 `json:"sampleNo"`
392
+	RequestTime  string  `json:"requestTime"`
393
+	ExecuteTime  string  `json:"executeTime"`
394
+	ReceiveTime  string  `json:"receiveTime"`
395
+	Item         string  `json:"item"`
396
+	CheckTime    string  `json:"checkTime"`
397
+	PatientType  string  `json:"patientType"`
398
+	RequestTimes string  `json:"request_time"`
401 399
 }
402 400
 
403 401
 type ReportInfo struct {
404
-	ReportId    string  `json:"reportId"`
405
-	ItemCode    string	`json:"itemCode"`
406
-	ItemName    string	`json:"itemName"`
407
-	StdCode     string	`json:"stdCode"`
408
-	Result 		string	`json:"result"`
409
-	Unit 		string	`json:"unit"`
410
-	SampleNo 	float64	`json:"sampleNo"`
411
-	Reference 	string	`json:"reference"`
412
-	Prompt 		string	`json:"prompt"`
402
+	ReportId  string  `json:"reportId"`
403
+	ItemCode  string  `json:"itemCode"`
404
+	ItemName  string  `json:"itemName"`
405
+	StdCode   string  `json:"stdCode"`
406
+	Result    string  `json:"result"`
407
+	Unit      string  `json:"unit"`
408
+	SampleNo  float64 `json:"sampleNo"`
409
+	Reference string  `json:"reference"`
410
+	Prompt    string  `json:"prompt"`
413 411
 }
414 412
 
415
-func GetHead(patient_id string,start_time string,end_time string)(head []HeadInfo,str string){
413
+func GetHead(patient_id string, start_time string, end_time string) (head []HeadInfo, str string) {
416 414
 	Domain := "http://www.szlg2h.cn:9991/xuetoushi/head/getHead?"
417
-	apiurl := "patient_id=" + patient_id + "&check_time_start=" + start_time + "&check_time_end=" + end_time
415
+	apiurl := "identity_Card=" + patient_id + "&check_time_start=" + start_time + "&check_time_end=" + end_time
418 416
 	apiurl = url.PathEscape(apiurl)
419 417
 	apiurl = Domain + apiurl
420
-	utils.InfoLog("url: %v",apiurl)
418
+	utils.InfoLog("url: %v", apiurl)
421 419
 	var respJSON []HeadInfo
422 420
 	httplib.Get(apiurl).ToJSON(&respJSON)
423 421
 	jsonStr, _ := json.Marshal(respJSON)
424
-	utils.InfoLog("请求患者检查头部数据接口返回数据: %v",string(jsonStr))
425
-	return respJSON,string(jsonStr)
422
+	utils.InfoLog("请求患者检查头部数据接口返回数据: %v", string(jsonStr))
423
+	return respJSON, string(jsonStr)
426 424
 }
427 425
 
428
-func GetReport(report_id string)(head  []ReportInfo,str string){
426
+func GetReport(report_id string) (head []ReportInfo, str string) {
429 427
 	Domain := "http://www.szlg2h.cn:9991/xuetoushi/detail/getDetail?"
430
-	apiurl := "report_id=" + report_id 
428
+	apiurl := "report_id=" + report_id
431 429
 	apiurl = url.PathEscape(apiurl)
432 430
 	apiurl = Domain + apiurl
433
-	
431
+
434 432
 	var respJSON []ReportInfo
435 433
 	httplib.Get(apiurl).ToJSON(&respJSON)
436 434
 	jsonStr, _ := json.Marshal(respJSON)
437
-	utils.InfoLog("请求患者检查详情数据接口返回数据: %v",string(jsonStr))
438
-	return respJSON,string(jsonStr)
439
-}
435
+	utils.InfoLog("请求患者检查详情数据接口返回数据: %v", string(jsonStr))
436
+	return respJSON, string(jsonStr)
437
+}

+ 262 - 0
service/pajm_service.go Wyświetl plik

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

+ 53 - 50
service/sh_service.go Wyświetl plik

@@ -4,12 +4,12 @@ import (
4 4
 	"IC/models"
5 5
 	"IC/utils"
6 6
 	"fmt"
7
+	"github.com/jinzhu/gorm"
7 8
 	"regexp"
8 9
 	"strconv"
9 10
 	"strings"
10 11
 	"time"
11 12
 	"unicode"
12
-	"github.com/jinzhu/gorm"
13 13
 )
14 14
 
15 15
 type KMResult struct {
@@ -70,28 +70,33 @@ func (KMResult) TableName() string {
70 70
 }
71 71
 
72 72
 type KMSheet struct {
73
-	FName                  string `gorm:"column:F_Name" json:"F_Name" form:"F_Name"`
74
-	FCompoundItemName      string `gorm:"column:F_CompoundItemName" json:"F_CompoundItemName" form:"F_CompoundItemName"`
75
-	FReference             string `gorm:"column:F_Reference" json:"F_Reference" form:"F_Reference"`
76
-	FSingleItemName        string `gorm:"column:F_SingleItemName" json:"F_SingleItemName" form:"F_SingleItemName"`
77
-	FRecordTime            string `gorm:"column:F_RecordTime" json:"F_RecordTime" form:"F_RecordTime"`
78
-	FCheckTime             string `gorm:"column:F_CheckTime" json:"F_CheckTime" form:"F_CheckTime"`
79
-	FResult                string `gorm:"column:F_Result" json:"F_Result" form:"F_Result"`
80
-	FUnit                  string `gorm:"column:F_Unit" json:"F_Unit" form:"F_Unit"`
73
+	FName             string `gorm:"column:F_Name" json:"F_Name" form:"F_Name"`
74
+	FCompoundItemName string `gorm:"column:F_CompoundItemName" json:"F_CompoundItemName" form:"F_CompoundItemName"`
75
+	FReference        string `gorm:"column:F_Reference" json:"F_Reference" form:"F_Reference"`
76
+	FSingleItemName   string `gorm:"column:F_SingleItemName" json:"F_SingleItemName" form:"F_SingleItemName"`
77
+	FRecordTime       string `gorm:"column:F_RecordTime" json:"F_RecordTime" form:"F_RecordTime"`
78
+	FCheckTime        string `gorm:"column:F_CheckTime" json:"F_CheckTime" form:"F_CheckTime"`
79
+	FResult           string `gorm:"column:F_Result" json:"F_Result" form:"F_Result"`
80
+	FUnit             string `gorm:"column:F_Unit" json:"F_Unit" form:"F_Unit"`
81 81
 }
82 82
 
83 83
 func (KMSheet) TableName() string {
84
-	return "Sheet"
84
+	return "KM_LIS_Result"
85
+}
86
+
87
+func GetPatientsInfoByName(name string, org_id int64) (info models.Patients, err error) {
88
+	err = readDb.Model(&models.Patients{}).Where("name = ? AND user_org_id = ?", name, org_id).First(&info).Error
89
+	return
85 90
 }
86 91
 
87
-//获取lis返回检验检查结果数据
92
+// 获取lis返回检验检查结果数据
88 93
 func GetSHResultDataInsertDB(org_id int64) (result []*KMResult) {
89 94
 
90 95
 	org := &models.DataUploadConfig{
91
-		OrgId:          10138,
96
+		OrgId:          10215,
92 97
 		ProvinceId:     19,
93 98
 		CityId:         291,
94
-		DepartmentName: "深圳市百霖血液透析中心",
99
+		DepartmentName: "肇庆三鹤血液透析中心",
95 100
 		HospitalId:     "MA5DB4KB6",
96 101
 		InstType:       1,
97 102
 		DbHost:         "localhost",
@@ -108,25 +113,25 @@ func GetSHResultDataInsertDB(org_id int64) (result []*KMResult) {
108 113
 			return
109 114
 		}
110 115
 
111
-	record, _ := GetLastSyncResultRecord(org_id)
112
-	fmt.Println(record)
113
-	var sync_time int64
114
-	if record.ID > 0 {
115
-		sync_time = record.Ctime
116
-	} else {
117
-		sync_time = 1627747200
118
-	}
116
+		record, _ := GetLastSyncResultRecord(org_id)
117
+		fmt.Println(record)
118
+		var sync_time int64
119
+		if record.ID > 0 {
120
+			sync_time = record.Ctime
121
+		} else {
122
+			sync_time = 1627747200
123
+		}
119 124
 
120
-	sync_time_temp := time.Unix(sync_time,0)
121
-	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
125
+		sync_time_temp := time.Unix(sync_time, 0)
126
+		syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
122 127
 
123
-		list, err := GetSHResultRecord(orgDb,syncTimeStr)
128
+		list, err := GetSHResultRecord(orgDb, syncTimeStr)
124 129
 		if err == nil {
125 130
 			// fmt.Println(list)
126 131
 
127 132
 			//插入到系统检验检查数据
128 133
 			for _, item := range list {
129
-				printInfo, _ := GetPatientsInfoByIDCardNo(item.FName, 10215)
134
+				printInfo, _ := GetPatientsInfoByName(item.FName, 10215)
130 135
 
131 136
 				if printInfo.ID == 0 {
132 137
 					fmt.Println(item)
@@ -136,10 +141,8 @@ func GetSHResultDataInsertDB(org_id int64) (result []*KMResult) {
136 141
 				}
137 142
 
138 143
 				project_id := int64(0)
139
-				
144
+
140 145
 				project_id, _ = GetShjhProjectID(org_id, item.FCompoundItemName)
141
-				
142
-				
143 146
 
144 147
 				item_id, _ := GetShItemID(org_id, item.FCompoundItemName, item.FSingleItemName, project_id)
145 148
 
@@ -150,14 +153,14 @@ func GetSHResultDataInsertDB(org_id int64) (result []*KMResult) {
150 153
 				recordDateStr := ""
151 154
 				//inspect_date := item.FRecordTime.Format("2006-01-02 15:04")
152 155
 
153
-				// timstr := strings.Split(item.FRecordTime, "T")
154
-				// timstem := strings.Split(timstr[1], "Z")
156
+				timstr := strings.Split(item.FRecordTime, "T")
157
+				timstem := strings.Split(timstr[1], "Z")
155 158
 
156
-				// recordDateStr = timstr[0] + " " + timstem[0]
157
-				recordDateStr = item.FRecordTime
158
-				date ,_ :=  utils.ParseTimeStringToTime("2006-01-02 15:04:05",recordDateStr)
159
+				recordDateStr = timstr[0] + " " + timstem[0]
160
+				// recordDateStr = item.FRecordTime
161
+				date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", recordDateStr)
159 162
 				record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
160
-			
163
+
161 164
 				// ftimstr := strings.Split(item.FCheckTime, "T")
162 165
 				// ftimstem := strings.Split(timstr[1], "Z")
163 166
 
@@ -255,33 +258,33 @@ func GetSHResultDataInsertDB(org_id int64) (result []*KMResult) {
255 258
 			writeMiddleDb.Save(&info)
256 259
 		}
257 260
 
258
-	// 第一步:跟进org_id 去中间库查出需要同步的数据
259
-	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
260
-	inspections, _ := GetSyncInspectionByOrgId(org_id)
261
+		// 第一步:跟进org_id 去中间库查出需要同步的数据
262
+		inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
263
+		inspections, _ := GetSyncInspectionByOrgId(org_id)
261 264
 
262
-	// 第二步:将数据同步到业务库
263
-	if len(inspection_references) > 0 {
264
-		for _, inspection_reference := range inspection_references {
265
-			SyncInspectionReference(&inspection_reference)
265
+		// 第二步:将数据同步到业务库
266
+		if len(inspection_references) > 0 {
267
+			for _, inspection_reference := range inspection_references {
268
+				SyncInspectionReference(&inspection_reference)
269
+			}
266 270
 		}
267
-	}
268 271
 
269
-	if len(inspections) > 0 {
270
-		for _, inspection := range inspections {
271
-			SyncInspection(&inspection)
272
+		if len(inspections) > 0 {
273
+			for _, inspection := range inspections {
274
+				SyncInspection(&inspection)
275
+			}
272 276
 		}
273 277
 	}
274
-}
275
-return
278
+	return
276 279
 
277 280
 }
278 281
 
279
-func GetSHResultRecord(rdb *gorm.DB,synctime string) (record []*KMSheet, err error) {
280
-	err = rdb.Model(&KMSheet{}).Where("F_CheckTime >= ?",synctime).Find(&record).Error
282
+func GetSHResultRecord(rdb *gorm.DB, synctime string) (record []*KMSheet, err error) {
283
+	err = rdb.Model(&KMSheet{}).Where("F_CheckTime >= ?", synctime).Find(&record).Error
281 284
 	return
282 285
 }
283 286
 
284
-//判断是否包含中文
287
+// 判断是否包含中文
285 288
 func IsChineseChar(str string) bool {
286 289
 	for _, r := range str {
287 290
 		if unicode.Is(unicode.Scripts["Han"], r) || (regexp.MustCompile("[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]").MatchString(string(r))) {

+ 2 - 2
service/szbl_service.go Wyświetl plik

@@ -33,7 +33,7 @@ func (SZBLJYJC) TableName() string {
33 33
 func GetSZBLResultDataInsertDB(org_id int64) (result []*SZBLJYJC) {
34 34
 
35 35
 	org := &models.DataUploadConfig{
36
-		OrgId:          10138,
36
+		OrgId:          10278,
37 37
 		ProvinceId:     19,
38 38
 		CityId:         291,
39 39
 		DepartmentName: "深圳市百霖血液透析中心",
@@ -71,7 +71,7 @@ func GetSZBLResultDataInsertDB(org_id int64) (result []*SZBLJYJC) {
71 71
 
72 72
 			//插入到系统检验检查数据
73 73
 			for _, item := range list {
74
-				printInfo, _ := GetPatientsInfoByIDCardNo(item.FName, 10138)
74
+				printInfo, _ := GetPatientsInfoByName(item.FName, 10278)
75 75
 
76 76
 				if printInfo.ID == 0 {
77 77
 					fmt.Println(item)

+ 282 - 0
service/tscyyy_service.go Wyświetl plik

@@ -0,0 +1,282 @@
1
+package service
2
+
3
+import (
4
+	"IC/models"
5
+	"IC/utils"
6
+	_ "IC/utils"
7
+	_"bytes"
8
+	"encoding/json"
9
+	_ "encoding/json"
10
+	_"encoding/xml"
11
+	_"fmt"
12
+	_ "fmt"
13
+	"github.com/astaxie/beego/httplib"
14
+	_ "github.com/jinzhu/gorm"
15
+
16
+	"strconv"
17
+	"strings"
18
+	"time"
19
+)
20
+
21
+
22
+type tscylis struct {
23
+	HisUserId    string `json:"his_user_id"`
24
+	PatientName  string `json:"patient_name"`
25
+	ProjectId    string  `json:"project_id"`
26
+	ProjectName  string `json:"project_name"`
27
+	InspectDate  string  `json:"inspect_date"`
28
+	ItemId       string  `json:"item_id"`
29
+	ItemName     string `json:"item_name"`
30
+	ItemType     string  `json:"item_type"`
31
+	ItemValue    string `json:"item_value"`
32
+	RangeMin     string `json:"range_min"`
33
+	RangeMax     string `json:"range_max"`
34
+	RangeValue   string `json:"range_value"`
35
+	RangeOptions string `json:"range_options"`
36
+	Unit         string `json:"unit"`
37
+	State        string  `json:"state"`
38
+	CTime        string  `json:"c_time"`
39
+	UTime        string  `json:"u_time"`
40
+}
41
+
42
+type tscyLisResult struct {
43
+	ErrorCode int64     `json:"error_code"`
44
+	Result    []tscylis `json:"data"`
45
+}
46
+
47
+func GetTscyLis(sync_time string, his_user_id string) (str tscyLisResult, checkStr string) {
48
+	apiurl := "http://60.2.56.98:8797/tscy/lis_report.do"
49
+	rep := httplib.Get(apiurl)
50
+	rep.Param("sync_time", sync_time)
51
+	rep.Param("his_user_id", his_user_id)
52
+	strs, err := rep.String()
53
+	if err != nil {
54
+		utils.InfoLog("err:%v", err)
55
+	}
56
+	utils.InfoLog("str:%v", strs)
57
+
58
+	var checkJSON tscyLisResult
59
+	json.Unmarshal([]byte(strs), &checkJSON)
60
+	// utils.InfoLog("checkJSON:%v", checkJSON)
61
+	return checkJSON, strs
62
+}
63
+
64
+// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
65
+func GetTscyProjectID(org_id int64, project_name string) (project_id int64, err error) {
66
+	var inspection_reference models.MiddleInspectionReference
67
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, project_name).First(&inspection_reference).Error
68
+	if inspection_reference.ID > 0 {
69
+		return inspection_reference.ProjectId, err
70
+	} else {
71
+		err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
72
+		if inspection_reference.ProjectId > 0 {
73
+			return inspection_reference.ProjectId + 1, err
74
+		} else {
75
+			return 92001, err
76
+		}
77
+	}
78
+}
79
+
80
+// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
81
+func GetTscyItemID(org_id int64,project_name string,item_name string,project_id int64) (item_id int64 ,err error) {
82
+	var inspection_reference models.MiddleInspectionReference
83
+	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
84
+	if inspection_reference.ID > 0 {
85
+		return inspection_reference.ItemId,err
86
+	} else {
87
+		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
88
+		utils.InfoLog("inspection_reference: %v",inspection_reference)
89
+		if inspection_reference.ItemId > 0 {
90
+			return inspection_reference.ItemId + 1,err
91
+		} else {
92
+			return project_id * 100 + 1 ,err
93
+		}
94
+	}
95
+}
96
+
97
+// 唐山朝阳医院透析中心Lis同步
98
+func SyncTscyLis() (err error) {
99
+	org_id := int64(9882)
100
+
101
+	// 第一步:获取上一次同步的时间点
102
+	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
103
+	var sync_time int64
104
+	if syncLastInfo.ID > 0 {
105
+		sync_time = syncLastInfo.SyncTime
106
+	} else {
107
+		sync_time = 1651334400
108
+	}
109
+	// 第二步:获取所有患者的病历号
110
+
111
+	patientList, _ := GetPatientGzjhByOrgId(org_id)
112
+	if len(patientList) > 0 {
113
+		for _, patient := range patientList {
114
+			if len(patient.IdCardNo) > 0 || len(patient.DialysisNo) > 0 {
115
+				// 上次同步时间转换为接口需要的格式
116
+				patient_id := patient.ID
117
+				// sync_time_temp := time.Unix(sync_time,0)
118
+				// syncTimeStr := sync_time_temp.Format("2006010215:04:05")
119
+				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
120
+				// 获取会员号
121
+
122
+				// utils.InfoLog("VipStr:%v", VipStr)
123
+
124
+				gzjhLis, _ := GetTscyLis(strconv.FormatInt(sync_time, 10), patient.IdCardNo)
125
+				// if len(gzjhLis.Result) == 0 {
126
+				// 	gzjhLis,_ = GethbdyLis(strconv.FormatInt(sync_time,10),VipStr)
127
+				// }
128
+				// utils.InfoLog("yzstr:%v", gzjhLis)
129
+
130
+				if len(gzjhLis.Result) > 0 {
131
+					// timeLayout := "2006010215:04:05"                             // 转化所需模板
132
+					// loc, _ := time.LoadLocation("Local")                         // 重要:获取时区
133
+					for _, info := range gzjhLis.Result {
134
+						utils.InfoLog("Result:%v", info)
135
+						// 根据project_id和item_id 判断该项是否存在
136
+						project_id := int64(0)
137
+						// if info.ProjectId > 0 {
138
+							project_id, _ = GetTscyProjectID(org_id, info.ProjectName)
139
+						// } else {
140
+						// 	continue
141
+						// }
142
+
143
+						item_id, _ := GetTscyItemID(org_id, info.ProjectName, info.ItemName, project_id)
144
+
145
+						tx := writeMiddleDb.Begin()
146
+						var inspection models.MiddleInspection
147
+						var inspection_reference models.MiddleInspectionReference
148
+
149
+						record_date,_ := strconv.ParseInt(info.InspectDate, 10, 64)
150
+
151
+						if record_date == 0 {
152
+							record_date = time.Now().Unix()
153
+						}
154
+
155
+						// record_date_str, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", recordDateStr)
156
+						// record_date := record_date_str.Unix()
157
+						inspect_date := time.Unix(record_date, 0).Format("2006-01-02 15:04")
158
+						// date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
159
+						// record_date,_ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
160
+						var total int
161
+						var RangeOptions string
162
+						var RangeMin string
163
+						var RangeMax string
164
+
165
+						// // 判断检查类型
166
+						ItemType := info.ItemType
167
+						// Range := strings.Split(info.RangeValue, "-")
168
+						// if len(Range) > 1 {
169
+							RangeMin = info.RangeMin
170
+							RangeMax = info.RangeMax
171
+						// 	ItemType = 1
172
+						// } else {
173
+						// 	ItemType = 2
174
+							RangeOptions = info.RangeOptions
175
+						// }
176
+
177
+						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
178
+						// if inspection_reference.ID > 0 {
179
+						// 	ItemType = int64(inspection_reference.RangeType)
180
+						// }
181
+						if total <= 0 {
182
+							inspection_reference.OrgId = org_id
183
+							inspection_reference.ProjectName = info.ProjectName
184
+							inspection_reference.Project = info.ProjectName
185
+							inspection_reference.ProjectId = project_id
186
+							inspection_reference.ItemName = info.ItemName
187
+							inspection_reference.ItemNameAddition = info.ItemId
188
+							inspection_reference.ItemId = item_id
189
+							inspection_reference.RangeType, _ = strconv.Atoi(ItemType)
190
+							inspection_reference.RangeMin = RangeMin
191
+							inspection_reference.RangeMax = RangeMax
192
+							// inspection_reference.RangeValue = RangeValue
193
+							inspection_reference.RangeOptions = RangeOptions
194
+							inspection_reference.Unit = info.Unit
195
+							inspection_reference.Status = 1
196
+							inspection_reference.CreatedTime = time.Now().Unix()
197
+							inspection_reference.UpdatedTime = time.Now().Unix()
198
+							inspection_reference.InspectDate = inspect_date
199
+							inspection_reference.UTime = inspect_date
200
+							err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
201
+							if err != nil {
202
+								tx.Rollback()
203
+							}
204
+						}
205
+
206
+						var itotal int
207
+						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
208
+						if itotal <= 0 {
209
+							info.ItemValue = strings.Replace(info.ItemValue, "&gt;", ">", -1)
210
+							info.ItemValue = strings.Replace(info.ItemValue, "&lt;", "<", -1)
211
+							inspection.PatientId = patient_id
212
+							inspection.OrgId = org_id
213
+							inspection.ProjectId = project_id
214
+							inspection.ItemName = inspection_reference.ItemName
215
+							inspection.ProjectName = inspection_reference.ProjectName
216
+							inspection.InspectType, _ = strconv.Atoi(ItemType)
217
+							inspection.ItemId = item_id
218
+							inspection.InspectValue = info.ItemValue
219
+							inspection.InspectDate = inspect_date
220
+							inspection.RecordDate = record_date
221
+							// inspection.InspectTips = report.Resultstate
222
+							inspection.Status = 1
223
+							inspection.CreatedTime = time.Now().Unix()
224
+							inspection.UpdatedTime = time.Now().Unix()
225
+							inspection.UTime = inspect_date
226
+							inspection.HisUserId = strconv.FormatInt(patient_id, 10)
227
+							err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
228
+							if err != nil {
229
+								tx.Rollback()
230
+							}
231
+						}
232
+
233
+						tx.Commit()
234
+					}
235
+				}
236
+			} else {
237
+				continue
238
+			}
239
+		}
240
+	}
241
+	var syncInfo models.MiddleSyncInfo
242
+	syncInfo.OrgId = org_id
243
+	syncInfo.SyncTime = time.Now().Unix()
244
+	syncInfo.SyncResultType = 1
245
+	syncInfo.SyncRsultRemark = "同步成功"
246
+	syncInfo.SyncTotalNum = 0
247
+	syncInfo.SyncSuccessNum = 0
248
+	syncInfo.SyncInfo = ""
249
+	syncInfo.CreateTime = time.Now().Unix()
250
+	syncInfo.UpdateTime = time.Now().Unix()
251
+
252
+	cwderr := CreateSyncInfo(&syncInfo)
253
+	if cwderr != nil {
254
+		utils.ErrorLog("创建同步信息失败:%v", cwderr)
255
+		return
256
+	}
257
+	SyncToTscytx()
258
+	return
259
+}
260
+
261
+func SyncToTscytx() {
262
+	utils.TraceLog("检验检查同步任务开始执行")
263
+	org_id := int64(9882)
264
+
265
+	// 第一步:跟进org_id 去中间库查出需要同步的数据
266
+	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
267
+	inspections, _ := GetSyncInspectionByOrgId(org_id)
268
+
269
+	// 第二步:将数据同步到业务库
270
+	if len(inspection_references) > 0 {
271
+		for _, inspection_reference := range inspection_references {
272
+			SyncInspectionReference(&inspection_reference)
273
+		}
274
+	}
275
+
276
+	if len(inspections) > 0 {
277
+		for _, inspection := range inspections {
278
+			SyncInspection(&inspection)
279
+		}
280
+	}
281
+	utils.SuccessLog("检验检查同步任务完成")
282
+}

+ 852 - 0
service/wfnfm_service.go Wyświetl plik

@@ -0,0 +1,852 @@
1
+package service
2
+
3
+import (
4
+	"IC/models"
5
+	"IC/utils"
6
+	_ "IC/utils"
7
+	_"bytes"
8
+	_"encoding/json"
9
+	_ "encoding/json"
10
+	_"encoding/xml"
11
+	_"fmt"
12
+	_"net/http"
13
+	_"io/ioutil"
14
+	_ "github.com/jinzhu/gorm"
15
+	"strconv"
16
+	_"strings"
17
+	"time"
18
+	"github.com/jinzhu/gorm"
19
+)
20
+
21
+type AdminUserList struct {
22
+	Id       int64  `json:"id"`
23
+	Name     string `json:"name"`
24
+	UserType int64  `json:"user_type"`
25
+	Status   int64  `json:"status"`
26
+}
27
+
28
+func GetAllAdminUsers(orgId, appid int64) (list []*AdminUserList, err error) {
29
+
30
+	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.org_id=? and uar.app_id =? and ua.status=1", orgId, appid).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
31
+	return
32
+}
33
+
34
+func GetPatientInformation(id int64, orgid int64) (models.Patients, error) {
35
+	patients := models.Patients{}
36
+	err := XTReadDB().Where("id = ? AND user_org_id = ?", id, orgid).Find(&patients).Error
37
+	return patients, err
38
+}
39
+
40
+func GetAllPatientByOrgID(orgid int64, timenow int64) (order []*models.DialysisOrder, err error) {
41
+	err = XTReadDB().Where("user_org_id = ? AND dialysis_date = ? AND stage = 2 AND status = ?", orgid, timenow, 1).Find(&order).Error
42
+	return order, err
43
+}
44
+
45
+//透析处方
46
+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
48
+	return
49
+}
50
+
51
+//透前评估
52
+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
54
+	return
55
+}
56
+
57
+//透后评估
58
+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
60
+	return
61
+}
62
+
63
+//透析监测
64
+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
66
+	return
67
+}
68
+
69
+//临时医嘱
70
+func FindDoctorAdviceOrderById(orgID int64,patientId int64, recordDate int64) (patient []*models.DoctorAdvice, err error) {
71
+	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).
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").
74
+		Find(&patient).Error
75
+	return
76
+}
77
+
78
+type DataUploadConfig struct {
79
+	DbHost         string `gorm:"column:db_host" json:"db_host"`
80
+	DbPort         string `gorm:"column:db_port" json:"db_port"`
81
+	DbUser         string `gorm:"column:db_user" json:"db_user"`
82
+	DbPass         string `gorm:"column:db_pass" json:"db_pass"`
83
+	DbName         string `gorm:"column:db_name" json:"db_name"`
84
+}
85
+
86
+func BatchCreateRecord(ps *models.EmrBloodDialyRecord, rdb *gorm.DB) (err error) {
87
+	err = rdb.Create(&ps).Error
88
+	return err
89
+}
90
+
91
+func BatchCreateDetail(ps *models.EmrBloodDialyDetail, rdb *gorm.DB) (err error) {
92
+	err = rdb.Create(&ps).Error
93
+	return err
94
+}
95
+
96
+func BatchCreateOrder(ps *models.EmrBloodDialyOrder, rdb *gorm.DB) (err error) {
97
+	err = rdb.Create(&ps).Error
98
+	return err
99
+}
100
+
101
+// 潍坊内分泌医院 同步健康数据上报
102
+func  EmrBloodDiaylOrder() {
103
+	org := &DataUploadConfig{
104
+		DbHost:         "127.0.0.1",
105
+		DbPort:         "1433",
106
+		DbPass:         "Aa123456",
107
+		DbUser:         "xtzk",
108
+		DbName:         "wfnfm",
109
+	}
110
+
111
+	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
112
+		orgDb, err := CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
113
+		if err != nil {
114
+			utils.ErrorLog("创建数据库连接失败:%v", err)
115
+			return
116
+		}
117
+
118
+		// 第二步:获取上一次同步的时间点
119
+		syncLastInfo, _ := GetSyncTimeByOrgIDForYs(1041401)
120
+		var sync_time int64
121
+		if syncLastInfo.ID > 0 {
122
+			sync_time = syncLastInfo.SyncTime + 86400
123
+		} else {
124
+			sync_time = 1664553600
125
+		}
126
+		adminUser, _ := GetAllAdminUsers(10414, 15102)
127
+		nowTimes := time.Now().Unix()
128
+		if sync_time < nowTimes {
129
+			for i := sync_time; i < nowTimes; i = i + 86400 {
130
+				tempsyncTimes := time.Unix(i, 0).Format("2006-01-02")
131
+				timeLayout := "2006-01-02 15:04:05"
132
+				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
133
+				timenow := timeStringToTime.Unix()
134
+				orders,_ := GetAllPatientByOrgID(10414,timenow)
135
+				if len(orders) > 0 {
136
+					for _, order := range orders {
137
+
138
+						//查询病人信息
139
+						patients, _ := GetPatientInformation(order.PatientId, 10414)
140
+
141
+						Records, _ := FindDoctorAdviceOrderById(10414,order.PatientId,timenow)
142
+						if len(Records) > 0 {
143
+							for _,record := range Records {
144
+								emrDetail := &models.EmrBloodDialyOrder{
145
+									ReqNo 				: patients.DialysisNo,
146
+									OrderType 			: "1",
147
+									OrderDate 			: time.Unix(record.StartTime, 0).Format("2006-01-02 15:04:05"),
148
+									OrderName 			: record.AdviceName,
149
+									Dosage 				: strconv.FormatFloat(record.PrescribingNumber, 'f', 1, 32)+record.PrescribingNumberUnit,
150
+									Usage 				: record.DeliveryWay,
151
+									ExecDate 			: time.Unix(record.ExecutionTime, 0).Format("2006-01-02 15:04:05"),
152
+									Orglevel 			: "二级",
153
+									Submitdate 			: time.Unix(record.CreatedTime, 0).Format("2006-01-02 15:04:05"),
154
+									Recordstate 		: "0",
155
+									Fectchdate 			: time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
156
+									OrganizationCode 	: "",
157
+									OrganizationName 	: "",
158
+									DistrictCode 		: "370724",
159
+									DistrictName 		: "临朐县",
160
+									Uploadmark 			: "0",
161
+								}
162
+								for _, admin := range adminUser {
163
+									if record.AdviceDoctor == admin.Id {
164
+										emrDetail.DoctorName = admin.Name
165
+									}
166
+									if record.ExecutionStaff == admin.Id{
167
+										emrDetail.NurseName = admin.Name
168
+									}
169
+								}
170
+
171
+								currentYear := time.Now().Year()        //当前年
172
+								emrDetail.Businessyear = int64(currentYear)
173
+								BatchCreateOrder(emrDetail,orgDb)
174
+							}
175
+						}
176
+					}
177
+					var syncInfo models.MiddleSyncInfo
178
+					syncInfo.OrgId = 1041401
179
+
180
+					syncInfo.SyncTime = i
181
+					syncInfo.SyncResultType = 1
182
+					syncInfo.SyncRsultRemark = "同步成功"
183
+					syncInfo.SyncTotalNum = 0
184
+					syncInfo.SyncSuccessNum = 0
185
+					syncInfo.SyncInfo = ""
186
+					syncInfo.CreateTime = time.Now().Unix()
187
+					syncInfo.UpdateTime = time.Now().Unix()
188
+
189
+					cwderr := CreateSyncInfo(&syncInfo)
190
+					if cwderr != nil {
191
+						utils.ErrorLog("创建同步信息失败:%v", cwderr)
192
+						return
193
+					}
194
+				}
195
+			}
196
+		}
197
+
198
+		
199
+		
200
+		
201
+		// 第四步:关闭数据库连接
202
+		CloseDB(orgDb)
203
+	}
204
+}
205
+
206
+// 潍坊内分泌医院 同步健康数据上报
207
+func  EmrBloodDiaylDetail() {
208
+	org := &DataUploadConfig{
209
+		DbHost:         "localhost",
210
+		DbPort:         "1433",
211
+		DbPass:         "Aa123456",
212
+		DbUser:         "xtzk",
213
+		DbName:         "wfnfm",
214
+	}
215
+
216
+	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
217
+		orgDb, err := CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
218
+		if err != nil {
219
+			utils.ErrorLog("创建数据库连接失败:%v", err)
220
+			return
221
+		}
222
+		// 第二步:获取上一次同步的时间点
223
+		syncLastInfo, _ := GetSyncTimeByOrgIDForYs(1041402)
224
+		var sync_time int64
225
+		if syncLastInfo.ID > 0 {
226
+			sync_time = syncLastInfo.SyncTime + 86400
227
+		} else {
228
+			sync_time = 1664553600
229
+		}
230
+	
231
+		nowTimes := time.Now().Unix()
232
+		if sync_time < nowTimes {
233
+			for i := sync_time; i < nowTimes; i = i + 86400 {
234
+				tempsyncTimes := time.Unix(i, 0).Format("2006-01-02")
235
+				timeLayout := "2006-01-02 15:04:05"
236
+				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
237
+				timenow := timeStringToTime.Unix()
238
+
239
+				orders,_ := GetAllPatientByOrgID(10414,timenow)
240
+				if len(orders) > 0 {
241
+					for _, order := range orders {
242
+
243
+						//查询病人信息
244
+						patients, _ := GetPatientInformation(order.PatientId, 10414)
245
+
246
+						Records, _ := FindAllMonitorRecord(10414, order.PatientId, timenow)
247
+						if len(Records) > 0 {
248
+							for _,record := range Records {
249
+								emrDetail := &models.EmrBloodDialyDetail{
250
+									ReqNo 				: patients.DialysisNo,
251
+									Patientname 		: patients.Name,
252
+									Idcard 				: patients.IdCardNo,
253
+									Hospitalcode 		: "MA3R6UFL9",
254
+									Hospitalname 		: "潍坊内分泌与代谢病医院",
255
+									BdDate				: time.Unix(record.MonitoringDate, 0).Format("2006-01-02") + " " + record.MonitoringTime ,
256
+									BdBp				: strconv.FormatFloat(record.SystolicBloodPressure, 'f', 1, 32) + "/" + strconv.FormatFloat(record.DiastolicBloodPressure, 'f', 1, 32),
257
+									BdT					: record.DialysateTemperature,
258
+									BdRate 				: record.PulseFrequency,
259
+									BdFlow 				: record.BloodFlowVolume,
260
+									BdVbp 				: record.VenousPressure,
261
+									BdTmp 				: record.TransmembranePressure,
262
+									BdUfvLimit 			: record.UltrafiltrationVolume,
263
+									Orglevel 			: "二级",
264
+									Submitdate 			: time.Unix(record.CreatedTime, 0).Format("2006-01-02 15:04:05"),
265
+									Recordstate 		: "0",
266
+									Fectchdate 			: time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
267
+									OrganizationCode 	: "",
268
+									OrganizationName 	: "",
269
+									DistrictCode 		: "370724",
270
+									DistrictName 		: "临朐县",
271
+									Uploadmark 			: "0",
272
+								}
273
+								currentYear := time.Now().Year()        //当前年
274
+								emrDetail.Businessyear = int64(currentYear)
275
+								BatchCreateDetail(emrDetail,orgDb)
276
+							}
277
+						}
278
+					}
279
+					var syncInfo models.MiddleSyncInfo
280
+					syncInfo.OrgId = 1041402
281
+	
282
+					syncInfo.SyncTime = i
283
+					syncInfo.SyncResultType = 1
284
+					syncInfo.SyncRsultRemark = "同步成功"
285
+					syncInfo.SyncTotalNum = 0
286
+					syncInfo.SyncSuccessNum = 0
287
+					syncInfo.SyncInfo = ""
288
+					syncInfo.CreateTime = time.Now().Unix()
289
+					syncInfo.UpdateTime = time.Now().Unix()
290
+	
291
+					cwderr := CreateSyncInfo(&syncInfo)
292
+					if cwderr != nil {
293
+						utils.ErrorLog("创建同步信息失败:%v", cwderr)
294
+						return
295
+					}
296
+				}
297
+			}
298
+		}
299
+		// 第四步:关闭数据库连接
300
+		CloseDB(orgDb)
301
+	}
302
+}
303
+
304
+// 潍坊内分泌医院 同步健康数据上报
305
+func  EmrBloodDiaylRecord() {
306
+	org := &DataUploadConfig{
307
+		DbHost:         "localhost",
308
+		DbPort:         "1433",
309
+		DbPass:         "Aa123456",
310
+		DbUser:         "xtzk",
311
+		DbName:         "wfnfm",
312
+	}
313
+
314
+	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
315
+		orgDb, err := CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
316
+		if err != nil {
317
+			utils.ErrorLog("创建数据库连接失败:%v", err)
318
+			return
319
+		}
320
+		adminUser, _ := GetAllAdminUsers(10414, 15102)
321
+
322
+		// 第二步:获取上一次同步的时间点
323
+		syncLastInfo, _ := GetSyncTimeByOrgIDForYs(1041403)
324
+		var sync_time int64
325
+		if syncLastInfo.ID > 0 {
326
+			sync_time = syncLastInfo.SyncTime + 86400
327
+		} else {
328
+			sync_time = 1664553600
329
+		}
330
+	
331
+		nowTimes := time.Now().Unix()
332
+		if sync_time < nowTimes {
333
+			for i := sync_time; i < nowTimes; i = i + 86400 {
334
+				tempsyncTimes := time.Unix(i, 0).Format("2006-01-02")
335
+				timeLayout := "2006-01-02 15:04:05"
336
+			
337
+				timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, tempsyncTimes+" 00:00:00")
338
+				timenow := timeStringToTime.Unix()
339
+
340
+				orders,_ := GetAllPatientByOrgID(10414,timenow)
341
+				if len(orders) > 0 {
342
+					for _, order := range orders {
343
+
344
+						//查询病人信息
345
+						patients, _ := GetPatientInformation(order.PatientId, 10414)
346
+						//透析处方
347
+						dialysisPrescription, _ := FindPatientPrescribeById(10414, order.PatientId, timenow)
348
+						//透前评估
349
+						PredialysisEvaluation, _ := FindPredialysisEvaluationById(10414, order.PatientId, timenow)
350
+						//透后评估
351
+						AssessmentAfterDislysis, _ := FindAssessmentAfterDislysisById(10414, order.PatientId, timenow)
352
+
353
+						emrRecord := &models.EmrBloodDialyRecord{
354
+							ReqNo 				: patients.DialysisNo,
355
+							Patientname 		: patients.Name,
356
+							Idcard 				: patients.IdCardNo,
357
+							Hospitalcode 		: "MA3R6UFL9",
358
+							Hospitalname 		: "潍坊内分泌与代谢病医院",
359
+							AdmissionId 		: patients.IdCardNo,
360
+							BdDate 				: time.Unix(order.DialysisDate, 0).Format("2006-01-02"),
361
+							BdMatno 			: dialysisPrescription.DialyzerPerfusionApparatus,
362
+							Temperature 		: PredialysisEvaluation.Temperature,
363
+							PulseRate 			: PredialysisEvaluation.PulseFrequency,
364
+							BreathingRate 		: PredialysisEvaluation.BreathingRate,
365
+							PressureH 			: PredialysisEvaluation.SystolicBloodPressure,
366
+							PressureL 			: PredialysisEvaluation.DiastolicBloodPressure,
367
+							UfvLimit 			: dialysisPrescription.DewaterAmount*1000,
368
+							FirstAnticoagulant 	: dialysisPrescription.AnticoagulantShouji,
369
+							BdHours 			: AssessmentAfterDislysis.ActualTreatmentHour,
370
+							BdType 				: dialysisPrescription.ModeId,
371
+							BdT 				: 36.5,
372
+							AnticoagulantTotal 	: dialysisPrescription.AnticoagulantZongliang,
373
+							BdCruorContiton 	: "2",
374
+							PatientWeight		: PredialysisEvaluation.DryWeight,
375
+							WeightBf 			: PredialysisEvaluation.WeightBefore,
376
+							WeightAf 			: AssessmentAfterDislysis.WeightAfter,
377
+							WeightBalan 		: PredialysisEvaluation.WeightBefore - PredialysisEvaluation.WeightBefore,
378
+							Vascular 			: "2",
379
+							Orglevel 			: "二级",
380
+							Submitdate 			: time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
381
+							Recordstate 		: "0",
382
+							Fectchdate 			: time.Unix(order.CreatedTime, 0).Format("2006-01-02 15:04:05"),
383
+							OrganizationCode 	: "",
384
+							OrganizationName 	: "",
385
+							DistrictCode 		: "370724",
386
+							DistrictName 		: "临朐县",
387
+							Uploadmark 			: "0",
388
+						}
389
+
390
+						for _, admin := range adminUser {
391
+							if dialysisPrescription.Creater == admin.Id {
392
+								emrRecord.DoctorName = admin.Name
393
+							}
394
+							if order.StartNurse == admin.Id{
395
+								emrRecord.OperName = admin.Name
396
+								emrRecord.PrimaryName = admin.Name
397
+							}
398
+						}
399
+
400
+						if(patients.Gender == 1){
401
+							emrRecord.SexCode = "1"
402
+							emrRecord.SexName = "男"
403
+						}
404
+						if(patients.Gender == 2){
405
+							emrRecord.SexCode = "2"
406
+							emrRecord.SexName = "女"
407
+						}
408
+
409
+						currentYear := time.Now().Year()        //当前年
410
+						birthYear := time.Unix(patients.Birthday, 0).Year()
411
+						emrRecord.Businessyear = int64(currentYear)
412
+						emrRecord.Age = int64(currentYear) - int64(birthYear)
413
+						switch dialysisPrescription.Anticoagulant {
414
+							case 1:
415
+								emrRecord.Anticoagulant = "无肝素"
416
+								break
417
+							case 2:
418
+								emrRecord.Anticoagulant = "普通肝素"
419
+								break
420
+							case 3:
421
+								emrRecord.Anticoagulant = "低分子肝素"
422
+								break
423
+							case 4:
424
+								emrRecord.Anticoagulant = "阿加曲班"
425
+								break
426
+							case 5:
427
+								emrRecord.Anticoagulant = "枸橼酸钠"
428
+								break
429
+							case 6:
430
+								emrRecord.Anticoagulant = "低分子肝素钙"
431
+								break
432
+							case 7:
433
+								emrRecord.Anticoagulant = "低分子肝素钠"
434
+								break
435
+						}
436
+
437
+						switch dialysisPrescription.ModeId {
438
+							case 1:
439
+								emrRecord.BdTypeName = "HD"
440
+								break
441
+							case 2:
442
+								emrRecord.BdTypeName = "HDF"
443
+								break
444
+							case 3:
445
+								emrRecord.BdTypeName = "HD+HP"
446
+								break
447
+							case 4:
448
+								emrRecord.BdTypeName = "HP"
449
+								break
450
+							case 5:
451
+								emrRecord.BdTypeName = "HF"
452
+								break
453
+							case 6:
454
+								emrRecord.BdTypeName = "SCUF"
455
+								break
456
+							case 7:
457
+								emrRecord.BdTypeName = "IUF"
458
+								break
459
+							case 8:
460
+								emrRecord.BdTypeName = "HFHD"
461
+								break
462
+							case 9:
463
+								emrRecord.BdTypeName = "HFHD+HP"
464
+								break
465
+							case 10:
466
+								emrRecord.BdTypeName = "PHF"
467
+								break
468
+							case 11:
469
+								emrRecord.BdTypeName = "HFR"
470
+								break
471
+							case 12:
472
+								emrRecord.BdTypeName = "HDF+HP"
473
+								break
474
+							default:
475
+								emrRecord.BdTypeName = "HD"
476
+								break
477
+						}
478
+
479
+						if AssessmentAfterDislysis.Cruor == "透析器-0度" || len(AssessmentAfterDislysis.Cruor) <= 0{
480
+							emrRecord.BdCruor = "2"
481
+							emrRecord.BdCruorName = "无凝血"
482
+						} else {
483
+							emrRecord.BdCruor = "1"
484
+							emrRecord.BdCruorName = "有凝血"
485
+						}
486
+
487
+						BatchCreateRecord(emrRecord,orgDb)
488
+					}
489
+				
490
+					var syncInfo models.MiddleSyncInfo
491
+					syncInfo.OrgId = 1041403
492
+		
493
+					syncInfo.SyncTime = i
494
+					syncInfo.SyncResultType = 1
495
+					syncInfo.SyncRsultRemark = "同步成功"
496
+					syncInfo.SyncTotalNum = 0
497
+					syncInfo.SyncSuccessNum = 0
498
+					syncInfo.SyncInfo = ""
499
+					syncInfo.CreateTime = time.Now().Unix()
500
+					syncInfo.UpdateTime = time.Now().Unix()
501
+		
502
+					cwderr := CreateSyncInfo(&syncInfo)
503
+					if cwderr != nil {
504
+						utils.ErrorLog("创建同步信息失败:%v", cwderr)
505
+						return
506
+					}
507
+				}
508
+			}
509
+		}
510
+		// 第四步:关闭数据库连接
511
+		CloseDB(orgDb)
512
+	}
513
+}
514
+
515
+// 福建天福医院透析中心Lis同步
516
+// func SyncFjtfLis() (err error) {
517
+// 	org_id := int64(10330)
518
+
519
+// 	// 第一步:获取上一次同步的时间点
520
+// 	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
521
+// 	var sync_time int64
522
+// 	if syncLastInfo.ID > 0 {
523
+// 		sync_time = syncLastInfo.SyncTime
524
+// 	} else {
525
+// 		sync_time = 1651334400  // 2022-05-01 00:00:00
526
+// 	}
527
+
528
+// 	sync_time_temp := time.Unix(sync_time,0)
529
+// 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
530
+// 	// 第二步:获取所有患者的病历号
531
+
532
+// 	patientList, _ := GetPatientGzjhByOrgId(org_id)
533
+// 	if len(patientList) > 0 {
534
+// 		for _, patient := range patientList {
535
+// 			if len(patient.IdCardNo) > 0 || len(patient.DialysisNo) > 0 {
536
+// 				patient_id := patient.ID
537
+// 				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
538
+// 				// utils.InfoLog("VipStr:%v", VipStr)
539
+
540
+// 				result, _ := FjtjGetLab(patient.IdCardNo,syncTimeStr)
541
+// 				var fjtfLab LabResult
542
+// 				if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
543
+// 					utils.ErrorLog("解析失败:%v", err)
544
+// 				}
545
+// 				fmt.Println(fjtfLab)
546
+
547
+// 				if len(fjtfLab.Result) > 0 {
548
+// 					// 根据获取的头部lab01获取检查结果
549
+	
550
+// 					for _, info := range fjtfLab.Result {
551
+// 						lacResult, _ := FjtjGetLac(info.Lab01)
552
+// 						var fjtfLac LacResult
553
+// 						if err := json.Unmarshal([]byte(lacResult), &fjtfLac); err != nil {
554
+// 							utils.ErrorLog("解析失败:%v", err)
555
+// 						}
556
+// 						fmt.Println(fjtfLac)
557
+// 						for _,cinfo := range fjtfLac.Result{
558
+// 							project_id := int64(0)
559
+// 							item_id := int64(0)
560
+// 							if len(cinfo.Bbx05a) > 0 {
561
+// 								project_id, _ = GetfjtfProjectID(org_id, cinfo.Bbx05a)
562
+// 								item_id, _ = GetFjtfItemID(org_id, cinfo.Bbx05a, cinfo.Bbx05, project_id)
563
+// 							} else {
564
+// 								project_id, _ = GetfjtfProjectID(org_id, cinfo.Bbx05)
565
+// 								item_id, _ = GetFjtfItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
566
+// 							}
567
+						
568
+
569
+// 							tx := writeMiddleDb.Begin()
570
+// 							var inspection models.MiddleInspection
571
+// 							var inspection_reference models.MiddleInspectionReference
572
+
573
+
574
+// 							loc, _ := time.LoadLocation("Local")
575
+// 							theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
576
+// 							record_date := theTime.Unix()
577
+
578
+// 						if record_date == 0 {
579
+// 							record_date = time.Now().Unix()
580
+// 						}
581
+
582
+// 						inspect_date := time.Unix(record_date, 0).Format("2006-01-02 15:04")
583
+// 						var total int
584
+// 						var RangeOptions string
585
+// 						var RangeMin string
586
+// 						var RangeMax string
587
+
588
+// 						// // 判断检查类型
589
+// 						ItemType := 1
590
+// 						Range := strings.Split(cinfo.Lac15, "-")
591
+// 						if len(Range) > 1 {
592
+// 							RangeMin = cinfo.Lac13
593
+// 							RangeMax = cinfo.Lac14
594
+// 							ItemType = 1
595
+// 						} else {
596
+// 							ItemType = 2
597
+// 							RangeOptions = cinfo.Lac15
598
+// 						}
599
+
600
+// 						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
601
+// 						// if inspection_reference.ID > 0 {
602
+// 						// 	ItemType = int64(inspection_reference.RangeType)
603
+// 						// }
604
+						
605
+// 						if total <= 0 {
606
+// 							inspection_reference.OrgId = org_id
607
+// 							if len(cinfo.Bbx05a) > 0 {
608
+// 								inspection_reference.ProjectName = cinfo.Bbx05a 
609
+// 								inspection_reference.Project = cinfo.Bbx05a
610
+// 							} else {
611
+// 								inspection_reference.ProjectName = cinfo.Bbx05
612
+// 								inspection_reference.Project = cinfo.Bbx05
613
+// 							}
614
+// 							inspection_reference.ProjectId = project_id
615
+// 							inspection_reference.ItemName = cinfo.Bbx05
616
+// 							inspection_reference.ItemId = item_id
617
+// 							inspection_reference.RangeType = ItemType
618
+// 							inspection_reference.RangeMin = RangeMin
619
+// 							inspection_reference.RangeMax = RangeMax
620
+// 							// inspection_reference.RangeValue = RangeValue
621
+// 							inspection_reference.RangeOptions = RangeOptions
622
+// 							inspection_reference.Unit = cinfo.Bdg02
623
+// 							inspection_reference.Status = 1
624
+// 							inspection_reference.CreatedTime = time.Now().Unix()
625
+// 							inspection_reference.UpdatedTime = time.Now().Unix()
626
+// 							inspection_reference.InspectDate = inspect_date
627
+// 							inspection_reference.UTime = inspect_date
628
+// 							err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
629
+// 							if err != nil {
630
+// 								tx.Rollback()
631
+// 							}
632
+// 						}
633
+
634
+// 						var itotal int
635
+// 						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
636
+// 						if itotal <= 0 {
637
+// 							inspection.PatientId = patient_id
638
+// 							inspection.OrgId = org_id
639
+// 							inspection.ProjectId = project_id
640
+// 							inspection.ItemName = inspection_reference.ItemName
641
+// 							inspection.ProjectName = inspection_reference.ProjectName
642
+// 							inspection.InspectType = ItemType
643
+// 							inspection.ItemId = item_id
644
+// 							inspection.InspectValue = cinfo.Lac10
645
+// 							inspection.InspectDate = inspect_date
646
+// 							inspection.RecordDate = record_date
647
+// 							inspection.InspectTips =  cinfo.Lac11
648
+// 							inspection.Status = 1
649
+// 							inspection.CreatedTime = time.Now().Unix()
650
+// 							inspection.UpdatedTime = time.Now().Unix()
651
+// 							inspection.UTime = inspect_date
652
+// 							inspection.HisUserId = strconv.FormatInt(patient_id, 10)
653
+// 							err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
654
+// 							if err != nil {
655
+// 								tx.Rollback()
656
+// 							}
657
+// 						}
658
+
659
+// 						tx.Commit()
660
+						
661
+// 					}
662
+// 				}
663
+// 				}
664
+// 			} else {
665
+// 				continue
666
+// 			}
667
+// 		}
668
+// 	}
669
+// 	var syncInfo models.MiddleSyncInfo
670
+// 	syncInfo.OrgId = org_id
671
+// 	syncInfo.SyncTime = time.Now().Unix()
672
+// 	syncInfo.SyncResultType = 1
673
+// 	syncInfo.SyncRsultRemark = "同步成功"
674
+// 	syncInfo.SyncTotalNum = 0
675
+// 	syncInfo.SyncSuccessNum = 0
676
+// 	syncInfo.SyncInfo = ""
677
+// 	syncInfo.CreateTime = time.Now().Unix()
678
+// 	syncInfo.UpdateTime = time.Now().Unix()
679
+
680
+// 	cwderr := CreateSyncInfo(&syncInfo)
681
+// 	if cwderr != nil {
682
+// 		utils.ErrorLog("创建同步信息失败:%v", cwderr)
683
+// 		return
684
+// 	}
685
+// 	SyncToFjtftx()
686
+// 	return
687
+// }
688
+
689
+// type LabResult struct {
690
+// 	Msg    string `json:"msg"`
691
+// 	Result []struct {
692
+// 		Lab01	int64		`json:"lab01"`
693
+// 		Lab58	string   	`json:"lab58"`
694
+// 	} `json:"result"`
695
+// 	Code string `json:"code"`
696
+// }
697
+
698
+// func FjtjGetLab(id_card_no string, synctime string) (string, string) {
699
+// 	inputData := make(map[string]interface{})
700
+
701
+// 	inputData["vaa15"] = id_card_no
702
+// 	inputData["begintime"] = synctime
703
+
704
+// 	var inputLog string
705
+// 	bytesData, err := json.Marshal(inputData)
706
+// 	inputLog = string(bytesData)
707
+// 	fmt.Println(string(bytesData))
708
+// 	if err != nil {
709
+// 		fmt.Println(err.Error())
710
+// 		return err.Error(), ""
711
+// 	}
712
+// 	reader := bytes.NewReader(bytesData)
713
+// 	url := "http://hip.zptfyy.com/esb/listener/getLab1"
714
+
715
+// 	request, err := http.NewRequest("POST", url, reader)
716
+// 	if err != nil {
717
+// 		fmt.Println(err.Error())
718
+// 		return err.Error(), ""
719
+// 	}
720
+
721
+// 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
722
+// 	request.Header.Set("code", "xt")
723
+
724
+// 	client := http.Client{}
725
+// 	resp, err := client.Do(request)
726
+// 	if err != nil {
727
+// 		fmt.Println(err.Error())
728
+// 		return err.Error(), ""
729
+// 	}
730
+// 	respBytes, err := ioutil.ReadAll(resp.Body)
731
+// 	if err != nil {
732
+// 		fmt.Println(err.Error())
733
+// 		return err.Error(), ""
734
+// 	}
735
+// 	str := string(respBytes)
736
+// 	return str, inputLog
737
+// }
738
+
739
+// type LacResult struct {
740
+// 	Msg    string `json:"msg"`
741
+// 	Result []struct {
742
+// 		Lab01	int64		`json:"labo1"`
743
+// 		Bbx05	string   	`json:"BBX05"`
744
+// 		Bbx05a	string   	`json:"BBX05A"`
745
+// 		Bfc03	string   	`json:"BFC03"`
746
+// 		Bdg02	string   	`json:"BDG02"`
747
+// 		Lac10	string   	`json:"LAC10"`
748
+// 		Lac11	string   	`json:"LAC11"`
749
+// 		Lac13	string   	`json:"LAC13"`
750
+// 		Lac14	string   	`json:"LAC14"`
751
+// 		Lac15	string   	`json:"LAC15"`
752
+// 		Lac25	string   	`json:"LAC25"`
753
+// 	} `json:"result"`
754
+// 	Code string `json:"code"`
755
+// }
756
+
757
+// func FjtjGetLac(lab01 int64) (string, string) {
758
+// 	inputData := make(map[string]interface{})
759
+
760
+// 	inputData["lab01"] = lab01
761
+
762
+// 	var inputLog string
763
+// 	bytesData, err := json.Marshal(inputData)
764
+// 	inputLog = string(bytesData)
765
+// 	fmt.Println(string(bytesData))
766
+// 	if err != nil {
767
+// 		fmt.Println(err.Error())
768
+// 		return err.Error(), ""
769
+// 	}
770
+// 	reader := bytes.NewReader(bytesData)
771
+// 	url := "http://hip.zptfyy.com/esb/listener/getLac1"
772
+
773
+// 	request, err := http.NewRequest("POST", url, reader)
774
+// 	if err != nil {
775
+// 		fmt.Println(err.Error())
776
+// 		return err.Error(), ""
777
+// 	}
778
+
779
+// 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
780
+// 	request.Header.Set("code", "xt")
781
+
782
+// 	client := http.Client{}
783
+// 	resp, err := client.Do(request)
784
+// 	if err != nil {
785
+// 		fmt.Println(err.Error())
786
+// 		return err.Error(), ""
787
+// 	}
788
+// 	respBytes, err := ioutil.ReadAll(resp.Body)
789
+// 	if err != nil {
790
+// 		fmt.Println(err.Error())
791
+// 		return err.Error(), ""
792
+// 	}
793
+// 	str := string(respBytes)
794
+// 	return str, inputLog
795
+// }
796
+
797
+// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
798
+// func GetfjtfProjectID(org_id int64, project_name string) (project_id int64, err error) {
799
+// 	var inspection_reference models.MiddleInspectionReference
800
+// 	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, project_name).First(&inspection_reference).Error
801
+// 	if inspection_reference.ID > 0 {
802
+// 		return inspection_reference.ProjectId, err
803
+// 	} else {
804
+// 		err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_reference).Error
805
+// 		if inspection_reference.ProjectId > 0 {
806
+// 			return inspection_reference.ProjectId + 1, err
807
+// 		} else {
808
+// 			return 330001, err
809
+// 		}
810
+// 	}
811
+// }
812
+
813
+// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
814
+// func GetFjtfItemID(org_id int64,project_name string,item_name string,project_id int64) (item_id int64 ,err error) {
815
+// 	var inspection_reference models.MiddleInspectionReference
816
+// 	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
817
+// 	if inspection_reference.ID > 0 {
818
+// 		return inspection_reference.ItemId,err
819
+// 	} else {
820
+// 		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
821
+// 		utils.InfoLog("inspection_reference: %v",inspection_reference)
822
+// 		if inspection_reference.ItemId > 0 {
823
+// 			return inspection_reference.ItemId + 1,err
824
+// 		} else {
825
+// 			return project_id * 100 + 1 ,err
826
+// 		}
827
+// 	}
828
+// }
829
+
830
+
831
+// func SyncToFjtftx() {
832
+// 	utils.TraceLog("检验检查同步任务开始执行")
833
+// 	org_id := int64(10330)
834
+
835
+// 	// 第一步:跟进org_id 去中间库查出需要同步的数据
836
+// 	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
837
+// 	inspections, _ := GetSyncInspectionByOrgId(org_id)
838
+
839
+// 	// 第二步:将数据同步到业务库
840
+// 	if len(inspection_references) > 0 {
841
+// 		for _, inspection_reference := range inspection_references {
842
+// 			SyncInspectionReference(&inspection_reference)
843
+// 		}
844
+// 	}
845
+
846
+// 	if len(inspections) > 0 {
847
+// 		for _, inspection := range inspections {
848
+// 			SyncInspection(&inspection)
849
+// 		}
850
+// 	}
851
+// 	utils.SuccessLog("检验检查同步任务完成")
852
+// }