陈少旭 2 lat temu
rodzic
commit
725a29ceb3

+ 46 - 0
controllers/patient_dataconfig_api_controller.go Wyświetl plik

@@ -33,12 +33,52 @@ func PatientDataConfigAPIControllerRegistRouters() {
33 33
 	beego.Router("/api/patient/physiquecheck/delete", &PatientDataConfigAPIController{}, "post:DeletePhysiqueCheck")
34 34
 	beego.Router("/api/patient/physiquecheck/modify", &PatientDataConfigAPIController{}, "get:ModifyPhysiqueCheck")
35 35
 
36
+	beego.Router("/api/patient/sickhistory/print", &PatientDataConfigAPIController{}, "get:GetSickhistoryPrints")
37
+	beego.Router("/api/patient/physiquecheck/print", &PatientDataConfigAPIController{}, "get:GetPhysiquecheckPrints")
38
+
36 39
 }
37 40
 
38 41
 type PatientDataConfigAPIController struct {
39 42
 	BaseAuthAPIController
40 43
 }
41 44
 
45
+func (this *PatientDataConfigAPIController) GetPhysiquecheckPrints() {
46
+
47
+	patientID, _ := this.GetInt64("patient_id")
48
+	idsStr := this.GetString("ids")
49
+	if patientID <= 0 || len(idsStr) == 0 {
50
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
51
+		return
52
+	}
53
+	recordIDStrs := strings.Split(idsStr, ",")
54
+	patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
55
+	sickHostory, _ := service.GetPatienttPhysiqueByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
56
+	this.ServeSuccessJSON(map[string]interface{}{
57
+		"patient":      patient,
58
+		"sickhistorys": sickHostory,
59
+	})
60
+
61
+}
62
+func (this *PatientDataConfigAPIController) GetSickhistoryPrints() {
63
+	patientID, _ := this.GetInt64("patient_id")
64
+	idsStr := this.GetString("ids")
65
+	if patientID <= 0 || len(idsStr) == 0 {
66
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
67
+		return
68
+	}
69
+	recordIDStrs := strings.Split(idsStr, ",")
70
+	patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
71
+	sickHostory, _ := service.GetPatientSickHistoryByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
72
+	for _, item := range sickHostory {
73
+		pc, _ := service.GetLastPatientPhysiqueCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientId, item.RecordDate)
74
+		item.XtPatientPhysiqueCheck = pc
75
+	}
76
+	this.ServeSuccessJSON(map[string]interface{}{
77
+		"patient":      patient,
78
+		"sickhistorys": sickHostory,
79
+	})
80
+}
81
+
42 82
 func (this *PatientDataConfigAPIController) GetSickHistorys() {
43 83
 	patientID, _ := this.GetInt64("patient_id")
44 84
 	startTimeYMDStr := this.GetString("start_time")
@@ -105,8 +145,10 @@ func (this *PatientDataConfigAPIController) CreateSickHistory() {
105 145
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
106 146
 		return
107 147
 	}
148
+	record_date := strings.Split(record_time_str, " ")
108 149
 
109 150
 	checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
151
+	checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
110 152
 
111 153
 	adminUserInfo := this.GetAdminUserInfo()
112 154
 	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
@@ -135,6 +177,7 @@ func (this *PatientDataConfigAPIController) CreateSickHistory() {
135 177
 		Ctime:                   now,
136 178
 		Mtime:                   now,
137 179
 		DoctorId:                doctor_id,
180
+		RecordDate:              checkDate_two.Unix(),
138 181
 	}
139 182
 
140 183
 	createErr := service.CreatePatientSickHistory(&record)
@@ -369,7 +412,9 @@ func (this *PatientDataConfigAPIController) CreatePhysiqueCheck() {
369 412
 		return
370 413
 	}
371 414
 
415
+	record_date := strings.Split(record_time_str, " ")
372 416
 	checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
417
+	checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
373 418
 
374 419
 	adminUserInfo := this.GetAdminUserInfo()
375 420
 	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
@@ -442,6 +487,7 @@ func (this *PatientDataConfigAPIController) CreatePhysiqueCheck() {
442 487
 		ShenzhangYatong:  shenzhang_yatong,
443 488
 		FubuDesc:         fubu_desc,
444 489
 		OthDesc:          oth_desc,
490
+		RecordDate:       checkDate_two.Unix(),
445 491
 	}
446 492
 	createErr := service.CreatePatientPhysiqueCheck(&record)
447 493
 	if createErr != nil {

+ 17 - 17
controllers/public_api_controller.go Wyświetl plik

@@ -115,23 +115,23 @@ func (c *PublicApiController) HandleSchedule() {
115 115
 
116 116
 func (c *PublicApiController) HandleOne() {
117 117
 	//fmt.Println("~~~~~~")
118
-	start_time := c.GetString("start_time")
119
-	end_time := c.GetString("end_time")
120
-
121
-	timeLayout := "2006-01-02"
122
-	loc, _ := time.LoadLocation("Local")
123
-	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
124
-	if err != nil {
125
-	}
126
-	startRecordDateTime := startTime.Unix()
127
-	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
128
-	if err != nil {
129
-	}
130
-	endRecordDateTime := endTime.Unix()
131
-	orders, _ := service.GetHisOrderDetailOne(startRecordDateTime, endRecordDateTime)
132
-	c.ServeSuccessJSON(map[string]interface{}{
133
-		"order": orders,
134
-	})
118
+	//start_time := c.GetString("start_time")
119
+	//end_time := c.GetString("end_time")
120
+	//
121
+	//timeLayout := "2006-01-02"
122
+	//loc, _ := time.LoadLocation("Local")
123
+	//startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
124
+	//if err != nil {
125
+	//}
126
+	//startRecordDateTime := startTime.Unix()
127
+	//endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
128
+	//if err != nil {
129
+	//}
130
+	//endRecordDateTime := endTime.Unix()
131
+	//orders, _ := service.GetHisOrderDetailOne(startRecordDateTime, endRecordDateTime)
132
+	//c.ServeSuccessJSON(map[string]interface{}{
133
+	//	"order": orders,
134
+	//})
135 135
 }
136 136
 
137 137
 //func (c *PublicApiController) HandleScheduleTwo() {

+ 24 - 20
models/patient_models.go Wyświetl plik

@@ -1828,21 +1828,23 @@ func (XtPatientFirstDisease) TableName() string {
1828 1828
 }
1829 1829
 
1830 1830
 type XtPatientSickHistory struct {
1831
-	ID                      int64  `gorm:"column:id" json:"id" form:"id"`
1832
-	OrgId                   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
1833
-	PatientId               int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1834
-	Recorder                int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
1835
-	RecordTime              int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
1836
-	Content                 string `gorm:"column:content" json:"content" form:"content"`
1837
-	Status                  int64  `gorm:"column:status" json:"status" form:"status"`
1838
-	Ctime                   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1839
-	Mtime                   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1840
-	Title                   string `gorm:"column:title" json:"title" form:"title"`
1841
-	IsShenyizhiHistory      int64  `gorm:"column:is_shenyizhi_history" json:"is_shenyizhi_history" form:"is_shenyizhi_history"`
1842
-	IsFumoDialysisHistory   int64  `gorm:"column:is_fumo_dialysis_history" json:"is_fumo_dialysis_history" form:"is_fumo_dialysis_history"`
1843
-	HypersusceptibilityDesc string `gorm:"column:hypersusceptibility_desc" json:"hypersusceptibility_desc" form:"hypersusceptibility_desc"`
1844
-	DoctorId                int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
1845
-	IsHypersusceptibility   int64  `gorm:"column:is_hypersusceptibility" json:"is_hypersusceptibility" form:"is_hypersusceptibility"`
1831
+	ID                      int64                  `gorm:"column:id" json:"id" form:"id"`
1832
+	OrgId                   int64                  `gorm:"column:org_id" json:"org_id" form:"org_id"`
1833
+	PatientId               int64                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1834
+	Recorder                int64                  `gorm:"column:recorder" json:"recorder" form:"recorder"`
1835
+	RecordTime              int64                  `gorm:"column:record_time" json:"record_time" form:"record_time"`
1836
+	RecordDate              int64                  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1837
+	Content                 string                 `gorm:"column:content" json:"content" form:"content"`
1838
+	Status                  int64                  `gorm:"column:status" json:"status" form:"status"`
1839
+	Ctime                   int64                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1840
+	Mtime                   int64                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1841
+	Title                   string                 `gorm:"column:title" json:"title" form:"title"`
1842
+	IsShenyizhiHistory      int64                  `gorm:"column:is_shenyizhi_history" json:"is_shenyizhi_history" form:"is_shenyizhi_history"`
1843
+	IsFumoDialysisHistory   int64                  `gorm:"column:is_fumo_dialysis_history" json:"is_fumo_dialysis_history" form:"is_fumo_dialysis_history"`
1844
+	HypersusceptibilityDesc string                 `gorm:"column:hypersusceptibility_desc" json:"hypersusceptibility_desc" form:"hypersusceptibility_desc"`
1845
+	DoctorId                int64                  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
1846
+	IsHypersusceptibility   int64                  `gorm:"column:is_hypersusceptibility" json:"is_hypersusceptibility" form:"is_hypersusceptibility"`
1847
+	XtPatientPhysiqueCheck  XtPatientPhysiqueCheck `gorm:"json:"ppc"`
1846 1848
 }
1847 1849
 
1848 1850
 func (XtPatientSickHistory) TableName() string {
@@ -1850,11 +1852,13 @@ func (XtPatientSickHistory) TableName() string {
1850 1852
 }
1851 1853
 
1852 1854
 type XtPatientPhysiqueCheck struct {
1853
-	ID               int64  `gorm:"column:id" json:"id" form:"id"`
1854
-	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
1855
-	PatientId        int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1856
-	Recorder         int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
1857
-	RecordTime       int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
1855
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
1856
+	OrgId      int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
1857
+	PatientId  int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1858
+	Recorder   int64 `gorm:"column:recorder" json:"recorder" form:"recorder"`
1859
+	RecordTime int64 `gorm:"column:record_time" json:"record_time" form:"record_time"`
1860
+	RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
1861
+
1858 1862
 	Status           int64  `gorm:"column:status" json:"status" form:"status"`
1859 1863
 	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1860 1864
 	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`

+ 23 - 0
service/patient_dataconfig_service.go Wyświetl plik

@@ -38,6 +38,24 @@ func GetPatientSickHistory(orgID int64, patientID int64, startTime int64, endTim
38 38
 	return records, nil
39 39
 }
40 40
 
41
+func GetPatientSickHistoryByIds(orgID int64, patientID int64, ids []string) ([]*models.XtPatientSickHistory, error) {
42
+	var records []*models.XtPatientSickHistory
43
+	err := readDb.Model(&models.XtPatientSickHistory{}).Where("org_id = ? and patient_id = ? and id in (?) and status = 1", orgID, patientID, ids).Order("record_time desc").Find(&records).Error
44
+	if err != nil {
45
+		return nil, err
46
+	}
47
+	return records, nil
48
+}
49
+
50
+func GetPatienttPhysiqueByIds(orgID int64, patientID int64, ids []string) ([]*models.XtPatientPhysiqueCheck, error) {
51
+	var records []*models.XtPatientPhysiqueCheck
52
+	err := readDb.Model(&models.XtPatientPhysiqueCheck{}).Where("org_id = ? and patient_id = ? and id in (?) and status = 1", orgID, patientID, ids).Order("record_time desc").Find(&records).Error
53
+	if err != nil {
54
+		return nil, err
55
+	}
56
+	return records, nil
57
+}
58
+
41 59
 func GetPatientPhysiqueCheck(orgID int64, patientID int64, startTime int64, endTime int64) ([]*models.XtPatientPhysiqueCheck, error) {
42 60
 	var records []*models.XtPatientPhysiqueCheck
43 61
 	err := readDb.Model(&models.XtPatientPhysiqueCheck{}).Where("org_id = ? and patient_id = ? and record_time >= ? and record_time <= ? and status = 1", orgID, patientID, startTime, endTime).Order("record_time desc").Find(&records).Error
@@ -47,6 +65,11 @@ func GetPatientPhysiqueCheck(orgID int64, patientID int64, startTime int64, endT
47 65
 	return records, nil
48 66
 }
49 67
 
68
+func GetLastPatientPhysiqueCheck(orgID int64, patientID int64, record_date int64) (records models.XtPatientPhysiqueCheck, err error) {
69
+	err = readDb.Model(&models.XtPatientPhysiqueCheck{}).Where("org_id = ? and patient_id = ? and record_date = ? and status = 1", orgID, patientID, record_date).Order("record_time desc").Last(&records).Error
70
+	return records, err
71
+}
72
+
50 73
 func CreatePatientCourseOfDisease(record *models.PatientDiseaseCourse) error {
51 74
 	err := writeDb.Model(&models.PatientDiseaseCourse{}).Create(record).Error
52 75
 	return err