|
@@ -491,8 +491,8 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
|
491
|
491
|
if end > 0 {
|
492
|
492
|
db = db.Where("start_time<=?", end)
|
493
|
493
|
}
|
494
|
|
- offset := (page - 1) * limit
|
495
|
|
- err = db.Group("x.id").Count(&total).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Offset(offset).Limit(limit).Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&doctoradvice).Error
|
|
494
|
+ //offset := (page - 1) * limit
|
|
495
|
+ err = db.Group("x.id").Count(&total).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&doctoradvice).Error
|
496
|
496
|
fmt.Print("err", err)
|
497
|
497
|
return
|
498
|
498
|
|
|
@@ -848,7 +848,7 @@ func GetAllDoctorTwo(orgid int64, appid int64) (appRole []*models.SgjUserAdminRo
|
848
|
848
|
func GetDoctorAdviceDetail(id int64, orgid int64) (advices []*models.DoctorAdvices, err error) {
|
849
|
849
|
|
850
|
850
|
db := XTReadDB().Table("xt_doctor_advice as x")
|
851
|
|
- err = db.Select("x.id,x.user_org_id,x.patient_id,x.advice_type,x.advice_date,x.start_time,x.advice_name,x.advice_desc,x.reminder_date,x.single_dose,x.single_dose_unit,x.prescribing_number,x.prescribing_number_unit,x.delivery_way,x.execution_frequency,x.advice_doctor,x.status,x.created_time,x.updated_time,x.advice_affirm,x.remark,x.stop_time,x.stop_reason,x.stop_doctor,x.stop_state,x.parent_id,x.execution_time,x.execution_staff,x.execution_state,x.checker,x.record_date,x.dialysis_order_id,x.check_time,x.check_state,x.drug_spec,x.drug_spec_unit,x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.template_id,x.modifier,s.name").Joins("left join xt_patients as s on s.id=x.patient_id").Where("x.groupno = ? and x.status = 1 and x.user_org_id = ?", id, orgid).Scan(&advices).Error
|
|
851
|
+ err = db.Order("x.id desc").Select("x.id,x.user_org_id,x.patient_id,x.advice_type,x.advice_date,x.start_time,x.advice_name,x.advice_desc,x.reminder_date,x.single_dose,x.single_dose_unit,x.prescribing_number,x.prescribing_number_unit,x.delivery_way,x.execution_frequency,x.advice_doctor,x.status,x.created_time,x.updated_time,x.advice_affirm,x.remark,x.stop_time,x.stop_reason,x.stop_doctor,x.stop_state,x.parent_id,x.execution_time,x.execution_staff,x.execution_state,x.checker,x.record_date,x.dialysis_order_id,x.check_time,x.check_state,x.drug_spec,x.drug_spec_unit,x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.template_id,x.modifier,s.name").Joins("left join xt_patients as s on s.id=x.patient_id").Where("x.groupno = ? and x.status = 1 and x.user_org_id = ?", id, orgid).Scan(&advices).Error
|
852
|
852
|
|
853
|
853
|
return advices, err
|
854
|
854
|
}
|
|
@@ -859,6 +859,12 @@ func DeleteManagement(groupid int64, orgid int64) error {
|
859
|
859
|
return err
|
860
|
860
|
}
|
861
|
861
|
|
|
862
|
+func DeleteChild(id int64) error {
|
|
863
|
+
|
|
864
|
+ err := XTWriteDB().Model(models.DoctorAdvice{}).Where("id=?", id).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
|
|
865
|
+ return err
|
|
866
|
+}
|
|
867
|
+
|
862
|
868
|
func GetNewPatient(id int64) (models.XtPatientsNew, error) {
|
863
|
869
|
patientsNew := models.XtPatientsNew{}
|
864
|
870
|
err := XTReadDB().Model(&patientsNew).Where("id=?", id).Find(&patientsNew).Error
|
|
@@ -910,33 +916,13 @@ func GetInspectionByOrgId(orgid int64) (*models.XtInspectionReference, error) {
|
910
|
916
|
|
911
|
917
|
}
|
912
|
918
|
|
913
|
|
-//func GetInspectionById(patientid int64,startime int64,endtime int64,orgId int64)(inspection []*models.XtInspectionReference,err error) {
|
914
|
|
-//
|
915
|
|
-// db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
|
916
|
|
-// if patientid > 0 {
|
917
|
|
-// db = db.Where("x.patient_id = ?", patientid)
|
918
|
|
-// }
|
919
|
|
-// if startime > 0 {
|
920
|
|
-// db = db.Where("x.inspect_date >= ?", startime)
|
921
|
|
-// }
|
922
|
|
-// if endtime > 0 {
|
923
|
|
-// db = db.Where("x.inspect_date<=?", endtime)
|
924
|
|
-// }
|
925
|
|
-// if orgId > 0 {
|
926
|
|
-// db = db.Where("x.org_id = ?", orgId)
|
927
|
|
-// }
|
928
|
|
-// err = db.Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,x.created_time").Find(inspection).Error
|
929
|
|
-//
|
930
|
|
-// return inspection,err
|
931
|
|
-//}
|
932
|
|
-
|
933
|
919
|
func GetAllInspection(orgid int64) (inspection []*models.XtInspectionReference, err error) {
|
934
|
920
|
|
935
|
921
|
err = XTReadDB().Model(&inspection).Where("org_id = ? and status = 1", orgid).Group("project_name").Find(&inspection).Error
|
936
|
922
|
return inspection, err
|
937
|
923
|
}
|
938
|
924
|
|
939
|
|
-func GetInspection(patientid int64, startime int64, endtime int64, limit int64, page int64, orgid int64) (inspection []*models.Inspection, total int64, err error) {
|
|
925
|
+func GetInspection(patientid int64, startime int64, endtime int64, limit int64, page int64, orgid int64, projectid int64) (inspection []*models.Inspection, total int64, err error) {
|
940
|
926
|
|
941
|
927
|
db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
|
942
|
928
|
if patientid > 0 {
|
|
@@ -951,6 +937,9 @@ func GetInspection(patientid int64, startime int64, endtime int64, limit int64,
|
951
|
937
|
if orgid > 0 {
|
952
|
938
|
db = db.Where("x.org_id = ?", orgid)
|
953
|
939
|
}
|
|
940
|
+ if projectid > 0 {
|
|
941
|
+ db = db.Where("x.project_id = ?", projectid)
|
|
942
|
+ }
|
954
|
943
|
err = db.Count(&total).Order("x.inspect_date desc").Group("x.id").
|
955
|
944
|
Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,x.created_time").Find(&inspection).Error
|
956
|
945
|
return inspection, total, err
|
|
@@ -984,3 +973,9 @@ func CreateFeedBack(feedback *models.XtPatientFeedback) error {
|
984
|
973
|
err := XTWriteDB().Model(&feedback).Create(&feedback).Error
|
985
|
974
|
return err
|
986
|
975
|
}
|
|
976
|
+
|
|
977
|
+func DeleteInspection(date int64, orgid int64) error {
|
|
978
|
+
|
|
979
|
+ err := XTWriteDB().Model(models.Inspection{}).Where("inspect_date = ? and org_id = ?", date, orgid).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
|
|
980
|
+ return err
|
|
981
|
+}
|