12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163 |
- package service
-
- import (
- "IC/models"
- "IC/utils"
- "fmt"
- "github.com/jinzhu/gorm"
- "strconv"
- "strings"
- "time"
- )
-
- type HisOrder struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
- SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
- MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
- XtHisPatient XtHisPatient `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
- }
-
- func (HisOrder) TableName() string {
- return "his_order"
- }
-
- type XtHisPatient struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- BalanceAccountsType int64 `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
- MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
- Name string `gorm:"column:name" json:"name" form:"name"`
- Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
- IdType int64 `gorm:"column:id_type" json:"id_type" form:"id_type"`
- MedicalTreatmentType int64 `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
- Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- Age int64 `gorm:"column:age" json:"age" form:"age"`
- PhoneNumber string `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
- IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
- RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
- AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
- Departments int64 `gorm:"column:departments" json:"departments" form:"departments"`
- IsNeedCostOfProduction int64 `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
- RegisterCost float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
- TreatmentCost float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
- CostOfProduction float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
- Total float64 `gorm:"column:total" json:"total" form:"total"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
- IsReturn int64 `gorm:"column:is_return" json:"is_return" form:"is_return"`
- Phone string `gorm:"column:phone" json:"phone" form:"phone"`
- SocialType int64 `gorm:"column:social_type" json:"social_type" form:"social_type"`
- IdCardType int64 `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
- PType string `gorm:"column:p_type" json:"p_type" form:"p_type"`
- Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
- SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
- }
-
- func (XtHisPatient) TableName() string {
- return "his_patient"
- }
-
- type HisPrescription struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- Type int64 `gorm:"column:type" json:"type" form:"type"`
- Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
- Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
- OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
- PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
- BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
- PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
- HisOrder HisOrder `gorm:"ForeignKey:Number;AssociationForeignKey:BatchNumber" json:"order"`
- Total string `gorm:"-" json:"total" form:"total"`
- PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
- MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
- }
-
- func (HisPrescription) TableName() string {
- return "his_prescription"
- }
-
- type CmSample struct {
- HospitalBarcode string `gorm:"column:hospital_barcode" json:"hospital_barcode" form:"hospital_barcode"`
- Hospsamplenumber string `gorm:"column:hospsamplenumber" json:"hospsamplenumber" form:"hospsamplenumber"`
- Pno string `gorm:"column:pno" json:"pno" form:"pno"`
- Ptype string `gorm:"column:ptype" json:"ptype" form:"ptype"`
- Bedno string `gorm:"column:bedno" json:"bedno" form:"bedno"`
- Pname string `gorm:"column:pname" json:"pname" form:"pname"`
- Psex string `gorm:"column:psex" json:"psex" form:"psex"`
- Page string `gorm:"column:page" json:"page" form:"page"`
- Pageunit string `gorm:"column:pageunit" json:"pageunit" form:"pageunit"`
- Ptel string `gorm:"column:ptel" json:"ptel" form:"ptel"`
- Stature string `gorm:"column:stature" json:"stature" form:"stature"`
- Avoirdupois string `gorm:"column:avoirdupois" json:"avoirdupois" form:"avoirdupois"`
- Gravweek string `gorm:"column:gravweek" json:"gravweek" form:"gravweek"`
- Collectiongravday string `gorm:"column:collectiongravday" json:"collectiongravday" form:"collectiongravday"`
- Birthday time.Time `gorm:"column:birthday" json:"birthday" form:"birthday"`
- Departname string `gorm:"column:departname" json:"departname" form:"departname"`
- Docname string `gorm:"column:docname" json:"docname" form:"docname"`
- Doctortel string `gorm:"column:doctortel" json:"doctortel" form:"doctortel"`
- Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
- Stype string `gorm:"column:stype" json:"stype" form:"stype"`
- Samstate string `gorm:"column:samstate" json:"samstate" form:"samstate"`
- Desccode string `gorm:"column:desccode" json:"desccode" form:"desccode"`
- Descr string `gorm:"column:descr" json:"descr" form:"descr"`
- Sampletime time.Time `gorm:"column:sampletime" json:"sampletime" form:"sampletime"`
- Senddate time.Time `gorm:"column:senddate" json:"senddate" form:"senddate"`
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
- Idcard string `gorm:"column:idcard" json:"idcard" form:"idcard"`
- CardClass string `gorm:"column:cardclass" json:"cardclass" form:"cardclass"`
- }
-
- func (CmSample) TableName() string {
- return "cm_sample"
- }
-
- type CmLisitems struct {
- ItemCode string `gorm:"column:item_code" json:"item_code" form:"item_code"`
- ItemName string `gorm:"column:item_name" json:"item_name" form:"item_name"`
- Testmethod string `gorm:"column:testmethod" json:"testmethod" form:"testmethod"`
- Iscompound string `gorm:"column:iscmpound" json:"iscmpound" form:"iscmpound"`
- DepartmentName string `gorm:"column:department_name" json:"department_name" form:"department_name"`
- }
-
- func (CmLisitems) TableName() string {
- return "v_cm_listtems"
- }
-
- type HisLabelPrintInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
- IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
- PProjectId int64 `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- DoctorName string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
- PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
- Phone string `gorm:"column:phone" json:"phone" form:"phone"`
-
- PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
- HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:PProjectId" json:"project"`
- Patient models.Patients `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patient"`
- VMHisProjectTeam VMHisProjectTeam `gorm:"ForeignKey:ID;AssociationForeignKey:ItemId" json:"team"`
- }
-
- func (HisLabelPrintInfo) TableName() string {
- return "his_label_print_info"
- }
-
- type LisSyncProcessStatusInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- IsInsert int64 `gorm:"column:is_insert" json:"is_insert" form:"is_insert"`
- IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
- ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
- }
-
- func (LisSyncProcessStatusInfo) TableName() string {
- return "lis_sync_process_status_info"
- }
-
- type CmResult struct {
- Barcode string `gorm:"column:barcode" json:"barcode" form:"barcode"`
- Itemcode string `gorm:"column:itemcode" json:"itemcode" form:"itemcode"`
- Itemname string `gorm:"column:itemname" json:"itemname" form:"itemname"`
- Unit string `gorm:"column:unit" json:"unit" form:"unit"`
- Result string `gorm:"column:result" json:"result" form:"result"`
- Refrange string `gorm:"column:refrange" json:"refrange" form:"refrange"`
- Ts string `gorm:"column:ts" json:"ts" form:"ts"`
- Jyys string `gorm:"column:jyys" json:"jyys" form:"jyys"`
- Shys string `gorm:"column:shys" json:"shys" form:"shys"`
- Hycode string `gorm:"column:hycode" json:"hycode" form:"hycode"`
- Reptype string `gorm:"column:reptype" json:"reptype" form:"reptype"`
- TJH string `gorm:"column:tjh" json:"tjh" form:"tjh"`
- Repdate time.Time `gorm:"column:repdate" json:"repdate" form:"repdate"`
- Groupname string `gorm:"column:groupname" json:"groupname" form:"groupname"`
- Groupcode string `gorm:"column:groupcode" json:"groupcode" form:"groupcode"`
- Brkb string `gorm:"column:brkb" json:"brkb" form:"brkb"`
- Mic string `gorm:"column:mic" json:"mic" form:"mic"`
- Yjjy string `gorm:"column:yjjy" json:"yjjy" form:"yjjy"`
- Name string `gorm:"column:name" json:"name" form:"name"`
- }
-
- func (CmResult) TableName() string {
- return "v_cm_result"
- }
-
- type LisSyncResultStatusInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
- ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
- GpSyncEndDate string `gorm:"column:gp_sync_end_date" json:"gp_sync_end_date" form:"gp_sync_end_date"`
- }
-
- func (LisSyncResultStatusInfo) TableName() string {
- return "lis_sync_result_status_info"
- }
-
- func GetLastSyncRecord(org_id int64) (record LisSyncProcessStatusInfo, err error) {
- err = readMiddleDb.Model(&LisSyncProcessStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
- return
- }
-
- func GetLastSyncResultRecord(org_id int64) (record LisSyncResultStatusInfo, err error) {
- err = readMiddleDb.Model(&LisSyncResultStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
- return
- }
-
- func GetResultRecord() (record []CmResult, err error) {
- err = dataBase.Model(&CmResult{}).Where("repdate >= 2021-08-12 00:00:00").Order("barcode asc").Find(&record).Error
- return
- }
-
- func GetResultRecordByID(id int64) (record []CmResult, err error) {
- err = readDb.Model(&CmResult{}).Where("barcode > ? AND repdate >= 2021-08-12 00:00:00", id).Order("barcode asc").Find(&record).Error
- return
- }
-
- func GetSaveResultRecord(record LisSyncResultStatusInfo) (err error) {
- err = dataBase.Save(record).Error
- return
- }
-
- func GetLisDataById(org_id int64, last_id int64) (list []*HisLabelPrintInfo, err error) {
- //err = readDb.Model(&HisLabelPrintInfo{}).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Find(&list).Error
-
- err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
- return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
- return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1")
- }).Where("status = 1")
- }).Where("status = 1")
- }).Where("status = 1")
- }).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Find(&list).Error
- return
- }
-
- func GetAllLisData(org_id int64) (list []*HisLabelPrintInfo, err error) {
- err = readDb.Model(&HisLabelPrintInfo{}).Preload("Patient", "status = 1").Preload("VMHisProjectTeam", "status = 1").Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
- return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
- return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1")
- }).Where("status = 1")
- }).Where("status = 1")
- }).Where("status = 1")
- }).Where("user_org_id = ? AND status = 1", org_id).Limit(5).Find(&list).Error
- return
- }
-
- func GetAllLisResultData(org_id int64) (list []*CmResult, err error) {
- err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1 ", org_id).Find(&list).Error
- return
- }
-
- func GetLisResultDataByRecord(org_id int64) (list []*CmResult, err error) {
- err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1", org_id).Find(&list).Error
- return
- }
-
- // 插入中间件逻辑
- func GetDataInsertDB(org_id int64) {
- record, _ := GetLastSyncRecord(org_id)
- if record.ID == 0 {
- var cms_arr []CmSample
- list, _ := GetAllLisData(org_id)
- //插入中间库中
- for _, item := range list {
- fmt.Println(item.HisPrescriptionProject)
-
- if item.ItemId > 0 {
-
- var cms CmSample
- cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
- cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
- cms.Ptype = "门诊"
- cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
-
- if item.Patient.Gender == 1 {
- cms.Psex = "男"
- } else if item.Patient.Gender == 2 {
- cms.Psex = "女"
- } else {
- cms.Psex = "不详"
-
- }
-
- cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
- cms.Pageunit = "岁"
- cms.Departname = "肾病学专业"
- role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
- cms.Docname = role.UserName
-
- diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
-
- //var config []*models.HisXtDiagnoseConfig
- var name string
- for _, item := range diagnosis_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- diagnosisConfig, _ := FindDiagnoseById(id)
- if len(name) == 0 {
- name = diagnosisConfig.ClassName
-
- } else {
- name = name + "," + diagnosisConfig.ClassName
- }
- }
-
- cms.Diagnosis = name
- cms.Stype = ""
- cms.Samstate = ""
- cms.Desccode = strconv.FormatInt(item.ItemId, 10)
- cms.Descr = item.ProjectName
-
- data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
- datatime := time.Unix(data/1000, 0)
- cms.Sampletime = datatime
- cms.Senddate = time.Now()
- cms_arr = append(cms_arr, cms)
-
- } else {
- var cms CmSample
- cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
- cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
- cms.Ptype = "门诊"
- cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
- if item.Patient.Gender == 1 {
- cms.Psex = "男"
- } else if item.Patient.Gender == 2 {
- cms.Psex = "女"
- } else {
- cms.Psex = "不详"
- }
- cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
- cms.Pageunit = "岁"
- cms.Departname = "肾病学专业"
- role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
- cms.Docname = role.UserName
-
- diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
-
- //var config []*models.HisXtDiagnoseConfig
- var name string
- for _, item := range diagnosis_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- diagnosisConfig, _ := FindDiagnoseById(id)
- if len(name) == 0 {
- name = diagnosisConfig.ClassName
-
- } else {
- name = name + "," + diagnosisConfig.ClassName
- }
- }
-
- cms.Diagnosis = name
- cms.Stype = ""
- cms.Samstate = ""
- cms.Desccode = strconv.FormatInt(item.ProjectId, 10)
- cms.Descr = item.ProjectName
-
- tm := time.Unix(item.Ctime, 0)
- //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
- //datatime := time.Unix(data/1000, 0)
- cms.Sampletime = tm
- cms.Senddate = time.Now()
- cms_arr = append(cms_arr, cms)
- }
- }
- //插入到中间库
- for _, item := range cms_arr {
- if len(item.Pno) > 0 {
- blDb.Save(item)
- }
- }
- //插入一条插入中间库记录数据
- var info LisSyncProcessStatusInfo
- info.Ctime = time.Now().Unix()
- info.Status = 1
- info.Mtime = time.Now().Unix()
- info.OrgId = org_id
- info.IsInsert = 1
- info.IsResult = 0
- info.LastId = list[len(list)-1].ID
- info.ResultDate = 0
- writeMiddleDb.Save(&info)
-
- } else {
- var cms_arr []CmSample
- if record.LastId != 0 {
- list, _ := GetLisDataById(org_id, record.LastId)
-
- //插入中间库中
- for _, item := range list {
- if item.ItemId > 0 {
- fmt.Println()
- //teams, _ := GetProjectTeamList(org_id, item.ItemId, item.PrescriptionId)
- //for _, subItem := range teams {
- var cms CmSample
- cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
- //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
- cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
- cms.Ptype = "门诊"
- cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
- if item.Patient.Gender == 1 {
- cms.Psex = "男"
- } else if item.Patient.Gender == 2 {
- cms.Psex = "女"
- } else {
- cms.Psex = "不详"
- }
-
- cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
- cms.Pageunit = "岁"
- cms.Departname = "肾病学专业"
- role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
- cms.Docname = role.UserName
- diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
- //var config []*models.HisXtDiagnoseConfig
- var name string
- for _, item := range diagnosis_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- diagnosisConfig, _ := FindDiagnoseById(id)
- if len(name) == 0 {
- name = diagnosisConfig.ClassName
-
- } else {
- name = name + "," + diagnosisConfig.ClassName
- }
- }
- cms.Diagnosis = name
- cms.Stype = ""
- cms.Samstate = ""
- cms.Desccode = strconv.FormatInt(item.ItemId, 10)
- cms.Descr = item.ProjectName
-
- //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
- //datatime := time.Unix(data/1000, 0)
- //cms.Sampletime = datatime
- tm := time.Unix(item.Ctime, 0)
- cms.Sampletime = tm
- cms.Senddate = time.Now()
- cms_arr = append(cms_arr, cms)
- } else {
- var cms CmSample
- cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
- //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
- cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
- cms.Ptype = "门诊"
- cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
- if item.Patient.Gender == 1 {
- cms.Psex = "男"
- } else if item.Patient.Gender == 2 {
- cms.Psex = "女"
- } else {
- cms.Psex = "不详"
- }
-
- cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
- cms.Pageunit = "岁"
- cms.Departname = "肾病学专业"
- role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
- cms.Docname = role.UserName
- diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
- var name string
- for _, item := range diagnosis_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- diagnosisConfig, _ := FindDiagnoseById(id)
- if len(name) == 0 {
- name = diagnosisConfig.ClassName
-
- } else {
- name = name + "," + diagnosisConfig.ClassName
- }
- }
-
- cms.Diagnosis = name
- cms.Stype = ""
- cms.Samstate = ""
- cms.Desccode = strconv.FormatInt(item.ProjectId, 10)
- cms.Descr = item.ProjectName
- tm := time.Unix(item.Ctime, 0)
- cms.Sampletime = tm
- cms.Senddate = time.Now()
- cms_arr = append(cms_arr, cms)
- }
- }
- //插入一条插入中间库记录数据
- for _, item := range cms_arr {
- if len(item.Pno) > 0 {
- blDb.Save(item)
- }
- }
- //插入一条插入中间库记录数据
- var info LisSyncProcessStatusInfo
- info.Ctime = time.Now().Unix()
- info.Status = 1
- info.Mtime = time.Now().Unix()
- info.OrgId = org_id
- info.IsInsert = 1
- info.IsResult = 0
- info.LastId = list[len(list)-1].ID
- info.ResultDate = 0
- writeMiddleDb.Save(&info)
- }
- }
- }
-
- // 获取lis返回检验检查结果数据
- func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
- record, _ := GetLastSyncResultRecord(org_id)
- if record.ID == 0 {
- list, err := GetResultRecord()
- if err == nil {
- fmt.Println(list)
-
- //插入到系统检验检查数据
- for _, item := range list {
- project_id := int64(0)
- xt_project_id := int64(0)
- if len(item.Barcode) > 0 {
- project_id, xt_project_id, _ = GetBljhProjectID(org_id, item.Groupname)
- } else {
- continue
- }
- printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
-
- if printInfo.ID == 0 {
- fmt.Println(item)
- fmt.Println(printInfo)
- fmt.Println("数据查询不到")
- continue
- }
-
- item_id, sys_item_id, _ := GetBlItemID(org_id, item.Groupname, item.Itemname, project_id)
-
- tx := writeMiddleDb.Begin()
- var inspection models.MiddleInspection
- var inspection_reference models.MiddleInspectionReference
-
- recordDateStr := ""
- inspect_date := item.Repdate.Format("2006-01-02 15:04")
- if item.Repdate.Unix() == 0 {
- recordDateStr = time.Now().Format("2006-01-02 15:04")
- } else {
-
- recordDateStr = inspect_date
- }
-
- date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
- record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
- var total int
- var RangeOptions string
- var RangeMin string
- var RangeMax string
- // 判断检查类型
- var ItemType int
- if strings.Contains(item.Refrange, "-") {
- ItemType = 1
- } else {
- ItemType = 2
-
- }
-
- if ItemType == 1 {
- Range := strings.Split(item.Refrange, "-")
- RangeMin = Range[0]
- RangeMax = Range[1]
- } else {
- RangeOptions = item.Refrange
- }
-
- if xt_project_id > 0 && sys_item_id > 0 {
- 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
- if inspection_reference.ID > 0 {
- ItemType = inspection_reference.RangeType
- }
- if total <= 0 {
- inspection_reference.OrgId = org_id
- inspection_reference.ProjectName = item.Groupname
- inspection_reference.Project = item.Groupname
- inspection_reference.ProjectId = project_id
- inspection_reference.ItemName = item.Itemname
- inspection_reference.ItemNameAddition = item.Barcode
- inspection_reference.ItemId = item_id
- inspection_reference.RangeType = ItemType
- inspection_reference.RangeMin = RangeMin
- inspection_reference.RangeMax = RangeMax
- inspection_reference.RangeOptions = RangeOptions
- inspection_reference.Unit = item.Unit
- inspection_reference.Status = 1
- inspection_reference.CreatedTime = time.Now().Unix()
- inspection_reference.UpdatedTime = time.Now().Unix()
- inspection_reference.InspectDate = inspect_date
- inspection_reference.UTime = inspect_date
- err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
- if err != nil {
- tx.Rollback()
- }
- }
-
- } else {
- 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
- if inspection_reference.ID > 0 {
- ItemType = inspection_reference.RangeType
- }
- if total <= 0 {
- inspection_reference.OrgId = org_id
- inspection_reference.ProjectName = item.Groupname
- inspection_reference.Project = item.Groupname
- inspection_reference.ProjectId = project_id
- inspection_reference.ItemName = item.Itemname
- inspection_reference.ItemNameAddition = item.Barcode
- inspection_reference.ItemId = item_id
- inspection_reference.RangeType = ItemType
- inspection_reference.RangeMin = RangeMin
- inspection_reference.RangeMax = RangeMax
- inspection_reference.RangeOptions = RangeOptions
- inspection_reference.Unit = item.Unit
- inspection_reference.Status = 1
- inspection_reference.CreatedTime = time.Now().Unix()
- inspection_reference.UpdatedTime = time.Now().Unix()
- inspection_reference.InspectDate = inspect_date
- inspection_reference.UTime = inspect_date
- err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
- if err != nil {
- tx.Rollback()
- }
- }
-
- }
-
- if xt_project_id > 0 && sys_item_id > 0 {
- var itotal int
- 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
- if itotal <= 0 {
- //item.Result = strings.Replace(item.Result, ">", ">", -1)
- //item.Result = strings.Replace(item.Result, "<", "<", -1)
- inspection.PatientId = printInfo.PatientId
- inspection.OrgId = org_id
- inspection.ProjectId = project_id
- inspection.ItemName = inspection_reference.ItemName
- inspection.ProjectName = inspection_reference.ProjectName
- inspection.InspectType = ItemType
- inspection.ItemId = item_id
-
- inspection.InspectValue = item.Result
- inspection.InspectDate = inspect_date
- inspection.RecordDate = record_date.Unix()
- inspection.Status = 1
- inspection.CreatedTime = time.Now().Unix()
- inspection.UpdatedTime = time.Now().Unix()
- inspection.UTime = inspect_date
- inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
- err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
- if err != nil {
- tx.Rollback()
- }
- }
-
- } else {
- var itotal int
- 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
- if itotal <= 0 {
- //item.Result = strings.Replace(item.Result, ">", ">", -1)
- //item.Result = strings.Replace(item.Result, "<", "<", -1)
- inspection.PatientId = printInfo.PatientId
- inspection.OrgId = org_id
- inspection.ProjectId = project_id
- inspection.ItemName = inspection_reference.ItemName
- inspection.ProjectName = inspection_reference.ProjectName
- inspection.InspectType = ItemType
- inspection.ItemId = item_id
-
- inspection.InspectValue = item.Result
- inspection.InspectDate = inspect_date
- inspection.RecordDate = record_date.Unix()
- inspection.Status = 1
- inspection.CreatedTime = time.Now().Unix()
- inspection.UpdatedTime = time.Now().Unix()
- inspection.UTime = inspect_date
- inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
- err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
- if err != nil {
- tx.Rollback()
- }
- }
-
- }
- tx.Commit()
-
- }
- //插入一条查询检验检查结果记录状态数据
- var info LisSyncResultStatusInfo
- info.Ctime = time.Now().Unix()
- info.Status = 1
- info.Mtime = time.Now().Unix()
- info.OrgId = org_id
- info.IsResult = 1
- code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
- info.LastId = code
- info.ResultDate = time.Now().Unix()
- writeMiddleDb.Save(&info)
- //
- }
-
- } else {
- if record.LastId != 0 {
- list, err := GetResultRecordByID(record.LastId)
- fmt.Println(list)
- //插入中间库中
- //插入一条插入中间库记录数据
- if err == nil {
-
- //插入到系统检验检查数据
- for _, item := range list {
- project_id := int64(0)
- sys_project_id := int64(0)
-
- if len(item.Barcode) > 0 {
- project_id, sys_project_id, _ = GetBljhProjectID(org_id, item.Groupname)
- } else {
- continue
- }
- printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
- item_id, sys_item_id, _ := GetBlItemID(org_id, item.Groupname, item.Itemname, project_id)
-
- tx := writeMiddleDb.Begin()
- var inspection models.MiddleInspection
- var inspection_reference models.MiddleInspectionReference
-
- recordDateStr := ""
- inspect_date := item.Repdate.Format("2006-01-02 15:04")
- if item.Repdate.Unix() == 0 {
- recordDateStr = time.Now().Format("2006-01-02 15:04")
- } else {
-
- recordDateStr = inspect_date
- }
-
- date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
- record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
- var total int
- var RangeOptions string
- var RangeMin string
- var RangeMax string
- // 判断检查类型
- var ItemType int
- if strings.Contains(item.Refrange, "-") {
- ItemType = 1
-
- } else {
- ItemType = 2
-
- }
-
- if ItemType == 1 {
- Range := strings.Split(item.Refrange, "-")
- RangeMin = Range[0]
- RangeMax = Range[1]
- } else {
- RangeOptions = item.Refrange
- }
-
- 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
- if inspection_reference.ID > 0 {
- ItemType = inspection_reference.RangeType
- }
- if total <= 0 {
- inspection_reference.OrgId = org_id
- inspection_reference.ProjectName = item.Groupname
- inspection_reference.Project = item.Groupname
- inspection_reference.ProjectId = project_id
- inspection_reference.ItemName = item.Itemname
- inspection_reference.ItemNameAddition = item.Barcode
- inspection_reference.ItemId = item_id
- inspection_reference.RangeType = ItemType
- inspection_reference.RangeMin = RangeMin
- inspection_reference.RangeMax = RangeMax
- inspection_reference.RangeOptions = RangeOptions
- inspection_reference.Unit = item.Unit
- inspection_reference.Status = 1
- inspection_reference.CreatedTime = time.Now().Unix()
- inspection_reference.UpdatedTime = time.Now().Unix()
- inspection_reference.InspectDate = inspect_date
- inspection_reference.UTime = inspect_date
- err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
- if err != nil {
- tx.Rollback()
- }
- }
-
- var itotal int
- 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
- if itotal <= 0 {
- inspection.PatientId = printInfo.PatientId
- inspection.OrgId = org_id
- inspection.ProjectId = project_id
- inspection.ItemName = inspection_reference.ItemName
- inspection.ProjectName = inspection_reference.ProjectName
- inspection.InspectType = ItemType
- inspection.ItemId = item_id
- inspection.InspectValue = item.Result
- inspection.InspectDate = inspect_date
- inspection.RecordDate = record_date.Unix()
- inspection.Status = 1
- inspection.CreatedTime = time.Now().Unix()
- inspection.UpdatedTime = time.Now().Unix()
- inspection.UTime = inspect_date
- inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
- err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
- if err != nil {
- tx.Rollback()
- }
- }
-
- if sys_project_id > 0 && sys_item_id > 0 {
- var itotal int
- 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
- if itotal <= 0 {
- //item.Result = strings.Replace(item.Result, ">", ">", -1)
- //item.Result = strings.Replace(item.Result, "<", "<", -1)
- inspection.PatientId = printInfo.PatientId
- inspection.OrgId = org_id
- inspection.ProjectId = project_id
- inspection.ItemName = inspection_reference.ItemName
- inspection.ProjectName = inspection_reference.ProjectName
- inspection.InspectType = ItemType
- inspection.ItemId = item_id
-
- inspection.InspectValue = item.Result
- inspection.InspectDate = inspect_date
- inspection.RecordDate = record_date.Unix()
- inspection.Status = 1
- inspection.CreatedTime = time.Now().Unix()
- inspection.UpdatedTime = time.Now().Unix()
- inspection.UTime = inspect_date
- inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
- err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
- if err != nil {
- tx.Rollback()
- }
- }
-
- } else {
- var itotal int
- 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
- if itotal <= 0 {
- //item.Result = strings.Replace(item.Result, ">", ">", -1)
- //item.Result = strings.Replace(item.Result, "<", "<", -1)
- inspection.PatientId = printInfo.PatientId
- inspection.OrgId = org_id
- inspection.ProjectId = project_id
- inspection.ItemName = inspection_reference.ItemName
- inspection.ProjectName = inspection_reference.ProjectName
- inspection.InspectType = ItemType
- inspection.ItemId = item_id
-
- inspection.InspectValue = item.Result
- inspection.InspectDate = inspect_date
- inspection.RecordDate = record_date.Unix()
- inspection.Status = 1
- inspection.CreatedTime = time.Now().Unix()
- inspection.UpdatedTime = time.Now().Unix()
- inspection.UTime = inspect_date
- inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
- err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
- if err != nil {
- tx.Rollback()
- }
- }
-
- }
-
- tx.Commit()
-
- }
- //插入一条查询检验检查结果记录状态数据
- var info LisSyncResultStatusInfo
- info.Ctime = time.Now().Unix()
- info.Status = 1
- info.Mtime = time.Now().Unix()
- info.OrgId = org_id
- info.IsResult = 1
- code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
- info.LastId = code
- info.ResultDate = time.Now().Unix()
- writeMiddleDb.Save(&info)
-
- }
-
- }
-
- }
-
- // 第一步:跟进org_id 去中间库查出需要同步的数据
- inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
- inspections, _ := GetSyncInspectionByOrgId(org_id)
-
- // 第二步:将数据同步到业务库
- if len(inspection_references) > 0 {
- for _, inspection_reference := range inspection_references {
- SyncInspectionReferenceTwo(&inspection_reference)
- }
- }
-
- if len(inspections) > 0 {
- for _, inspection := range inspections {
- SyncInspection(&inspection)
- }
- }
- return
-
- }
-
- func GetAdminUserInfoByID(org_id int64, admin_user_id int64) (role UserAdminRole, err error) {
- err = readUserDb.Model(&UserAdminRole{}).Where("org_id = ? AND status = 1 AND admin_user_id = ?", org_id, admin_user_id).First(&role).Error
- return
- }
-
- type UserAdminRole struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- AppId int64 `gorm:"column:app_id" json:"app_id" form:"app_id"`
- RoleId int64 `gorm:"column:role_id" json:"role_id" form:"role_id"`
- UserName string `gorm:"column:user_name" json:"user_name" form:"user_name"`
- Avatar string `gorm:"column:avatar" json:"avatar" form:"avatar"`
- UserType int64 `gorm:"column:user_type" json:"user_type" form:"user_type"`
- UserTitle int64 `gorm:"column:user_title" json:"user_title" form:"user_title"`
- Intro string `gorm:"column:intro" json:"intro" form:"intro"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- UserTitleName string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
- RoleIds string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
- Message string `gorm:"column:message" json:"message" form:"message"`
- Sex int64 `gorm:"column:sex" json:"sex" form:"sex"`
- Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
- Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
- IsSort int64 `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
- Department string `gorm:"column:department" json:"department" form:"department"`
- DepartmentId int64 `gorm:"column:department_id" json:"department_id" form:"department_id"`
- Age int64 `gorm:"column:age" json:"age" form:"age"`
- Nation string `gorm:"column:nation" json:"nation" form:"nation"`
- CardType int64 `gorm:"column:card_type" json:"card_type" form:"card_type"`
- IdCard string `gorm:"column:id_card" json:"id_card" form:"id_card"`
- Education int64 `gorm:"column:education" json:"education" form:"education"`
- StudyMajorName string `gorm:"column:study_major_name" json:"study_major_name" form:"study_major_name"`
- WorkMajorName string `gorm:"column:work_major_name" json:"work_major_name" form:"work_major_name"`
- RoleType int64 `gorm:"column:role_type" json:"role_type" form:"role_type"`
- MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
- DoctorCode string `gorm:"column:doctor_code" json:"doctor_code" form:"doctor_code"`
- Licensing int64 `gorm:"column:licensing" json:"licensing" form:"licensing"`
- JobNumber string `gorm:"column:job_number" json:"job_number" form:"job_number"`
- PrescriptionQualificationIdentification int64 `gorm:"column:prescription_qualification_identification" json:"prescription_qualification_identification" form:"prescription_qualification_identification"`
- IdentificationOutpatients int64 `gorm:"column:identification_outpatients" json:"identification_outpatients" form:"identification_outpatients"`
- StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
- MedicalRangeCode int64 `gorm:"column:medical_range_code" json:"medical_range_code" form:"medical_range_code"`
- MedicalLevel int64 `gorm:"column:medical_level" json:"medical_level" form:"medical_level"`
- MedicalTypeJob int64 `gorm:"column:medical_type_job" json:"medical_type_job" form:"medical_type_job"`
- PharmacistRegistrationNumber string `gorm:"column:pharmacist_registration_number" json:"pharmacist_registration_number" form:"pharmacist_registration_number"`
- DoctorRangeCode int64 `gorm:"column:doctor_range_code" json:"doctor_range_code" form:"doctor_range_code"`
- DoctorLevel int64 `gorm:"column:doctor_level" json:"doctor_level" form:"doctor_level"`
- DoctorTypeJob int64 `gorm:"column:doctor_type_job" json:"doctor_type_job" form:"doctor_type_job"`
- DoctorNumber string `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
- OutpatientIllnessCategory string `gorm:"column:outpatient_illness_category" json:"outpatient_illness_category" form:"outpatient_illness_category"`
- IsActive int64 `gorm:"column:is_active" json:"is_active" form:"is_active"`
- ActiveStatus int64 `gorm:"column:active_status" json:"active_status" form:"active_status"`
- }
-
- func (UserAdminRole) TableName() string {
- return "sgj_user_admin_role"
- }
-
- func FindDiagnoseById(id int64) (*HisXtDiagnoseConfig, error) {
- dealer := &HisXtDiagnoseConfig{}
- err := readDb.Model(&HisXtDiagnoseConfig{}).Where("id = ? AND status = 1", id).First(&dealer).Error
- return dealer, err
- }
-
- type HisXtDiagnoseConfig struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- ClassName string `gorm:"column:class_name" json:"class_name" form:"class_name"`
- Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
- Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
- ContentCode string `gorm:"column:content_code" json:"content_code" form:"content_code"`
- CountryCode string `gorm:"column:country_code" json:"country_code" form:"country_code"`
- CountryContentName string `gorm:"column:country_content_name" json:"country_content_name" form:"country_content_name"`
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- }
-
- func (HisXtDiagnoseConfig) TableName() string {
- return "his_xt_diagnose_config"
- }
-
- type VMHisProjectTeam struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- ProjectTeam string `gorm:"column:project_team" json:"project_team" form:"project_team"`
- Price float64 `gorm:"column:price" json:"price" form:"price"`
- Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
- Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
- TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
- TeamType int64 `gorm:"column:team_type" json:"team_type" form:"team_type"`
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
- UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
- ProjectId string `gorm:"column:project_id" json:"project_id" form:"project_id"`
- VMItemProjectList []*VMItemProjectList `gorm:"-" json:"list" form:"list"`
- ItemId string `gorm:"column:item_id" json:"item_id" form:"item_id"`
- }
-
- func (VMHisProjectTeam) TableName() string {
- return "xt_his_project_team"
- }
-
- type VMItemProjectList struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- Number int64 `gorm:"column:number" json:"number" form:"number"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
- UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
- TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
- Type int64 `gorm:"column:type" json:"type" form:"type"`
- VMHisProject VMHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
- }
-
- func (VMItemProjectList) TableName() string {
- return "xt_his_project_list"
- }
-
- type VMHisProject struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
- Price float64 `gorm:"column:price" json:"price" form:"price"`
- Unit string `gorm:"column:unit" json:"unit" form:"unit"`
- CostClassify int64 `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
- StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
- NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
- MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
- }
-
- func (VMHisProject) TableName() string {
- return "xt_his_project"
- }
-
- type HisPrescriptionProject struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
- Price float64 `gorm:"column:price" json:"price" form:"price"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
- Count int64 `gorm:"column:count" json:"count" form:"count"`
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
- MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
- SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
- Day string `gorm:"column:day" json:"day" form:"day"`
- VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
- Unit string `gorm:"column:unit" json:"unit" form:"unit"`
- Type int64 `gorm:"column:type" json:"type" form:"type"`
- Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
- ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
- ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
- ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
- CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
- CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
- Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
- StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
- TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
-
- FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
- DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
- WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
- HisPrescription HisPrescription `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"his_prescription"`
- }
-
- func (HisPrescriptionProject) TableName() string {
- return "his_prescription_project"
- }
- func GetProjectTeamList(orgid int64, id int64, p_id int64) (project []*HisPrescriptionProject, err error) {
- err = readDb.Model(&HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1 AND team_id = ? AND prescription_id = ?", orgid, id, p_id).Find(&project).Error
- return
- }
-
- func GetHisLabelPrintInfoById(id string) (info HisLabelPrintInfo, err error) {
- err = readDb.Model(&HisLabelPrintInfo{}).Where("id = ?", id).First(&info).Error
- return
- }
-
- func GetPatientsInfoByIDCardNo(id_card_no string, org_id int64) (info models.Patients, err error) {
- err = readDb.Model(&models.Patients{}).Where("id_card_no = ? AND user_org_id = ?", id_card_no, org_id).First(&info).Error
- return
- }
-
- func GetAllLisDataFor10191(org_id int64) (list []models.HisLabelPrintStatusInfo, err error) {
- err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Preload("Patient", "status = 1").Where("user_org_id = ? AND status = 1 and apply_code = ''", org_id).Find(&list).Error
- return
- }
-
- func GetAllLisDataFor10191LastId(org_id int64, last_id int64) (list []*models.HisLabelPrintStatusInfo, err error) {
- 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
- return
- }
|