Procházet zdrojové kódy

时间选择更新

XMLWAN před 4 roky
rodič
revize
abd2a78aef

+ 31 - 7
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Zobrazit soubor

@@ -1466,14 +1466,32 @@ func (this *NewDialysisApiController) GetAllDoctor() {
1466 1466
 
1467 1467
 func (this *NewDialysisApiController) GetAllInspection() {
1468 1468
 
1469
-	inspection, err := service.GetAllInspection(0)
1470
-	if err != nil {
1471
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1472
-		return
1469
+	//查询该机构是否存在检验检测项目
1470
+	orgid := this.GetMobileAdminUserInfo().Org.Id
1471
+	fmt.Print("orgid", orgid)
1472
+	_, errcode := service.GetInspectionByOrgId(orgid)
1473
+	if errcode == gorm.ErrRecordNotFound {
1474
+		inspection, err := service.GetAllInspection(0)
1475
+		if err != nil {
1476
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1477
+			return
1478
+		}
1479
+		this.ServeSuccessJSON(map[string]interface{}{
1480
+			"inspection": inspection,
1481
+		})
1482
+	} else if errcode == nil {
1483
+		inspection, err := service.GetAllInspection(orgid)
1484
+		if err != nil {
1485
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1486
+			return
1487
+		}
1488
+		this.ServeSuccessJSON(map[string]interface{}{
1489
+			"inspection": inspection,
1490
+		})
1491
+	} else {
1492
+
1473 1493
 	}
1474
-	this.ServeSuccessJSON(map[string]interface{}{
1475
-		"inspection": inspection,
1476
-	})
1494
+
1477 1495
 }
1478 1496
 
1479 1497
 func (this *NewDialysisApiController) GetInspection() {
@@ -1498,6 +1516,12 @@ func (this *NewDialysisApiController) GetInspection() {
1498 1516
 	orgid := adminInfo.Org.Id
1499 1517
 	fmt.Print("patient", patient)
1500 1518
 	fmt.Print("orgid", orgid)
1519
+
1520
+	//查询该机构是否存在
1521
+	//inspection, _ := service.GetInspectionById(patient.BloodId, startime, endtime, orgid)
1522
+	//if len(inspection) == 0 {
1523
+	//
1524
+	//}
1501 1525
 	inspection, total, err := service.GetInspection(patient.BloodId, startime, endtime, limit, page, orgid)
1502 1526
 	if err != nil {
1503 1527
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 22 - 0
models/inspection_models.go Zobrazit soubor

@@ -20,6 +20,28 @@ func (Inspection) TableName() string {
20 20
 	return "xt_inspection"
21 21
 }
22 22
 
23
+type Inspections struct {
24
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
25
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
26
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
27
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
28
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
29
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
30
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
31
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
32
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
33
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
34
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
35
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
36
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
37
+	RangeType    int64  `gorm:"column:range_type" json:"range_type" form:"range_type"`
38
+	RangeMin     string `gorm:"column:range_min" json:"range_min" form:"range_min"`
39
+	RangeMax     string `gorm:"column:range_max" json:"range_max" form:"range_max"`
40
+	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
41
+	RangeOptions string `gorm:"column:range_options" json:"range_options" form:"range_options"`
42
+	Unit         string `gorm:"column:unit" json:"unit" form:"unit"`
43
+}
44
+
23 45
 type InspectionReference struct {
24 46
 	ID               int64  `gorm:"column:id" json:"id" form:"id"`
25 47
 	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`

+ 38 - 4
service/patientmanage_service.go Zobrazit soubor

@@ -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