|
@@ -689,26 +689,56 @@ func ToSearchePatient(keyword string, orgId int64) (paitents []*models.XtPatient
|
689
|
689
|
}
|
690
|
690
|
|
691
|
691
|
func SearchallPatient(keyword string, orgid int64) (patients []*models.XtPatientsNew, err error) {
|
692
|
|
- likeKey := "%" + keyword + "%"
|
693
|
|
- err = XTReadDB().Where("name like ? or dialysis_no = ? and user_org_id = ?", likeKey, keyword, orgid).Find(&patients).Error
|
|
692
|
+ db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
|
|
693
|
+ if len(keyword) > 0 {
|
|
694
|
+ likeKey := "%" + keyword + "%"
|
|
695
|
+ db = db.Where("x.name LIKE ? OR x.dialysis_no LIKE ?", likeKey, likeKey)
|
|
696
|
+ }
|
|
697
|
+ if orgid > 0 {
|
|
698
|
+ db = db.Where("x.user_org_id = ?", orgid)
|
|
699
|
+ }
|
|
700
|
+ err = db.Select("x.id,x.user_org_id,x.user_id,x.avatar,x.patient_type,x.dialysis_no,x.admission_number,x.source,x.lapseto,x.partition_id,x.bed_id,x.name,x.alias,x.gender,x.marital_status,x.id_card_no,x.birthday,x.reimbursement_way_id,x.health_care_type,x.health_care_no,x.health_care_due_date,x.height,x.blood_type,x.rh,x.health_care_due_alert_date,x.education_level,x.profession,x.phone,x.home_telephone,x.relative_phone,x.relative_relations,x.home_address,x.work_unit,x.unit_address,x.children,x.receiving_date,x.is_hospital_first_dialysis,x.first_dialysis_date,x.first_dialysis_hospital,x.predialysis_condition,x.pre_hospital_dialysis_frequency,x.pre_hospital_dialysis_times,x.hospital_first_dialysis_date,x.induction_period,x.initial_dialysis,x.total_dialysis,x.attending_doctor_id,x.head_nurse_id,x.evaluate,x.diagnose,x.remark,x.registrars_id,x.registrars,x.qr_code,x.binding_state,x.patient_complains,x.present_history,x.past_history,x.temperature,x.pulse,x.respiratory,x.sbp,x.dbp,x.status,x.created_time,x.updated_time,x.nation,x.native_place,x.age,x.infectious_next_record_time,x.is_infectious,x.remind_cycle,x.response_result,x.is_open_remind,x.first_treatment_date,x.dialysis_age,x.expense_kind,x.tell_phone,x.contact_name,x.blood_patients,x.slow_patients,x.member_patients,x.ecommer_patients,x.blood_id,x.slow_id,x.member_id,x.member_fistdate,x.member_patienttype,x.member_treatement,x.equitment_id").Find(&patients).Error
|
694
|
701
|
return patients, err
|
695
|
702
|
}
|
696
|
703
|
|
697
|
704
|
func GetSearchallBlood(keyword string, orgid int64) (patients []*models.XtPatientsNew, err error) {
|
698
|
|
- likeKey := "%" + keyword + "%"
|
699
|
|
- err = XTReadDB().Where("name like ? or dialysis_no = ? and user_org_id = ? and blood_patients = 1", likeKey, keyword, orgid).Find(&patients).Error
|
|
705
|
+
|
|
706
|
+ db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1 and x.blood_patients = 1")
|
|
707
|
+ if len(keyword) > 0 {
|
|
708
|
+ likeKey := "%" + keyword + "%"
|
|
709
|
+ db = db.Where("x.name LIKE ? OR x.dialysis_no LIKE ?", likeKey, likeKey)
|
|
710
|
+ }
|
|
711
|
+ if orgid > 0 {
|
|
712
|
+ db = db.Where("x.user_org_id = ?", orgid)
|
|
713
|
+ }
|
|
714
|
+ err = db.Select("x.id,x.user_org_id,x.user_id,x.avatar,x.patient_type,x.dialysis_no,x.admission_number,x.source,x.lapseto,x.partition_id,x.bed_id,x.name,x.alias,x.gender,x.marital_status,x.id_card_no,x.birthday,x.reimbursement_way_id,x.health_care_type,x.health_care_no,x.health_care_due_date,x.height,x.blood_type,x.rh,x.health_care_due_alert_date,x.education_level,x.profession,x.phone,x.home_telephone,x.relative_phone,x.relative_relations,x.home_address,x.work_unit,x.unit_address,x.children,x.receiving_date,x.is_hospital_first_dialysis,x.first_dialysis_date,x.first_dialysis_hospital,x.predialysis_condition,x.pre_hospital_dialysis_frequency,x.pre_hospital_dialysis_times,x.hospital_first_dialysis_date,x.induction_period,x.initial_dialysis,x.total_dialysis,x.attending_doctor_id,x.head_nurse_id,x.evaluate,x.diagnose,x.remark,x.registrars_id,x.registrars,x.qr_code,x.binding_state,x.patient_complains,x.present_history,x.past_history,x.temperature,x.pulse,x.respiratory,x.sbp,x.dbp,x.status,x.created_time,x.updated_time,x.nation,x.native_place,x.age,x.infectious_next_record_time,x.is_infectious,x.remind_cycle,x.response_result,x.is_open_remind,x.first_treatment_date,x.dialysis_age,x.expense_kind,x.tell_phone,x.contact_name,x.blood_patients,x.slow_patients,x.member_patients,x.ecommer_patients,x.blood_id,x.slow_id,x.member_id,x.member_fistdate,x.member_patienttype,x.member_treatement,x.equitment_id").Find(&patients).Error
|
700
|
715
|
return patients, err
|
701
|
716
|
}
|
702
|
717
|
|
703
|
718
|
func GetSlowSearchePatient(keyword string, orgid int64) (patients []*models.XtPatientsNew, err error) {
|
704
|
|
- likeKey := "%" + keyword + "%"
|
705
|
|
- err = XTReadDB().Where("name like ? or dialysis_no = ? and user_org_id = ? and slow_patients = 1", likeKey, keyword, orgid).Find(&patients).Error
|
|
719
|
+
|
|
720
|
+ db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1 and x.slow_patients = 1")
|
|
721
|
+ if len(keyword) > 0 {
|
|
722
|
+ likeKey := "%" + keyword + "%"
|
|
723
|
+ db = db.Where("x.name LIKE ? OR x.dialysis_no LIKE ?", likeKey, likeKey)
|
|
724
|
+ }
|
|
725
|
+ if orgid > 0 {
|
|
726
|
+ db = db.Where("x.user_org_id = ?", orgid)
|
|
727
|
+ }
|
|
728
|
+ err = db.Select("x.id,x.user_org_id,x.user_id,x.avatar,x.patient_type,x.dialysis_no,x.admission_number,x.source,x.lapseto,x.partition_id,x.bed_id,x.name,x.alias,x.gender,x.marital_status,x.id_card_no,x.birthday,x.reimbursement_way_id,x.health_care_type,x.health_care_no,x.health_care_due_date,x.height,x.blood_type,x.rh,x.health_care_due_alert_date,x.education_level,x.profession,x.phone,x.home_telephone,x.relative_phone,x.relative_relations,x.home_address,x.work_unit,x.unit_address,x.children,x.receiving_date,x.is_hospital_first_dialysis,x.first_dialysis_date,x.first_dialysis_hospital,x.predialysis_condition,x.pre_hospital_dialysis_frequency,x.pre_hospital_dialysis_times,x.hospital_first_dialysis_date,x.induction_period,x.initial_dialysis,x.total_dialysis,x.attending_doctor_id,x.head_nurse_id,x.evaluate,x.diagnose,x.remark,x.registrars_id,x.registrars,x.qr_code,x.binding_state,x.patient_complains,x.present_history,x.past_history,x.temperature,x.pulse,x.respiratory,x.sbp,x.dbp,x.status,x.created_time,x.updated_time,x.nation,x.native_place,x.age,x.infectious_next_record_time,x.is_infectious,x.remind_cycle,x.response_result,x.is_open_remind,x.first_treatment_date,x.dialysis_age,x.expense_kind,x.tell_phone,x.contact_name,x.blood_patients,x.slow_patients,x.member_patients,x.ecommer_patients,x.blood_id,x.slow_id,x.member_id,x.member_fistdate,x.member_patienttype,x.member_treatement,x.equitment_id").Find(&patients).Error
|
706
|
729
|
return patients, err
|
707
|
730
|
}
|
708
|
731
|
|
709
|
732
|
func GetMemberSearchPatient(keyword string, orgid int64) (patients []*models.XtPatientsNew, err error) {
|
710
|
|
- likeKey := "%" + keyword + "%"
|
711
|
|
- err = XTReadDB().Where("name like ? or dialysis_no = ? and user_org_id = ? and member_patients = 1", likeKey, keyword, orgid).Find(&patients).Error
|
|
733
|
+ db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1 and x.member_patients = 1")
|
|
734
|
+ if len(keyword) > 0 {
|
|
735
|
+ likeKey := "%" + keyword + "%"
|
|
736
|
+ db = db.Where("x.name LIKE ? OR x.dialysis_no LIKE ?", likeKey, likeKey)
|
|
737
|
+ }
|
|
738
|
+ if orgid > 0 {
|
|
739
|
+ db = db.Where("x.user_org_id = ?", orgid)
|
|
740
|
+ }
|
|
741
|
+ err = db.Select("x.id,x.user_org_id,x.user_id,x.avatar,x.patient_type,x.dialysis_no,x.admission_number,x.source,x.lapseto,x.partition_id,x.bed_id,x.name,x.alias,x.gender,x.marital_status,x.id_card_no,x.birthday,x.reimbursement_way_id,x.health_care_type,x.health_care_no,x.health_care_due_date,x.height,x.blood_type,x.rh,x.health_care_due_alert_date,x.education_level,x.profession,x.phone,x.home_telephone,x.relative_phone,x.relative_relations,x.home_address,x.work_unit,x.unit_address,x.children,x.receiving_date,x.is_hospital_first_dialysis,x.first_dialysis_date,x.first_dialysis_hospital,x.predialysis_condition,x.pre_hospital_dialysis_frequency,x.pre_hospital_dialysis_times,x.hospital_first_dialysis_date,x.induction_period,x.initial_dialysis,x.total_dialysis,x.attending_doctor_id,x.head_nurse_id,x.evaluate,x.diagnose,x.remark,x.registrars_id,x.registrars,x.qr_code,x.binding_state,x.patient_complains,x.present_history,x.past_history,x.temperature,x.pulse,x.respiratory,x.sbp,x.dbp,x.status,x.created_time,x.updated_time,x.nation,x.native_place,x.age,x.infectious_next_record_time,x.is_infectious,x.remind_cycle,x.response_result,x.is_open_remind,x.first_treatment_date,x.dialysis_age,x.expense_kind,x.tell_phone,x.contact_name,x.blood_patients,x.slow_patients,x.member_patients,x.ecommer_patients,x.blood_id,x.slow_id,x.member_id,x.member_fistdate,x.member_patienttype,x.member_treatement,x.equitment_id").Find(&patients).Error
|
712
|
742
|
return patients, err
|
713
|
743
|
}
|
714
|
744
|
|
|
@@ -813,3 +843,35 @@ func DeleteManagement(groupid int64, orgid int64) error {
|
813
|
843
|
err := XTWriteDB().Model(models.DoctorAdvice{}).Where("groupno=? and user_org_id = ?", groupid, orgid).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
|
814
|
844
|
return err
|
815
|
845
|
}
|
|
846
|
+
|
|
847
|
+func GetNewPatient(id int64) (models.XtPatientsNew, error) {
|
|
848
|
+ patientsNew := models.XtPatientsNew{}
|
|
849
|
+ err := XTReadDB().Model(&patientsNew).Where("id=?", id).Find(&patientsNew).Error
|
|
850
|
+ return patientsNew, err
|
|
851
|
+}
|
|
852
|
+
|
|
853
|
+func UpdatedPatient(patients models.Patients, id int64) error {
|
|
854
|
+
|
|
855
|
+ err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious}).Error
|
|
856
|
+
|
|
857
|
+ return err
|
|
858
|
+}
|
|
859
|
+
|
|
860
|
+func UpdateXtPatientNew(patients models.XtPatientsNew, id int64) error {
|
|
861
|
+
|
|
862
|
+ err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious}).Error
|
|
863
|
+
|
|
864
|
+ return err
|
|
865
|
+}
|
|
866
|
+
|
|
867
|
+func UpdateCustomer(cdmpatient models.CdmPatients, id int64) error {
|
|
868
|
+
|
|
869
|
+ err := PatientWriteDB().Model(&cdmpatient).Where("id=?", id).Update(map[string]interface{}{"name": cdmpatient.Name, "phone": cdmpatient.Phone, "gender": cdmpatient.Gender, "birthday": cdmpatient.Birthday, "diagnose": cdmpatient.Diagnose, "source": cdmpatient.Source, "avatar": cdmpatient.Avatar, "id_card_no": cdmpatient.IdCardNo, "updated_time": cdmpatient.UpdatedTime}).Error
|
|
870
|
+ return err
|
|
871
|
+}
|
|
872
|
+
|
|
873
|
+func UpdatedCustomer(customer models.SgjUserCustomer, id int64) error {
|
|
874
|
+
|
|
875
|
+ err := UserWriteDB().Model(&customer).Where("id = ?", id).Update(map[string]interface{}{"name": customer.Name, "mobile": customer.Mobile, "gender": customer.Gender, "birthday": customer.Birthday, "ill_date": customer.IllDate, "avatar": customer.Avatar, "illness_id": customer.IllnessId, "treat_type": customer.TreatType}).Error
|
|
876
|
+ return err
|
|
877
|
+}
|