|
@@ -645,9 +645,11 @@ func (c *InspectionApiController) EditPatientInspection() {
|
645
|
645
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
|
646
|
646
|
return
|
647
|
647
|
}
|
648
|
|
- inspMap := make(map[int64]*models.Inspection)
|
|
648
|
+ inspMap := make(map[string]models.Inspection)
|
649
|
649
|
for _, item := range insp {
|
650
|
|
- inspMap[item.ID] = item
|
|
650
|
+ fmt.Println(item.ID)
|
|
651
|
+ a := strconv.FormatInt(item.ProjectId, 10) + "-" + strconv.FormatInt(item.ItemId, 10)
|
|
652
|
+ inspMap[a] = item
|
651
|
653
|
}
|
652
|
654
|
|
653
|
655
|
addinsp := make([]models.Inspection, 0)
|
|
@@ -657,32 +659,40 @@ func (c *InspectionApiController) EditPatientInspection() {
|
657
|
659
|
|
658
|
660
|
for _, item := range from.FormItem {
|
659
|
661
|
fmt.Println(item.ID)
|
660
|
|
- if item.ID == 0 {
|
661
|
|
- var inspection models.Inspection
|
662
|
|
- inspection.OrgId = adminUserInfo.CurrentOrgId
|
663
|
|
- inspection.PatientId = patient
|
664
|
|
- inspection.ProjectId = from.ProjectId
|
665
|
|
- inspection.ItemId = item.ItemId
|
666
|
|
- inspection.ItemName = item.ItemName
|
667
|
|
- inspection.ProjectName = item.ProjectName
|
668
|
|
- inspection.InspectType = item.RangeType
|
669
|
|
- inspection.InspectValue = item.Value
|
670
|
|
- inspection.InspectDate = date
|
671
|
|
- inspection.Status = 1
|
672
|
|
- inspection.CreatedTime = time.Now().Unix()
|
673
|
|
- inspection.UpdatedTime = time.Now().Unix()
|
674
|
|
- addinsp = append(addinsp, inspection)
|
675
|
|
- } else {
|
676
|
|
- inspection := *inspMap[item.ID]
|
677
|
|
- inspection.InspectValue = item.Value
|
678
|
|
- inspection.InspectDate = date
|
679
|
|
- inspection.UpdatedTime = time.Now().Unix()
|
680
|
|
- editinsp = append(editinsp, inspection)
|
681
|
|
- noMap = append(noMap, item.ID)
|
682
|
|
- }
|
683
|
662
|
|
684
|
|
- }
|
|
663
|
+ ref, _ := service.GetInspectionReferenceById(item.ItemId)
|
|
664
|
+ //if item.ID == 0 {
|
|
665
|
+ // var inspection models.Inspection
|
|
666
|
+ // inspection.OrgId = adminUserInfo.CurrentOrgId
|
|
667
|
+ // inspection.PatientId = patient
|
|
668
|
+ // inspection.ProjectId = from.ProjectId
|
|
669
|
+ // inspection.ItemId = item.ItemId
|
|
670
|
+ // inspection.ItemName = item.ItemName
|
|
671
|
+ // inspection.ProjectName = item.ProjectName
|
|
672
|
+ // inspection.InspectType = item.RangeType
|
|
673
|
+ // inspection.InspectValue = item.Value
|
|
674
|
+ // inspection.InspectDate = date
|
|
675
|
+ // inspection.Status = 1
|
|
676
|
+ // inspection.CreatedTime = time.Now().Unix()
|
|
677
|
+ // inspection.UpdatedTime = time.Now().Unix()
|
|
678
|
+ // addinsp = append(addinsp, inspection)
|
|
679
|
+ //} else {
|
|
680
|
+ //fmt.Println(item.ID)
|
|
681
|
+ a := strconv.FormatInt(item.ProjectId, 10) + "-" + strconv.FormatInt(ref.ItemId, 10)
|
|
682
|
+ fmt.Println(a)
|
|
683
|
+ fmt.Println(inspMap)
|
|
684
|
+
|
|
685
|
+ inspection := inspMap[a]
|
|
686
|
+ inspection.InspectValue = item.Value
|
|
687
|
+ inspection.InspectDate = date
|
|
688
|
+ inspection.UpdatedTime = time.Now().Unix()
|
|
689
|
+ editinsp = append(editinsp, inspection)
|
|
690
|
+ noMap = append(noMap, item.ID)
|
|
691
|
+ //}
|
685
|
692
|
|
|
693
|
+ }
|
|
694
|
+ //fmt.Println(editinsp)
|
|
695
|
+ //return
|
686
|
696
|
err = service.EditPatientInspection(addinsp, editinsp, noMap, patient, adminUserInfo.CurrentOrgId, from.ProjectId, date)
|
687
|
697
|
if err != nil {
|
688
|
698
|
utils.ErrorLog("%v", err)
|
|
@@ -894,7 +904,7 @@ func (c *InspectionApiController) GetAllPatientInspection() {
|
894
|
904
|
|
895
|
905
|
switch upload_type {
|
896
|
906
|
case 1:
|
897
|
|
- var inspections []*models.Inspection
|
|
907
|
+ var inspections []models.Inspection
|
898
|
908
|
|
899
|
909
|
for _, item := range ids {
|
900
|
910
|
id, _ := strconv.ParseInt(item, 10, 64)
|
|
@@ -933,7 +943,7 @@ func (c *InspectionApiController) GetAllPatientInspection() {
|
933
|
943
|
|
934
|
944
|
break
|
935
|
945
|
case 3:
|
936
|
|
- var inspections []*models.Inspection
|
|
946
|
+ var inspections []models.Inspection
|
937
|
947
|
|
938
|
948
|
for _, item := range ids {
|
939
|
949
|
id, _ := strconv.ParseInt(item, 10, 64)
|
|
@@ -992,7 +1002,7 @@ func (c *InspectionApiController) GetAllPatientInspection() {
|
992
|
1002
|
|
993
|
1003
|
break
|
994
|
1004
|
case 6:
|
995
|
|
- var inspections []*models.Inspection
|
|
1005
|
+ var inspections []models.Inspection
|
996
|
1006
|
|
997
|
1007
|
for _, item := range ids {
|
998
|
1008
|
id, _ := strconv.ParseInt(item, 10, 64)
|
|
@@ -1015,7 +1025,7 @@ func (c *InspectionApiController) GetAllPatientInspection() {
|
1015
|
1025
|
|
1016
|
1026
|
break
|
1017
|
1027
|
case 7:
|
1018
|
|
- var inspections []*models.Inspection
|
|
1028
|
+ var inspections []models.Inspection
|
1019
|
1029
|
|
1020
|
1030
|
for _, item := range ids {
|
1021
|
1031
|
id, _ := strconv.ParseInt(item, 10, 64)
|