private void btnRequestPreparation_Click(object sender, EventArgs e) { scintillaResPreparation.Text = string.Empty; try { var str = scintillaReqPreparation.Text.Trim(); GetPreparationRequest request = null; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str))) { var argElement = XDocument.Load(ms).Descendants("arg0").First(); var arg0 = XmlHelper.XmlDeserialize <Arg0>(argElement.ToString()); request = new GetPreparationRequest { Arg0 = arg0 }; } var res = soapService.GetPreparation(request); var resStr = XmlHelper.XmlSerializeToString(res); scintillaResPreparation.Focus(); scintillaResPreparation.Text = XmlHelper.FormatXML(resStr); scintillaResPreparation.FormatStyle(StyleType.Xml); } catch (Exception ex) { logger.Error(ex, ex.Message); MessageBox.Show(ex.Message); } }
public GetPreparationResponse getPreparation(GetPreparationRequest request) { HttpContext.Current.Request.InputStream.Position = 0; var requestStr = new StreamReader(HttpContext.Current.Request.InputStream, Encoding.UTF8).ReadToEnd(); WorkContext = new WorkContextSoapHeader(); try { var relativeItemCode = request.Arg0.ItemCode; if (RuleMappingHelper.ItemCode_HKID_Mapping.ContainsKey(relativeItemCode)) { relativeItemCode = RuleMappingHelper.ItemCode_HKID_Mapping[relativeItemCode]; } var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format("bin/Data/DM/getPreparation/{0}.xml", relativeItemCode)); var doc = XDocument.Load(file); XNamespace x = "http://schemas.xmlsoap.org/soap/envelope/"; XNamespace x2 = "http://biz.dms.pms.model.ha.org.hk/"; var element = doc.Descendants(x + "Body") .Descendants(x2 + "getPreparationResponse").First(); var str = element.ToString().Replace("ns2:getPreparationResponse", "getPreparationResponse"); var response = XmlHelper.XmlDeserialize <GetPreparationResponse>(str); /* * var element1 = doc.Descendants(x + "Body") * .Descendants(x2 + "getDrugMdsPropertyHqResponse") * .Descendants("return"); * var returnStrs = string.Format(@"<getDrugMdsPropertyHqResponse>{0}</getDrugMdsPropertyHqResponse>", string.Join("", element1.Select(item => item.ToString()).ToArray())); * var response = XmlHelper.XmlDeserialize<GetDrugMdsPropertyHqResponse>(returnStrs); */ return(response); } catch (Exception ex) { ex = ex; //Logger ex return(new GetPreparationResponse { }); } }
public MdsCheckFinalResult MDSCheck(InventoryObj drugItem, string caseNumber, PatientDemoEnquiry patientEnquiry, AlertProfileResult alertProfileRes) { MDSCheckResult resultBeforeMDS = new MDSCheckResult() { hasMdsAlert = false }; if (alertProfileRes == null || (alertProfileRes.AdrProfile.Count == 0 && alertProfileRes.AlertProfile.Count == 0 && alertProfileRes.AllergyProfile.Count == 0) ) { /*ErrorMessage = "System cannot perform Allergy, ADR and G6PD Deficiency Contraindication checking. * Please exercise your professional judgement during the downtime period and contact [vendor contact information].*/ resultBeforeMDS.errorCode = "8520001001"; //system error, hasMdsAlert = false, only medication alert, hasMdsAlert = true resultBeforeMDS.errorDesc = "System cannot perform Allergy, AlertProfile is empty."; //here should use drug name, not drugItemCode return(resultBeforeMDS.ToConvert(drugItem.CommonName)); } #region check if need MDS check /****2.5.3 3:System should not perform MDS checking on a drug item if its itemCode starts with “PDF”, * e.g. “PDF 2Q “, “PDF 48”. no prompt message *****/ if (mdsChecker.CheckDrugCodeIfNoNeedMDSCheck(drugItem.Billnum)) { //here should use drug name, not drugItemCode return(resultBeforeMDS.ToConvert(drugItem.CommonName)); } /*****2.5.3 2: ADR record (1.4.2) if its severity is “Mild”, not perform MDS checking for current ADR profile*****/ mdsChecker.CheckADRProfileForMDSCheck(ref alertProfileRes, caseNumber); #endregion var CASE_NUMBER = patientEnquiry.CaseList[0].Number.Trim().ToUpper(); var patientCache = FullCacheHK.PataientCache[CASE_NUMBER]; var getDrugMdsPropertyHqReq = new GetDrugMdsPropertyHqRequest { Arg0 = new Arg { ItemCode = new List <string> { drugItem.Billnum } } }; var getDrugMdsPropertyHqRes = soapSvc.GetDrugMdsPropertyHq(getDrugMdsPropertyHqReq); #region JUST FOR SIMULATOR if (patientCache != null) { patientCache.MDSCache.Register(drugItem.Billnum, new MDSCheckResultCache { DrugMdsPropertyHqReq = getDrugMdsPropertyHqReq, DrugMdsPropertyHqRes = getDrugMdsPropertyHqRes }); } #endregion if (getDrugMdsPropertyHqRes == null || getDrugMdsPropertyHqRes.Return.Count == 0) { resultBeforeMDS.errorCode = "8520001002"; resultBeforeMDS.errorDesc = "System cannot perform Allergy, Drug Master Response is empty."; return(resultBeforeMDS.ToConvert(drugItem.CommonName)); } var drugProperty = getDrugMdsPropertyHqRes.Return[0].DrugProperty; var getPreparationReq = new GetPreparationRequest { Arg0 = new Arg0 { DispHospCode = "", DispWorkstore = "", ItemCode = drugItem.Billnum, TrueDisplayname = drugProperty.Displayname, FormCode = drugProperty.FormCode, SaltProperty = drugProperty.SaltProperty, DrugScope = "I", SpecialtyType = "I", PasSpecialty = "", PasSubSpecialty = "", CostIncluded = true, HqFlag = true } }; var getPreparationRes = soapSvc.GetPreparation(getPreparationReq); if (getPreparationRes == null || getPreparationRes.Return == null) { resultBeforeMDS.errorCode = "8520001003"; resultBeforeMDS.errorDesc = "System cannot perform Allergy, Drug Preparation Response is empty."; return(resultBeforeMDS.ToConvert(drugItem.CommonName)); } #region JUST FOR SIMULATOR if (patientCache != null) { patientCache.MDSCache[drugItem.Billnum].PreparationReq = getPreparationReq; patientCache.MDSCache[drugItem.Billnum].PreparationRes = getPreparationRes; } #endregion string drugName = drugProperty.Displayname; /*if hasG6pdDeficiency is true or hasPregnancy is true, then “true”, else “false”*/ bool hasG6pdDeficiency = mdsChecker.CheckIsG6PD(alertProfileRes.AlertProfile); bool checkDdcm = hasG6pdDeficiency; bool checkDam = alertProfileRes.AllergyProfile.Count() > 0; bool checkAdr = alertProfileRes.AdrProfile.Count() > 0; //if no ddcm, no allergy, no adr, then no need do MDS check if (!checkDdcm && !checkDam && !checkAdr) { return(new MdsCheckFinalResult()); } MDSCheckInputParm mdsRequest = new MDSCreater().CreateMDSRequest(patientEnquiry, alertProfileRes, getDrugMdsPropertyHqRes, getPreparationRes, ref drugName ); /************do Final MDS Check*********************/ MDSCheckResult mdsCheckResult = restSvc.CheckMDS(mdsRequest); //filter final MDS check result mdsCheckResult.FilterMdsResult(); #region JUST FOR SIMULATOR if (patientCache != null) { patientCache.MDSCache[drugItem.Billnum].Req = mdsRequest; patientCache.MDSCache[drugItem.Billnum].Res = mdsCheckResult; } #endregion //convert mds result to message object to show return(mdsCheckResult.ToConvert(drugName)); }