public void TestRejectRIS() { RIS testRIS = new RIS(); int i = testRIS.RISReject(1); Assert.AreEqual(1, i); }
async public void SendAck(AckParam ack) { if (ack != null) { RIS risObj = new RIS(); risObj.ReceiveORMO01Acknowledgment(ack.Acknowledgment); } }
/// <summary> Evaluate an RTF control that needs special processing. /// /// </summary> /// <param name="ipfn"> /// </param> /// <returns> /// </returns> private ErrorRtf ParseSpecialKeyword(IPFN ipfn) { ErrorRtf ret = ErrorRtf.OK; if (!UtilStrByteMode.isLocaleDefLangDBCS()) { if (_destState == RDS.SKIP && ipfn != IPFN.BIN) { /* if we're skipping, and it's not */ return(ret); /* the \bin keyword, ignore it. */ } if (ipfn == IPFN.FONT || ipfn == IPFN.CHARSET || ipfn == IPFN.UNICODE) { return(ret); } } else { if (_destState == RDS.SKIP && ipfn != IPFN.BIN && ipfn != IPFN.FONT && ipfn != IPFN.CHARSET && ipfn != IPFN.UNICODE) { return(ret); } } if (ipfn == IPFN.BIN) { _internalState = RIS.BIN; _cbBin = _lParam; } else if (ipfn == IPFN.SKIP_DEST) { _skipDestIfUnk = true; } else if (ipfn == IPFN.HEX) { _internalState = RIS.HEX; } else if (ipfn == IPFN.FONT) { _fontNum = (int)_lParam; } else if (ipfn == IPFN.CHARSET) { _charsetTable[_fontNum] = (int)_lParam; } else if (ipfn == IPFN.UNICODE) { _internalState = RIS.UNICODE; } else { ret = ErrorRtf.BAD_TABLE; } return(ret); }
async public void ORMOutBound(RISORMO01OutboundParam outbound) { SoapCredential.UserName = AppSettings.GetByKey("USERNAME"); SoapCredential.Password = AppSettings.GetByKey("PASSWORD"); SoapCredential.Domain = AppSettings.GetByKey("DOMAIN"); if (outbound != null) { RIS risObj = new RIS(); outbound.RISORMO01Outbound.MessageControlId = outbound.RISORMO01Outbound.OrderId; risObj.ORMOutBound(outbound.RISORMO01Outbound); } }
/// <summary> Always restore relevant info from the top of the SAVE list. /// /// </summary> /// <returns> /// </returns> private ErrorRtf PopState() { StackSave savedPop = (StackSave)_stack.Pop(); if (savedPop == null) { return(ErrorRtf.STACK_UNDERFLOW); } _destState = RDS.getObj(savedPop.rds); _internalState = RIS.getObj(savedPop.ris); _group--; return(ErrorRtf.OK); }
/// <summary> Constructor /// /// </summary> public Rtf() { _stack = new Stack(); _group = 0; _cbBin = 0; _lParam = 0; _outputOnce = false; _skipDestIfUnk = false; _processCrlfSpecial = false; _destState = RDS.NORM; _internalState = RIS.NORM; _fontNum = 0; if (UtilStrByteMode.isLocaleDefLangDBCS()) { setCodePageTable(); } }
/// <summary> Save relevant info on a linked list of SAVE structures. /// /// </summary> /// <returns> /// </returns> private ErrorRtf PushState() { StackSave saveNew = new StackSave(); if (saveNew == null) { return(ErrorRtf.STACK_OVERFLOW); } saveNew.rds = RDS.getObj(_destState); saveNew.ris = RIS.getObj(_internalState); _internalState = RIS.NORM; _stack.Push(saveNew); _group++; return(ErrorRtf.OK); }
public static RIS getObj(RIS copyFrom) { if (copyFrom == NORM) { return(NORM); } else if (copyFrom == BIN) { return(BIN); } else if (copyFrom == HEX) { return(HEX); } else { return(null); } }
async public void RIS_ORUResult(RISORUR01OutboundParam ack) { SoapCredential.UserName = AppSettings.GetByKey("USERNAME"); SoapCredential.Password = AppSettings.GetByKey("PASSWORD"); SoapCredential.Domain = AppSettings.GetByKey("DOMAIN"); string url = System.Configuration.ConfigurationManager.AppSettings["RISImgurl"]; var reportPath = System.Configuration.ConfigurationManager.AppSettings["RISReportsSharedFolder"]; url = url.Replace("$", "&"); if (ack != null) { url = url + ack.RISORUR01Outbound.PatientId + "&AccessionNumber=" + ack.RISORUR01Outbound.AccessionNumber; RIS risObj = new RIS(); ack.RISORUR01Outbound.ImageUrl = url; ack.RISORUR01Outbound.ReportPath = reportPath + ack.RISORUR01Outbound.ReportPath; ack.RISORUR01Outbound.MessageControlId = ack.RISORUR01Outbound.OrderId; risObj.ORUResult(ack.RISORUR01Outbound); } }
/// <summary> Route the character to the appropriate destination stream. /// /// </summary> /// <param name="ch"> /// </param> /// <param name="outputTxt"> /// </param> /// <returns> /// </returns> private ErrorRtf ParseChar(char ch, StringBuilder outputTxt) { ErrorRtf ret = ErrorRtf.OK; if (_internalState == RIS.BIN && --_cbBin <= 0) { _internalState = RIS.NORM; } if (_destState == RDS.SKIP) { } /* Toss this character. */ else if (_destState == RDS.NORM) { /* Output a character. Properties are valid at this point. */ ret = PrintChar(ch, outputTxt); } else { } /* handle other destinations.... */ return(ret); }
/// <summary> Converts Rtf Text to Plain Text /// Step 1: Isolate RTF keywords and send them to ParseKeyword; Push and pop state at the start and end of /// RTF groups Send text to ParseChar for further processing. /// /// </summary> /// <param name="rtfTxt"> /// </param> /// <param name="outputTxt"> /// </param> /// <returns> /// </returns> public ErrorRtf toTxt(String rtfTxt, StringBuilder outputTxt) { long cNibble = 2; long b = 0; int currPos = 0; bool skipNewline = false; long blobStrLen; char blobChar; ErrorRtf ec; byte[] dbcsBytes = new byte[2]; bool skipParseChar = false; int charset = 0; int codePage = 0; _outputOnce = false; _processCrlfSpecial = false; blobStrLen = rtfTxt.Length; _index = 0; _destState = RDS.NORM; if (rtfTxt == null || blobStrLen == 0 || !isRtf(rtfTxt)) { return(ErrorRtf.OK); } while (_index < blobStrLen) { blobChar = rtfTxt[_index]; _index++; if (_group < 0) { return(ErrorRtf.STACK_UNDERFLOW); } /* if we're parsing binary data, handle it directly */ if (_internalState == RIS.BIN) { if ((ec = ParseChar(blobChar, outputTxt)) != ErrorRtf.OK) { return(ec); } } else { switch (blobChar) { case '{': skipNewline = false; if ((ec = PushState()) != ErrorRtf.OK) { return(ec); } break; case '}': skipNewline = true; if ((ec = PopState()) != ErrorRtf.OK) { return(ec); } break; case '\\': skipNewline = false; if ((ec = ParseKeyword(rtfTxt, outputTxt)) != ErrorRtf.OK) { return(ec); } break; case (char)RtfChar.LF: case (char)RtfChar.CR: /* cr and lf are noise characters... */ if (_processCrlfSpecial) { /* Once we reach the 0x0a while ProcessCRLFSpecial_, reset the ProcessCRLFSpecial_ */ if (blobChar == (char)RtfChar.LF) { _processCrlfSpecial = false; } } else { /*---------------------------------------------------------------*/ /* skip new lines coming only from the RTF header 1/1/98 - #2390 */ /*---------------------------------------------------------------*/ /* Skip the LF (0x0a) if we are not in the ProcessCRLFSpecial_ */ if (blobChar == (char)RtfChar.LF || (blobChar == (char)RtfChar.CR && skipNewline && !_outputOnce)) { break; } } goto default; default: if (blobChar != (char)RtfChar.CR) { skipNewline = false; } if (_internalState == RIS.NORM) { if ((ec = ParseChar(blobChar, outputTxt)) != ErrorRtf.OK) { return(ec); } } else if (_internalState == RIS.UNICODE) { if ((ec = ParseChar((char)_lParam, outputTxt)) != ErrorRtf.OK) { return(ec); } _internalState = RIS.NORM; } else { /* parsing hex data */ if (_internalState != RIS.HEX) { return(ErrorRtf.ASSERTION); } b = b << 4; if (Char.IsDigit(blobChar)) { b += (int)blobChar - (int)'0'; } else { if (Char.IsLower(blobChar)) { if (blobChar < 'a' || blobChar > 'f') { return(ErrorRtf.INVALID_HEX); } b += 10 + (int)blobChar - (int)'a'; } else { if (blobChar < 'A' || blobChar > 'F') { return(ErrorRtf.INVALID_HEX); } b += 10 + (int)blobChar - (int)'A'; } } cNibble--; if (cNibble == 0) { if (UtilStrByteMode.isLocaleDefLangDBCS()) { charset = getCharset(_fontNum); if (!skipParseChar && is1stByte(b, charset)) // leading byte of a double-byte character { dbcsBytes[0] = (byte)b; dbcsBytes[1] = (byte)0; skipParseChar = true; } else { if (skipParseChar && is2ndByte(b, charset)) // trailing byte of a double-byte character { dbcsBytes[1] = (byte)b; } else // single-byte character { dbcsBytes[0] = (byte)b; dbcsBytes[1] = (byte)0; } // convert DBCS to Unicode codePage = getCodePage(charset); string workStr = Encoding.GetEncoding(codePage).GetString(dbcsBytes, 0, 2); char[] workChar = workStr.ToCharArray(); b = (long)workChar[0]; skipParseChar = false; } } if (!skipParseChar) { if ((ec = ParseChar((char)b, outputTxt)) != ErrorRtf.OK) { return(ec); } } cNibble = 2; b = 0; _internalState = RIS.NORM; } } /* end else (ris != risNorm) */ break; } /* switch */ } /* else (ris != risBin) */ } /* while */ if (_group < 0L) { return(ErrorRtf.STACK_UNDERFLOW); } if (_group > 0L) { return(ErrorRtf.UNMATCHED_BRACE); } /*-------------------------------------------------------------------*/ /* Eliminate suffix of carrige return + line feed */ /* (Check last characters - just in case format is not the expected) */ /*-------------------------------------------------------------------*/ currPos = outputTxt.Length; if (currPos >= 3 && (outputTxt[currPos - 3] == (char)RtfChar.CR && outputTxt[currPos - 2] == (char)RtfChar.LF && outputTxt[currPos - 1] == (char)RtfChar.CR || outputTxt[currPos - 3] == (char)RtfChar.LF && outputTxt[currPos - 2] == (char)RtfChar.CR && outputTxt[currPos - 1] == (char)RtfChar.CR)) { outputTxt.Remove(currPos - 3, 3); } return(ErrorRtf.OK); }
public async Task <string> addPatientOrder(PatientRadiologyOrder patientRadiologyOrder, bool isActivityOrder = false) { SoapEntityRepository entityRepository = SoapEntityRepository.GetService(); mzk_patientorder patientOrderEntity = new mzk_patientorder(); try { mzk_casetype caseType = mzk_casetype.OutPatient; patientOrderEntity.mzk_appointable = true; if (!string.IsNullOrEmpty(patientRadiologyOrder.appointmentId)) { patientOrderEntity.mzk_orderingappointment = new EntityReference("mzk_patientorder", new Guid(patientRadiologyOrder.appointmentId)); patientOrderEntity.mzk_fulfillmentappointment = new EntityReference("mzk_patientorder", new Guid(patientRadiologyOrder.appointmentId)); if (!string.IsNullOrEmpty(patientRadiologyOrder.PatientId)) { patientOrderEntity.mzk_customer = new EntityReference("contact", new Guid(patientRadiologyOrder.PatientId)); } if (!string.IsNullOrEmpty(patientRadiologyOrder.CaseTransRecId)) { patientOrderEntity.mzk_AXCaseTransRefRecId = Convert.ToDecimal(patientRadiologyOrder.CaseTransRecId); } if (!string.IsNullOrEmpty(patientRadiologyOrder.CaseId)) { patientOrderEntity.mzk_caseid = new EntityReference("incident", new Guid(patientRadiologyOrder.CaseId)); } if (!string.IsNullOrEmpty(patientRadiologyOrder.TestName)) { patientOrderEntity.mzk_ProductId = new EntityReference(xrm.Product.EntityLogicalName, Products.getProductId(patientRadiologyOrder.TestName)); if (patientOrderEntity.mzk_ProductId == null && patientOrderEntity.mzk_ProductId.Id == Guid.Empty) { throw new ValidationException("Product not found for the corresponding item. Please contact system administrator"); } } patientOrderEntity.Attributes["mzk_orderdate"] = DateTime.Now.Date; patientOrderEntity.mzk_FulfillmentDate = patientRadiologyOrder.FulfillmentDate; if (patientRadiologyOrder.clinicRecId > 0) { patientOrderEntity.Attributes["mzk_axclinicrefrecid"] = Convert.ToDecimal(patientRadiologyOrder.clinicRecId); } if (!string.IsNullOrEmpty(patientRadiologyOrder.orderingLocationId)) { patientOrderEntity.Attributes["mzk_orderinglocation"] = new EntityReference("mzk_organizationalunit", new Guid(patientRadiologyOrder.orderingLocationId)); } if (!string.IsNullOrEmpty(patientRadiologyOrder.treatmentLocationId)) { patientOrderEntity.Attributes["mzk_treatmentlocation"] = new EntityReference("mzk_organizationalunit", new Guid(patientRadiologyOrder.treatmentLocationId)); } } else if (patientRadiologyOrder.EncounterId != null && patientRadiologyOrder.EncounterId != string.Empty) { if (patientRadiologyOrder.TestName != null && patientRadiologyOrder.TestName != string.Empty) { patientOrderEntity.Attributes["mzk_productid"] = new EntityReference("product", new Guid(patientRadiologyOrder.TestName)); } if (patientRadiologyOrder.Frequency != null && patientRadiologyOrder.Frequency != string.Empty) { patientOrderEntity.Attributes["mzk_frequencyid"] = new EntityReference("mzk_ordersetup", new Guid(patientRadiologyOrder.Frequency)); } if (patientRadiologyOrder.AssociatedDiagnosis != null && patientRadiologyOrder.AssociatedDiagnosis != string.Empty) { patientOrderEntity.Attributes["mzk_associateddiagnosisid"] = new EntityReference("mzk_concept", new Guid(patientRadiologyOrder.AssociatedDiagnosis)); } if (patientRadiologyOrder.ClinicalNotes != null && patientRadiologyOrder.ClinicalNotes != string.Empty) { patientOrderEntity.Attributes["mzk_clinicalnotes"] = patientRadiologyOrder.ClinicalNotes; } if (patientRadiologyOrder.StudyDate != null && patientRadiologyOrder.StudyDate != string.Empty) { patientOrderEntity.Attributes["mzk_studydate"] = new OptionSetValue(Convert.ToInt32(patientRadiologyOrder.StudyDate)); } if (patientRadiologyOrder.clinicRecId > 0) { patientOrderEntity.Attributes["mzk_axclinicrefrecid"] = Convert.ToDecimal(patientRadiologyOrder.clinicRecId); } if (!string.IsNullOrEmpty(patientRadiologyOrder.orderingLocationId)) { patientOrderEntity.Attributes["mzk_orderinglocation"] = new EntityReference("mzk_organizationalunit", new Guid(patientRadiologyOrder.orderingLocationId)); } if (!string.IsNullOrEmpty(patientRadiologyOrder.treatmentLocationId)) { patientOrderEntity.Attributes["mzk_treatmentlocation"] = new EntityReference("mzk_organizationalunit", new Guid(patientRadiologyOrder.treatmentLocationId)); } if (patientRadiologyOrder.OrderDate != DateTime.MinValue) { patientOrderEntity.Attributes["mzk_orderdate"] = patientRadiologyOrder.OrderDate; } else { patientOrderEntity.Attributes["mzk_orderdate"] = DateTime.Now.Date; } patientOrderEntity.Attributes["mzk_fulfillmentdate"] = patientOrderEntity.Attributes["mzk_orderdate"]; } //for Radiology patientOrderEntity.Attributes["mzk_type"] = new OptionSetValue(3); if (patientRadiologyOrder.EncounterId != null && patientRadiologyOrder.EncounterId != string.Empty) { patientOrderEntity.Attributes["mzk_patientencounterid"] = new EntityReference("mzk_patientencounter", new Guid(patientRadiologyOrder.EncounterId)); PatientEncounter encounter = new PatientEncounter(); encounter.EncounterId = patientRadiologyOrder.EncounterId; List <PatientEncounter> listEncounter = encounter.encounterDetails(encounter).Result; if (!string.IsNullOrEmpty(CaseId)) { Speciality specialty = new Speciality(); patientOrderEntity.Attributes["mzk_specialtyname"] = specialty.getSpeciality(CaseId); } encounter = encounter.encounterDetails(encounter).Result.ToList().First <PatientEncounter>(); PatientId = encounter.PatientId; caseType = encounter.caseTypeValue; patientOrderEntity.Attributes["mzk_customer"] = new EntityReference("contact", new Guid(PatientId)); } StatusManager statusManager = StatusManager.getRootStatus(mzk_entitytype.RadiologyOrder, caseType, isActivityOrder); if (statusManager != null) { patientOrderEntity.mzk_OrderStatus = new OptionSetValue(statusManager.status); patientOrderEntity.mzk_StatusManagerDetail = new EntityReference(mzk_statusmanagerdetails.EntityLogicalName, new Guid(statusManager.StatusId)); } bool isDuplicateAllowed = false; if (!string.IsNullOrEmpty(patientRadiologyOrder.EncounterId) && !string.IsNullOrEmpty(patientRadiologyOrder.TestName)) { isDuplicateAllowed = new PatientEncounter().DuplicateDetection(patientRadiologyOrder.EncounterId, patientRadiologyOrder.TestName); } else { isDuplicateAllowed = true; } if (isDuplicateAllowed == true) { Id = Convert.ToString(entityRepository.CreateEntity(patientOrderEntity)); if (AppSettings.GetByKey("OperationsIntegration").ToLower() == true.ToString().ToLower()) { if (!string.IsNullOrEmpty(patientRadiologyOrder.EncounterId)) { if (patientOrderEntity.Attributes.Contains("mzk_treatmentlocation")) { Clinic clinic = new Clinic().getClinicDetails(patientOrderEntity.GetAttributeValue <EntityReference>("mzk_treatmentlocation").Id.ToString()); await this.createCaseTrans(patientRadiologyOrder.EncounterId, Id, patientRadiologyOrder.TestName, (mzk_orderstatus)patientOrderEntity.mzk_OrderStatus.Value, 1, "", AXRepository.AXServices.HMUrgency.None, "", "", "", 0, clinic.mzk_axclinicrefrecid); } else { await this.createCaseTrans(patientRadiologyOrder.EncounterId, Id, patientRadiologyOrder.TestName, (mzk_orderstatus)patientOrderEntity.mzk_OrderStatus.Value, 1, "", AXRepository.AXServices.HMUrgency.None, "", "", "", 0, 0); } } } } else { throw new ValidationException("Same Radiology Test cannot be added multiple times."); } if (!string.IsNullOrEmpty(Id) && !string.IsNullOrEmpty(patientRadiologyOrder.appointmentId) && AppSettings.GetByKey("RISIntegration").ToLower() == true.ToString().ToLower()) { RIS ris = new RIS(); Patient patient = new Patient(); if (patientRadiologyOrder.registered) { await patient.updatePatientRIS(patientRadiologyOrder.PatientId); } else { await patient.createPatientRIS(patientRadiologyOrder.appointmentId, patientRadiologyOrder.PatientId); } } //await this.addContrastOrder(patientRadiologyOrder, Id); } catch (Exception ex) { if (!string.IsNullOrEmpty(Id)) { entityRepository.DeleteEntity(mzk_patientorder.EntityLogicalName, new Guid(Id)); } throw ex; } return(Id.ToString()); }