Browse Source

医保对接

csx 4 years ago
parent
commit
fde22c8788

+ 1 - 1
controllers/his_api_controller.go View File

@@ -142,7 +142,7 @@ func (c *HisApiController) GetHisPatientList() {
142 142
 	recordDateTime := theTime.Unix()
143 143
 	adminInfo := c.GetAdminUserInfo()
144 144
 	patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
145
-	patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
145
+	patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, 0)
146 146
 	patients = append(patients, patients_two...)
147 147
 	patients = RemoveRepeatedPatient(patients)
148 148
 

+ 2 - 1
controllers/his_project_api_controller.go View File

@@ -1283,11 +1283,12 @@ func (this *HisProjectApiController) GetAllHisPatient() {
1283 1283
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1284 1284
 	recordDateTime := theTime.Unix()
1285 1285
 	adminUserInfo := this.GetAdminUserInfo()
1286
-	patients, err := service.GetScheduleHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime)
1286
+	patients, err := service.GetScheduleHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime, 0)
1287 1287
 	if err != nil {
1288 1288
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1289 1289
 		return
1290 1290
 	}
1291
+
1291 1292
 	this.ServeSuccessJSON(map[string]interface{}{
1292 1293
 		"list": patients,
1293 1294
 	})

+ 32 - 4
controllers/new_mobile_api_controllers/mobile_his_api_controller.go View File

@@ -616,6 +616,9 @@ func (c *MobileHisApiController) setProjectWithJSON(project *models.HisPrescript
616 616
 }
617 617
 func (c *MobileHisApiController) GetHisPatientList() {
618 618
 	record_date := c.GetString("record_date")
619
+	sch_type, _ := c.GetInt64("sch_type")
620
+	visit_type, _ := c.GetInt64("visit_type")
621
+
619 622
 	timeLayout := "2006-01-02"
620 623
 	loc, _ := time.LoadLocation("Local")
621 624
 
@@ -626,13 +629,38 @@ func (c *MobileHisApiController) GetHisPatientList() {
626 629
 	}
627 630
 	recordDateTime := theTime.Unix()
628 631
 	adminInfo := c.GetMobileAdminUserInfo()
629
-	patients, _ := service.GetScheduleHisPatientList(adminInfo.Org.Id, "", recordDateTime)
632
+	patients, _ := service.GetScheduleHisPatientList(adminInfo.Org.Id, "", recordDateTime, sch_type)
630 633
 	patients_two, _ := service.GetHisPatientList(adminInfo.Org.Id, "", recordDateTime)
631 634
 	patients = append(patients, patients_two...)
632 635
 	patients = RemoveRepeatedPatient(patients)
633
-	c.ServeSuccessJSON(map[string]interface{}{
634
-		"list": patients,
635
-	})
636
+	if visit_type == 0 {
637
+		c.ServeSuccessJSON(map[string]interface{}{
638
+			"list": patients,
639
+		})
640
+
641
+	} else if visit_type == 1 { //未就诊
642
+		var patientsOne []*service.Patients
643
+		for _, item := range patients {
644
+			if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
645
+				patientsOne = append(patientsOne, item)
646
+			}
647
+		}
648
+		c.ServeSuccessJSON(map[string]interface{}{
649
+			"list": patientsOne,
650
+		})
651
+
652
+	} else if visit_type == 2 { //已就诊
653
+		var patientsTwo []*service.Patients
654
+		for _, item := range patients {
655
+
656
+			if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
657
+				patientsTwo = append(patientsTwo, item)
658
+			}
659
+		}
660
+		c.ServeSuccessJSON(map[string]interface{}{
661
+			"list": patientsTwo,
662
+		})
663
+	}
636 664
 
637 665
 }
638 666
 

+ 9 - 3
service/his_service.go View File

@@ -140,9 +140,15 @@ func (HisPrescription) TableName() string {
140 140
 	return "his_prescription"
141 141
 }
142 142
 
