123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- package service
-
- import (
- "XT_New/models"
- "bytes"
- "encoding/json"
- "fmt"
- "github.com/jinzhu/gorm"
- "io/ioutil"
- "net/http"
- )
-
- func SavePatientMessageInfo() (string, string) {
-
- //input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputData["patType"] = "1" // 就诊凭证编号
- inputData["patIdNo"] = "440510199211080038" // 开始时间
- inputData["patName"] = "测试患者4 " // 人员姓名
-
- inputData["patMobile"] = "13535547902" // 人员姓名
- inputData["patSex"] = "M" // 人员姓名
- inputData["patMarriage"] = "1" // 人员姓名
- inputData["birthday"] = "1992-10-23" // 人员姓名
- inputData["patAddress"] = "11111" // 人员姓名
- inputData["thirdPartyID"] = "6936" // 人员姓名
- inputData["patAge"] = "30" // 人员姓名
- //input["req"] = inputData
-
- var inputLog string
- bytesData, err := json.Marshal(inputData)
- inputLog = string(bytesData)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
- var url string
- gdyb_url := "http://218.104.146.179:9091/esb/listener/savePatientMessageInfo"
- url = gdyb_url
-
- //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
- request, err := http.NewRequest("GET", url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("code", "Xmrjyy")
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- fmt.Println(string(respBytes))
- str := string(respBytes)
- return str, inputLog
-
- }
-
- func SaveReg(reg models.Reg) (string, string) {
-
- //input := make(map[string]interface{})
- inputData := make(map[string]interface{})
-
- inputData["deptId"] = reg.DeptId
- inputData["clinicUnitId"] = ""
- inputData["healthCardNo"] = ""
- fmt.Println(reg.PatientId)
- inputData["patientId"] = reg.PatientId
- inputData["patientName"] = reg.PatientName
- inputData["idCardNo"] = reg.IdCardNo
- inputData["phone"] = ""
- inputData["doctorId"] = ""
- inputData["doctorLevelCode"] = ""
- inputData["regDate"] = reg.RegDate
-
- inputData["shiftCode"] = ""
- inputData["startTime"] = ""
- inputData["endTime"] = ""
-
- inputData["scheduleId"] = ""
- inputData["periodId"] = ""
-
- inputData["svObjectId"] = ""
- inputData["diseaseId"] = ""
- inputData["regFee"] = reg.RegFee
-
- inputData["treatFee"] = reg.TreatFee
- inputData["operatorId"] = reg.OperatorId
- inputData["remark"] = "血透"
-
- inputData["orderType"] = "0"
- inputData["clinicCode"] = ""
- inputData["infoSeq"] = ""
-
- //input["Request"] = inputData
-
- var inputLog string
- bytesData, err := json.Marshal(inputData)
- inputLog = string(bytesData)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
- var url string
- gdyb_url := "http://218.104.146.179:9091/esb/listener/saveReg"
- url = gdyb_url
-
- //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
- request, err := http.NewRequest("POST", url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("code", "Xmrjyy")
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- fmt.Println(string(respBytes))
- str := string(respBytes)
- return str, inputLog
-
- }
- func GetWaitPayDetail() (string, string) {
-
- //input := make(map[string]interface{})
- inputData := make(map[string]interface{})
-
- inputData["clinicSeq"] = "30445" // 就诊凭证编号
- inputData["prescriptionId"] = "" // 开始时间
- inputData["patientId"] = "701822660170096645" // 人员姓名
-
- var inputLog string
- bytesData, err := json.Marshal(inputData)
- inputLog = string(bytesData)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
- var url string
- gdyb_url := "http://218.104.146.179:9091/esb/listener/getWaitPayDetail"
- url = gdyb_url
-
- //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
- request, err := http.NewRequest("POST", url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("code", "Xmrjyy")
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- fmt.Println(string(respBytes))
- str := string(respBytes)
- return str, inputLog
-
- }
- func OpKeepAccounts(number string, cus []*models.NewCustomTwo) (string, string) {
-
- inputData := make(map[string]interface{})
- feedetail := make([]map[string]interface{}, 0)
- for _, item := range cus {
- feedetailInfo := make(map[string]interface{})
- feedetailInfo["itemCode"] = item.MedListCodg
- feedetailInfo["num"] = item.Cut
- feedetail = append(feedetail, feedetailInfo)
- }
- inputData["item"] = feedetail
- inputData["clinicSeq"] = number // 就诊凭证编号
- var inputLog string
- bytesData, err := json.Marshal(inputData)
- inputLog = string(bytesData)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
- var url string
- gdyb_url := "http://218.104.146.179:9091/esb/listener/opKeepAccounts"
- url = gdyb_url
-
- request, err := http.NewRequest("POST", url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("code", "Xmrjyy")
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- fmt.Println(string(respBytes))
- str := string(respBytes)
- return str, inputLog
-
- }
- func OpCancelKeepAccounts(setl_id string, op_name string, op_code string) (string, string) {
- inputData := make(map[string]interface{})
- inputData["docId"] = setl_id
- inputData["operCode"] = "111"
- inputData["operName"] = "2222"
- var inputLog string
- bytesData, err := json.Marshal(inputData)
- inputLog = string(bytesData)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
- var url string
- gdyb_url := "http://218.104.146.179:9091/esb/listener/opCancelKeepAccounts"
- url = gdyb_url
- request, err := http.NewRequest("POST", url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("code", "Xmrjyy")
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- fmt.Println(string(respBytes))
- str := string(respBytes)
- return str, inputLog
-
- }
-
- func UpdateHisPatientStatus(his *models.VMHisPatient) {
- writeDb.Save(&his)
- }
-
- func GetUnSettleHisPrescriptionFive(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
- }).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3 AND order_status <> 2 ", org_id)
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 and order_status <> 5 AND p_type = ?", org_id, record_date, patient_id, p_type).
- Find(&prescription).Error
- return
- }
-
- func GetUnSettleMonthHisPrescription(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 5 AND p_type <> 1", org_id, start_date, end_date, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetHisOrderFour(patient_id string, infoSeq string, docId string) (order models.HisOrder, err error) {
- if len(docId) > 0 {
- err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND setl_id = ? AND status = 1", infoSeq, patient_id, docId).First(&order).Error
- } else {
- err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND status = 1 ", infoSeq, patient_id).First(&order).Error
- }
- return
- }
|