/// <summary> /// 日间手术室已签到未发药 已分配窗口 /// </summary> public string InPatientGetCurrentWindow(string ptno, string orderNo) { var sql = $@" SELECT DISTINCT(CHUANGKOU) CODE FROM TWOCS_PRSLIP_CHECK {{0}} GROUP BY CHUANGKOU"; var wb = new WhereBuilder(); wb.And("PTNO", ptno, true); wb.And("ORDERNO", orderNo, true); wb.And("FLAG =1", AnalyzableKind.KeepOriginal); //wb.And("GBOUT IS NULL", AnalyzableKind.KeepOriginal); //wb.And("STATUS =0", AnalyzableKind.KeepOriginal); wb.And($@"BDATE <= TO_DATE('{Environ.SlowTime.ToString("yyyy-MM-dd")}','YYYY-MM-DD') AND BDATE >= TO_DATE('{Environ.SlowTime.AddDays(-2).ToString("yyyy-MM-dd")}', 'YYYY-MM-DD') ", AnalyzableKind.KeepOriginal); wb.And("CHECKDATE IS not NULL", AnalyzableKind.KeepOriginal); wb.And("CHECKTIME IS not NULL", AnalyzableKind.KeepOriginal); wb.And("OUTDATE IS NULL", AnalyzableKind.KeepOriginal); wb.And("OUTTIME IS NULL", AnalyzableKind.KeepOriginal); var windows = DBaser.Query <PharmacyWindow>(sql, wb); if (windows.Length > 1) { return(string.Empty);// throw new Exception("一个处方单被分配到多个窗口!"); } if (windows.Length == 0) { return(string.Empty);//throw new Exception("未找到窗口记录!"); } return(windows.First()?.Code); }
/// <summary> /// 排队人最少的窗口 /// </summary> /// <param name="dm">是否取毒麻药品</param> /// <param name="working"></param> public WindowJobs[] GetWorkingWindowsLineUpNums(bool dm, bool working = true) { var sql = $@" SELECT AA.CHUANGKUO CODE,AA.CHUANGKUO CHUANGKOU ,BB.COUNT FROM ( SELECT CHUANGKUO FROM TWOCS_PRCAOZUO P, ( SELECT CODE FROM TWBAS_BASECODE WHERE BUSINESS='药房' AND BUN='窗口' AND NFLAG1='1') B WHERE JOBDATE = TRUNC(SYSDATE) AND GBEND='0' AND P.CHUANGKUO=B.CODE {(dm ? "AND CHUANGKUO IN ('14','15')" : "")} GROUP BY CHUANGKUO ) AA LEFT JOIN ( SELECT COUNT(*) COUNT ,CHUANGKOU FROM ( SELECT * FROM ( SELECT P.PTNO, p.GBPRINT, p.GBOUT, A.SNAME,A.SEX, A.BIRTHDATE,P.BI CODE, TW_HSP_PMPA.TWBAS_GETNAME.PTBINAME(P.PTNO) CODENAME, P.CHUANGKOU, --TW_HSP_PMPA.TWBAS_COMMON.S_CodeName('药房','窗口',P.CHUANGKOU) CHUANGKOU, P.STATUS, A.JUSO, A.JUMIN ,P.BDATE,P.TUYAKNO,TO_CHAR(P.CHECKTIME,'YYYY-MM-DD HH24:MI') CHECKTIME FROM TW_HSP_OCS.TWOCS_PRSLIP P, TW_HSP_PMPA.TWBAS_PATIENT A WHERE P.PTNO = A.PTNO AND ( P.GBOUT = '0' OR P.GBOUT IS NULL ) AND P.STATUS ='0' AND P.FLAG = '2' --AND P.Gbio = 'O' AND P.ENTDATE = TO_DATE( to_char(sysdate,'yyyy-MM-dd'),'YYYY-MM-DD') ) GROUP BY PTNO, GBPRINT, GBOUT,TUYAKNO,CHECKTIME, SNAME,SEX, BIRTHDATE, CODE,CODENAME, STATUS, JUSO, JUMIN ,BDATE,CHUANGKOU -- ORDER BY TUYAKNO,GBPRINT ) GROUP BY CHUANGKOU ) BB ON AA.CHUANGKUO=BB.CHUANGKOU "; var jobs = DBaser.Query <WindowJobs>(sql); if (dm && jobs.Length == 0) { return(GetWorkingWindowsLineUpNums(false)); } //throw new Exception("毒麻取药窗口10 、11 未开放!"); else if (jobs.Length == 0) { throw new Exception("取药窗口未开放!"); } return(jobs); }
public IAI_PATIENT Select(string id) { var wb = new WhereBuilder(); wb.And("patient_id", id, true); return(DBaser.Query <IAI_PATIENT>("Select * From IAI_PATIENT", wb).First()); }
/// <summary> /// 获取 已经 签到病人信息 /// </summary> public InPatientCheck GetInPatientCheckedInfo(string ptno) { if (ptno.IsEmpty()) { throw new Exception("患者编号为空!"); } var sql = $@" SELECT /*+ rule */ DECODE(O.ORDERGUBUN,'B','B','H','H','L') ORDERGUBUN, O.Ptno , M.Sname, M.Sex, M.Age, O.WardCode, M.Roomcode, M.Bedno, TW_HSP_PMPA.TWBAS_GETNAME.WARDNAME(O.WARDCODE) WARDNAME , TW_HSP_PMPA.TWBAS_COMMON.S_CodeName('BASIC','BI',O.BI) BI1 ,O.BI, TW_HSP_PMPA.TWBAS_GETNAME.DEPTNAME(O.DEPTCODE) DEPTNAME,O.DEPTCODE, TW_HSP_PMPA.TWBAS_GETNAME.DRNAME(O.DRCODE) DRNAME,O.DRCODE, TW_HSP_PMPA.TWBAS_COMMON.S_CodeName('IPD','在院状态',M.AMSET1) AMSET1 , O.JUPSU, M.INDATE FROM TW_HSP_OCS.TWOCS_IORDER_ZG O, TW_HSP_PMPA.VIEW_MASTER M , TW_HSP_PMPA.TWBAS_NSUGA N WHERE o.ptno='{ptno}' and O.BDATE <= TO_DATE('{Environ.SlowTime.ToString("yyyy-MM-dd")}','YYYY-MM-DD') AND O.BDATE >= TO_DATE('{Environ.SlowTime.AddDays(-2).ToString("yyyy-MM-dd")}','YYYY-MM-DD') AND O.GBPICKUP = '1' AND SUBSTR(O.SENDDEPT1,1,2) = '70' AND O.GBAUTO NOT IN ('T','Z') AND O.STATUS = '0' AND O.JUPSU = '1' AND O.ORDERGUBUN = 'H' AND N.SUNEXT = O.SUCODE AND O.SUNSUNAP ='3' AND M.AMSET4 <> '2' AND M.AMSET1 = '0' AND (O.STOPCHKID IS NULL OR TRIM(O.STOPCHKID) = '' ) AND O.STOPCHKDATE IS NULL AND O.PTNO = M.PTNO AND O.BI = M.BI AND O.INDATE = M.INDATE AND O.ADMSEQNO = M.ADMSEQNO GROUP BY DECODE(O.ORDERGUBUN,'B','B','H','H','L'), O.Ptno , M.Sname, M.Sex, M.Age, O.Bi, O.WardCode, M.Roomcode, M.Bedno, O.DEPTCODE, O.DRCODE, M.AMSET1, O.JUPSU, M.INDATE "; var wb = new WhereBuilder(); var result = DBaser.Query <InPatientCheck>(sql, wb); if (result.Length != 1) { return(null); } return(result[0]); }
public override IAI_PROVIDER Select(PRPM_IN306010UV01 queryEntity) { var wb = new WhereBuilder(); wb.And("healthcareprovider_id", queryEntity?.controlActProcess?.queryByParameterPayload?.providerID?.value?.extension, true); var result = DBaser.Query <IAI_PROVIDER>("Select * From IAI_PROVIDER", wb).First(); if (result == null) { throw new Exception("未查找到结果"); } return(result); }
/// <summary> /// 获取门诊今日处方 /// </summary> public Prescription[] GetOutPresNO(string ptno) { var sql = $@" SELECT PRESNO FROM TWOCS_OORDER WHERE PTNO = '{ptno}' AND BDATE = TO_DATE('{Environ.SlowTime.ToString("yyyy-MM-dd")}','YYYY-MM-DD') "; var wb = new WhereBuilder(); var PresNOs = DBaser.Query <Prescription>(sql, wb); return(PresNOs); }
/// <summary> /// 存在登记医嘱True; /// </summary> public WindowJobs[] GetWindowJobs() { var sql = $@" SELECT PUMCODE CODE, COUNT(*)COUNT FROM TWORD_JBINFO_180104 WHERE MINQTY='药房报道机日志' and placecode=to_char(sysdate,'yyyy-MM-dd') GROUP BY PUMCODE "; var windowJobs = DBaser.Query <WindowJobs>(sql); return(windowJobs); }
/// <summary> /// 获取患者的 处方、预约 处方单状态单 /// </summary> public Prescription[] GetInPresNO(string ptno) { var sql = $@" SELECT DISTINCT(PRESNO) PRESNO,BDATE,PTNO FROM TWOCS_IORDER {{0}} GROUP BY PRESNO,BDATE,PTNO"; var wb = new WhereBuilder(); wb.And("PTNO", ptno, true); wb.And("JUPSU in ('0','1')", AnalyzableKind.KeepOriginal); wb.And("BDATE= TRUNC(SYSDATE)", AnalyzableKind.KeepOriginal); var PresNOs = DBaser.Query <Prescription>(sql, wb); return(PresNOs); }
/// <summary> /// 获取日间手术病人医嘱 /// </summary> public TWOCS_PRSLIP_CHECK[] GetInpatientOrder(InPatientCheck inPatient) { if (inPatient == null) { return new TWOCS_PRSLIP_CHECK[] { } } ; var sql = $@" SELECT I.SENDDEPT1,I.PTNO, I.BI, I.INDATE, I.ADMSEQNO, I.WARDCODE, M.ROOMCODE, M.BEDNO, I.DEPTCODE, I.DRCODE, I.ORDERGUBUN, I.ORDERCODE, C.BOHUMCODE, I.BDATE, I.SUCODE, I.BUN, I.SLIPNO, I.PLUSCODE DOSCODE, I.PLUSNAME, I.CONTENTS, I.BCONTENTS, I.REALQTY, I.DIV, I.NAL, I.QTY, I.JSQTY, I.GRP, I.POWDER, I.TFLAG, I.SELF, I.ER, I.REMARK, I.PRN, I.STATUS, C.BASEUNIT, C.LABELUNIT, T.BOAMT BASEAMT,T.BOAMT * I.JSQTY AMT1, '' AMT2, I.ORDERNO, I.PKORDERNO, ROWNUM, '001757', '20010107', TRUNC(SYSDATE), TO_CHAR(SYSDATE,'HH24:MI:SS'), T.PUMCODE ,'MZ' FROM TW_HSP_OCS.TWOCS_IORDER_ZG I, TW_HSP_OCS.TWOCS_ORDERCODE C, TW_HSP_PMPA.TWBAS_TSUGA T, TW_HSP_PMPA.TWBAS_NSUGA N, TW_HSP_PMPA.VIEW_MASTER M WHERE I.PTNO = '{inPatient.PTNO}' AND I.BDATE <= TO_DATE('{Environ.SlowTime.ToString("yyyy-MM-dd")}','YYYY-MM-DD') AND I.BDATE >= TO_DATE('{Environ.SlowTime.AddDays(-2).ToString("yyyy-MM-dd")}','YYYY-MM-DD') AND I.GBPICKUP = '1' AND SUBSTR(I.SENDDEPT1,1,1) = '7' AND I.GBAUTO NOT IN ('T','Z') AND I.STATUS = '0' AND I.ORDERGUBUN = 'H' AND I.WARDCODE = '{inPatient.WARDCODE}' AND I.DEPTCODE = '{inPatient.DEPTCODE}' AND I.DRCODE = '{inPatient.DRCODE}' AND I.JUPSU = '0' AND N.SUNEXT = I.SUCODE AND (I.STOPCHKID IS NULL OR TRIM(I.STOPCHKID) = '') AND I.STOPCHKDATE IS NULL AND I.SUNSUNAP ='3' AND I.ORDERCODE = C.ORDERCODE AND I.SUCODE = T.SUCODE AND I.PTNO = M.PTNO "; var wb = new WhereBuilder(); var result = DBaser.Query <TWOCS_PRSLIP_CHECK>(sql, wb); return(result); }
/// <summary> /// 获取全部窗口 /// </summary> public PharmacyWindow[] GetAllWindow() { var sql = $@" SELECT * FROM TW_HSP_PMPA.TWBAS_BASECODE {{0}} Order By Code "; var wb = new WhereBuilder(); wb.And("BUSINESS", "药房"); wb.And("BUN", "窗口"); wb.And("GBUSE", "0"); wb.And("NFLAG1", "1"); var result = DBaser.Query <PharmacyWindow>(sql, wb); return(result); }
public override IAI_MEDICAL_REGISTRATION Select(PRPA_IN900300UV02 queryEntity) { var result = DBaser.Query <IAI_MEDICAL_REGISTRATION>( "Select * From IAI_MEDICAL_REGISTRATION", new WhereBuilder("medical_type", EncounterEventTypeCode.ADMITTER).And("encounterevent_id", queryEntity ?.controlActProcess ?.queryByParameterPayload ?.careEventID ?.value ?.extension)).First(); if (result == null) { throw new Exception("无记录"); } return(result); }
/// <summary> /// 已签到未发药 已分配窗口 /// </summary> public PharmacyWindow[] GetCurrentWindow(string ptno, string presno) { var sql = $@" SELECT DISTINCT(CHUANGKOU) CODE FROM TWOCS_PRSLIP {{0}} GROUP BY CHUANGKOU"; var wb = new WhereBuilder(); wb.And("PTNO", ptno, true); wb.And("PRESNO", presno, true); wb.And("BDATE= TRUNC(SYSDATE)", AnalyzableKind.KeepOriginal); wb.And("CHECKDATE IS NOT NULL", AnalyzableKind.KeepOriginal); wb.And("CHECKTIME IS NOT NULL", AnalyzableKind.KeepOriginal); wb.And("(GBOUT IS NULL OR GBOUT =0) ", AnalyzableKind.KeepOriginal); return(DBaser.Query <PharmacyWindow>(sql, wb)); }
public override IAI_ORGANIZATION Select(PRPM_IN406010UV01 queryEntity) { var result = DBaser.Query <IAI_ORGANIZATION>( "Select * From IAI_ORGANIZATION", new WhereBuilder("organization_id", queryEntity ?.controlActProcess ?.queryByParameterPayload ?.organizationID ?.value ?.extension)).First(); if (result == null) { throw new Exception("无记录"); } return(result); }
public override IAI_DICT Select(CodeSystem item) { var key = $"{item.codeSystemName}_{item.code}"; string myCache = cache[key] as string; if (myCache == null) { CacheItemPolicy policy = new CacheItemPolicy(); policy.AbsoluteExpiration = DateTime.Now.AddSeconds(60 * 10); var wb = new WhereBuilder(); wb.And("CODE_SYSTEM_NAME", item?.codeSystemName, true); wb.And("CODE", item?.code); var sql = $@" Select * From IAI_DICT "; var result = DBaser.Query <IAI_DICT>(sql, wb).First(); if (result == null) { throw new Exception("无记录"); } //return result; myCache = result.DISPLAY_NAME; cache.Set(key, myCache, policy); } return(new IAI_DICT { DISPLAY_NAME = cache.Get(key) as string, }); //var wb = new WhereBuilder(); //wb.And("CODE_SYSTEM_NAME", item?.codeSystemName, true); //wb.And("CODE", item?.code); //var sql = $@" Select * // From IAI_DICT "; //var result = DBaser.Query<IAI_DICT>(sql, wb).First(); //if (result == null) //{ // throw new Exception("无记录"); //} //return result; }
public override IAI_OBSERVATION Select(QUMT_IN020030PL queryEntity) { var result = DBaser.Query <IAI_OBSERVATION>( "Select * From IAI_OBSERVATION", new WhereBuilder("observation_id", queryEntity ?.controlActProcess ?.queryByParameter ?.queryByParameterPayload ?.actId ?.value ?.extension)).First(); if (result == null) { throw new Exception("无记录"); } return(result); }
/// <summary> /// 获取工作窗口的取药数量 /// </summary> public PharmacyWindow[] GetWorkingWindow() { var sql = $@" SELECT CHUANGKUO CODE FROM TWOCS_PRCAOZUO P, ( SELECT CODE FROM TWBAS_BASECODE WHERE BUSINESS='药房' AND BUN='窗口' AND NFLAG1='1') B WHERE JOBDATE = TRUNC(SYSDATE) AND GBEND='0' AND P.CHUANGKUO=B.CODE GROUP BY CHUANGKUO"; var wb = new WhereBuilder(); var result = DBaser.Query <PharmacyWindow>(sql, wb); return(result); }
public override IAI_MEDICAL_REGISTRATION Select(PRPA_IN900300UV02 item) { var wb = new WhereBuilder(); wb.And("encounterevent_id", item?.controlActProcess?.queryByParameterPayload?.careEventID?.value?.extension, true); wb.And("medical_type", EncounterEventTypeCode.DISCHARGE); var sql = $@" Select * From IAI_MEDICAL_REGISTRATION "; var result = DBaser.Query <IAI_MEDICAL_REGISTRATION>(sql, wb).First(); if (result == null) { throw new Exception("无记录"); } return(result); }
/// <summary> /// 获取患者的 处方、预约 处方单状态单 /// </summary> public Prescription[] GetPresNOwithWindow(string ptno) { var sql = $@" SELECT PRESNO,PTNO, TUYAKNO, DEPTCODE, DRCODE,DRNAME, USERID, GBPRINT, SNAME, SEX, BIRTHDATE, CODE, CODENAME, DEPTNAMEK,STATUS, JUSO, JUMIN ,BDATE,CHUANGKOU,ORDERGUBUN,A FROM ( SELECT P.PRESNO,P.PTNO, p.TUYAKNO, p.DEPTCODE, p.DRCODE, p.USERID, p.GBPRINT, A.SNAME, TW_HSP_PMPA.TWBAS_COMMON.S_CodeName('药房','窗口',P.CHUANGKOU) CHUANGKOU, A.SEX, A.BIRTHDATE, P.BI CODE, P.STATUS, TW_HSP_PMPA.TWBAS_GETNAME.DEPTNAME(P.DEPTCODE) DEPTNAMEK, TW_HSP_PMPA.TWBAS_GETNAME.DRNAME(P.DRCODE) DRNAME, TW_HSP_PMPA.TWBAS_COMMON.S_CodeName('BASIC','BI',P.BI) CODENAME , A.JUSO, A.JUMIN, P.BDATE,ORDERGUBUN, (CASE WHEN P.BUN IN ('E0','E1') AND P.GBHIGH IS NULL THEN 'K' WHEN P.BUN IN ('E2') AND P.GBHIGH IS NULL THEN 'Z' WHEN P.BUN IN ('F0','F1') THEN 'C' WHEN P.GBHIGH ='N' AND SLIPNO NOT IN ('1132','2132') THEN 'D' WHEN P.GBHIGH ='N' AND SLIPNO IN ('1132','2132') THEN 'D2' ELSE '0' END) A FROM TW_HSP_OCS.TWOCS_PRSLIP P, TW_HSP_PMPA.TWBAS_PATIENT A WHERE P.PTNO = A.PTNO AND P.PTNO = '{ptno}' AND P.CHUANGKOU != '00' AND (P.GBOUT = '0' OR P.GBOUT IS NULL) AND P.ENTDATE >= TO_DATE('{Environ.SlowTime.AddDays(-2).ToString("yyyy-MM-dd")}','YYYY-MM-DD') AND P.ENTDATE <= TO_DATE('{Environ.SlowTime.ToString("yyyy-MM-dd")}','YYYY-MM-DD') AND P.Gbio = 'O' AND P.STATUS = '0' AND ((P.DEPTCODE ='ER' AND P.BUN IN ('F0','F1')) OR P.DEPTCODE <> 'ER') ) GROUP BY PRESNO,PTNO, TUYAKNO, DEPTCODE,DRNAME, DRCODE, USERID, GBPRINT, SNAME, SEX, BIRTHDATE, CODE, CODENAME, DEPTNAMEK,STATUS, JUSO, JUMIN ,BDATE,CHUANGKOU,ORDERGUBUN,A ORDER BY GBPRINT,TUYAKNO DESC "; var wb = new WhereBuilder(); var PresNOs = DBaser.Query <Prescription>(sql, wb); return(PresNOs); }