143
-func GetScheduleHisPatientList(org_id int64, keywords string, record_date int64) (patients []*Patients, err error) {
144
-	db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id).
145
-		Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ?", record_date, org_id)
143
+func GetScheduleHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*Patients, err error) {
144
+	db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
145
+
146
+	if sch_type != 0 {
147
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_type = ?", record_date, org_id, sch_type)
148
+	} else {
149
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? ", record_date, org_id)
150
+	}
151
+
146 152
 	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
147 153
 	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
148 154
 	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error

+ 28 - 15
service/mobile_dialysis_service.go View File

@@ -37,7 +37,7 @@ func MobileGetDialysisScheduals(orgID int64, scheduleDate int64, scheduleType in
37 37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
38 38
 		Preload("TreatmentSummary", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
39 39
 		Preload("AssessmentAfterDislysis", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
40
-
40
+		Preload("HisAdvices", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
41 41
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
42 42
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
43 43
 		// }).
@@ -102,26 +102,25 @@ func (AssessmentAfterDislysis) TableName() string {
102 102
 }
103 103
 
104 104
 type MDialysisScheduleVM struct {
105
-	ID           int64 `gorm:"column:id" json:"id"`
106
-	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
107
-	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id"`
108
-	BedId        int64 `gorm:"column:bed_id" json:"bed_id"`
109
-	PatientId    int64 `gorm:"column:patient_id" json:"patient_id"`
110
-	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
111
-	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
112
-	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week"`
113
-	ModeId       int64 `gorm:"column:mode_id" json:"mode_id"`
114
-	Status       int64 `gorm:"column:status" json:"status"`
115
-
105
+	ID                       int64                             `gorm:"column:id" json:"id"`
106
+	UserOrgId                int64                             `gorm:"column:user_org_id" json:"user_org_id"`
107
+	PartitionId              int64                             `gorm:"column:partition_id" json:"partition_id"`
108
+	BedId                    int64                             `gorm:"column:bed_id" json:"bed_id"`
109
+	PatientId                int64                             `gorm:"column:patient_id" json:"patient_id"`
110
+	ScheduleDate             int64                             `gorm:"column:schedule_date" json:"schedule_date"`
111
+	ScheduleType             int64                             `gorm:"column:schedule_type" json:"schedule_type"`
112
+	ScheduleWeek             int64                             `gorm:"column:schedule_week" json:"schedule_week"`
113
+	ModeId                   int64                             `gorm:"column:mode_id" json:"mode_id"`
114
+	Status                   int64                             `gorm:"column:status" json:"status"`
116 115
 	SchedualPatient          *MSchedualPatientVMList           `gorm:"ForeignKey:PatientId" json:"patient"`
117 116
 	DeviceNumber             *MDeviceNumberVM                  `gorm:"ForeignKey:BedId" json:"device_number"`
118 117
 	DialysisOrder            *MDialysisOrderVMList             `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
119 118
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
120 119
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_before_dislysis"`
121 120
 	AssessmentAfterDislysis  *AssessmentAfterDislysis          `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_after_dislysis"`
122
-
123
-	Advices          []*VMDoctorAdvice   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
124
-	TreatmentSummary *VMTreatmentSummary `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
121
+	HisAdvices               []*VMHisDoctorAdviceInfo          `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"his_doctor_advice"`
122
+	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
123
+	TreatmentSummary         *VMTreatmentSummary               `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
125 124
 }
126 125
 
127 126
 func (MDialysisScheduleVM) TableName() string {
@@ -298,6 +297,20 @@ func (VMDoctorAdvice) TableName() string {
298 297
 	return "xt_doctor_advice"
299 298
 }
300 299
 
300
+type VMHisDoctorAdviceInfo struct {
301
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
302
+	UserOrgId      int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
303
+	PatientId      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
304
+	HisPatientId   int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
305
+	ExecutionTime  int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
306
+	ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
307
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
308
+}
309
+
310
+func (VMHisDoctorAdviceInfo) TableName() string {
311
+	return "his_doctor_advice_info"
312
+}
313
+
301 314
 // 获取透析记录
302 315
 func MobileGetDialysisRecord(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
303 316
 	var record models.DialysisOrder