Browse Source

物联网

张保健 4 years ago
parent
commit
20f5495aa1

+ 33 - 0
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -713,6 +713,39 @@ func (c *CheckWeightApiController) GetPatientList() {
713 713
 		"servicetime": serviceTime,
714 714
 	})
715 715
 }
716
+
717
+func (c *CheckWeightApiController) GetPatientListForSchedules() {
718
+	thisTime := time.Now()
719
+	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
720
+	timeLayout := "2006-01-02 15:04:05"
721
+	loc, _ := time.LoadLocation("Local")
722
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
723
+	syncTime := theStartTime.Unix()
724
+	adminUserInfo := c.GetMobileAdminUserInfo()
725
+	patientList, total, error := service.GetPatientListBySchedules(adminUserInfo.Org.Id, syncTime)
726
+	patientSchedule := make([]map[string]interface{},0)
727
+	for _, item := range patientList {
728
+		patientTemp := make(map[string]interface{})
729
+		patientTemp["patient_id"] = item.PatientId
730
+		patientTemp["patient_name"] = item.Patient.Name
731
+		patientTemp["schedule_type"] = item.ScheduleType
732
+		patientSchedule = append(patientSchedule, patientTemp)
733
+	}
734
+
735
+	if error != nil {
736
+		c.ErrorLog("获取病人列表失败:%v", error)
737
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
738
+		return
739
+	}
740
+	serviceTime := time.Now().Unix()
741
+	c.ServeSuccessJSON(map[string]interface{}{
742
+		"patientlist": patientSchedule,
743
+		"total":       total,
744
+		"servicetime": serviceTime,
745
+	})
746
+}
747
+
748
+
716 749
 func (c *CheckWeightApiController) GetPatientListById() {
717 750
 	patientId, _ := c.GetInt64("patient_id", 0)
718 751
 	if patientId <= 0 {

+ 1 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -12,6 +12,7 @@ func MobileAPIControllersRegisterRouters() {
12 12
 	beego.Router("/m/api/savebloodpressure", &CheckWeightApiController{}, "Post:SaveBloodPressure")
13 13
 	beego.Router("/m/api/checkbeforedialysis", &CheckWeightApiController{}, "get:GetPatientInfoBeforeDialysis")
14 14
 	beego.Router("/m/api/getpatientlist", &CheckWeightApiController{}, "get:GetPatientList")
15
+	beego.Router("/m/api/getschedulepatient", &CheckWeightApiController{}, "get:GetPatientListForSchedules")
15 16
 	beego.Router("/m/api/getpatientinfo", &CheckWeightApiController{}, "get:GetPatientListById")
16 17
 	beego.Router("/m/api/checkdialysis", &CheckWeightApiController{}, "get:GetPatientInfoDialysis")
17 18
 	beego.Router("/m/api/savecheckdialysis", &CheckWeightApiController{}, "Post:SavePatientInfoDialysis")

+ 22 - 0
models/schedule_models.go View File

@@ -28,6 +28,28 @@ func (Schedule) TableName() string {
28 28
 	return "xt_schedule"
29 29
 }
30 30
 
31
+type SchedulePatients struct {
32
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
33
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
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
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
37
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
38
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
39
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
40
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
41
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
42
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
43
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
44
+	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
45
+	Patient      PatientListForFace        `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
46
+}
47
+
48
+func (SchedulePatients) TableName() string {
49
+	return "xt_schedule"
50
+}
51
+
52
+
31 53
 type PatientSchedule struct {
32 54
 	Schedule
33 55
 

+ 194 - 0
service/gdyb_service.go View File

@@ -716,6 +716,200 @@ func Gdyb2208(psnNo string, mdtrtId string, setlId string) string {
716 716
 	return str
717 717
 }
718 718
 
719
+//  门诊结算撤销
720
+func Gdyb4101(psnNo string, mdtrtId string, setlId string) string {
721
+	// 生成签名
722
+	nonce := GetRandomString(32)
723
+	timestamp := time.Now().Unix()
724
+	signature := setSignature(timestamp, nonce)
725
+
726
+	// 生成输入报文
727
+	inputMessage := SetInputMessage(nonce, timestamp)
728
+	input := make(map[string]interface{})
729
+	inputData := make(map[string]interface{})
730
+	inputMessage["infno"] = "4101" // 交易编码
731
+
732
+	inputData["mdtrt_id"] = mdtrtId // 就诊 ID  必填(来自2201接口返回)
733
+	inputData["setl_id"] = setlId   // 结算 ID  必填
734
+	inputData["fixmedins_name"] = ""   // 定点医药机构名称  必填
735
+	inputData["fixmedins_code"] = ""   // 定点医药机构编码  必填
736
+	inputData["hi_setl_lv"] = ""   // 医保结算等级
737
+	inputData["hi_no"] = ""   // 医保编号
738
+	inputData["medcasno"] = ""   // 病案号  必填
739
+	inputData["dcla_time"] = ""   // 申报时间  必填
740
+	inputData["psn_name"] = ""   // 人员姓名  必填
741
+	inputData["gend"] = ""   // 性别  必填
742
+	inputData["brdy"] = ""   // 出生日期  必填
743
+	inputData["age"] = ""   // 年龄  必填
744
+	inputData["ntly"] = ""   // 国籍  必填
745
+	inputData["nwb_age"] = ""   // 年龄  必填
746
+	inputData["naty"] = ""   // 民族  必填
747
+	inputData["patn_cert_type"] = ""   // 患者证件类别  必填
748
+	inputData["certno"] = ""   // 证件号码  必填
749
+	inputData["prfs"] = ""   // 职业  必填
750
+	inputData["curr_addr"] = ""   // 现住址  必填
751
+	inputData["emp_name"] = ""   // 单位名称  必填
752
+	inputData["emp_addr"] = ""   // 单位地址  必填
753
+	inputData["emp_tel"] = ""   // 单位电话  必填
754
+	inputData["poscode"] = ""   // 邮编  必填
755
+	inputData["coner_name"] = ""   // 联系人姓名  必填
756
+	inputData["patn_rlts"] = ""   // 与患者关系  必填
757
+	inputData["coner_addr"] = ""   // 联系人地址  必填
758
+	inputData["coner_tel"] = ""   // 联系人电话  必填
759
+	inputData["hi_type"] = ""   // 医保类型  必填
760
+	inputData["insuplc"] = ""   // 参保地  必填
761
+	inputData["sp_psn_type"] = ""   // 特殊人员类型  必填
762
+	inputData["nwb_adm_type"] = ""   // 新生儿入院类型  必填
763
+	inputData["nwb_bir_wt"] = ""   // 新生儿出生体重  必填
764
+	inputData["nwb_adm_wt"] = ""   // 新生儿入院体重  必填
765
+	inputData["opsp_diag_caty"] = ""   // 门诊慢特病诊断  必填
766
+	inputData["opsp_mdtrt_date"] = ""   // 门诊慢特病就诊日期  必填
767
+	inputData["ipt_med_type"] = ""   // 住院医疗类型  必填
768
+	inputData["adm_way"] = ""   // 入院途径  必填
769
+	inputData["trt_type"] = ""   // 治疗类别  必填
770
+	inputData["adm_time"] = ""   // 入院时间  必填
771
+	inputData["adm_caty"] = ""   // 入院科别  必填
772
+	inputData["refldept_dept"] = ""   // 转科科别  必填
773
+	inputData["dscg_time"] = ""   // 出院时间  必填
774
+	inputData["dscg_caty"] = ""   // 出院科别  必填
775
+	inputData["act_ipt_days"] = ""   // 实际住院天数  必填
776
+	inputData["otp_wm_dise"] = ""   // 门(急) 诊西医诊断  必填
777
+	inputData["wm_dise_code"] = ""   // 门(急) 诊中医诊断  必填
778
+	inputData["otp_tcm_dise"] = ""   // 西医诊断疾病代码  必填
779
+	inputData["tcm_dise_code"] = ""   // 中医诊断代码  必填
780
+	inputData["oprn_oprt_code_cnt"] = ""   // 手术操作代码计数  必填
781
+	inputData["vent_used_dura"] = ""   // 呼吸机使用时长  必填
782
+	inputData["pwcry_bfadm_coma_dura"] = ""   // 颅脑损伤患者入院前昏迷时长  必填
783
+	inputData["pwcry_afadm_coma_dura"] = ""   // 颅脑损伤患者入院后昏迷时长  必填
784
+	inputData["bld_cat"] = ""   // 输血品种  必填
785
+	inputData["bld_amt"] = ""   // 输血量  必填
786
+	inputData["bld_unt"] = ""   // 输血计量单位  必填
787
+	inputData["spga_nurscare_days"] = ""   // 特级护理天数  必填
788
+	inputData["lv1_nurscare_days"] = ""   // 一级护理天数  必填
789
+	inputData["scd_nurscare_days"] = ""   // 二级护理天数  必填
790
+	inputData["lv3_nurscare_days"] = ""   // 三级护理天数  必填
791
+	inputData["acp_medins_name"] = ""   // 拟接收机构名称  必填
792
+	inputData["acp_optins_code"] = ""   // 拟接收机构代码  必填
793
+	inputData["bill_code"] = ""   // 票据代码  必填
794
+	inputData["bill_no"] = ""   // 票据号码  必填
795
+	inputData["biz_sn"] = ""   // 业务流水号  必填
796
+	inputData["days_rinp_flag_31"] = ""   // 出院 31 天内再住院计划标志  必填
797
+	inputData["days_rinp_pup_31"] = ""   // 出院 31 天内再住院目的  必填
798
+	inputData["chfpdr_name"] = ""   // 主诊医师姓名  必填
799
+	inputData["chfpdr_code"] = ""   // 主诊医师代码  必填
800
+	inputData["setl_begn_date"] = ""   // 结算开始日期  必填
801
+	inputData["setl_end_date"] = ""   // 结算结束日期  必填
802
+	inputData["psn_selfpay"] = ""   // 个人自付  必填
803
+	inputData["psn_ownpay"] = ""   // 个人自费  必填
804
+	inputData["acct_pay"] = ""   // 个人账户支出  必填
805
+	inputData["hi_paymtd"] = ""   // 医保支付方式  必填
806
+	inputData["hsorg"] = ""   // 医保机构  必填
807
+	inputData["hsorg_opter"] = ""   // 医保机构经办人  必填
808
+	inputData["medins_fill_dept"] = ""   // 医疗机构填报部门  必填
809
+	inputData["medins_fill_psn"] = ""   // 医疗机构填报人  必填
810
+
811
+	payinfo := make([]map[string]interface{},0)  // 基金支付信息
812
+	payinfotemp := make(map[string]interface{})
813
+	payinfotemp["fund_pay_type"] =  "" // 基金支付类型  必填
814
+	payinfotemp["fund_payamt"] = ""    // 基金支付金额
815
+	payinfo = append(payinfo,payinfotemp)
816
+
817
+	opspdiseinfo := make([]map[string]interface{},0) // 门诊慢特病诊断信息
818
+	opspdiseinfotemp := make(map[string]interface{})
819
+	opspdiseinfotemp["diag_name"] =  "" // 诊断名称  必填
820
+	opspdiseinfotemp["diag_code"] = ""    // 诊断代码 必填
821
+	opspdiseinfotemp["oprn_oprt_name"] = ""    // 手术操作名称 必填
822
+	opspdiseinfotemp["oprn_oprt_code"] = ""    // 手术操作代码 必填
823
+	opspdiseinfo = append(opspdiseinfo,opspdiseinfotemp)
824
+
825
+	diseinfo := make([]map[string]interface{},0) // 住院诊断信息
826
+	diseinfotemp := make(map[string]interface{})
827
+	diseinfotemp["diag_type"] =  "" // 诊断类别  必填
828
+	diseinfotemp["diag_code"] = ""    // 诊断代码 必填
829
+	diseinfotemp["diag_name"] = ""    // 诊断名称 必填
830
+	diseinfotemp["adm_cond_type"] = ""    // 入院病情类型 必填
831
+	diseinfo = append(diseinfo,diseinfotemp)
832
+
833
+	iteminfo := make([]map[string]interface{},0) // 住院诊断信息
834
+	iteminfotemp := make(map[string]interface{})
835
+	iteminfotemp["med_chrgitm"] =  "" // 医疗收费项目  必填
836
+	iteminfotemp["amt"] = ""    // 金额 必填
837
+	iteminfotemp["claa_sumfee"] = ""    // 甲类费用合计 必填
838
+	iteminfotemp["clab_amt"] = ""    // 乙类金额 必填
839
+	iteminfotemp["fulamt_ownpay_amt"] = ""    // 全自费金额 必填
840
+	iteminfotemp["oth_amt"] = ""    // 其他金额 必填
841
+	iteminfo = append(iteminfo,iteminfotemp)
842
+
843
+	oprninfo := make([]map[string]interface{},0) // 手术操作信息
844
+	oprninfotemp := make(map[string]interface{})
845
+	oprninfotemp["oprn_oprt_type"] =  "" // 手术操作类别  必填
846
+	oprninfotemp["oprn_oprt_name"] = ""    // 手术操作名称 必填
847
+	oprninfotemp["oprn_oprt_code"] = ""    // 手术操作代码 必填
848
+	oprninfotemp["oprn_oprt_date"] = ""    // 手术操作日期 必填
849
+	oprninfotemp["anst_way"] = ""    // 麻醉方式 必填
850
+	oprninfotemp["oper_dr_name"] = ""    // 术者医师姓名 必填
851
+	oprninfotemp["oper_dr_code"] = ""    // 术者医师代码 必填
852
+	oprninfotemp["anst_dr_name"] = ""    // 麻醉医师姓名 必填
853
+	oprninfotemp["anst_dr_code"] = ""    // 麻醉医师代码 必填
854
+	oprninfo = append(oprninfo,iteminfotemp)
855
+
856
+	icuinfo := make([]map[string]interface{},0) // 重症监护信息
857
+	icuinfotemp := make(map[string]interface{})
858
+	icuinfotemp["scs_cutd_ward_type"] =  "" // 重症监护病房类型  必填
859
+	icuinfotemp["scs_cutd_inpool_time"] = ""    // 重症监护进入时间 必填
860
+	icuinfotemp["scs_cutd_exit_time"] = ""    // 重症监护退出时间 必填
861
+	icuinfotemp["scs_cutd_sum_dura"] = ""    // 重症监护合计时长 必填
862
+	icuinfo = append(icuinfo,iteminfotemp)
863
+
864
+
865
+
866
+
867
+	input["setlinfo"] = inputData
868
+	input["payinfo"] = payinfo
869
+	input["opspdiseinfo"] = opspdiseinfo
870
+	input["diseinfo"] = diseinfo
871
+	input["iteminfo"] = iteminfo
872
+	input["oprninfo"] = oprninfo
873
+	input["icuinfo"] = icuinfo
874
+	inputMessage["input"] = input //交易输入
875
+
876
+	bytesData, err := json.Marshal(inputMessage)
877
+	fmt.Println(string(bytesData))
878
+	if err != nil {
879
+		fmt.Println(err.Error())
880
+		return err.Error()
881
+	}
882
+	reader := bytes.NewReader(bytesData)
883
+
884
+	url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
885
+	request, err := http.NewRequest("POST", url, reader)
886
+	if err != nil {
887
+		fmt.Println(err.Error())
888
+		return err.Error()
889
+	}
890
+
891
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
892
+	request.Header.Set("x-tif-paasid", "test_hosp")
893
+	request.Header.Set("x-tif-signature", signature)
894
+	request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
895
+	request.Header.Set("x-tif-nonce", nonce)
896
+
897
+	client := http.Client{}
898
+	resp, err := client.Do(request)
899
+	if err != nil {
900
+		fmt.Println(err.Error())
901
+		return err.Error()
902
+	}
903
+	respBytes, err := ioutil.ReadAll(resp.Body)
904
+	if err != nil {
905
+		fmt.Println(err.Error())
906
+		return err.Error()
907
+	}
908
+	str := string(respBytes)
909
+	fmt.Println(str)
910
+	return str
911
+}
912
+
719 913
 // 生成签名
720 914
 func setSignature(timestamp int64, nonce string) string {
721 915
 	str := strconv.FormatInt(timestamp, 10) + SceretKey + nonce + strconv.FormatInt(timestamp, 10)

+ 6 - 0
service/patient_service.go View File

@@ -89,6 +89,12 @@ func GetPatientListByUpdateTime(orgID int64, syncTime int64, force int64) (patie
89 89
 	return
90 90
 }
91 91
 
92
+func GetPatientListBySchedules(orgID int64, syncTime int64) (patients []*models.SchedulePatients, total int64, err error) {
93
+	db := readDb.Model(&models.SchedulePatients{}).Where("user_org_id=?  AND  status=1  AND  schedule_date = ?", orgID,syncTime).Preload("Patient", "status = 1 AND user_org_id = ? ", orgID,)
94
+	err = db.Count(&total).Find(&patients).Error
95
+	return
96
+}
97
+
92 98
 func GetPatientListById(orgID int64, patientId int64) (patients models.PatientListForFace, err error) {
93 99
 	err = readDb.Model(&models.PatientListForFaceList{}).Where("user_org_id=? and id = ? and status=1", orgID, patientId).First(&patients).Error
94 100
 	return