XMLWAN 3 år sedan
förälder
incheckning
af4fa3324e

+ 23 - 4
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go Visa fil

@@ -124,19 +124,37 @@ func (this *XcxApiController) GetLoginInfor() {
124 124
 	fmt.Println("c出啊大发阿方阿道夫发 阿方阿")
125 125
 	//mobile := this.GetString("mobile")
126 126
 	//fmt.Println(mobile)
127
-	role, err := service.GetLoginInfor("18923081560")
128
-
129
-	if role.ID == 0 {
127
+	info, err := service.GetMobilePatientInfo("18923081560")
128
+	if info.ID == 0 {
130 129
 		if err == nil {
131 130
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
132 131
 			return
133 132
 		}
134 133
 
135 134
 		this.ServeSuccessJSON(map[string]interface{}{
136
-			"role":    role,
137 135
 			"is_bind": false,
136
+			"info":    info,
138 137
 		})
139 138
 	} else {
139
+		role, errcode := service.GetLoginInfor("18923081560")
140
+		if errcode == gorm.ErrRecordNotFound {
141
+			role := models.XcxAdminUserRole{
142
+				PatientName: info.Name,
143
+				IdCardNo:    info.IdCardNo,
144
+				Mobile:      info.TellPhone,
145
+				Code:        "",
146
+				PatientId:   info.ID,
147
+				UserOrgId:   info.UserOrgId,
148
+				Status:      1,
149
+				Ctime:       time.Now().Unix(),
150
+				Mtime:       0,
151
+				Appid:       "",
152
+				Appsecret:   "",
153
+				SessionKey:  "",
154
+			}
155
+			err := service.CreateXcxAdminUser(role)
156
+			fmt.Println(err)
157
+		}
140 158
 		if err == nil {
141 159
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
142 160
 			return
@@ -145,6 +163,7 @@ func (this *XcxApiController) GetLoginInfor() {
145 163
 		this.ServeSuccessJSON(map[string]interface{}{
146 164
 			"role":    role,
147 165
 			"is_bind": true,
166
+			"info":    info,
148 167
 		})
149 168
 	}
150 169
 

+ 92 - 0
models/xcx_user_models.go Visa fil

@@ -20,3 +20,95 @@ func (XcxAdminUserRole) TableName() string {
20 20
 
21 21
 	return "xcx_admin_user_role"
22 22
 }
23
+
24
+type XcxPatients struct {
25
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
26
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
27
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
28
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
29
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
30
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
31
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
32
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
33
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
34
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
35
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
36
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
37
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
38
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
39
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
40
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
41
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
42
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
43
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
44
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
45
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
46
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
47
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
48
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
49
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
50
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
51
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
52
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
53
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
54
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
55
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
56
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
57
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
58
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
59
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
60
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
61
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
62
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
63
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
64
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
65
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
66
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
67
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
68
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
69
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
70
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
71
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
72
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
73
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
74
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
75
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
76
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
77
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
78
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
79
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
80
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains" form:"patient_complains"`
81
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history" form:"present_history"`
82
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
83
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
84
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse" form:"pulse"`
85
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory" form:"respiratory"`
86
+	Sbp                          int64   `gorm:"column:sbp" json:"sbp" form:"sbp"`
87
+	Dbp                          int64   `gorm:"column:dbp" json:"dbp" form:"dbp"`
88
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
89
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
90
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
91
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
92
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
93
+	Age                          int64   `gorm:"column:age" json:"age" form:"age"`
94
+	InfectiousNextRecordTime     int64   `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time" form:"infectious_next_record_time"`
95
+	IsInfectious                 int64   `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
96
+	RemindCycle                  int64   `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
97
+	ResponseResult               string  `gorm:"column:response_result" json:"response_result" form:"response_result"`
98
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
99
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
100
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
101
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
102
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
103
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
104
+	UserSysBeforeCount           int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
105
+	IsExcelExport                int64   `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
106
+	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
107
+	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
108
+	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
109
+}
110
+
111
+func (XcxPatients) TableName() string {
112
+
113
+	return "xt_patients"
114
+}

+ 14 - 0
service/xcx_mobile_api_service.go Visa fil

@@ -30,3 +30,17 @@ func GetLoginInfor(mobile string) (models.XcxAdminUserRole, error) {
30 30
 	err := UserReadDB().Model(&role).Where("mobile = ? and status = 1", mobile).Find(&role).Error
31 31
 	return role, err
32 32
 }
33
+
34
+func GetMobilePatientInfo(mobile string) (*models.XcxPatients, error) {
35
+
36
+	patients := models.XcxPatients{}
37
+	err := XTReadDB().Model(&patients).Where("tell_phone = ? and status = 1", mobile).Find(&patients).Error
38
+	if err == gorm.ErrRecordNotFound {
39
+		return nil, err
40
+	}
41
+
42
+	if err != nil {
43
+		return nil, err
44
+	}
45
+	return &patients, nil
46
+}