123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672 |
- package coordinate
-
- import (
- "encoding/json"
- "fmt"
- "gdyb/controllers"
- "gdyb/enums"
- "gdyb/models"
- "gdyb/service"
- "gdyb/utils"
- "github.com/astaxie/beego"
- "math/rand"
- "os"
- "strconv"
- "strings"
- "time"
- )
-
- type ResultUpload struct {
- Code string `json:"code"`
- Msg string `json:"msg"`
- Result []struct {
- List []interface{} `json:"list"`
- Page int64 `json:"page"`
- Pagenumber int64 `json:"pagenumber"`
- Records int64 `json:"records"`
- RecordsFiltered int64 `json:"recordsFiltered"`
- RecordsTotal int64 `json:"recordsTotal"`
- Result string `json:"result"`
- ResultMsg string `json:"resultMsg"`
- Total int64 `json:"total"`
- TotalPage int64 `json:"totalPage"`
- Userdata string `json:"userdata"`
- Code string `json:"code"`
- } `json:"result"`
- }
-
- type ResultQuery struct {
- Msg string `json:"msg"`
- Result []struct {
- Type string `json:"type"`
- Name string `json:"name"`
- Vaa01 int64 `json:"vaa01"`
- Vaa07 int64 `json:"vaa07"`
- Visittime string `json:"visittime"`
- } `json:"result"`
- Code string `json:"code"`
- }
-
- type CoordinateController struct {
- controllers.BaseAuthAPIController
- }
-
- type ResultReg struct {
- ResultCode string `json:"resultCode"`
- ResultDesc string `json:"resultDesc"`
- InfoSeq string `json:"infoSeq"`
- }
-
- func CoordinateRegistRouters() {
- beego.Router("/coordinate/settleAccount", &CoordinateController{}, "get:SettleAccount")
-
- }
-
- func (c *CoordinateController) SettleAccount() {
- patient_id, _ := c.GetInt64("patient_id")
- record_date := c.GetString("record_date")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- diagnosis_id := c.GetString("diagnosis")
- sick_type, _ := c.GetInt64("sick_type")
- reg_type, _ := c.GetInt64("p_type")
- org_id, _ := c.GetInt64("org_id")
- org_id = 10340
- org, _ := service.GetOrgById(org_id)
- patient, _ := service.GetPatientByID(org.Id, patient_id)
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
-
- result, request := service.GetHisPatientForCoordinate(patient.IdCardNo)
- saveLog(result, request, "查询", "查询", org.OrgName)
- var res ResultQuery
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res.Code == "10000" {
- if len(res.Result) == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientNoRegException)
- return
- }
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- org_id := org.Id
- recordDateTime := theTime.Unix()
- patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
- if patientPrescription.ID == 0 {
- patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwoTen(org_id, patient.ID, recordDateTime)
- }
- departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
- doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
- //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
-
- var prescriptions []*models.HisPrescription
-
- if settle_accounts_type == 1 { //日结
- prescriptions, _ = service.GetUnSettleHisPrescriptionFiveTen(org_id, patient_id, recordDateTime, 2)
- } else { //月结
-
- start_time_str := c.GetString("start_time")
- end_time_str := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartTime := theStartTime.Unix()
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndTime := theEndTime.Unix()
- prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
- }
- var total float64
-
- for _, item := range prescriptions {
- fmt.Println(item)
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- total = total + (subItem.Price * subItem.PrescribingNumber)
- }
- }
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- total = total + (subItem.Price * cnt)
- }
- }
-
- }
-
- var ids []int64
-
- for _, item := range prescriptions {
- ids = append(ids, item.ID)
- }
-
- var customs []*models.NewCustomTwo
- for _, item := range prescriptions {
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- cus := &models.NewCustomTwo{
- AdviceId: subItem.ID,
- ProjectId: 0,
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
- Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", subItem.Price),
- MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
- Type: 1,
- }
- customs = append(customs, cus)
- }
- }
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- if subItem.Type == 2 {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- cus := &models.NewCustomTwo{
- AdviceId: 0,
- ProjectId: subItem.ID,
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
- Cut: fmt.Sprintf("%.4f", cnt),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.HisProject.MedicalCode,
- Type: 2,
- }
- customs = append(customs, cus)
-
- } else {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- cus := &models.NewCustomTwo{
- AdviceId: 0,
- ProjectId: subItem.ID,
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
- Cut: fmt.Sprintf("%.4f", cnt),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
- Type: 3,
- }
- customs = append(customs, cus)
- }
-
- }
- }
- }
-
- var info models.UploadInfo
- info.Vaa01 = res.Result[0].Vaa01
- info.Fasong = "1"
- info.Vaa07 = res.Result[0].Vaa07
- info.Bck01c = departmwnt.Number
- info.Bce02a = doctor_info.DoctorNumber
-
- diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
- var config []*models.HisXtDiagnoseConfig
- for _, item := range diagnosis_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- diagnosisConfig, _ := service.FindDiagnoseById(id)
- config = append(config, &diagnosisConfig)
- }
- for index, item := range config {
- var diag models.Diag
- diag.Vao06 = strconv.FormatInt(int64(index+1), 10)
- diag.Bak02 = item.CountryCode
- info.Diag = append(info.Diag, &diag)
- }
- var presInfos []*models.PresInfo
- var presDetails []*models.PresDetail
-
- var doctoradvices []*models.HisDoctorAdviceInfo
- var groups []int64
- for _, item := range prescriptions {
- for _, subItem := range item.HisDoctorAdviceInfo {
- doctoradvices = append(doctoradvices, subItem)
- }
- }
-
- for _, item := range doctoradvices {
- groups = append(groups, item.Groupno)
- }
- groups = RemoveRepeatedGroupElement(groups)
-
- type DoctorAdvices struct {
- GroupNo int64
- item []*models.HisDoctorAdviceInfo
- }
- var doctoradvice []*DoctorAdvices
-
- for _, group := range groups {
- var da DoctorAdvices
- da.GroupNo = group
- for _, item := range doctoradvices {
- if group == item.Groupno {
- da.item = append(da.item, item)
- }
- }
- doctoradvice = append(doctoradvice, &da)
- }
-
- for _, item := range doctoradvice {
- var presDetail models.PresDetail
- var presInfo models.PresInfo
- presInfo.Cbmid = strconv.FormatInt(item.GroupNo, 10)
-
- presInfo.Cbm06 = "0"
- presInfo.Cbm07 = ""
- presDetail.Vaf59 = strconv.FormatInt(item.GroupNo, 10)
- var infoItems []*models.Item
- for index, subItem := range item.item {
- ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
-
- var infoItem models.Item
- infoItem.Rownr = strconv.FormatInt(int64(index), 10)
- infoItem.Vaf11 = "2"
- infoItem.Vaf36 = time.Unix(subItem.CreatedTime, 0).Format("2006-01-02 15:04:05")
- infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber
- infoItem.Bda01 = "1"
- infoItem.Bby01 = ""
- if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
- infoItem.Vaf22 = subItem.BaseDrugLib.DrugName + " " + subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
- }
- infoItem.Vaf14 = subItem.BaseDrugLib.DrugName
- infoItem.Bdi01 = ef.Code
- infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10)
- infoItem.Vaf18 = fmt.Sprintf("%.2f", subItem.SingleDose)
-
- infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
- infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
- infoItem.Vaf35 = "0"
- infoItem.Vaf32 = "0"
- infoItem.Bck01b = departmwnt.Number
- infoItem.Bck01d = departmwnt.Number
- infoItem.Vaf58 = "0"
- infoItem.Vaf61 = "1"
- infoItems = append(infoItems, &infoItem)
- }
-
- presDetail.Item = infoItems
- presDetails = append(presDetails, &presDetail)
- presInfo.PresDetail = presDetails
- presInfos = append(presInfos, &presInfo)
-
- }
-
- for index, item := range prescriptions {
- var presDetail models.PresDetail
- var presInfo models.PresInfo
- presInfo.Cbmid = strconv.FormatInt(item.ID, 10)
- if item.Type == 1 {
- presInfo.Cbm06 = "0"
- } else {
- presInfo.Cbm06 = "5"
- }
-
- if item.Type == 1 {
- presInfo.Cbm07 = item.MedType
- } else {
- presInfo.Cbm07 = item.MedType
- }
-
- presDetail.Vaf59 = strconv.FormatInt(int64(index+1), 10)
- var infoItems []*models.Item
- //for index, subItem := range item.HisDoctorAdviceInfo {
- // ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
- //
- // var infoItem models.Item
- // infoItem.Rownr = strconv.FormatInt(int64(index+1), 10)
- // infoItem.Vaf11 = "2"
- // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
- // infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber
- // infoItem.Bda01 = "1"
- // infoItem.Bby01 = ""
- // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
- // infoItem.Vaf22 = subItem.BaseDrugLib.DrugName + " " + subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
- // }
- // infoItem.Vaf14 = subItem.BaseDrugLib.DrugName
- // infoItem.Bdi01 = ef.Code
- // infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10)
- // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
- // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
- // infoItem.Vaf35 = "0"
- // infoItem.Vaf32 = "0"
- // infoItem.Bck01b = departmwnt.Number
- // infoItem.Bck01d = departmwnt.Number
- // infoItem.Vaf58 = "0"
- // infoItem.Vaf61 = "1"
- // infoItems = append(infoItems, &infoItem)
- //}
- for _, subItem := range item.HisPrescriptionProject {
- //ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
-
- if subItem.Type == 2 {
- if subItem.HisProject.CostClassify == 10 {
- var infoItem models.Item
- infoItem.Rownr = "0"
- infoItem.Vaf11 = "2"
- infoItem.Vaf36 = time.Unix(subItem.Ctime, 0).Format("2006-01-02 15:04:05")
- infoItem.Bbx01 = subItem.HisProject.MedicalCode
- infoItem.Bda01 = "Z"
- infoItem.Bby01 = ""
- infoItem.Vaf14 = subItem.HisProject.ProjectName
- infoItem.Vaf15 = subItem.HisProject.ProjectName
- infoItem.Bdi01 = "160"
- infoItem.Vaf17 = subItem.Day
- infoItem.Vaf20 = subItem.SingleDose
- infoItem.Vaf21 = subItem.Count
- infoItem.Vaf35 = "0"
- infoItem.Vaf18 = ""
- infoItem.Vaf32 = "1"
- infoItem.Bck01b = departmwnt.Number
- infoItem.Bck01d = departmwnt.Number
- infoItem.Vaf58 = "0"
- infoItem.Vaf61 = "1"
- infoItems = append(infoItems, &infoItem)
-
- } else {
-
- var infoItem models.Item
- infoItem.Rownr = "0"
- infoItem.Vaf11 = "1"
- infoItem.Vaf36 = time.Unix(subItem.Ctime, 0).Format("2006-01-02 15:04:05")
- infoItem.Bbx01 = subItem.HisProject.MedicalCode
-
- if subItem.HisProject.CostClassify == 2 {
- infoItem.Bda01 = "T"
- } else if subItem.HisProject.CostClassify == 3 {
- infoItem.Bda01 = "L"
- } else {
- infoItem.Bda01 = "T"
- }
- infoItem.Bby01 = ""
- infoItem.Vaf14 = subItem.HisProject.ProjectName
-
- infoItem.Bdi01 = "160"
- infoItem.Vaf17 = subItem.Day
- infoItem.Vaf20 = subItem.SingleDose
- infoItem.Vaf21 = subItem.Count
- infoItem.Vaf35 = "0"
- infoItem.Vaf18 = fmt.Sprintf("%.2f", subItem.SingleDose)
- infoItem.Vaf32 = "0"
- infoItem.Bck01b = departmwnt.Number
- infoItem.Bck01d = departmwnt.Number
- infoItem.Vaf58 = "0"
- infoItem.Vaf61 = "1"
- infoItems = append(infoItems, &infoItem)
-
- }
-
- } else {
- var infoItem models.Item
- infoItem.Rownr = "0"
- infoItem.Vaf11 = "1"
- infoItem.Vaf36 = time.Unix(subItem.Ctime, 0).Format("2006-01-02 15:04:05")
- infoItem.Bbx01 = subItem.GoodInfo.MedicalInsuranceNumber
- infoItem.Bda01 = "M"
- infoItem.Bby01 = ""
- infoItem.Vaf14 = subItem.GoodInfo.GoodName + " " + subItem.GoodInfo.SpecificationName
- infoItem.Bdi01 = "160"
- infoItem.Vaf17 = subItem.Day
- infoItem.Vaf20 = subItem.SingleDose
- infoItem.Vaf21 = subItem.Count
- infoItem.Vaf35 = "0"
- infoItem.Vaf32 = "0"
- infoItem.Bck01b = departmwnt.Number
- infoItem.Bck01d = departmwnt.Number
- infoItem.Vaf58 = "0"
- infoItem.Vaf61 = "1"
- infoItems = append(infoItems, &infoItem)
-
- }
-
- }
-
- presDetail.Item = infoItems
- presDetails = append(presDetails, &presDetail)
- presInfo.PresDetail = presDetails
- presInfos = append(presInfos, &presInfo)
- }
-
- info.PresInfo = presInfos
- var result2 string
- var request2 string
- if res.Result[0].Type == "1" {
- result2, request2 = service.UploadPrescriptionForCoordinate(info)
- } else {
- result2, request2 = service.UploadPrescriptionForCoordinateHospital(info)
- }
- saveLog(result2, request2, "上传明细", "上传明细", org.OrgName)
-
- var res2 ResultUpload
- if err := json.Unmarshal([]byte(result2), &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res2.Code == "10000" && len(res2.Result) > 0 && res2.Result[0].Code != "500" && len(res2.Result[0].List) > 0 {
-
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(100000) + 10000
- ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
- his := models.VMHisPatient{
- Name: patient.Name,
- Gender: patient.Gender,
- Birthday: patient.Birthday,
- MedicalTreatmentType: 0,
- IdType: 1,
- IdCardNo: patient.IdCardNo,
- BalanceAccountsType: 1,
- MedicalInsuranceNumber: "",
- RegisterType: 0,
- RegisterCost: 0,
- TreatmentCost: 0,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- PsnNo: strconv.FormatInt(int64(res.Result[0].Vaa01), 10),
- PsnCertType: "",
- Certno: patient.IdCardNo,
- PsnName: patient.Name,
- Gend: "",
- Naty: "",
- Brdy: "",
- Age: 0,
- Iinfo: "",
- Idetinfo: "",
- PatientId: patient.ID,
- RecordDate: theTime.Unix(),
- UserOrgId: org_id,
- AdminUserId: admin_user_id,
- IsReturn: 1,
- Doctor: patientPrescription.DoctorId,
- Departments: patientPrescription.Departments,
- IptOtpNo: ipt_otp_no,
- Number: strconv.FormatInt(int64(res.Result[0].Vaa07), 10),
- PhoneNumber: patient.Phone,
- }
- service.UpdateHisPatientStatusTwo(&his)
- service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
- tm := time.Unix(time.Now().Unix(), 0)
-
- order := &models.HisOrder{
- PsnNo: his.PsnNo,
- UserOrgId: org_id,
- HisPatientId: his.ID,
- PatientId: patient_id,
- SettleAccountsDate: recordDateTime,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Status: 1,
- OrderStatus: 1,
- MdtrtId: his.Number,
- Number: ipt_otp_no,
- SetlId: "",
- MedfeeSumamt: total,
- MedType: strconv.Itoa(int(reg_type)),
- SettleEndTime: 0,
- SettleStartTime: 0,
- SettleType: settle_accounts_type,
- Diagnosis: diagnosis_id,
- PType: 2,
- SetlTime: tm.Format("2006-01-02 15:04:05"),
- }
- err = service.CreateOrder(order)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderExceptionT)
- return
- }
-
- for _, item := range customs {
- var advice_id int64 = 0
- var project_id int64 = 0
- var item_id int64 = 0
-
- var types int64 = 0
-
- if item.Type == 1 {
- advice_id = item.AdviceId
- project_id = 0
- item_id = 0
- } else if item.Type == 2 {
- advice_id = 0
- item_id = 0
-
- project_id = item.ProjectId
- } else if item.Type == 3 {
- advice_id = 0
- item_id = item.ItemId
- project_id = 0
- }
- detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
- cut, _ := strconv.ParseFloat(item.Cut, 32)
- pric, _ := strconv.ParseFloat(item.Price, 32)
- info := &models.HisOrderInfo{
- OrderNumber: order.Number,
- UploadDate: time.Now().Unix(),
- AdviceId: advice_id,
- DetItemFeeSumamt: detItemFeeSumamt,
- Cnt: cut,
- Pric: pric,
- PatientId: patient_id,
- Status: 1,
- Mtime: time.Now().Unix(),
- Ctime: time.Now().Unix(),
- UserOrgId: org_id,
- HisPatientId: his.ID,
- OrderId: order.ID,
- ProjectId: project_id,
- Type: types,
- ItemId: item_id,
- }
- service.CreateOrderInfo(info)
- }
- his.Diagnosis = diagnosis_id
- his.SickType = sick_type
- his.RegisterType = reg_type
- his.MedicalTreatmentType = reg_type
- service.UpdataHisPateintTwoTen(&his)
- err = service.UpDatePrescriptionNumber(org_id, ids, order.Number)
- err = service.UpDateHisPrescriptionInfoNumberTen(org_id, patient_id, order.Number, recordDateTime, his.ID)
- err = service.UpdataOrderStatusThreeTen(strconv.FormatInt(int64(chrgBchno), 10), org_id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "医嘱保存成功",
- })
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res2.Msg + "----" + res2.Result[0].ResultMsg,
- })
-
- }
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.Msg,
- })
-
- }
-
- }
-
- type Charset string
-
- const (
- UTF8 = Charset("UTF-8")
- GB18030 = Charset("GB18030")
- )
-
- func saveLog(result string, request string, infno string, desc string, org_name string) {
-
- //org_id, _ := beego.AppConfig.Int64("org_id")
- //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
- dir := org_name + "日志"
- utils.Mkdir(dir)
- month := time.Unix(1557042972, 0).Format("1")
- year := time.Now().Format("2006")
- month = time.Now().Format("01")
- day := time.Now().Format("02")
- hour := time.Now().Format("15")
- min := time.Now().Format("04")
- sec := time.Now().Format("05")
-
- result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
-
- file := org_name + "_" + year + month + day + "_log"
- file_name := file + ".txt"
- file_path := org_name + "日志" + "/" + file_name
- exist, _ := utils.PathExists(file_path)
- if exist { //存在
- fmt.Println("存在")
- f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
- if err != nil {
- fmt.Println("read fail")
- }
- content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
- n, _ := f.Seek(0, 2)
- _, err = f.WriteAt([]byte(content), n)
-
- } else { //不存在
- fmt.Println("文件不存在,创建文件")
- f, err := os.Create(org_name + "日志" + "/" + file_name)
- defer f.Close()
- if err != nil {
- } else {
- _, err = f.Write([]byte("记录日志"))
- }
- }
-
- }
-
- func RemoveRepeatedGroupElement(arr []int64) (newArr []int64) {
- newArr = make([]int64, 0)
- for i := 0; i < len(arr); i++ {
- repeat := false
- for j := i + 1; j < len(arr); j++ {
- if arr[i] == arr[j] {
- repeat = true
- break
- }
- }
- if !repeat {
- newArr = append(newArr, arr[i])
- }
- }
- return
- }
|