|
@@ -712,7 +712,10 @@ func (this *HisProjectApiController) SaveHisPatient() {
|
712
|
712
|
timeLayout := "2006-01-02"
|
713
|
713
|
loc, _ := time.LoadLocation("Local")
|
714
|
714
|
age, _ := this.GetInt64("age")
|
715
|
|
- birthday := this.GetString("birthDay")
|
|
715
|
+ birthday := this.GetString("birthday")
|
|
716
|
+
|
|
717
|
+ patient_id, _ := this.GetInt64("id")
|
|
718
|
+
|
716
|
719
|
birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
|
717
|
720
|
birthUnix := birthdays.Unix()
|
718
|
721
|
certificates, _ := this.GetInt64("certificates")
|
|
@@ -722,19 +725,19 @@ func (this *HisProjectApiController) SaveHisPatient() {
|
722
|
725
|
cost_float, _ := strconv.ParseFloat(costs, 64)
|
723
|
726
|
department, _ := this.GetInt64("department")
|
724
|
727
|
doctor, _ := this.GetInt64("doctor")
|
725
|
|
- medicalcare, _ := this.GetInt64("medicalCare")
|
726
|
|
- idcard := this.GetString("idCard")
|
727
|
|
- medicalExpenses, _ := this.GetInt64("medicalExpenses")
|
|
728
|
+ medicalcare, _ := this.GetInt64("medical_care")
|
|
729
|
+ idcard := this.GetString("id_card")
|
|
730
|
+ medicalExpenses, _ := this.GetInt64("medical_expenses")
|
728
|
731
|
medicalExpense := strconv.FormatInt(medicalExpenses, 10)
|
729
|
732
|
medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
|
730
|
|
- medicalinsurancecard := this.GetString("medicalInsuranceCard")
|
|
733
|
+ medicalinsurancecard := this.GetString("medical_insurance_card")
|
731
|
734
|
|
732
|
735
|
name := this.GetString("name")
|
733
|
736
|
register, _ := this.GetInt64("register")
|
734
|
|
- registrationfee, _ := this.GetInt64("registrationFee")
|
|
737
|
+ registrationfee, _ := this.GetInt64("registration_fee")
|
735
|
738
|
registrationfees := strconv.FormatInt(registrationfee, 10)
|
736
|
739
|
registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
|
737
|
|
- settlementValue, _ := this.GetInt64("settlementValue")
|
|
740
|
+ settlementValue, _ := this.GetInt64("settlement_value")
|
738
|
741
|
sex, _ := this.GetInt64("sex")
|
739
|
742
|
total, _ := this.GetInt64("total")
|
740
|
743
|
totals := strconv.FormatInt(total, 10)
|
|
@@ -748,10 +751,44 @@ func (this *HisProjectApiController) SaveHisPatient() {
|
748
|
751
|
social_type, _ := this.GetInt64("social_type")
|
749
|
752
|
id_card_type, _ := this.GetInt64("id_card_type")
|
750
|
753
|
|
751
|
|
- bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
|
752
|
|
- if errcode == gorm.ErrRecordNotFound {
|
753
|
|
- patient := models.XtHisPatient{
|
754
|
|
- Age: age,
|
|
754
|
+ diagnosis_id, _ := this.GetInt64("diagnosis")
|
|
755
|
+ sick_type, _ := this.GetInt64("sick_type")
|
|
756
|
+ reg_type := this.GetString("p_type")
|
|
757
|
+
|
|
758
|
+ tempPatient, _ := service.GetPatientByIDCardAndName(idcard, adminUserInfo.CurrentOrgId, name)
|
|
759
|
+ if tempPatient.ID == 0 {
|
|
760
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoBloodPatientException)
|
|
761
|
+ return
|
|
762
|
+ }
|
|
763
|
+
|
|
764
|
+ var patient service.Patients
|
|
765
|
+ if patient_id == 0 {
|
|
766
|
+ patient, _ = service.GetPatientByIDCard(idcard, adminUserInfo.CurrentOrgId)
|
|
767
|
+
|
|
768
|
+ } else {
|
|
769
|
+ patient, _ = service.GetPatientByIDTwo(adminUserInfo.CurrentOrgId, patient_id)
|
|
770
|
+
|
|
771
|
+ }
|
|
772
|
+
|
|
773
|
+ if patient.ID == 0 {
|
|
774
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
|
775
|
+ return
|
|
776
|
+ }
|
|
777
|
+ if len(patient.IdCardNo) == 0 {
|
|
778
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
|
|
779
|
+ return
|
|
780
|
+ }
|
|
781
|
+
|
|
782
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
783
|
+ timeArr := strings.Split(timeStr, "-")
|
|
784
|
+ var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(patient.ID, 10)
|
|
785
|
+
|
|
786
|
+ his, err := service.GetHisPatientInfo(adminUserInfo.CurrentOrgId, patient.ID, recordDate.Unix())
|
|
787
|
+
|
|
788
|
+ var hisPatient models.XtHisPatient
|
|
789
|
+ if err == gorm.ErrRecordNotFound || his.ID == 0 {
|
|
790
|
+ hisPatient = models.XtHisPatient{
|
|
791
|
+ PatientId: patient_id,
|
755
|
792
|
Birthday: birthUnix,
|
756
|
793
|
IdType: certificates,
|
757
|
794
|
CostOfProduction: cost_float,
|
|
@@ -764,6 +801,8 @@ func (this *HisProjectApiController) SaveHisPatient() {
|
764
|
801
|
TreatmentCost: medicalExpense_float,
|
765
|
802
|
MedicalInsuranceNumber: medicalinsurancecard,
|
766
|
803
|
Name: name,
|
|
804
|
+ Age: age,
|
|
805
|
+ Number: str,
|
767
|
806
|
RegisterType: register,
|
768
|
807
|
RegisterCost: registrationfees_float,
|
769
|
808
|
BalanceAccountsType: settlementValue,
|
|
@@ -777,83 +816,19 @@ func (this *HisProjectApiController) SaveHisPatient() {
|
777
|
816
|
Phone: phone,
|
778
|
817
|
SocialType: social_type,
|
779
|
818
|
IdCardType: id_card_type,
|
|
819
|
+ Diagnosis: diagnosis_id,
|
|
820
|
+ PType: reg_type,
|
|
821
|
+ SickType: sick_type,
|
780
|
822
|
}
|
781
|
|
-
|
782
|
|
- err := service.CreateHisPatient(&patient)
|
783
|
|
- lastPatient, err := service.GetLastPatient(orgId)
|
784
|
|
- timeStr := time.Now().Format("2006-01-02")
|
785
|
|
- timeArr := strings.Split(timeStr, "-")
|
786
|
|
- var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
|
787
|
|
-
|
788
|
|
- hisPatient := models.HisPatient{
|
789
|
|
- Number: str,
|
790
|
|
- }
|
791
|
|
- err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
|
792
|
|
- fmt.Println("er", err)
|
793
|
|
- if err != nil {
|
794
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
|
795
|
|
- return
|
796
|
|
- }
|
|
823
|
+ service.CreateHisPatient(&hisPatient)
|
797
|
824
|
this.ServeSuccessJSON(map[string]interface{}{
|
798
|
|
- "patient": patient,
|
|
825
|
+ "his_info": hisPatient,
|
799
|
826
|
})
|
800
|
|
- } else if errcode == nil {
|
801
|
|
- patient := models.XtHisPatient{
|
802
|
|
- Age: age,
|
803
|
|
- Birthday: birthUnix,
|
804
|
|
- IdType: certificates,
|
805
|
|
- CostOfProduction: cost_float,
|
806
|
|
- Departments: department,
|
807
|
|
- AdminUserId: doctor,
|
808
|
|
- MedicalTreatmentType: medicalcare,
|
809
|
|
- IdCardNo: idcard,
|
810
|
|
- IsNeedCostOfProduction: cost_checked,
|
811
|
|
- TreatmentCost: medicalExpense_float,
|
812
|
|
- MedicalInsuranceNumber: medicalinsurancecard,
|
813
|
|
- Name: name,
|
814
|
|
- RegisterType: register,
|
815
|
|
- RegisterCost: registrationfees_float,
|
816
|
|
- BalanceAccountsType: settlementValue,
|
817
|
|
- Gender: sex,
|
818
|
|
- Total: totals_float,
|
819
|
|
- UserOrgId: orgId,
|
820
|
|
- PatientId: bloodPatient.ID,
|
821
|
|
- Ctime: time.Now().Unix(),
|
822
|
|
- Phone: phone,
|
823
|
|
- SocialType: social_type,
|
824
|
|
- IdCardType: id_card_type,
|
825
|
|
- RecordDate: nowtime,
|
826
|
|
- Status: 1,
|
827
|
|
- IsReturn: 1,
|
828
|
|
- }
|
829
|
|
-
|
830
|
|
- //查询今日没有退号的患者是否已挂号
|
831
|
|
- _, errcode := service.GetTodayHisPatient(nowtime, bloodPatient.ID, adminUserInfo.CurrentOrgId)
|
832
|
|
- if errcode == gorm.ErrRecordNotFound {
|
833
|
|
- err := service.CreateHisPatient(&patient)
|
834
|
|
- lastPatient, err := service.GetLastPatient(orgId)
|
835
|
|
- timeStr := time.Now().Format("2006-01-02")
|
836
|
|
- timeArr := strings.Split(timeStr, "-")
|
837
|
|
- var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
|
838
|
|
-
|
839
|
|
- hisPatient := models.HisPatient{
|
840
|
|
- Number: str,
|
841
|
|
- }
|
842
|
|
- err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
|
843
|
|
- //fmt.Println("er", err)
|
844
|
|
- if err != nil {
|
845
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
|
846
|
|
- return
|
847
|
|
- }
|
848
|
|
- this.ServeSuccessJSON(map[string]interface{}{
|
849
|
|
- "patient": patient,
|
850
|
|
- })
|
851
|
|
- } else if errcode == nil {
|
852
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
|
853
|
|
- return
|
854
|
|
- }
|
855
|
|
-
|
|
827
|
+ } else {
|
|
828
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisRegisterException)
|
|
829
|
+ return
|
856
|
830
|
}
|
|
831
|
+
|
857
|
832
|
}
|
858
|
833
|
|
859
|
834
|
func (this *HisProjectApiController) GetAllProjectTeam() {
|