|
@@ -897,6 +897,39 @@ func UpdatedCustomer(customer models.SgjUserCustomer, id int64) error {
|
897
|
897
|
return err
|
898
|
898
|
}
|
899
|
899
|
|
|
900
|
+func GetInspectionByOrgId(orgid int64) (*models.XtInspectionReference, error) {
|
|
901
|
+ diseases := models.XtInspectionReference{}
|
|
902
|
+ err := XTReadDB().Model(&diseases).Where("org_id = ? and status = 1", orgid).Find(&diseases).Error
|
|
903
|
+ if err == gorm.ErrRecordNotFound {
|
|
904
|
+ return nil, err
|
|
905
|
+ }
|
|
906
|
+ if err != nil {
|
|
907
|
+ return nil, err
|
|
908
|
+ }
|
|
909
|
+ return &diseases, nil
|
|
910
|
+
|
|
911
|
+}
|
|
912
|
+
|
|
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
|
+
|
900
|
933
|
func GetAllInspection(orgid int64) (inspection []*models.XtInspectionReference, err error) {
|
901
|
934
|
|
902
|
935
|
err = XTReadDB().Model(&inspection).Where("org_id = ? and status = 1", orgid).Group("project_name").Find(&inspection).Error
|
|
@@ -918,15 +951,16 @@ func GetInspection(patientid int64, startime int64, endtime int64, limit int64,
|
918
|
951
|
if orgid > 0 {
|
919
|
952
|
db = db.Where("x.org_id = ?", orgid)
|
920
|
953
|
}
|
921
|
|
- err = db.Count(&total).Order("x.inspect_date").Group("x.id").
|
|
954
|
+ err = db.Count(&total).Order("x.inspect_date desc").Group("x.id").
|
922
|
955
|
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
|
923
|
956
|
return inspection, total, err
|
924
|
957
|
}
|
925
|
958
|
|
926
|
|
-func GetInspectionDetail(patientid int64, date int64, orgid int64, projectid int64) (inspection []*models.Inspection, err error) {
|
|
959
|
+func GetInspectionDetail(patientid int64, date int64, orgid int64, projectid int64) (inspection []*models.Inspections, err error) {
|
927
|
960
|
|
928
|
961
|
db := XTReadDB().Table("xt_inspection as x").Where("x.status =1")
|
929
|
|
-
|
|
962
|
+ table := XTReadDB().Table("xt_inspection_reference as r")
|
|
963
|
+ fmt.Print("table", table)
|
930
|
964
|
if patientid > 0 {
|
931
|
965
|
db = db.Where("x.patient_id = ?", patientid)
|
932
|
966
|
}
|
|
@@ -941,7 +975,7 @@ func GetInspectionDetail(patientid int64, date int64, orgid int64, projectid int
|
941
|
975
|
if projectid > 0 {
|
942
|
976
|
db = db.Where("x.project_id = ?", projectid)
|
943
|
977
|
}
|
944
|
|
- 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.status,x.created_time,x.updated_time").Scan(&inspection).Error
|
|
978
|
+ 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.status,x.created_time,x.updated_time,r.range_type,r.range_min,r.range_max,r.range_value,r.range_options,r.unit").Joins("left join xt_inspection_reference as r on r.id = x.item_id ").Scan(&inspection).Error
|
945
|
979
|
return inspection, err
|
946
|
980
|
}
|
947
|
981
|
|