12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591 |
- package coordinate
-
- import (
- "encoding/json"
- "encoding/xml"
- "fmt"
- "gdyb/controllers"
- "gdyb/enums"
- "gdyb/models"
- "gdyb/service"
- "gdyb/utils"
- "github.com/astaxie/beego"
- "io/ioutil"
- "math/rand"
- "os"
- "strconv"
- "strings"
- "time"
- )
-
- type CoordinateController struct {
- controllers.BaseAuthAPIController
- }
-
- type ResultReg struct {
- ResultCode string `json:"resultCode"`
- ResultDesc string `json:"resultDesc"`
- InfoSeq string `json:"infoSeq"`
- }
-
- type ResultSettle struct {
- ResultCode string `json:"resultCode"`
- ResultDesc string `json:"resultDesc"`
- }
-
- type ResultCancelSettle struct {
- ResultCode string `json:"resultCode"`
- ResultDesc string `json:"resultDesc"`
- }
-
- type Settle struct {
- PatientId string `json:"resultCode"`
- DocId string `json:"docId"`
- InfoSeq string `json:"infoSeq"`
- }
-
- type Refund struct {
- PatientId string `json:"resultCode"`
- DocId string `json:"docId"`
- InfoSeq string `json:"infoSeq"`
- }
-
- type RefundDetail struct {
- Msg string `json:"msg"`
- Result []struct {
- ResultMsg string `json:"resultMsg"`
- Code string `json:"code"`
- Records int `json:"records"`
- TotalPage int `json:"totalPage"`
- List []struct {
- Zae01 int64 `json:"ZAE01"`
- } `json:"list"`
- RecordsTotal int `json:"recordsTotal"`
- Pagenumber int `json:"pagenumber"`
- Result string `json:"result"`
- Total int `json:"total"`
- RecordsFtered int `json:"recordsFtered"`
- Page int `json:"page"`
- } `json:"result"`
- Code string `json:"code"`
- }
- type RefundDetailtwo struct {
- Msg string `json:"msg"`
- Code string `json:"code"`
- }
-
-
- type ResultQuery struct {
- Msg string `json:"msg"`
- Result []struct {
- Type string `json:"type"`
- Name string `json:"name"`
- Vaa01 int `json:"vaa01"`
- Vaa07 int `json:"vaa07"`
- Visittime string `json:"visittime"`
- } `json:"result"`
- Code string `json:"code"`
- }
-
- type Data struct {
- List []ListItem `json:"resultObj"`
- Result bool `json:"result"`
- Code int `json:"code"`
- ResultMsg string `json:"resultMsg"`
- Msg string `json:"msg"`
- Error bool `json:"error"`
- Success bool `json:"success"`
- }
-
-
- type Data10 struct {
- List []ListItem10 `json:"resultObj"`
- Result bool `json:"result"`
- Code int `json:"code"`
- ResultMsg string `json:"resultMsg"`
- Msg string `json:"msg"`
- Error bool `json:"error"`
- Success bool `json:"success"`
- }
-
- type ListItem10 struct {
- Vaf01 int64 `json:"vaf01"`
- }
-
-
- type ListItem struct {
- Acf01 int64 `json:"acf01"`
- Bcq04 string `json:"bcq04"`
- Abw01 string `json:"abw01"`
- Aau01 string `json:"aau01"`
- Vaa08 string `json:"vaa08"`
- Vae11 string `json:"vae11"`
- Vaa05 string `json:"vaa05"`
- Vaa10 int `json:"vaa10"`
- Vaa01 int `json:"vaa01"`
- Vaa07 int `json:"vaa07"`
- Vaa12 string `json:"vaa12"`
- Abbrp string `json:"abbrp"`
- Bck01A int `json:"bck01a"`
- Bck01B int `json:"bck01b"`
-
- Vaa15 string `json:"vaa15"`
- Vaa35 string `json:"vaa35"`
- }
-
- 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"`
- } `json:"result"`
- }
-
- func CoordinateRcegistRouters() {
- beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
- //坐标挂号
- beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
- //坐标记账
- //beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
- //坐标撤销记账
- //beego.Router("/coordinate/opCancelKeepAccounts", &CoordinateController{}, "get:OpCancelKeepAccounts")
- //坐标结算回调
- beego.Router("/coordinate/settle", &CoordinateController{}, "post:Settle")
- //坐标退费回调
- beego.Router("/coordinate/refund", &CoordinateController{}, "post:Refund")
- //坐标患者查询~上传医嘱~结算功能
- //beego.Router("/coordinate/settleAccount", &CoordinateController{}, "get:SettleAccount")
-
- beego.Router("/coordinate/other", &CoordinateController{}, "get:NMGother")
-
- ////内蒙古
- beego.Router("/nmg/coordinate/settleAccount", &CoordinateController{}, "get:NMGSettleAccount")
- beego.Router("/nmg/coordinate/settleAccount/cancel", &CoordinateController{}, "get:NMGCancelSettleAccount")
-
-
- beego.Router("/nmg/coordinate/querystock", &CoordinateController{}, "get:QueryStock")
-
- /* beego.Router("/nmg/coordinate/deladvice", &CoordinateController{}, "get:NMGdeladvice")
- beego.Router("/nmg/coordinate/createadvice", &CoordinateController{}, "get:NMGcreateadvice")
- beego.Router("/nmg/coordinate/querydiagnose", &CoordinateController{}, "get:NMGquerydiagnose")
- beego.Router("/nmg/coordinate/querycheck", &CoordinateController{}, "get:NMGquerycheck")
- */
-
-
-
- }
-
- ////删医嘱
- //func (c *CoordinateController)NMGdeladvice(){
- // patient_id, _ := c.GetInt64("patient_id")
- // id, _ := c.GetInt64("id")
- //
- //
- // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
- // result, _ := service.GetNMGHisPatientForCoordinate(0,0,0,patient.Name)
- // var res Data
- // if err := json.Unmarshal([]byte(result), &res); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // service.CancleNMGPrescriptionForCoordinate(res.List[0].Acf01,)
- //
- //}
-
-
-
-
-
- type ProjectStruct struct {
- Data []struct {
- Bbx01 int64 `json:"bbx01"`
- Bda02 string `json:"bda02"`
- Bbx04 string `json:"bbx04"`
- Bbx05 string `json:"bbx05"`
- Bby06 string `json:"bby06"`
- Bdg02 string `json:"bdg02"`
- Acf01 int64 `json:"acf01"`
- Price float64 `json:"price"`
- Bck01 int64 `json:"bck01"`
- Lsqty float64 `json:"lsqty"`
- Bce03a string `json:"bce03a"`
- Bbx24 string `json:"bbx24"`
- Bbx25 string `json:"bbx25"`
- } `json:"data"`
- }
-
- type Medicine struct {
- Data []struct {
- Bby01 int `json:"bby01"`
- Ypmc string `json:"ypmc"`
- Gg string `json:"gg"`
- Dw string `json:"dw"`
- Jhj float64 `json:"jhj"`
- Pfj float64 `json:"pfj"`
- Lsj float64 `json:"lsj"`
- Sysl float64 `json:"sysl"`
- Ypjx string `json:"ypjx"`
- Jldw string `json:"jldw"`
- Sccj string `json:"sccj"`
- Cd string `json:"cd"`
- } `json:"data"`
- }
-
- func (c *CoordinateController)QueryStock(){
- result, _ := service.GetDrugs()
- fmt.Println(result)
- result2, _ := service.GetProject()
- saveLog(result, "", "查询", "查询", "")
- saveLog(result2, "", "查询", "查询", "")
-
-
- var project ProjectStruct
- err := json.Unmarshal([]byte(result2), &project)
- if err != nil {
- fmt.Println("解析JSON出错:", err)
- return
- }
- fmt.Println(project)
- var drug Medicine
- err2 := json.Unmarshal([]byte(result), &drug)
- if err2 != nil {
- fmt.Println("解析JSON出错:", err2)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "project": project,
- "drug": drug,
- })
- }
-
-
- //查询检查
- func (c *CoordinateController)NMGquerycheck(){
-
-
- }
-
- func (c *CoordinateController)NMGother(){
-
- //service.GetDeptEmp()
- service.GetDrugInterval()
- //service.GetUsage()
- //service.GetDrugs()
- //service.GetProject()
-
-
-
-
- }
-
-
-
- type ResultObj struct {
- Cbm01 int `json:"cbm01"`
- Vaf01List []int `json:"vaf01List"`
- }
-
- type Response struct {
- ResultObj []ResultObj `json:"resultObj"`
- Result bool `json:"result"`
- Code int `json:"code"`
- ResultMsg string `json:"resultMsg"`
- Msg string `json:"msg"`
- Error bool `json:"error"`
- Success bool `json:"success"`
- }
-
-
-
- type Responsexml struct {
- XMLName xml.Name `xml:"root"`
- ErrorCode int `xml:"errorcode"`
- ErrorMsg string `xml:"errormsg"`
- Data string `xml:"data"`
- }
-
- //获取患者信息-判断是否存在上传过的医嘱,先删除后保存当天医嘱-记账
- func (c *CoordinateController) NMGSettleAccount() {
- 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 = 10454
- org, _ := service.GetOrgById(org_id)
- patient, _ := service.GetPatientByID(org.Id, patient_id)
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- //住院
- result, request := service.GetNMGHisPatientForCoordinate(0,0,2,patient.Name)
- //门诊
- result5, request5 := service.GetNMGHisPatientForCoordinate(0,0,1,patient.Name)
-
- saveLog(result, request, "住院查询", "住院查询", "")
- saveLog(result5, request5, "门诊查询", "门诊查询", "")
-
- var res Data
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- var res8 Data
- if err := json.Unmarshal([]byte(result5), &res8); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- //优先查询今天门诊的患者,如果今天没有门诊的患者查询出住院的患者
- if res8.Code == 200 {
- var res9 Data
- //res9.List = append(res9.List, res.List...)
- res9.List = append(res9.List, res8.List...)
-
- var li ListItem
- for _, item := range res9.List {
- cure_date := strings.Split(item.Vae11, " ")
- if cure_date[0] == record_date && patient.Name == item.Vaa05 {
- li = item
- }
- }
-
- if li.Acf01 == 0 && li.Vaa07 == 0 && li.Vaa01 == 0 { //今天没有门诊患者,则查询出最后一个日期的住院患者
- var res10 Data
- //res9.List = append(res9.List, res.List...)
- res10.List = append(res10.List, res.List...)
- layout := "2006-01-02 15:04:05"
- var maxDate time.Time
- for _, item := range res10.List {
- currentDate, err := time.Parse(layout, item.Vae11)
- if err != nil {
- fmt.Println("Error parsing date:", err)
- continue
- }
- if currentDate.After(maxDate) {
- maxDate = currentDate
- }
- if !maxDate.IsZero() {
- fmt.Println("The maximum date is:", maxDate.Format(layout))
- } else {
- fmt.Println("No valid dates found")
- }
- }
- fmt.Println(maxDate.Format("2006-01-02 15:04:05"))
- for _, item := range res10.List {
- if item.Vae11 == maxDate.Format("2006-01-02 15:04:05") && patient.Name == item.Vaa05{
- li = item
- }
- }
- }
- fmt.Println(li)
-
- 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.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
- }
- departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
- admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
- doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
-
- var prescriptions []*models.HisPrescription
- settle_accounts_type = 1
- if settle_accounts_type == 1 { //日结
- prescriptions, _ = service.GetUnSettleHisPrescriptionFive(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 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 {
- tempTime := time.Unix(item.PreTime, 0)
- //timeFormat := tempTime.Format("20060102150405")
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- 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,
- ItemId: subItem.BaseDrugLib.ZuobiaoId,
- StartTime: timeFormatOne,
- Content: subItem.AdviceName,
- Bby01: subItem.BaseDrugLib.Bby01,
- }
- customs = append(customs, cus)
- }
- }
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- if subItem.Type == 2 {
- tempTime := time.Unix(item.PreTime, 0)
- //timeFormat := tempTime.Format("20060102150405")
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- 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,
- ItemId: subItem.HisProject.ZuobiaoId,
- StartTime: timeFormatOne,
- Content: subItem.HisProject.ProjectName,
- Bby01: subItem.HisProject.Bby01,
-
- }
- customs = append(customs, cus)
-
- } else {
- tempTime := time.Unix(item.PreTime, 0)
- //timeFormat := tempTime.Format("20060102150405")
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- 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,
- ItemId: subItem.GoodInfo.ZuobiaoId,
- StartTime: timeFormatOne,
- Content: subItem.GoodInfo.GoodName,
- Bby01: subItem.GoodInfo.Bby01,
-
- }
- customs = append(customs, cus)
- }
-
- }
- }
- }
-
- var info models.UploadInfo
- info.Acf01 = int64(li.Acf01)
- info.Bce01 = admin_user_info.DoctorNumber
- info.Bck01 = "48"
- info.Vaa07 = int64(li.Vaa07)
- info.Vaa01 = int64(li.Vaa01)
- info.Vaa05 = li.Vaa05
- info.Bce01a = doctor_info.DoctorNumber
-
- //for _, item := range customs {
- // var cha models.ChargeList
- // cha.Bby01 = item.Bby01
- // cha.Vaj25 = item.Cut
- // cha.Bbx01 = item.ItemId
- // cha.Vaf21 = item.Cut
- // cha.Vaf22 = item.Content
- // cha.Vaf42 = item.StartTime
- // info.ChargeList = append(info.ChargeList, cha)
- //}
-
- for _, item := range customs {
- var cha models.ChargeListtwo
- cha.Bby01 = item.Bby01
- cha.Vaj25 = item.Cut
- info.ChargeListtwo = append(info.ChargeListtwo, cha)
- }
-
- var root models.Root
- var tradeInfo models.TradeInfo
- var cBM1 models.CBM1
- var vAF1 models.VAF1
- var vAO1 models.VAO1
- var vBQ1 models.VBQ1
-
- if li.Acf01 == 1 {
- tradeInfo.PatSource = 1
- tradeInfo.Type = 0
- } else {
- tradeInfo.PatSource = 2
- tradeInfo.Type = 1
-
- }
- tradeInfo.Detpid = departmwnt.Number
- tradeInfo.Empid = doctor_info.DoctorNumber
- tradeInfo.Empno = doctor_info.DoctorCode
- tradeInfo.Empname = doctor_info.UserName
- root.TradeInfo = tradeInfo
- //
- //
- //var del_ids []string
- //
- //
- ////信息
- for _, item := range prescriptions {
- fmt.Println("999999999")
- //del_ids = append(del_ids, item.Cbm01)
- var ie_cbm1 models.IEone
-
- ie_cbm1.CBMID = strconv.FormatInt(item.ID, 10)
- ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
- ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
- //ie_cbm1.CBM06 = strconv.FormatInt(int64(res.List[0].Acf01), 10)
-
- if li.Acf01 == 1 {
- ie_cbm1.CBM06 = item.Cbm07
- ie_cbm1.BCK01A = "0"
- } else {
- ie_cbm1.CBM06 = "0"
- ie_cbm1.BCK01A =strconv.FormatInt(int64(li.Bck01A), 10) //病区id
- }
- ie_cbm1.CBM07 = item.Cbm07
- ie_cbm1.BCK01B = strconv.FormatInt(int64(li.Bck01B), 10)
- ie_cbm1.BCK01C = departmwnt.Number
- ie_cbm1.CBM19 = "0"
- cBM1.Ie = append(cBM1.Ie, ie_cbm1)
- }
- root.CBM1 = cBM1
- ////医嘱
- for _, item := range prescriptions {
- fmt.Println("88888888888")
- if item.Type == 1 {
- for _, subitem := range item.HisDoctorAdviceInfo {
- var ie_cbm1 models.IEtwo
- ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
- ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
- ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
- ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
- ie_cbm1.ROWNR = strconv.FormatInt(subitem.Groupno, 10)
-
- ie_cbm1.VAF10 = "1"
- ie_cbm1.VAF11 = "2"
- ie_cbm1.BDA01 = "1" //诊疗类型
- ie_cbm1.BBX01 = subitem.BaseDrugLib.ZuobiaoId
- ie_cbm1.VAF14 = "" //检验样本类型
- ie_cbm1.VAF15 = "" //检验样本类型
- ie_cbm1.BBY01 = "" //药品规格id或材料规格id
-
- if li.Acf01 == 1 {
- ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
-
- } else {
- ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
-
- }
- ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
- ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
- ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
- ie_cbm1.VAF21 = fmt.Sprintf("%.2f", subitem.PrescribingNumber)
-
- ie_cbm1.VAF22 = subitem.AdviceName
- ie_cbm1.Crypt = "0"
- ie_cbm1.VAF23 = ""
- ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
- ie_cbm1.VAF26 = subitem.ExecutionFrequency
- ie_cbm1.VAF27 = "1"
- ie_cbm1.VAF28 = ""
- ie_cbm1.VAF29 = ""
-
- ie_cbm1.VAF30 = ""
- ie_cbm1.VAF31 = "0"
-
- ie_cbm1.VAF32 = "0" //todo
- ie_cbm1.VAF33 = "0"
- ie_cbm1.VAF34 = "0"
- ie_cbm1.VAF35 = "0"
-
- tempTime1 := time.Unix(subitem.StartTime, 0)
- timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
- ie_cbm1.VAF36 = timeFormatOne
- ie_cbm1.VAF37 = "1899-12-30"
- doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
- ie_cbm1.BCK01C = departmwnt.Number
-
- ie_cbm1.BCE02A = doctor_info.DoctorNumber
- ie_cbm1.BCE03A = doctor_info.UserName
- ie_cbm1.BCE03B = ""
-
- ie_cbm1.VAF53 = "-1"
- ie_cbm1.VAF55 = subitem.Remark
- ie_cbm1.BCK01D = departmwnt.Number
- ie_cbm1.VAF58 = "0"
- ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno), 10)
-
- ie_cbm1.VAF60 = ""
- ie_cbm1.VAF61 = "1"
- ie_cbm1.VAF62 = "0"
- ie_cbm1.LSign = "0"
- ie_cbm1.BDA01A = ie_cbm1.BDA01
- ie_cbm1.LRoute = "0"
- ie_cbm1.BCE01A = doctor_info.DoctorNumber
- ie_cbm1.BCE01B = "0"
-
- ie_cbm1.VAF01B = "0"
- ie_cbm1.VCO01 = "0"
- ie_cbm1.BCE01H = "0"
- ie_cbm1.BCE03H = ""
- ie_cbm1.BIW02 = ""
- ie_cbm1.RCurrent = "0"
- ie_cbm1.FCheck = "0"
- ie_cbm1.UnameA = ""
- ie_cbm1.VEH02 = ""
- vAF1.Ie = append(vAF1.Ie, ie_cbm1)
- }
-
- //每种药品下的给药途径
- for _, subitem := range item.HisDoctorAdviceInfo {
- way, _ := service.GetDrugwayDicByName(subitem.DeliveryWay, c.GetAdminUserInfo().CurrentOrgId)
- var ie_cbm1 models.IEtwo
- ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
- ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
- ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
- ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
- ie_cbm1.ROWNR = "0"
- ie_cbm1.VAF10 = "1"
- ie_cbm1.VAF11 = "2"
- ie_cbm1.BDA01 = "T" //诊疗类型
- ie_cbm1.BBX01 = way.Code
- ie_cbm1.VAF14 = "" //检验样本类型
- ie_cbm1.VAF15 = "" //检验样本类型
- ie_cbm1.BBY01 = "" //药品规格id或材料规格id
- if li.Acf01 == 1 {
- ie_cbm1.VAF17 = strconv.FormatInt(int64(subitem.Day), 10) //药品规格id或材料规格id
- } else {
- ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
- }
- ie_cbm1.VAF18 = fmt.Sprintf("%.2f", subitem.SingleDose) //药品规格id或材料规格id
- ie_cbm1.VAF19 = fmt.Sprintf("%.2f", subitem.SingleDose) + " " + subitem.SingleDoseUnit //药品规格id或材料规格id
- ie_cbm1.VAF20 = fmt.Sprintf("%.2f", subitem.SingleDose)
- //ie_cbm1.VAF21 = fmt.Sprintf("%.2f",subitem.PrescribingNumber)
-
- //ie_cbm1.VAF18 = "" //药品规格id或材料规格id
- //ie_cbm1.VAF19 = ""
- //ie_cbm1.VAF20 = ""
- ie_cbm1.VAF21 = "1"
-
- ie_cbm1.VAF22 = way.Name
- ie_cbm1.Crypt = "0"
- ie_cbm1.VAF23 = ""
- ie_cbm1.BCK01B = subitem.BaseDrugLib.Bck01b
- ie_cbm1.VAF26 = ""
- ie_cbm1.VAF27 = ""
- ie_cbm1.VAF28 = ""
- ie_cbm1.VAF29 = ""
- ie_cbm1.BCK01C = departmwnt.Number
-
- ie_cbm1.VAF30 = ""
- ie_cbm1.VAF31 = "0"
-
- ie_cbm1.VAF32 = "1" //todo
- ie_cbm1.VAF33 = "0"
- ie_cbm1.VAF34 = "0"
- ie_cbm1.VAF35 = "0"
-
- tempTime1 := time.Unix(subitem.StartTime, 0)
- timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
- ie_cbm1.VAF36 = timeFormatOne
- ie_cbm1.VAF37 = "1899-12-30"
- doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
-
- ie_cbm1.BCE02A = doctor_info.DoctorNumber
- ie_cbm1.BCE03A = doctor_info.UserName
- ie_cbm1.BCE03B = ""
-
- ie_cbm1.VAF53 = "-1"
- ie_cbm1.VAF55 = subitem.Remark
- ie_cbm1.BCK01D = departmwnt.Number
- ie_cbm1.VAF58 = "0"
- ie_cbm1.VAF59 = strconv.FormatInt(int64(subitem.Groupno), 10)
-
- ie_cbm1.VAF60 = ""
- ie_cbm1.VAF61 = "1"
- ie_cbm1.VAF62 = "0"
- ie_cbm1.LSign = "0"
- ie_cbm1.BDA01A = ie_cbm1.BDA01
- ie_cbm1.LRoute = "0"
- ie_cbm1.BCE01A = doctor_info.DoctorNumber
- ie_cbm1.BCE01B = "0"
-
- ie_cbm1.VAF01B = "0"
- ie_cbm1.VCO01 = "0"
- ie_cbm1.BCE01H = "0"
- ie_cbm1.BCE03H = ""
- ie_cbm1.BIW02 = ""
- ie_cbm1.RCurrent = "0"
- ie_cbm1.FCheck = "0"
- ie_cbm1.UnameA = ""
- ie_cbm1.VEH02 = ""
- vAF1.Ie = append(vAF1.Ie, ie_cbm1)
- }
-
- } else if item.Type == 2 {
- for index, subitem := range item.HisPrescriptionProject {
- if subitem.Type == 2 {
- if subitem.HisProject.CostClassify != 3 {
- var ie_cbm1 models.IEtwo
- ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
- ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
- ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
- ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
- ie_cbm1.ROWNR = strconv.FormatInt(int64(index), 10)
- ie_cbm1.VAF10 = "1"
- ie_cbm1.VAF11 = "2"
- ie_cbm1.BDA01 = "T" //诊疗类型
- ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
- ie_cbm1.VAF14 = "" //检验样本类型
- ie_cbm1.VAF15 = "" //检验样本类型
- ie_cbm1.BBY01 = "" //药品规格id或材料规格id
- if li.Acf01 == 1 {
- ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
- } else {
- ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
- }
- ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
- ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
- ie_cbm1.VAF20 = subitem.SingleDose
- ie_cbm1.VAF21 = subitem.Count
-
- ie_cbm1.VAF22 = subitem.HisProject.ProjectName
- ie_cbm1.Crypt = "0"
- ie_cbm1.VAF23 = ""
- ie_cbm1.BCK01B = subitem.HisProject.Bck01b
- ie_cbm1.VAF26 = subitem.ExecutionFrequency
- ie_cbm1.VAF27 = "1"
- ie_cbm1.VAF28 = ""
- ie_cbm1.VAF29 = ""
- ie_cbm1.BCK01C = departmwnt.Number
-
- ie_cbm1.VAF30 = ""
- ie_cbm1.VAF31 = "0"
-
- ie_cbm1.VAF32 = "0" //todo
- ie_cbm1.VAF33 = "0"
- ie_cbm1.VAF34 = "0"
- ie_cbm1.VAF35 = "0"
-
- tempTime1 := time.Unix(subitem.StartTime, 0)
- timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
- ie_cbm1.VAF36 = timeFormatOne
- ie_cbm1.VAF37 = "1899-12-30"
- doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
-
- ie_cbm1.BCE02A = doctor_info.DoctorNumber
- ie_cbm1.BCE03A = doctor_info.UserName
- ie_cbm1.BCE03B = ""
-
- ie_cbm1.VAF53 = "-1"
- ie_cbm1.VAF55 = subitem.Remark
- ie_cbm1.BCK01D = departmwnt.Number
- ie_cbm1.VAF58 = "0"
- ie_cbm1.VAF59 = strconv.FormatInt(int64(index), 10)
-
- ie_cbm1.VAF60 = ""
- ie_cbm1.VAF61 = "1"
- ie_cbm1.VAF62 = "0"
- ie_cbm1.LSign = "0"
- ie_cbm1.BDA01A = "" //诊疗类型
- ie_cbm1.LRoute = "0"
- ie_cbm1.BCE01A = doctor_info.DoctorNumber
-
- //ie_cbm1.BCE01A = doctor_info.UserName
- ie_cbm1.BCE01B = "0"
-
- ie_cbm1.VAF01B = "0"
- ie_cbm1.VCO01 = "0"
- ie_cbm1.BCE01H = "0"
- ie_cbm1.BCE03H = ""
- ie_cbm1.BIW02 = ""
- ie_cbm1.RCurrent = "0"
- ie_cbm1.FCheck = "0"
- ie_cbm1.UnameA = ""
- ie_cbm1.VEH02 = ""
- vAF1.Ie = append(vAF1.Ie, ie_cbm1)
- }
- if subitem.HisProject.CostClassify == 3 {
- var ie_cbm1 models.IEtwo
- ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
- ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
- ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
- ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
- ie_cbm1.ROWNR = strconv.FormatInt(int64(index), 10)
- ie_cbm1.VAF10 = "1"
- ie_cbm1.VAF11 = "2"
- ie_cbm1.BDA01 = "L" //诊疗类型
- ie_cbm1.BBX01 = subitem.HisProject.ZuobiaoId
- ie_cbm1.VAF14 = "" //检验样本类型
- ie_cbm1.VAF15 = "" //检验样本类型
- ie_cbm1.BBY01 = "" //药品规格id或材料规格id
- if li.Acf01 == 1 {
- ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
- } else {
- ie_cbm1.VAF17 = "0" //药品规格id或材料规格idn
- }
- ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
- ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
- ie_cbm1.VAF20 = subitem.SingleDose
- ie_cbm1.VAF21 = subitem.Count
-
- ie_cbm1.VAF22 = subitem.HisProject.ProjectName
- ie_cbm1.Crypt = "0"
- ie_cbm1.VAF23 = ""
- ie_cbm1.BCK01B = subitem.HisProject.Bck01b
- ie_cbm1.VAF26 = subitem.ExecutionFrequency
- ie_cbm1.VAF27 = "1"
- ie_cbm1.VAF28 = ""
- ie_cbm1.VAF29 = ""
- ie_cbm1.BCK01C = departmwnt.Number
- ie_cbm1.VAF30 = ""
- ie_cbm1.VAF31 = "0"
- ie_cbm1.VAF32 = "0" //todo
- ie_cbm1.VAF33 = "0"
- ie_cbm1.VAF34 = "0"
- ie_cbm1.VAF35 = "0"
- tempTime1 := time.Unix(subitem.StartTime, 0)
- timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
- ie_cbm1.VAF36 = timeFormatOne
- ie_cbm1.VAF37 = "1899-12-30"
- doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
-
- ie_cbm1.BCE02A = doctor_info.DoctorNumber
- ie_cbm1.BCE03A = doctor_info.UserName
- ie_cbm1.BCE03B = ""
-
- ie_cbm1.VAF53 = "-1"
- ie_cbm1.VAF55 = subitem.Remark
- ie_cbm1.BCK01D = departmwnt.Number
- ie_cbm1.VAF58 = "0"
- ie_cbm1.VAF59 = strconv.FormatInt(int64(index), 10)
-
- ie_cbm1.VAF60 = ""
- ie_cbm1.VAF61 = "1"
- ie_cbm1.VAF62 = "0"
- ie_cbm1.LSign = "0"
- ie_cbm1.BDA01A = "" //诊疗类型
- ie_cbm1.LRoute = "0"
- ie_cbm1.BCE01A = doctor_info.DoctorNumber
-
- //ie_cbm1.BCE01A = doctor_info.UserName
- ie_cbm1.BCE01B = "0"
-
- ie_cbm1.VAF01B = "0"
- ie_cbm1.VCO01 = "0"
- ie_cbm1.BCE01H = "0"
- ie_cbm1.BCE03H = ""
- ie_cbm1.BIW02 = ""
- ie_cbm1.RCurrent = "0"
- ie_cbm1.FCheck = "0"
- ie_cbm1.UnameA = ""
- ie_cbm1.VEH02 = ""
- vAF1.Ie = append(vAF1.Ie, ie_cbm1)
- }
-
- } else if subitem.Type == 3 {
- var ie_cbm1 models.IEtwo
- ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
- ie_cbm1.VAF04 = strconv.FormatInt(int64(li.Acf01), 10)
- ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- ie_cbm1.VAF06 = strconv.FormatInt(int64(li.Vaa07), 10)
- ie_cbm1.BCK01A = strconv.FormatInt(int64(li.Bck01A), 10)
- ie_cbm1.ROWNR = strconv.FormatInt(int64(index), 10)
-
- ie_cbm1.VAF10 = "1"
- ie_cbm1.VAF11 = "2"
- ie_cbm1.BDA01 = "4" //诊疗类型
- ie_cbm1.BBX01 = subitem.GoodInfo.ZuobiaoId
- ie_cbm1.VAF14 = "" //检验样本类型
- ie_cbm1.VAF15 = "" //检验样本类型
- ie_cbm1.BBY01 = "" //药品规格id或材料规格id
-
- if li.Acf01 == 1 {
- ie_cbm1.VAF17 = subitem.Day //药品规格id或材料规格id
-
- } else {
- ie_cbm1.VAF17 = "0" //药品规格id或材料规格id
-
- }
- ie_cbm1.VAF18 = subitem.SingleDose //药品规格id或材料规格id
- ie_cbm1.VAF19 = subitem.SingleDose + " " + subitem.Unit //药品规格id或材料规格id
- ie_cbm1.VAF20 = subitem.SingleDose
- ie_cbm1.VAF21 = subitem.Count
- ie_cbm1.BCK01C = departmwnt.Number
-
- ie_cbm1.VAF22 = subitem.GoodInfo.GoodName
- ie_cbm1.Crypt = "0"
- ie_cbm1.VAF23 = ""
- ie_cbm1.BCK01B = subitem.GoodInfo.Bck01b
- ie_cbm1.VAF26 = ""
- ie_cbm1.VAF27 = ""
- ie_cbm1.VAF28 = ""
- ie_cbm1.VAF29 = ""
-
- ie_cbm1.VAF30 = ""
- ie_cbm1.VAF31 = "0"
-
- ie_cbm1.VAF32 = "0" //todo
- ie_cbm1.VAF33 = "0"
- ie_cbm1.VAF34 = "0"
- ie_cbm1.VAF35 = "0"
-
- tempTime1 := time.Unix(subitem.StartTime, 0)
- timeFormatOne := tempTime1.Format("2006-01-02 15:04:05")
- ie_cbm1.VAF36 = timeFormatOne
- ie_cbm1.VAF37 = "1899-12-30"
- doctor_info, _ := service.GetAdminUserInfoByID(org_id, item.Creator)
-
- ie_cbm1.BCE02A = doctor_info.DoctorNumber
- ie_cbm1.BCE03A = doctor_info.UserName
- ie_cbm1.BCE03B = ""
- ie_cbm1.BCK01C = departmwnt.Number
-
- ie_cbm1.VAF53 = "-1"
- ie_cbm1.VAF55 = subitem.Remark
- ie_cbm1.BCK01D = departmwnt.Number
- ie_cbm1.VAF58 = "0"
- ie_cbm1.VAF59 = strconv.FormatInt(int64(index), 10)
- ie_cbm1.VAF60 = ""
- ie_cbm1.VAF61 = "1"
- ie_cbm1.VAF62 = "0"
- ie_cbm1.LSign = "0"
- ie_cbm1.BDA01A = "" //诊疗类型
- ie_cbm1.LRoute = "0"
- ie_cbm1.BCE01A = doctor_info.DoctorNumber
- ie_cbm1.BCE01B = "0"
- ie_cbm1.VAF01B = "0"
- ie_cbm1.VCO01 = "0"
- ie_cbm1.BCE01H = "0"
- ie_cbm1.BCE03H = ""
- ie_cbm1.BIW02 = ""
- ie_cbm1.RCurrent = "0"
- ie_cbm1.FCheck = "0"
- ie_cbm1.UnameA = ""
- ie_cbm1.VEH02 = ""
- vAF1.Ie = append(vAF1.Ie, ie_cbm1)
- }
- }
- }
-
- }
- root.VAF1 = vAF1
- for _, item := range prescriptions {
-
- dias := strings.Split(patientPrescription.Diagnosis, ",")
- //service.get
-
- //诊断
- for index, subitem := range dias {
- diagnosisConfig, _ := service.FindDiagnoseByIdtwo(subitem)
-
- if index == 0 {
- var ie_cbm1 models.IEthree
- ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
- ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
- ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
- ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
- ie_cbm1.VAO07 = "1"
- ie_cbm1.VAO10 = "0"
- ie_cbm1.VAO11 = "6"
- ie_cbm1.BAK01A = "31537"
- ie_cbm1.CAM01 = diagnosisConfig.CountryCode
- ie_cbm1.VAO15 = diagnosisConfig.ClassName
- ie_cbm1.VAO18 = "0"
- ie_cbm1.VAO22 = "1"
- ie_cbm1.IAA01 = ""
- ie_cbm1.IAD03 = ""
- ie_cbm1.BAK01B = ""
- ie_cbm1.VAO26 = ""
- ie_cbm1.IAD04 = ""
- ie_cbm1.IAD01 = ""
- ie_cbm1.VAO25 = "1"
- ie_cbm1.VAO35 = ""
- vAO1.Ie = append(vAO1.Ie, ie_cbm1)
-
- } else {
- var ie_cbm1 models.IEthree
- ie_cbm1.CBMID = strconv.FormatInt(int64(item.ID), 10)
- ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
- ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
- ie_cbm1.VAO06 = strconv.FormatInt(int64(index+1), 10)
- ie_cbm1.VAO07 = "1"
- ie_cbm1.VAO10 = "0"
- ie_cbm1.VAO11 = "6"
- ie_cbm1.BAK01A = "31537"
- ie_cbm1.CAM01 = diagnosisConfig.CountryCode
- ie_cbm1.VAO15 = diagnosisConfig.ClassName
- ie_cbm1.VAO18 = "0"
- ie_cbm1.VAO22 = "1"
- ie_cbm1.IAA01 = ""
- ie_cbm1.IAD03 = ""
- ie_cbm1.BAK01B = ""
- ie_cbm1.VAO26 = ""
- ie_cbm1.IAD04 = ""
- ie_cbm1.IAD01 = ""
- ie_cbm1.VAO25 = "2"
- ie_cbm1.VAO35 = ""
- vAO1.Ie = append(vAO1.Ie, ie_cbm1)
- }
- }
- }
- ////
- //////检验检查医嘱
- //for _, item := range prescriptions{
- // fmt.Println("6666666666666")
- // if item.Type == 2{
- // for _, subitem := range item.HisPrescriptionProject {
- // if subitem.Type == 2{
- // if subitem.HisProject.CostClassify == 3 {
- // var ie_cbm1 models.IEfour
- // ie_cbm1.VBQ01 = strconv.FormatInt(int64(item.ID), 10)
- // ie_cbm1.VAA01 = strconv.FormatInt(int64(li.Vaa01), 10)
- // ie_cbm1.VAA07 = strconv.FormatInt(int64(li.Vaa07), 10)
- // ie_cbm1.ACF01 = strconv.FormatInt(int64(li.Acf01), 10)
- // ie_cbm1.VAP01 = "0"
- // ie_cbm1.VBQ07 = "0"
- // ie_cbm1.BCK01A = departmwnt.Number
- // ie_cbm1.BCK01B= "0"
- // ie_cbm1.BCE03A= ""
- // ie_cbm1.BCE01A= "0"
- // ie_cbm1.VBQ27= subitem.HisProject.ProjectName
- // ie_cbm1.VBQ28= patientPrescription.Diagnosis
- // ie_cbm1.VBQ29= ""
- // ie_cbm1.VBQ30= ""
- // vBQ1.Ie = append(vBQ1.Ie, ie_cbm1)
- // }
- //
- // }
- //
- // }
- // }
- //}
-
- root.VAO1 = vAO1
- root.VBQ1 = vBQ1
- zuobiao, _ := service.Getzuobiao(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
- //idss := strings.Split(zuobiao.AdiviceIds,",")
- is_success := true
- failed_mag := ""
- //查询出对应的坐标系统医嘱id,先进行删除操作,在创建医嘱。如果没有医嘱id,则直接创建医嘱
- if zuobiao.ID > 0 {
- cbm01s := strings.Split(zuobiao.Cbm01, ",")
- fmt.Println(cbm01s)
-
- for _, iditem := range cbm01s {
- fmt.Println(iditem)
- var root2 models.Root2
- var tradeInfo2 models.TradeInfo
- if li.Acf01 == 1 {
- tradeInfo2.PatSource = 1
- tradeInfo2.Type = 0
- } else {
- tradeInfo2.PatSource = 2
- tradeInfo2.Type = 1
-
- }
- tradeInfo2.Detpid = departmwnt.Number
- tradeInfo2.Empid = doctor_info.DoctorNumber
- tradeInfo2.Empno = doctor_info.DoctorCode
- tradeInfo2.Empname = doctor_info.UserName
-
- var vaf01 models.VAF10
- var ie1111 models.IEfive
- ie1111.VAF01 = iditem
- vaf01.Ie = append(vaf01.Ie, ie1111)
- root2.TradeInfo = tradeInfo2
- root2.VAF1 = vaf01
- xmlStr2, err := xml.MarshalIndent(root2, "", " ")
- if err != nil {
- fmt.Println("转换为XML时发生错误:", err)
- return
- }
- result1, log := service.CancleNMGPrescriptionForCoordinatetwo("0002", string(xmlStr2))
- fmt.Println(string(xmlStr2))
- fmt.Println(result1)
- fmt.Println(log)
- saveLog(result1, log, "删除明细", "删除明细", org.OrgName)
- var res8 Responsexml
- if err = xml.Unmarshal([]byte(result1), &res8); err != nil {
- fmt.Println(err)
- return
- }
-
- if res8.ErrorCode != 0 {
- is_success = false
- failed_mag = res8.ErrorMsg
- }
- }
- }
- if is_success {
- xmlStr, err := xml.MarshalIndent(root, "", " ")
- if err != nil {
- fmt.Println("转换为XML时发生错误:", err)
- return
- }
- //上传医嘱版本2
- result3, request3 := service.UploadNMGPrescriptionForCoordinatetwo("0001", string(xmlStr))
- fmt.Println(string(xmlStr))
- saveLog(result3, request3, "上传明细", "上传明细", org.OrgName)
-
- var res3 Responsexml
- if err = xml.Unmarshal([]byte(result3), &res3); err != nil {
- fmt.Println(err)
- }
- fmt.Println(res3)
- if res3.ErrorCode == 0 {
- var zuobiao_advice models.HisZuobiaoAdvice
- zuobiao_advice.Status = 1
- zuobiao_advice.RecordDate = recordDateTime
- zuobiao_advice.PatientId = patient_id
- zuobiao_advice.Cbm01 = res3.Data
- zuobiao_advice.Ctime = time.Now().Unix()
- zuobiao_advice.Mtime = time.Now().Unix()
- zuobiao_advice.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
- service.Createzuobiao(&zuobiao_advice)
- if li.Acf01 != 1{
- //记账
- result2, request2 := service.NMGSettleForCoordinate(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
- }
-
- }
- 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(li.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(li.Vaa07), 10),
- PhoneNumber: patient.Phone,
- }
- service.UpdateHisPatientStatusten(&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: strconv.FormatInt(int64(li.Vaa07), 10),
- Number: strconv.FormatInt(int64(li.Vaa07), 10),
- SetlId: "",
- MedfeeSumamt: 0,
- MedType: strconv.Itoa(int(reg_type)),
- SettleEndTime: 0,
- SettleStartTime: 0,
- SettleType: settle_accounts_type,
- Diagnosis: diagnosis_id,
- PType: int64(li.Acf01),
- SetlTime: tm.Format("2006-01-02 15:04:05"),
- }
- err = service.CreateOrder(order)
- if err != nil {
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
- 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
- }
- 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.UpdataHisPateintTwo(&his)
- err = service.UpDatePrescriptionNumber(org_id, ids, strconv.FormatInt(int64(chrgBchno), 10))
- err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(chrgBchno), 10), recordDateTime, his.ID)
- err = service.UpdataOrderStatusThreef(strconv.FormatInt(int64(chrgBchno), 10), org_id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "成功",
- })
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res3.ErrorMsg,
- })
-
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": failed_mag,
- })
-
- }
- }else{
-
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.Msg,
- })
- }
- }
- func (c *CoordinateController)NMGCancelSettleAccount(){
- order_id, _ := c.GetInt64("order_id")
- record_date := c.GetString("record_date")
- order, _ := service.GetHisOrderByID(order_id)
- patient, _ := service.GetPatientByID(order.UserOrgId, order.PatientId)
- if order.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
- return
- }
- //住院
- result, request := service.GetNMGHisPatientForCoordinate(0,0,2,patient.Name)
- //门诊
- result5, request5 := service.GetNMGHisPatientForCoordinate(0,0,1,patient.Name)
- saveLog(result, request, "住院查询", "住院查询", "")
- saveLog(result5, request5, "门诊查询", "门诊查询", "")
- var res Data
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var res8 Data
- if err := json.Unmarshal([]byte(result5), &res8); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
-
- if res.Code == 200 || res8.Code == 200 {
- var res9 Data
- res9.List = append(res9.List, res.List...)
- res9.List = append(res9.List, res8.List...)
-
- var li ListItem
- for _, item := range res9.List {
- cure_date := strings.Split(item.Vae11, " ")
- if cure_date[0] == record_date && patient.Name == item.Vaa05 {
- li = item
- }
- }
-
- if li.Acf01 == 0 && li.Vaa07 == 0 && li.Vaa01 == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": "患者今天尚未挂号,请先挂号进行记账操作",
- })
- return
- }
-
- if li.Acf01 == 1 {
- err := service.UpdataOrderStatustwo(order_id, order.Number, c.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销记账成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }else {
- result, request_log := service.NMGCancleSettleForCoordinate(order.PType,order.Number)
- saveLog(result, request_log, "撤销记账", "撤销记账", "")
- var res RefundDetailtwo
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res.Code == "200" {
- err := service.UpdataOrderStatustwo(order_id, order.Number, c.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销记账成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.Msg,
- })
-
- }
- }
- }else{
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.Msg,
- })
- }
- }
-
-
-
-
-
-
-
- //func (c *CoordinateController)NMGgetcheck(){
- // 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 = 10454
- // org, _ := service.GetOrgById(org_id)
- // patient, _ := service.GetPatientByID(org.Id, patient_id)
- // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- // result, request := service.GetNMGHisPatientForCoordinate(0,0,2,patient.Name)
- // result5, request5 := service.GetNMGHisPatientForCoordinate(0,0,1,patient.Name)
- //
- // saveLog(result, request, "查询", "查询", "")
- // saveLog(result5, request5, "查询", "查询", "")
- //
- // var res Data
- // if err := json.Unmarshal([]byte(result), &res); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- //
- // var res8 Data
- // if err := json.Unmarshal([]byte(result5), &res8); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- //
- // if res.Code == 200 || res8.Code == 200 {
- // var res9 Data
- // res9.List = append(res9.List,res.List...)
- // res9.List = append(res9.List,res8.List...)
- //
- //
- // var li ListItem
- // for _, item := range res9.List{
- // cure_date := strings.Split(item.Vae11, " ")
- // if cure_date[0] == record_date && patient.Name == item.Vaa05{
- // li = item
- // }
- // }
- // fmt.Println("11111111")
- // fmt.Println(li)
- // fmt.Println("11111111")
- // 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.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
- // }
- // //departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
- // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
- // //doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
- //
- //
- //
- //
- // //service.QueryNMGChenckForCoordinate(li.Acf01,li.Vaa01,li.Vaa07,"")
- //
- //
- // } else {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "failed_code": -10,
- // "msg": res.Msg,
- // })
- // }
- //
- //
- //}
-
-
-
-
-
-
- //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 = 3877
- // 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.FindLastPatientPrescriptionInfo(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.GetUnSettleHisPrescriptionFive(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 = int64(res.Result[0].Vaa01)
- // info.Fasong = "1"
- // info.Vaa07 = int64(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
- // 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 _, subItem := range item.HisDoctorAdviceInfo {
- // ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
- //
- // var infoItem models.Item
- // infoItem.Rownr = "0"
- // infoItem.Vaf11 = "1"
- // 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 {
- // var infoItem models.Item
- // infoItem.Rownr = "0"
- // infoItem.Vaf11 = "1"
- // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 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.Vaf22 = subItem.HisProject.ProjectName
- // infoItem.Bdi01 = ef.Code
- // infoItem.Vaf17 = subItem.Day
- // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
- // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count)
- // infoItem.Vaf35 = "0"
- // infoItem.Vaf18 = "0"
- // 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.ExecutionTime, 0).Format("2006-01-02 15:04:05")
- // infoItem.Bbx01 = subItem.GoodInfo.MedicalInsuranceNumber
- // infoItem.Bda01 = "M"
- // infoItem.Bby01 = ""
- // infoItem.Vaf22 = subItem.GoodInfo.GoodName + " " + subItem.GoodInfo.SpecificationName
- // infoItem.Bdi01 = ef.Code
- // infoItem.Vaf17 = subItem.Day
- // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
- // infoItem.Vaf21 = fmt.Sprintf("%.2f", 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
- //
- // result2, request2 := service.UploadPrescriptionForCoordinate(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" {
- //
- // 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.UpdateHisPatientStatusten(&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.ErrorCodeCreateOrderException)
- // 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.UpdataHisPateintTwo(&his)
- // err = service.UpDatePrescriptionNumber(org_id, ids, strconv.FormatInt(int64(chrgBchno), 10))
- // err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(chrgBchno), 10), recordDateTime, his.ID)
- // err = service.UpdataOrderStatusThreef(strconv.FormatInt(int64(chrgBchno), 10), org_id)
- //
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "医嘱保存成功",
- // })
- //
- // } else {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "failed_code": -10,
- // "msg": res.Msg,
- // })
- //
- // }
- //
- // } else {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "failed_code": -10,
- // "msg": res.Msg,
- // })
- //
- // }
- //
- //}
-
- func (c *CoordinateController) Settle() {
- //参数1 patient_id
- //参数2 就诊号
- //参数3 单据id
- fmt.Println(c.Ctx.Request.Body)
- body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
- fmt.Println(string(body))
-
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- return
- }
- patien_id := respJSON["vaa01"].(float64)
- infoSeq := respJSON["vaa07"].(float64)
-
- //strconv.For(patien_id, 10)
-
- vaa001 := fmt.Sprintf("%f", patien_id)
- vaa007 := fmt.Sprintf("%f", infoSeq)
-
- setl_id := respJSON["setl_id"].(string)
- order, _ := service.GetHisOrderFour(vaa001, vaa007, "")
- order.SetlId = setl_id
- if order.ID == 0 {
- json := make(map[string]interface{})
- json["msg"] = "结算记录不存在,请检查参数是否正确"
- json["code"] = "-1"
- c.Data["json"] = json
- c.ServeJSON()
- return
- }
- order.OrderStatus = 2
- service.UpDateOrder(order)
- service.UpdataOrderStatusTwo(order.Number, order.UserOrgId)
- json := make(map[string]interface{})
- json["msg"] = "结算成功"
- json["code"] = "0"
- c.Data["json"] = json
- c.ServeJSON()
- return
- }
- func (c *CoordinateController) Refund() {
- //参数1 patient_id
- //参数2 就诊号
- //参数3 单据id
- body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- return
- }
- patien_id := respJSON["vaa01"].(float64)
- infoSeq := respJSON["vaa07"].(float64)
- //strconv.For(patien_id, 10)
- vaa001 := fmt.Sprintf("%f", patien_id)
- vaa007 := fmt.Sprintf("%f", infoSeq)
- docId := respJSON["setl_id"].(string)
- order, _ := service.GetHisOrderFour(vaa001, vaa007, docId)
- if order.ID == 0 {
- json := make(map[string]interface{})
- json["msg"] = "结算记录不存在,请检查参数是否正确"
- json["code"] = "-1"
- c.Data["json"] = json
- c.ServeJSON()
- return
- }
- service.UpdataOrderStatustwo(order.ID, order.Number, order.UserOrgId)
- json := make(map[string]interface{})
- json["msg"] = "退费成功"
- json["code"] = "0"
- c.Data["json"] = json
- c.ServeJSON()
- return
- }
-
-
- func (c *CoordinateController) SavePatientMessageInfo() {
- result, request_log := service.SavePatientMessageInfo()
- fmt.Println(result)
- fmt.Println(request_log)
-
- }
- func (c *CoordinateController) checkpatient() {
-
- }
- func (c *CoordinateController) Register() {
- patient_id, _ := c.GetInt64("patient_id")
- diagnosis_time := c.GetString("diagnosis_time")
- record_date := c.GetString("record_date")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- org_id, _ := c.GetInt64("org_id")
- patient, _ := service.GetPatientByID(org_id, patient_id)
- org, _ := service.GetOrgById(org_id)
-
- 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
- }
- if len(patient.ZbPatientId) == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnNoEmpty)
- return
- }
-
- recordDateTime := theTime.Unix()
- patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
- if patientPrescription.ID == 0 {
- patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
- }
- doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
- admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
- reg := models.Reg{
- DeptId: "0112",
- PatientId: patient.ZbPatientId,
- PatientName: patient.Name,
- DoctorId: doctor_info.DoctorNumber,
- RegDate: strings.Split(diagnosis_time, " ")[0],
- RegFee: "0",
- TreatFee: "0",
- OperatorId: admin_user_info.UserName,
- IdCardNo: patient.IdCardNo,
- }
-
- result, request_log := service.SaveReg(reg)
- fmt.Println(result)
- fmt.Println(request_log)
- saveLog(result, request_log, "登记", "登记", org.OrgName)
- var res ResultReg
- if err := json.Unmarshal([]byte(result), &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res.ResultCode == "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: patient.ZbPatientId,
- 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: res.InfoSeq,
- PhoneNumber: patient.Phone,
- }
- service.UpdateHisPatientStatus(&his)
- service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
- c.ServeSuccessJSON(map[string]interface{}{
- "his_info": his,
- })
- } else {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ResultDesc,
- })
-
- }
- }
-
- //func (c *CoordinateController) GetWaitPayDetail() {
- // result, request_log := service.GetWaitPayDetail()
- // fmt.Println(result)
- // fmt.Println(request_log)
- //
- //}
-
- //func (c *CoordinateController) OpKeepAccounts() {
- // id, _ := c.GetInt64("id")
- // record_time := c.GetString("record_time")
- // his_patient_id, _ := c.GetInt64("his_patient_id")
- // timeLayout := "2006-01-02"
- // loc, _ := time.LoadLocation("Local")
- // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- // fapiao_code := c.GetString("fapiao_code")
- // fapiao_number := c.GetString("fapiao_number")
- // diagnosis_id := c.GetString("diagnosis")
- // sick_type, _ := c.GetInt64("sick_type")
- // reg_type, _ := c.GetInt64("p_type")
- // org_id, _ := c.GetInt64("org_id")
- // org, _ := service.GetOrgById(org_id)
- //
- // his, _ := service.GetHisPatientByIdThree(his_patient_id)
- //
- // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- // if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- // }
- // recordDateTime := theTime.Unix()
- // //adminUser := c.GetAdminUserInfo()
- // var prescriptions []*models.HisPrescription
- // var start_time int64
- // var end_time int64
- //
- // //ids_str := c.GetString("ids")
- // //ids_arr := strings.Split(ids_str, ",")
- //
- // if settle_accounts_type == 1 { //日结
- // //fmt.Println(reg_type)
- // prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, 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()
- // start_time = recordStartTime
- // 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()
- // end_time = recordEndTime
- // prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, id, recordStartTime, recordEndTime)
- // }
- //
- // timestamp := time.Now().Unix()
- // tempTime := time.Unix(timestamp, 0)
- // timeFormat := tempTime.Format("20060102150405")
- // chrgBchno := rand.Intn(100000) + 10000
- // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
- // strconv.FormatInt(his.PatientId, 10)
- //
- // var ids []int64
- //
- // for _, item := range prescriptions {
- // ids = append(ids, item.ID)
- // }
- // 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)
- // }
- // }
- //
- // for _, subItem := range item.HisAdditionalCharge {
- // total = total + (subItem.Price * float64(subItem.Count))
- // }
- // }
- //
- // tm := time.Unix(time.Now().Unix(), 0)
- //
- // 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)
- //
- // }
- //
- // }
- // }
- // for _, item := range item.HisAdditionalCharge {
- // cus := &models.NewCustomTwo{
- // ItemId: item.ID,
- // AdviceId: 0,
- // ProjectId: 0,
- // DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
- // Cut: fmt.Sprintf("%.4f", float64(item.Count)),
- // FeedetlSn: item.FeedetlSn,
- // Price: fmt.Sprintf("%.4f", float64(item.Price)),
- // MedListCodg: item.XtHisAddtionConfig.Code,
- // Type: 3,
- // }
- // customs = append(customs, cus)
- // }
- // }
- // result, request_log := service.OpKeepAccounts(his.Number, customs)
- // saveLog(result, request_log, "记账", "记账", org.OrgName)
- //
- // var res ResultSettle
- // if err := json.Unmarshal([]byte(result), &res); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // if res.ResultCode == "0" {
- //
- // //totals, _ := strconv.ParseFloat(total, 64)
- // order := &models.HisOrder{
- // PsnNo: his.PsnNo,
- // UserOrgId: org_id,
- // HisPatientId: his.ID,
- // PatientId: id,
- // SettleAccountsDate: recordDateTime,
- // Ctime: time.Now().Unix(),
- // Mtime: time.Now().Unix(),
- // Status: 1,
- // OrderStatus: 1,
- // MdtrtId: his.Number,
- // Number: chrg_bchno,
- // SetlId: "",
- // MedfeeSumamt: total,
- // MedType: strconv.Itoa(int(reg_type)),
- // SettleEndTime: end_time,
- // SettleStartTime: start_time,
- // SettleType: settle_accounts_type,
- // FaPiaoCode: fapiao_code,
- // FaPiaoNumber: fapiao_number,
- // Diagnosis: diagnosis_id,
- // PType: 2,
- // SetlTime: tm.Format("2006-01-02 15:04:05"),
- // }
- // err = service.CreateOrder(order)
- // if err != nil {
- // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
- // 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: 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.UpdataHisPateintThree(&his)
- // err = service.UpDatePrescriptionNumber(org_id, ids, chrg_bchno)
- // err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, id, chrg_bchno, recordDateTime, his_patient_id)
- // err = service.UpdataOrderStatusThreef(chrg_bchno, org_id)
- // if err == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "记账成功",
- // })
- // }
- // } else {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "failed_code": -10,
- // "msg": res.ResultDesc,
- // })
- // }
- //
- //}
- //
- //func (c *CoordinateController) OpCancelKeepAccounts() {
- // order_id, _ := c.GetInt64("order_id")
- // admin_user_id, _ := c.GetInt64("admin_user_id")
- // org_id, _ := c.GetInt64("org_id")
- // org, _ := service.GetOrgById(org_id)
- //
- // order, _ := service.GetHisOrderByID(order_id)
- // if order.ID == 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
- // return
- // }
- //
- // role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
- // result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
- // saveLog(result, request_log, "撤销记账", "撤销记账", org.OrgName)
- // var res RefundDetail
- // if err := json.Unmarshal([]byte(result), &res); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // fmt.Println(result)
- // fmt.Println(request_log)
- // fmt.Println(res)
- // flag := 0
- // isSuccess := false
- // for _, item := range res.Result {
- // if item.Code == "200" {
- // flag = flag + 1
- // }
- // }
- // if len(res.Result) == flag {
- // isSuccess = true
- // }
- // var errMsg string
- // for _, item := range res.Result {
- // errMsg = errMsg + "\n" + item.ResultMsg
- // }
- //
- // if isSuccess {
- // err := service.UpdataOrderStatustwo(order_id, order.Number, org_id)
- // if err == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "撤销记账成功",
- // })
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // } else {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "failed_code": -10,
- // "msg": errMsg,
- // })
- //
- // }
- //}
-
- //func saveLog(result string, request string, infno string, desc string) {
- //
- // org_id, _ := beego.AppConfig.Int64("org_id")
- // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
- // dir := miConfig.OrgName + "日志"
- // 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 := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
- // file_name := file + ".txt"
- // file_path := miConfig.OrgName + "日志" + "/" + 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(miConfig.OrgName + "日志" + "/" + file_name)
- // defer f.Close()
- // if err != nil {
- // } else {
- // _, err = f.Write([]byte("记录日志"))
- // }
- // }
- //
- //}
-
- 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("记录日志"))
- }
- }
-
- }
|