|
@@ -146,23 +146,25 @@ func (CmLisitems) TableName() string {
|
146
|
146
|
}
|
147
|
147
|
|
148
|
148
|
type HisLabelPrintInfo struct {
|
149
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
150
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
151
|
|
- Number string `gorm:"column:number" json:"number" form:"number"`
|
152
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
153
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
154
|
|
- DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
|
155
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
156
|
|
- ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
|
157
|
|
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
158
|
|
- IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
|
159
|
|
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
160
|
|
- ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
|
161
|
|
- PProjectId int64 `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
|
162
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
163
|
|
- DoctorName string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
|
164
|
|
- PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
|
165
|
|
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
|
|
149
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
150
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
151
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
152
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
153
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
154
|
+ DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
|
|
155
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
156
|
+ ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
|
|
157
|
+ ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
158
|
+ IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
|
|
159
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
160
|
+ ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
|
|
161
|
+ PProjectId int64 `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
|
|
162
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
163
|
+ DoctorName string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
|
|
164
|
+ PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
|
|
165
|
+ FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
|
|
166
|
+ Phone string `gorm:"column:phone" json:"phone" form:"phone"`
|
|
167
|
+
|
166
|
168
|
PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
|
167
|
169
|
HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:PProjectId" json:"project"`
|
168
|
170
|
Patient models.Patients `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patient"`
|
|
@@ -216,14 +218,15 @@ func (CmResult) TableName() string {
|
216
|
218
|
}
|
217
|
219
|
|
218
|
220
|
type LisSyncResultStatusInfo struct {
|
219
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
220
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
221
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
222
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
223
|
|
- LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
|
224
|
|
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
225
|
|
- IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
|
226
|
|
- ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
|
|
221
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
222
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
223
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
224
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
225
|
+ LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
|
|
226
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
227
|
+ IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
|
|
228
|
+ ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
|
|
229
|
+ GpSyncEndDate string `gorm:"column:gp_sync_end_date" json:"gp_sync_end_date" form:"gp_sync_end_date"`
|
227
|
230
|
}
|
228
|
231
|
|
229
|
232
|
func (LisSyncResultStatusInfo) TableName() string {
|
|
@@ -293,7 +296,7 @@ func GetLisResultDataByRecord(org_id int64) (list []*CmResult, err error) {
|
293
|
296
|
return
|
294
|
297
|
}
|
295
|
298
|
|
296
|
|
-//插入中间件逻辑
|
|
299
|
+// 插入中间件逻辑
|
297
|
300
|
func GetDataInsertDB(org_id int64) {
|
298
|
301
|
record, _ := GetLastSyncRecord(org_id)
|
299
|
302
|
if record.ID == 0 {
|
|
@@ -540,7 +543,7 @@ func GetDataInsertDB(org_id int64) {
|
540
|
543
|
}
|
541
|
544
|
}
|
542
|
545
|
|
543
|
|
-//获取lis返回检验检查结果数据
|
|
546
|
+// 获取lis返回检验检查结果数据
|
544
|
547
|
func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
545
|
548
|
record, _ := GetLastSyncResultRecord(org_id)
|
546
|
549
|
if record.ID == 0 {
|
|
@@ -551,8 +554,9 @@ func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
551
|
554
|
//插入到系统检验检查数据
|
552
|
555
|
for _, item := range list {
|
553
|
556
|
project_id := int64(0)
|
|
557
|
+ xt_project_id := int64(0)
|
554
|
558
|
if len(item.Barcode) > 0 {
|
555
|
|
- project_id, _ = GetBljhProjectID(org_id, item.Groupname)
|
|
559
|
+ project_id, xt_project_id, _ = GetBljhProjectID(org_id, item.Groupname)
|
556
|
560
|
} else {
|
557
|
561
|
continue
|
558
|
562
|
}
|
|
@@ -565,7 +569,7 @@ func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
565
|
569
|
continue
|
566
|
570
|
}
|
567
|
571
|
|
568
|
|
- item_id, _ := GetBlItemID(org_id, item.Groupname, item.Itemname, project_id)
|
|
572
|
+ item_id, sys_item_id, _ := GetBlItemID(org_id, item.Groupname, item.Itemname, project_id)
|
569
|
573
|
|
570
|
574
|
tx := writeMiddleDb.Begin()
|
571
|
575
|
var inspection models.MiddleInspection
|
|
@@ -590,7 +594,6 @@ func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
590
|
594
|
var ItemType int
|
591
|
595
|
if strings.Contains(item.Refrange, "-") {
|
592
|
596
|
ItemType = 1
|
593
|
|
-
|
594
|
597
|
} else {
|
595
|
598
|
ItemType = 2
|
596
|
599
|
|
|
@@ -604,60 +607,123 @@ func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
604
|
607
|
RangeOptions = item.Refrange
|
605
|
608
|
}
|
606
|
609
|
|
607
|
|
- err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
608
|
|
- if inspection_reference.ID > 0 {
|
609
|
|
- ItemType = inspection_reference.RangeType
|
610
|
|
- }
|
611
|
|
- if total <= 0 {
|
612
|
|
- inspection_reference.OrgId = org_id
|
613
|
|
- inspection_reference.ProjectName = item.Groupname
|
614
|
|
- inspection_reference.Project = item.Groupname
|
615
|
|
- inspection_reference.ProjectId = project_id
|
616
|
|
- inspection_reference.ItemName = item.Itemname
|
617
|
|
- inspection_reference.ItemNameAddition = item.Barcode
|
618
|
|
- inspection_reference.ItemId = item_id
|
619
|
|
- inspection_reference.RangeType = ItemType
|
620
|
|
- inspection_reference.RangeMin = RangeMin
|
621
|
|
- inspection_reference.RangeMax = RangeMax
|
622
|
|
- inspection_reference.RangeOptions = RangeOptions
|
623
|
|
- inspection_reference.Unit = item.Unit
|
624
|
|
- inspection_reference.Status = 1
|
625
|
|
- inspection_reference.CreatedTime = time.Now().Unix()
|
626
|
|
- inspection_reference.UpdatedTime = time.Now().Unix()
|
627
|
|
- inspection_reference.InspectDate = inspect_date
|
628
|
|
- inspection_reference.UTime = inspect_date
|
629
|
|
- err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
630
|
|
- if err != nil {
|
631
|
|
- tx.Rollback()
|
|
610
|
+ if xt_project_id > 0 && sys_item_id > 0 {
|
|
611
|
+ err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and xt_project_id = ? and xt_item_id = ? and status = 1", org_id, xt_project_id, sys_item_id).Find(&inspection_reference).Count(&total).Error
|
|
612
|
+ if inspection_reference.ID > 0 {
|
|
613
|
+ ItemType = inspection_reference.RangeType
|
|
614
|
+ }
|
|
615
|
+ if total <= 0 {
|
|
616
|
+ inspection_reference.OrgId = org_id
|
|
617
|
+ inspection_reference.ProjectName = item.Groupname
|
|
618
|
+ inspection_reference.Project = item.Groupname
|
|
619
|
+ inspection_reference.ProjectId = project_id
|
|
620
|
+ inspection_reference.ItemName = item.Itemname
|
|
621
|
+ inspection_reference.ItemNameAddition = item.Barcode
|
|
622
|
+ inspection_reference.ItemId = item_id
|
|
623
|
+ inspection_reference.RangeType = ItemType
|
|
624
|
+ inspection_reference.RangeMin = RangeMin
|
|
625
|
+ inspection_reference.RangeMax = RangeMax
|
|
626
|
+ inspection_reference.RangeOptions = RangeOptions
|
|
627
|
+ inspection_reference.Unit = item.Unit
|
|
628
|
+ inspection_reference.Status = 1
|
|
629
|
+ inspection_reference.CreatedTime = time.Now().Unix()
|
|
630
|
+ inspection_reference.UpdatedTime = time.Now().Unix()
|
|
631
|
+ inspection_reference.InspectDate = inspect_date
|
|
632
|
+ inspection_reference.UTime = inspect_date
|
|
633
|
+ err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
|
634
|
+ if err != nil {
|
|
635
|
+ tx.Rollback()
|
|
636
|
+ }
|
632
|
637
|
}
|
633
|
|
- }
|
634
|
638
|
|
635
|
|
- var itotal int
|
636
|
|
- err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
637
|
|
- if itotal <= 0 {
|
638
|
|
- //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
639
|
|
- //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
640
|
|
- inspection.PatientId = printInfo.PatientId
|
641
|
|
- inspection.OrgId = org_id
|
642
|
|
- inspection.ProjectId = project_id
|
643
|
|
- inspection.ItemName = inspection_reference.ItemName
|
644
|
|
- inspection.ProjectName = inspection_reference.ProjectName
|
645
|
|
- inspection.InspectType = ItemType
|
646
|
|
- inspection.ItemId = item_id
|
647
|
|
- inspection.InspectValue = item.Result
|
648
|
|
- inspection.InspectDate = inspect_date
|
649
|
|
- inspection.RecordDate = record_date.Unix()
|
650
|
|
- inspection.Status = 1
|
651
|
|
- inspection.CreatedTime = time.Now().Unix()
|
652
|
|
- inspection.UpdatedTime = time.Now().Unix()
|
653
|
|
- inspection.UTime = inspect_date
|
654
|
|
- inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
655
|
|
- err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
656
|
|
- if err != nil {
|
657
|
|
- tx.Rollback()
|
|
639
|
+ } else {
|
|
640
|
+ err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
|
641
|
+ if inspection_reference.ID > 0 {
|
|
642
|
+ ItemType = inspection_reference.RangeType
|
658
|
643
|
}
|
|
644
|
+ if total <= 0 {
|
|
645
|
+ inspection_reference.OrgId = org_id
|
|
646
|
+ inspection_reference.ProjectName = item.Groupname
|
|
647
|
+ inspection_reference.Project = item.Groupname
|
|
648
|
+ inspection_reference.ProjectId = project_id
|
|
649
|
+ inspection_reference.ItemName = item.Itemname
|
|
650
|
+ inspection_reference.ItemNameAddition = item.Barcode
|
|
651
|
+ inspection_reference.ItemId = item_id
|
|
652
|
+ inspection_reference.RangeType = ItemType
|
|
653
|
+ inspection_reference.RangeMin = RangeMin
|
|
654
|
+ inspection_reference.RangeMax = RangeMax
|
|
655
|
+ inspection_reference.RangeOptions = RangeOptions
|
|
656
|
+ inspection_reference.Unit = item.Unit
|
|
657
|
+ inspection_reference.Status = 1
|
|
658
|
+ inspection_reference.CreatedTime = time.Now().Unix()
|
|
659
|
+ inspection_reference.UpdatedTime = time.Now().Unix()
|
|
660
|
+ inspection_reference.InspectDate = inspect_date
|
|
661
|
+ inspection_reference.UTime = inspect_date
|
|
662
|
+ err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
|
663
|
+ if err != nil {
|
|
664
|
+ tx.Rollback()
|
|
665
|
+ }
|
|
666
|
+ }
|
|
667
|
+
|
659
|
668
|
}
|
660
|
669
|
|
|
670
|
+ if xt_project_id > 0 && sys_item_id > 0 {
|
|
671
|
+ var itotal int
|
|
672
|
+ err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and xt_project_id = ? and xt_item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, xt_project_id, sys_item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
673
|
+ if itotal <= 0 {
|
|
674
|
+ //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
|
675
|
+ //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
|
676
|
+ inspection.PatientId = printInfo.PatientId
|
|
677
|
+ inspection.OrgId = org_id
|
|
678
|
+ inspection.ProjectId = project_id
|
|
679
|
+ inspection.ItemName = inspection_reference.ItemName
|
|
680
|
+ inspection.ProjectName = inspection_reference.ProjectName
|
|
681
|
+ inspection.InspectType = ItemType
|
|
682
|
+ inspection.ItemId = item_id
|
|
683
|
+
|
|
684
|
+ inspection.InspectValue = item.Result
|
|
685
|
+ inspection.InspectDate = inspect_date
|
|
686
|
+ inspection.RecordDate = record_date.Unix()
|
|
687
|
+ inspection.Status = 1
|
|
688
|
+ inspection.CreatedTime = time.Now().Unix()
|
|
689
|
+ inspection.UpdatedTime = time.Now().Unix()
|
|
690
|
+ inspection.UTime = inspect_date
|
|
691
|
+ inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
692
|
+ err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
|
693
|
+ if err != nil {
|
|
694
|
+ tx.Rollback()
|
|
695
|
+ }
|
|
696
|
+ }
|
|
697
|
+
|
|
698
|
+ } else {
|
|
699
|
+ var itotal int
|
|
700
|
+ err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
701
|
+ if itotal <= 0 {
|
|
702
|
+ //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
|
703
|
+ //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
|
704
|
+ inspection.PatientId = printInfo.PatientId
|
|
705
|
+ inspection.OrgId = org_id
|
|
706
|
+ inspection.ProjectId = project_id
|
|
707
|
+ inspection.ItemName = inspection_reference.ItemName
|
|
708
|
+ inspection.ProjectName = inspection_reference.ProjectName
|
|
709
|
+ inspection.InspectType = ItemType
|
|
710
|
+ inspection.ItemId = item_id
|
|
711
|
+
|
|
712
|
+ inspection.InspectValue = item.Result
|
|
713
|
+ inspection.InspectDate = inspect_date
|
|
714
|
+ inspection.RecordDate = record_date.Unix()
|
|
715
|
+ inspection.Status = 1
|
|
716
|
+ inspection.CreatedTime = time.Now().Unix()
|
|
717
|
+ inspection.UpdatedTime = time.Now().Unix()
|
|
718
|
+ inspection.UTime = inspect_date
|
|
719
|
+ inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
720
|
+ err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
|
721
|
+ if err != nil {
|
|
722
|
+ tx.Rollback()
|
|
723
|
+ }
|
|
724
|
+ }
|
|
725
|
+
|
|
726
|
+ }
|
661
|
727
|
tx.Commit()
|
662
|
728
|
|
663
|
729
|
}
|
|
@@ -686,13 +752,15 @@ func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
686
|
752
|
//插入到系统检验检查数据
|
687
|
753
|
for _, item := range list {
|
688
|
754
|
project_id := int64(0)
|
|
755
|
+ sys_project_id := int64(0)
|
|
756
|
+
|
689
|
757
|
if len(item.Barcode) > 0 {
|
690
|
|
- project_id, _ = GetBljhProjectID(org_id, item.Groupname)
|
|
758
|
+ project_id, sys_project_id, _ = GetBljhProjectID(org_id, item.Groupname)
|
691
|
759
|
} else {
|
692
|
760
|
continue
|
693
|
761
|
}
|
694
|
762
|
printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
|
695
|
|
- item_id, _ := GetBlItemID(org_id, item.Groupname, item.Itemname, project_id)
|
|
763
|
+ item_id, sys_item_id, _ := GetBlItemID(org_id, item.Groupname, item.Itemname, project_id)
|
696
|
764
|
|
697
|
765
|
tx := writeMiddleDb.Begin()
|
698
|
766
|
var inspection models.MiddleInspection
|
|
@@ -731,7 +799,7 @@ func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
731
|
799
|
RangeOptions = item.Refrange
|
732
|
800
|
}
|
733
|
801
|
|
734
|
|
- err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
|
802
|
+ err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and xt_project_id = ? and xt_item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
735
|
803
|
if inspection_reference.ID > 0 {
|
736
|
804
|
ItemType = inspection_reference.RangeType
|
737
|
805
|
}
|
|
@@ -783,6 +851,64 @@ func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
783
|
851
|
}
|
784
|
852
|
}
|
785
|
853
|
|
|
854
|
+ if sys_project_id > 0 && sys_item_id > 0 {
|
|
855
|
+ var itotal int
|
|
856
|
+ err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and xt_project_id = ? and xt_item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, sys_item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
857
|
+ if itotal <= 0 {
|
|
858
|
+ //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
|
859
|
+ //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
|
860
|
+ inspection.PatientId = printInfo.PatientId
|
|
861
|
+ inspection.OrgId = org_id
|
|
862
|
+ inspection.ProjectId = project_id
|
|
863
|
+ inspection.ItemName = inspection_reference.ItemName
|
|
864
|
+ inspection.ProjectName = inspection_reference.ProjectName
|
|
865
|
+ inspection.InspectType = ItemType
|
|
866
|
+ inspection.ItemId = item_id
|
|
867
|
+
|
|
868
|
+ inspection.InspectValue = item.Result
|
|
869
|
+ inspection.InspectDate = inspect_date
|
|
870
|
+ inspection.RecordDate = record_date.Unix()
|
|
871
|
+ inspection.Status = 1
|
|
872
|
+ inspection.CreatedTime = time.Now().Unix()
|
|
873
|
+ inspection.UpdatedTime = time.Now().Unix()
|
|
874
|
+ inspection.UTime = inspect_date
|
|
875
|
+ inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
876
|
+ err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
|
877
|
+ if err != nil {
|
|
878
|
+ tx.Rollback()
|
|
879
|
+ }
|
|
880
|
+ }
|
|
881
|
+
|
|
882
|
+ } else {
|
|
883
|
+ var itotal int
|
|
884
|
+ err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
885
|
+ if itotal <= 0 {
|
|
886
|
+ //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
|
887
|
+ //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
|
888
|
+ inspection.PatientId = printInfo.PatientId
|
|
889
|
+ inspection.OrgId = org_id
|
|
890
|
+ inspection.ProjectId = project_id
|
|
891
|
+ inspection.ItemName = inspection_reference.ItemName
|
|
892
|
+ inspection.ProjectName = inspection_reference.ProjectName
|
|
893
|
+ inspection.InspectType = ItemType
|
|
894
|
+ inspection.ItemId = item_id
|
|
895
|
+
|
|
896
|
+ inspection.InspectValue = item.Result
|
|
897
|
+ inspection.InspectDate = inspect_date
|
|
898
|
+ inspection.RecordDate = record_date.Unix()
|
|
899
|
+ inspection.Status = 1
|
|
900
|
+ inspection.CreatedTime = time.Now().Unix()
|
|
901
|
+ inspection.UpdatedTime = time.Now().Unix()
|
|
902
|
+ inspection.UTime = inspect_date
|
|
903
|
+ inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
904
|
+ err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
|
905
|
+ if err != nil {
|
|
906
|
+ tx.Rollback()
|
|
907
|
+ }
|
|
908
|
+ }
|
|
909
|
+
|
|
910
|
+ }
|
|
911
|
+
|
786
|
912
|
tx.Commit()
|
787
|
913
|
|
788
|
914
|
}
|
|
@@ -811,7 +937,7 @@ func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
811
|
937
|
// 第二步:将数据同步到业务库
|
812
|
938
|
if len(inspection_references) > 0 {
|
813
|
939
|
for _, inspection_reference := range inspection_references {
|
814
|
|
- SyncInspectionReference(&inspection_reference)
|
|
940
|
+ SyncInspectionReferenceTwo(&inspection_reference)
|
815
|
941
|
}
|
816
|
942
|
}
|
817
|
943
|
|
|
@@ -1024,3 +1150,13 @@ func GetPatientsInfoByIDCardNo(id_card_no string, org_id int64) (info models.Pat
|
1024
|
1150
|
err = readDb.Model(&models.Patients{}).Where("id_card_no = ? AND user_org_id = ?", id_card_no, org_id).First(&info).Error
|
1025
|
1151
|
return
|
1026
|
1152
|
}
|
|
1153
|
+
|
|
1154
|
+func GetAllLisDataFor10191(org_id int64) (list []models.HisLabelPrintStatusInfo, err error) {
|
|
1155
|
+ err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Preload("Patient", "status = 1").Where("user_org_id = ? AND status = 1 and apply_code = ''", org_id).Find(&list).Error
|
|
1156
|
+ return
|
|
1157
|
+}
|
|
1158
|
+
|
|
1159
|
+func GetAllLisDataFor10191LastId(org_id int64, last_id int64) (list []*models.HisLabelPrintStatusInfo, err error) {
|
|
1160
|
+ err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Preload("Patient", "status = 1").Where("user_org_id = ? AND status = 1 and is_print = 1 and id > ?", org_id, last_id).Find(&list).Error
|
|
1161
|
+ return
|
|
1162
|
+}
|