Ejemplo n.º 1
0
        public static IRace CreateInstance(RaceType raceType)
        {
            IRace race = null;

            switch (raceType)
            {
            case RaceType.Human:
                race = new Human();
                break;

            case RaceType.NE:
                race = new NE();
                break;

            case RaceType.ORC:
                race = new ORC();
                break;

            case RaceType.Undead:
                race = new Undead();
                break;

            default:
                throw new Exception("wrong raceType");
            }

            return(race);
        }
Ejemplo n.º 2
0
        public ORM(compositeType parent, string name) : base(parent, name)
        {
            data = new abstractType[19];

            data[0] = new MSH(this, "MSH");
            data[1] = new NTE(this, "NTE");
            //Patient
            data[2] = new PID(this, "PID");
            data[3] = new PD1(this, "PD1");
            //Patient_VISIT
            data[4] = new PV1(this, "PV1");
            data[5] = new PV2(this, "PV2");
            //INsurance
            data[6] = new IN1(this, "IN1");
            data[7] = new IN2(this, "IN2");
            data[8] = new IN3(this, "IN3");

            data[9]  = new GT1(this, "GT1");
            data[10] = new AL1(this, "AL1");
            //Order
            data[11] = new ORC(this, "ORC");
            //Order_Detail
            data[12] = new OBR(this, "OBR");
            data[13] = new NTE(this, "NTE");
            data[14] = new DG1(this, "DG1");
            //Observation
            data[15] = new OBX(this, "OBX");
            data[16] = new NTE(this, "NTE");
            data[17] = new CTI(this, "CTI");
            data[18] = new BLG(this, "BLG");
        }
        /// <summary>
        /// 细节没有消失  只是转移
        /// 转移了矛盾,并没有消除矛盾
        ///
        /// 集中了矛盾
        /// </summary>
        /// <param name="raceType"></param>
        /// <returns></returns>
        public static IRace CreateRace(RaceType raceType)
        {
            IRace iRace = null;

            switch (raceType)
            {
            case RaceType.Human:
                iRace = new Human();
                break;

            case RaceType.Undead:
                iRace = new Undead();
                break;

            case RaceType.ORC:
                iRace = new ORC();
                break;

            case RaceType.NE:
                iRace = new NE();
                break;

            //增加一个分支
            default:
                throw new Exception("wrong raceType");
            }
            return(iRace);
        }
Ejemplo n.º 4
0
        private static void ProduceORC(ORC orc, Neusoft.HISFC.Models.Order.Order order)
        {
            orc.OrderControl.Value = "NW";
            orc.DateTimeOfTransaction.TimeOfAnEvent.Value = DateTime.Now.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture);

            //XCN enteredby = orc.GetEnteredBy(0);
            //enteredby.IDNumber.Value = order.Doctor.ID;
            //enteredby.FamilyLastName.FamilyName.Value = order.Doctor.Name.Substring(0, 1);
            //enteredby.GivenName.Value = order.Doctor.Name.Substring(1);

            XCN verifiedBy = orc.GetVerifiedBy(0);

            verifiedBy.IDNumber.Value = order.Nurse.ID;
            verifiedBy.FamilyLastName.FamilyName.Value = order.Nurse.Name.Substring(0, 1);
            verifiedBy.GivenName.Value = order.Nurse.Name.Substring(1);

            //开立医师
            XCN op = orc.GetOrderingProvider(0);

            op.IDNumber.Value = order.Doctor.ID;
            op.FamilyLastName.FamilyName.Value = order.Doctor.Name.Substring(0, 1);
            op.GivenName.Value = order.Doctor.Name.Substring(1);

            //orc.EntererSLocation.Building.Value = "2";
            //orc.EntererSLocation.Floor.Value = "10";
            //orc.EntererSLocation.Room.Value = "23";
            //orc.EntererSLocation.Bed.Value = "234";
        }
        public static IRace CreateRaceConfig()
        {
            RaceType raceType = (RaceType)Enum.Parse(typeof(RaceType), IRacTypeConfig);

            IRace iRace = null;

            switch (raceType)
            {
            case RaceType.Human:
                iRace = new Human();
                break;

            case RaceType.Undead:
                iRace = new Undead();
                break;

            case RaceType.ORC:
                iRace = new ORC();
                break;

            case RaceType.NE:
                iRace = new NE();
                break;

            default:
                throw new Exception("wrong raceType");
            }
            return(iRace);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 通过传递参数创建实例类型
        /// </summary>
        /// <param name="raceType"></param>
        /// <returns></returns>
        public static IRace GetRace(RaceType raceType)
        {
            IRace race = null;

            switch (raceType)
            {
            case RaceType.Human:
                race = new Human();
                break;

            case RaceType.NE:
                race = new NE();
                break;

            case RaceType.ORC:
                race = new ORC();
                break;

            case RaceType.Undead:
                race = new Undead();
                break;

            default:
                throw new Exception($"种族{raceType}不存在");
            }
            return(race);
        }
Ejemplo n.º 7
0
        public static IRace CreateInstance(RaceType type)
        {
            IRace iRace = null;

            switch (type)
            {
            case RaceType.Human:
                iRace = new Human("123");
                break;

            case RaceType.NE:
                iRace = new NE();
                break;

            case RaceType.ORC:
                iRace = new ORC();
                break;

            case RaceType.Undead:
                iRace = new Undead();
                break;

            case RaceType.Five:
                iRace = new Five();
                break;

            default:
                throw new Exception("wrong RaceType");
            }
            return(iRace);
        }
Ejemplo n.º 8
0
 public HL7Results()
 {
     ORCSegment  = new ORC();
     NTESegments = new List <NTE>();
     HL7Details  = new List <HL7Details>();
     CTISegments = new List <CTI>();
     BLGSegment  = new BLG();
 }
Ejemplo n.º 9
0
 public void Parse(string str)
 {
     PID.Parse(str);
     AL1.Parse(str);
     ORC.Parse(str);
     PV1.Parse(str);
     MSH.Parse(str);
     NTE.Parse(str);
     OBR.Parse(str);
 }
Ejemplo n.º 10
0
 public virtual void SetORC(ORC orc, Order order, Procedure procedure, string orderControlCode)
 {
     orc.OrderControl.Value = orderControlCode;
     orc.PlacerOrderNumber.EntityIdentifier.Value = procedure.Number;
     orc.PlacerGroupNumber.EntityIdentifier.Value = order.AccessionNumber;
     orc.OrderStatus.Value = order.Status.ToString();
     orc.DateTimeOfTransaction.Time.Value = ExtractHL7DateTime(DateTime.Now);
     SetPhysician(orc.GetOrderingProvider(0), order.OrderingPractitioner);
     orc.GetQuantityTiming(0).Priority.Value = order.Priority.ToString();
 }
Ejemplo n.º 11
0
        private List <ORC> CabeceraORC(RFFACCAB model)
        {
            ORC        mORC  = new ORC();
            List <ORC> lmORC = new List <ORC>();

            mORC.ORC_1 = model.FORDCOM;
            lmORC.Add(mORC);

            return(lmORC);
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("欢迎来到.net高级班公开课之设计模式特训,今天是Eleven老师为大家带来的简单工厂模式");

                Player uu = new Player()
                {
                    Id   = 11,
                    Name = "Nine(479-悠悠吾心-女-合肥)"
                };
                {
                    Human  human  = new Human();
                    Undead undead = new Undead();
                    NE     ne     = new NE();
                    ORC    orc    = new ORC();

                    uu.PlayHuman(human);
                    uu.PlayUndead(undead);

                    uu.PlayWar3(human);
                    uu.PlayWar3(undead);
                    uu.PlayWar3(ne);
                    uu.PlayWar3(orc);
                }
                Console.WriteLine("*******************CreateInstance********************");
                {
                    IRace human  = ObjectFactory.CreateInstance(RaceType.Human);  // new Human();
                    IRace undead = ObjectFactory.CreateInstance(RaceType.Undead); // new Undead();
                    IRace ne     = ObjectFactory.CreateInstance(RaceType.NE);     // new NE();
                    IRace orc    = ObjectFactory.CreateInstance(RaceType.ORC);    //new ORC();


                    uu.PlayWar3(human);
                    uu.PlayWar3(undead);
                    uu.PlayWar3(ne);
                    uu.PlayWar3(orc);
                }
                Console.WriteLine("*****************CreateInstanceConfig********************");
                {
                    IRace race = ObjectFactory.CreateInstanceConfig();
                    uu.PlayWar3(race);
                }
                Console.WriteLine("*****************CreateInstanceConfigReflection********************");
                {
                    IRace race = ObjectFactory.CreateInstanceConfigReflection();
                    uu.PlayWar3(race);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }
Ejemplo n.º 13
0
 internal SPRC(ushort leftTopColumn, short leftTopOffset, ushort topLeftRow, short topLeftOffset, ushort rightBottomColumn, short rightBottomOffset, ushort bottomRightRow, short bottomRightOffset)
 {
     m_orc        = new ORC();
     m_orc.m_colL = leftTopColumn;
     m_orc.m_dxL  = leftTopOffset;
     m_orc.m_rwT  = topLeftRow;
     m_orc.m_dyT  = topLeftOffset;
     m_orc.m_colR = rightBottomColumn;
     m_orc.m_dxR  = rightBottomOffset;
     m_orc.m_rwB  = bottomRightRow;
     m_orc.m_dyB  = bottomRightOffset;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Get CALLBACKPHONENUMBER Records from ORC
        /// </summary>
        public static IEnumerable GetCALLBACKPHONENUMBERRecords(this ORC message)
        {
            object[] result = message.GetRecords("CALLBACKPHONENUMBERRepetitionsUsed", "GetCALLBACKPHONENUMBER");

            if ((result != null) && (result.Count() > 0))
            {
                for (int i = 0; i < result.Count(); i++)
                {
                    yield return(result[i]);
                }
            }
        }
Ejemplo n.º 15
0
        protected virtual void HandleNewOrder(ORC orc, OBR obr)
        {
            string placerNumber = obr.PlacerOrderNumber.EntityIdentifier.Value;
            var    order        = _persistenceManager.GetOrderByPlacer(placerNumber);

            if (order != null)
            {
                throw new Exception("Cannot create order which already exists");
            }

            var accessionNumber   = PersistenceContext.GetBroker <IAccessionNumberBroker>().GetNext();
            var diagnosticService = FindDiagnosticService(obr.UniversalServiceIdentifier.Identifier.Value,
                                                          PersistenceContext);
            var requestedTime     = ParseNullableDateTimeFromDateField(obr.RequestedDateTime.Time.Value);
            var orderingPhysician = GetOrderingPhysician(obr.GetOrderingProvider(0));
            var orderingFacility  = FindFacility(orc.GetOrderingFacilityName(0).OrganizationName.Value,
                                                 PersistenceContext);
            var orderingStaff = FindStaff(orc.GetOrderingProvider(0).IDNumber.Value, PersistenceContext);
            var priority      = ParseOrderPriority(obr.PriorityOBR.Value);

            order = Order.NewOrder(
                new OrderCreationArgs(Platform.Time, orderingStaff, "HL7", accessionNumber,
                                      Patient, Visit, diagnosticService, obr.GetReasonForStudy(0).Text.Value,
                                      priority, orderingFacility, orderingFacility, requestedTime,
                                      orderingPhysician,
                                      new List <ResultRecipient>()),
                PersistenceContext.GetBroker <IProcedureNumberBroker>(),
                PersistenceContext.GetBroker <IDicomUidBroker>()
                );

            order.PlacerNumber = placerNumber;
            var familyPhysician = GetFamilyPhysicianRecipients(GetProfileForFacility(orderingFacility));

            if (familyPhysician != null)
            {
                order.ResultRecipients.Add(familyPhysician);
            }

            _persistenceManager.AddOrder(order);

            foreach (var procedure in order.Procedures)
            {
                procedure.CreateProcedureSteps();
                procedure.Schedule(requestedTime);
                procedure.PerformingDepartment = GetPerformingDepartment(procedure.PerformingFacility,
                                                                         obr.ProcedureCode.Identifier.Value);
            }
        }
Ejemplo n.º 16
0
    {/// <summary>
     /// 段工厂创建消息工厂创建segmentType,生成MSH|MSA|EVN|PID等
     /// </summary>
     /// <param name="parent"></param>
     /// <param name="product"></param>
     /// <param name="name"></param>
     /// <returns></returns>
        public override abstractType Create(compositeType parent, Enum product, string name)
        {
            abstractType tmp = null;

            switch (product)
            {
            case enumSegment.PID: tmp = new PID(parent, name); break;

            case enumSegment.MSH: tmp = new MSH(parent, name); break;

            case enumSegment.MSA: tmp = new MSA(parent, name); break;

            case enumSegment.ERR: tmp = new ERR(parent, name); break;

            case enumSegment.NTE: tmp = new NTE(parent, name); break;

            case enumSegment.PD1: tmp = new PD1(parent, name); break;

            case enumSegment.PV1: tmp = new PV1(parent, name); break;

            case enumSegment.PV2: tmp = new PV2(parent, name); break;

            case enumSegment.IN1: tmp = new IN1(parent, name); break;

            case enumSegment.IN2: tmp = new IN2(parent, name); break;

            case enumSegment.IN3: tmp = new IN3(parent, name); break;

            case enumSegment.GT1: tmp = new GT1(parent, name); break;

            case enumSegment.AL1: tmp = new AL1(parent, name); break;

            case enumSegment.ORC: tmp = new ORC(parent, name); break;

            case enumSegment.OBR: tmp = new OBR(parent, name); break;

            case enumSegment.CTI: tmp = new CTI(parent, name); break;

            case enumSegment.BLG: tmp = new BLG(parent, name); break;

            case enumSegment.DG1: tmp = new DG1(parent, name); break;

            case enumSegment.OBX: tmp = new OBX(parent, name); break;

            default: throw new NotSupportedException();
            }
            return(tmp);
        }
Ejemplo n.º 17
0
        public override string DoProcess(IMessage m)
        {
            ORM_O01 ormO01 = m as ORM_O01;

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    ORC    orc         = ormO01.GetORDER(0).ORC;
                    int    yeWuLx      = 0;//-1:退单,0:单据恢复到初时状态,1:预约,2:登记,3:报告完成,4:审核报告
                    string shenQingDId = orc.PlacerOrderNumber.EntityIdentifier.Value;
                    string caoZuoYuan  = orc.GetEnteredBy(0).IDNumber.Value;
                    string caoZuoKs    = orc.EntererSLocation.PointOfCare.Value;

                    string errMsg = string.Empty;
                    //检查登记
                    if (orc.OrderControl.Value == "SC" &&
                        orc.OrderStatus.Value == "SC")
                    {
                        yeWuLx = 2;
                        //解析消息,得到消息内容
                    }
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        return(SetACK(ormO01, "ACK", "", "", errMsg));
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.Append("申请单ID:[").Append(shenQingDId).Append("]").Append(Environment.NewLine);
                    sb.Append("操作员:[").Append(caoZuoYuan).Append("]").Append(Environment.NewLine);
                    sb.Append("附:接收到消息后,可参考组装消息进行解析,在此不再罗列,只以[申请单ID]作为测试");
                    LogHelp.WriteLog("接收消息内容:" + Environment.NewLine, sb.ToString());
                    scope.Complete();
                    return(SetACK(ormO01, "ACK", "", ""));
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    return(SetACK(ormO01, "ACK", "", "", ex.Message));
                }
                else
                {
                    return(SetACK(ormO01, "ACK", "", "", ex.Message + Environment.CommandLine + ex.InnerException.Message));
                }
            }
        }
Ejemplo n.º 18
0
        public OSU_O51(OMG_O19 message) : base(new CustomModelClassFactory())
        {
            add(typeof(MSH), true, false);
            add(typeof(PID), true, false);
            add(typeof(ORC), true, false);
            AddStructure("MSH");
            AddStructure("PID");
            AddStructure("ORC");

            ValidationContext = new DefaultValidation();

            MSH = new MSH(this, new DefaultModelClassFactory());

            MSH.SendingFacility.UniversalID.Value       = message.MSH.ReceivingFacility.UniversalID.Value;
            MSH.SendingFacility.NamespaceID.Value       = message.MSH.ReceivingFacility.NamespaceID.Value;
            MSH.SendingFacility.UniversalIDType.Value   = message.MSH.ReceivingFacility.UniversalIDType.Value;
            MSH.ReceivingFacility.UniversalID.Value     = message.MSH.SendingFacility.UniversalID.Value;
            MSH.ReceivingFacility.NamespaceID.Value     = message.MSH.SendingFacility.NamespaceID.Value;
            MSH.ReceivingFacility.UniversalIDType.Value = message.MSH.SendingFacility.UniversalIDType.Value;
            MSH.FieldSeparator.Value               = message.MSH.FieldSeparator.Value;
            MSH.EncodingCharacters.Value           = message.MSH.EncodingCharacters.Value;
            MSH.MessageType.MessageStructure.Value = "OSU_O51";
            MSH.MessageType.MessageCode.Value      = "OSU";
            MSH.MessageType.TriggerEvent.Value     = "O51";
            MSH.MessageControlID.Value             = Guid.NewGuid().ToString("N");
            MSH.ProcessingID.ProcessingID.Value    = "P";
            MSH.VersionID.VersionID.Value          = "2.5.1";
            var profileId = MSH.AddMessageProfileIdentifier();

            profileId.NamespaceID.Value = "360x";
            var result = MSH.GetMessageProfileIdentifier(0);

            MSH.AcceptAcknowledgmentType.Value      = "NE";
            MSH.ApplicationAcknowledgmentType.Value = "NE";

            PID = message.PATIENT.PID;
            //PID.AdministrativeSex.Value = message.PATIENT.PID.AdministrativeSex.Value;
            //PID.BirthOrder.Value = message.PATIENT.PID.BirthOrder.Value;
            //PID.BirthPlace.Value = message.PATIENT.PID.BirthPlace.Value;

            ORC = new ORC(this, new DefaultModelClassFactory());
            ORC.PlacerOrderNumber.NamespaceID.Value     = Guid.NewGuid().ToString();
            ORC.PlacerOrderNumber.UniversalIDType.Value = "ISO";
        }
Ejemplo n.º 19
0
        void buildRxeAndOrcSegments(OMP_O09_PID omp_o09, IList <string> rxNumbers)
        {
            string nowTimestamp = DateTime.Now.ToString("yyyyMMddhhmmss");

            for (int i = 0; i < rxNumbers.Count; i++)
            {
                RXE rxe = omp_o09.getRxe(i);
                rxe.QuantityTiming.Quantity.Quantity.Value           = "1";
                rxe.QuantityTiming.StartDateTime.TimeOfAnEvent.Value = nowTimestamp;
                rxe.GiveCode.Identifier.Value         = "RF";
                rxe.GiveCode.NameOfCodingSystem.Value = "HL70119";
                rxe.GiveAmountMinimum.Value           = "1";
                rxe.GiveUnits.Identifier.Value        = "1 refill unit";
                rxe.PrescriptionNumber.Value          = rxNumbers[i];

                ORC orc = omp_o09.getOrc(i);
                orc.PlacerOrderNumber.EntityIdentifier.Value = rxNumbers[i] + "-" + nowTimestamp;
                orc.OrderControl.Value = "RF";
            }
        }
Ejemplo n.º 20
0
        protected virtual void HandleOrders(ORC orc, OBR obr)
        {
            switch (orc.OrderControl.Value)
            {
            case NewOrderOrderControlCode:
                HandleNewOrder(orc, obr);
                break;

            case CancelRequestOrderControlCode:
            case DiscontinueRequestOrderControlCode:
                HandleCancelDiscontinueOrder(obr);
                break;

            case StatusChangedOrderControlCode:
                HandleStatusChanged(obr);
                break;

            case NumberAssignedOrderControlCode:
                HandleNumberAssigned(obr);
                break;
            }
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("欢迎来到.net高级班公开课之设计模式特训,今天是Eleven老师为大家带来的工厂方法设计模式");
                {
                    Human  human  = new Human();
                    Undead undead = new Undead();
                    NE     ne     = new NE();
                    ORC    orc    = new ORC();

                    //Six six=new Six()//参数信息很麻烦
                }
                {
                    IRace human  = new Human();
                    IRace undead = new Undead();
                    IRace ne     = new NE();
                    IRace orc    = new ORC();
                }
                {
                    IFactory humanFactory = new HumanFactory();
                    IRace    human        = humanFactory.CreateInstance();

                    IFactory fiveFactory = new FiveFactory();
                    IRace    five        = fiveFactory.CreateInstance();

                    IFactory sixFactory = new SixFactoryExtend();// new SixFactory();

                    IRace six = sixFactory.CreateInstance();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Constructs an HL7 segment for the specified Segments enum object
        /// </summary>
        /// <param name="seg">The Segments enum object to construct for</param>
        public Segment(Segments seg)
        {
            switch (seg)
            {
            case Segments.ABS:
                ABS abs = new ABS();
                Name        = abs.Name;
                Description = abs.Description;
                Fields      = abs.Fields;
                break;

            case Segments.ACC:
                ACC acc = new ACC();
                Name        = acc.Name;
                Description = acc.Description;
                Fields      = acc.Fields;
                break;

            case Segments.ADD:
                ADD add = new ADD();
                Name        = add.Name;
                Description = add.Description;
                Fields      = add.Fields;
                break;

            case Segments.AFF:
                AFF aff = new AFF();
                Name        = aff.Name;
                Description = aff.Description;
                Fields      = aff.Fields;
                break;

            case Segments.AIG:
                AIG aig = new AIG();
                Name        = aig.Name;
                Description = aig.Description;
                Fields      = aig.Fields;
                break;

            case Segments.AIL:
                AIL ail = new AIL();
                Name        = ail.Name;
                Description = ail.Description;
                Fields      = ail.Fields;
                break;

            case Segments.AIP:
                AIP aip = new AIP();
                Name        = aip.Name;
                Description = aip.Description;
                Fields      = aip.Fields;
                break;

            case Segments.AIS:
                AIS ais = new AIS();
                Name        = ais.Name;
                Description = ais.Description;
                Fields      = ais.Fields;
                break;

            case Segments.AL1:
                AL1 al1 = new AL1();
                Name        = al1.Name;
                Description = al1.Description;
                Fields      = al1.Fields;
                break;

            case Segments.APR:
                APR apr = new APR();
                Name        = apr.Name;
                Description = apr.Description;
                Fields      = apr.Fields;
                break;

            case Segments.ARQ:
                ARQ arq = new ARQ();
                Name        = arq.Name;
                Description = arq.Description;
                Fields      = arq.Fields;
                break;

            case Segments.AUT:
                AUT aut = new AUT();
                Name        = aut.Name;
                Description = aut.Description;
                Fields      = aut.Fields;
                break;

            case Segments.BHS:
                BHS bhs = new BHS();
                Name        = bhs.Name;
                Description = bhs.Description;
                Fields      = bhs.Fields;
                break;

            case Segments.BLC:
                BLC blc = new BLC();
                Name        = blc.Name;
                Description = blc.Description;
                Fields      = blc.Fields;
                break;

            case Segments.BLG:
                BLG blg = new BLG();
                Name        = blg.Name;
                Description = blg.Description;
                Fields      = blg.Fields;
                break;

            case Segments.BPO:
                BPO bpo = new BPO();
                Name        = bpo.Name;
                Description = bpo.Description;
                Fields      = bpo.Fields;
                break;

            case Segments.BPX:
                BPX bpx = new BPX();
                Name        = bpx.Name;
                Description = bpx.Description;
                Fields      = bpx.Fields;
                break;

            case Segments.BTS:
                BTS bts = new BTS();
                Name        = bts.Name;
                Description = bts.Description;
                Fields      = bts.Fields;
                break;

            case Segments.BTX:
                BTX btx = new BTX();
                Name        = btx.Name;
                Description = btx.Description;
                Fields      = btx.Fields;
                break;

            case Segments.CDM:
                CDM cdm = new CDM();
                Name        = cdm.Name;
                Description = cdm.Description;
                Fields      = cdm.Fields;
                break;

            case Segments.CER:
                CER cer = new CER();
                Name        = cer.Name;
                Description = cer.Description;
                Fields      = cer.Fields;
                break;

            case Segments.CM0:
                CM0 cm0 = new CM0();
                Name        = cm0.Name;
                Description = cm0.Description;
                Fields      = cm0.Fields;
                break;

            case Segments.CM1:
                CM1 cm1 = new CM1();
                Name        = cm1.Name;
                Description = cm1.Description;
                Fields      = cm1.Fields;
                break;

            case Segments.CM2:
                CM2 cm2 = new CM2();
                Name        = cm2.Name;
                Description = cm2.Description;
                Fields      = cm2.Fields;
                break;

            case Segments.CNS:
                CNS cns = new CNS();
                Name        = cns.Name;
                Description = cns.Description;
                Fields      = cns.Fields;
                break;

            case Segments.CON:
                CON con = new CON();
                Name        = con.Name;
                Description = con.Description;
                Fields      = con.Fields;
                break;

            case Segments.CSP:
                CSP csp = new CSP();
                Name        = csp.Name;
                Description = csp.Description;
                Fields      = csp.Fields;
                break;

            case Segments.CSR:
                CSR csr = new CSR();
                Name        = csr.Name;
                Description = csr.Description;
                Fields      = csr.Fields;
                break;

            case Segments.CSS:
                CSS css = new CSS();
                Name        = css.Name;
                Description = css.Description;
                Fields      = css.Fields;
                break;

            case Segments.CTD:
                CTD ctd = new CTD();
                Name        = ctd.Name;
                Description = ctd.Description;
                Fields      = ctd.Fields;
                break;

            case Segments.CTI:
                CTI cti = new CTI();
                Name        = cti.Name;
                Description = cti.Description;
                Fields      = cti.Fields;
                break;

            case Segments.DB1:
                DB1 db1 = new DB1();
                Name        = db1.Name;
                Description = db1.Description;
                Fields      = db1.Fields;
                break;

            case Segments.DG1:
                DG1 dg1 = new DG1();
                Name        = dg1.Name;
                Description = dg1.Description;
                Fields      = dg1.Fields;
                break;

            case Segments.DRG:
                DRG drg = new DRG();
                Name        = drg.Name;
                Description = drg.Description;
                Fields      = drg.Fields;
                break;

            case Segments.DSC:
                DSC dsc = new DSC();
                Name        = dsc.Name;
                Description = dsc.Description;
                Fields      = dsc.Fields;
                break;

            case Segments.DSP:
                DSP dsp = new DSP();
                Name        = dsp.Name;
                Description = dsp.Description;
                Fields      = dsp.Fields;
                break;

            case Segments.ECD:
                ECD ecd = new ECD();
                Name        = ecd.Name;
                Description = ecd.Description;
                Fields      = ecd.Fields;
                break;

            case Segments.ECR:
                ECR ecr = new ECR();
                Name        = ecr.Name;
                Description = ecr.Description;
                Fields      = ecr.Fields;
                break;

            case Segments.EDU:
                EDU edu = new EDU();
                Name        = edu.Name;
                Description = edu.Description;
                Fields      = edu.Fields;
                break;

            case Segments.EQL:
                EQL eql = new EQL();
                Name        = eql.Name;
                Description = eql.Description;
                Fields      = eql.Fields;
                break;

            case Segments.EQP:
                EQP eqp = new EQP();
                Name        = eqp.Name;
                Description = eqp.Description;
                Fields      = eqp.Fields;
                break;

            case Segments.EQU:
                EQU equ = new EQU();
                Name        = equ.Name;
                Description = equ.Description;
                Fields      = equ.Fields;
                break;

            case Segments.ERQ:
                ERQ erq = new ERQ();
                Name        = erq.Name;
                Description = erq.Description;
                Fields      = erq.Fields;
                break;

            case Segments.ERR:
                ERR err = new ERR();
                Name        = err.Name;
                Description = err.Description;
                Fields      = err.Fields;
                break;

            case Segments.EVN:
                EVN evn = new EVN();
                Name        = evn.Name;
                Description = evn.Description;
                Fields      = evn.Fields;
                break;

            case Segments.FAC:
                FAC fac = new FAC();
                Name        = fac.Name;
                Description = fac.Description;
                Fields      = fac.Fields;
                break;

            case Segments.FHS:
                FHS fhs = new FHS();
                Name        = fhs.Name;
                Description = fhs.Description;
                Fields      = fhs.Fields;
                break;

            case Segments.FT1:
                FT1 ft1 = new FT1();
                Name        = ft1.Name;
                Description = ft1.Description;
                Fields      = ft1.Fields;
                break;

            case Segments.FTS:
                FTS fts = new FTS();
                Name        = fts.Name;
                Description = fts.Description;
                Fields      = fts.Fields;
                break;

            case Segments.GOL:
                GOL gol = new GOL();
                Name        = gol.Name;
                Description = gol.Description;
                Fields      = gol.Fields;
                break;

            case Segments.GP1:
                GP1 gp1 = new GP1();
                Name        = gp1.Name;
                Description = gp1.Description;
                Fields      = gp1.Fields;
                break;

            case Segments.GP2:
                GP2 gp2 = new GP2();
                Name        = gp2.Name;
                Description = gp2.Description;
                Fields      = gp2.Fields;
                break;

            case Segments.GT1:
                GT1 gt1 = new GT1();
                Name        = gt1.Name;
                Description = gt1.Description;
                Fields      = gt1.Fields;
                break;

            case Segments.IAM:
                IAM iam = new IAM();
                Name        = iam.Name;
                Description = iam.Description;
                Fields      = iam.Fields;
                break;

            case Segments.IIM:
                IIM iim = new IIM();
                Name        = iim.Name;
                Description = iim.Description;
                Fields      = iim.Fields;
                break;

            case Segments.IN1:
                IN1 in1 = new IN1();
                Name        = in1.Name;
                Description = in1.Description;
                Fields      = in1.Fields;
                break;

            case Segments.IN2:
                IN2 in2 = new IN2();
                Name        = in2.Name;
                Description = in2.Description;
                Fields      = in2.Fields;
                break;

            case Segments.IN3:
                IN3 in3 = new IN3();
                Name        = in3.Name;
                Description = in3.Description;
                Fields      = in3.Fields;
                break;

            case Segments.INV:
                INV inv = new INV();
                Name        = inv.Name;
                Description = inv.Description;
                Fields      = inv.Fields;
                break;

            case Segments.IPC:
                IPC ipc = new IPC();
                Name        = ipc.Name;
                Description = ipc.Description;
                Fields      = ipc.Fields;
                break;

            case Segments.ISD:
                ISD isd = new ISD();
                Name        = isd.Name;
                Description = isd.Description;
                Fields      = isd.Fields;
                break;

            case Segments.LAN:
                LAN lan = new LAN();
                Name        = lan.Name;
                Description = lan.Description;
                Fields      = lan.Fields;
                break;

            case Segments.LCC:
                LCC lcc = new LCC();
                Name        = lcc.Name;
                Description = lcc.Description;
                Fields      = lcc.Fields;
                break;

            case Segments.LCH:
                LCH lch = new LCH();
                Name        = lch.Name;
                Description = lch.Description;
                Fields      = lch.Fields;
                break;

            case Segments.LDP:
                LDP ldp = new LDP();
                Name        = ldp.Name;
                Description = ldp.Description;
                Fields      = ldp.Fields;
                break;

            case Segments.LOC:
                LOC loc = new LOC();
                Name        = loc.Name;
                Description = loc.Description;
                Fields      = loc.Fields;
                break;

            case Segments.LRL:
                LRL lrl = new LRL();
                Name        = lrl.Name;
                Description = lrl.Description;
                Fields      = lrl.Fields;
                break;

            case Segments.MFA:
                MFA mfa = new MFA();
                Name        = mfa.Name;
                Description = mfa.Description;
                Fields      = mfa.Fields;
                break;

            case Segments.MFE:
                MFE mfe = new MFE();
                Name        = mfe.Name;
                Description = mfe.Description;
                Fields      = mfe.Fields;
                break;

            case Segments.MFI:
                MFI mfi = new MFI();
                Name        = mfi.Name;
                Description = mfi.Description;
                Fields      = mfi.Fields;
                break;

            case Segments.MRG:
                MRG mrg = new MRG();
                Name        = mrg.Name;
                Description = mrg.Description;
                Fields      = mrg.Fields;
                break;

            case Segments.MSA:
                MSA msa = new MSA();
                Name        = msa.Name;
                Description = msa.Description;
                Fields      = msa.Fields;
                break;

            case Segments.MSH:
                MSH msh = new MSH();
                Name        = msh.Name;
                Description = msh.Description;
                Fields      = msh.Fields;
                break;

            case Segments.NCK:
                NCK nck = new NCK();
                Name        = nck.Name;
                Description = nck.Description;
                Fields      = nck.Fields;
                break;

            case Segments.NDS:
                NDS nds = new NDS();
                Name        = nds.Name;
                Description = nds.Description;
                Fields      = nds.Fields;
                break;

            case Segments.NK1:
                NK1 nk1 = new NK1();
                Name        = nk1.Name;
                Description = nk1.Description;
                Fields      = nk1.Fields;
                break;

            case Segments.NPU:
                NPU npu = new NPU();
                Name        = npu.Name;
                Description = npu.Description;
                Fields      = npu.Fields;
                break;

            case Segments.NSC:
                NSC nsc = new NSC();
                Name        = nsc.Name;
                Description = nsc.Description;
                Fields      = nsc.Fields;
                break;

            case Segments.NST:
                NST nst = new NST();
                Name        = nst.Name;
                Description = nst.Description;
                Fields      = nst.Fields;
                break;

            case Segments.NTE:
                NTE nte = new NTE();
                Name        = nte.Name;
                Description = nte.Description;
                Fields      = nte.Fields;
                break;

            case Segments.OBR:
                OBR obr = new OBR();
                Name        = obr.Name;
                Description = obr.Description;
                Fields      = obr.Fields;
                break;

            case Segments.OBX:
                OBX obx = new OBX();
                Name        = obx.Name;
                Description = obx.Description;
                Fields      = obx.Fields;
                break;

            case Segments.ODS:
                ODS ods = new ODS();
                Name        = ods.Name;
                Description = ods.Description;
                Fields      = ods.Fields;
                break;

            case Segments.ODT:
                ODT odt = new ODT();
                Name        = odt.Name;
                Description = odt.Description;
                Fields      = odt.Fields;
                break;

            case Segments.OM1:
                OM1 om1 = new OM1();
                Name        = om1.Name;
                Description = om1.Description;
                Fields      = om1.Fields;
                break;

            case Segments.OM2:
                OM2 om2 = new OM2();
                Name        = om2.Name;
                Description = om2.Description;
                Fields      = om2.Fields;
                break;

            case Segments.OM3:
                OM3 om3 = new OM3();
                Name        = om3.Name;
                Description = om3.Description;
                Fields      = om3.Fields;
                break;

            case Segments.OM4:
                OM4 om4 = new OM4();
                Name        = om4.Name;
                Description = om4.Description;
                Fields      = om4.Fields;
                break;

            case Segments.OM5:
                OM5 om5 = new OM5();
                Name        = om5.Name;
                Description = om5.Description;
                Fields      = om5.Fields;
                break;

            case Segments.OM6:
                OM6 om6 = new OM6();
                Name        = om6.Name;
                Description = om6.Description;
                Fields      = om6.Fields;
                break;

            case Segments.OM7:
                OM7 om7 = new OM7();
                Name        = om7.Name;
                Description = om7.Description;
                Fields      = om7.Fields;
                break;

            case Segments.ORC:
                ORC orc = new ORC();
                Name        = orc.Name;
                Description = orc.Description;
                Fields      = orc.Fields;
                break;

            case Segments.ORG:
                ORG org = new ORG();
                Name        = org.Name;
                Description = org.Description;
                Fields      = org.Fields;
                break;

            case Segments.OVR:
                OVR ovr = new OVR();
                Name        = ovr.Name;
                Description = ovr.Description;
                Fields      = ovr.Fields;
                break;

            case Segments.PCR:
                PCR pcr = new PCR();
                Name        = pcr.Name;
                Description = pcr.Description;
                Fields      = pcr.Fields;
                break;

            case Segments.PD1:
                PD1 pd1 = new PD1();
                Name        = pd1.Name;
                Description = pd1.Description;
                Fields      = pd1.Fields;
                break;

            case Segments.PDA:
                PDA pda = new PDA();
                Name        = pda.Name;
                Description = pda.Description;
                Fields      = pda.Fields;
                break;

            case Segments.PDC:
                PDC pdc = new PDC();
                Name        = pdc.Name;
                Description = pdc.Description;
                Fields      = pdc.Fields;
                break;

            case Segments.PEO:
                PEO peo = new PEO();
                Name        = peo.Name;
                Description = peo.Description;
                Fields      = peo.Fields;
                break;

            case Segments.PES:
                PES pes = new PES();
                Name        = pes.Name;
                Description = pes.Description;
                Fields      = pes.Fields;
                break;

            case Segments.PID:
                PID pid = new PID();
                Name        = pid.Name;
                Description = pid.Description;
                Fields      = pid.Fields;
                break;

            case Segments.PR1:
                PR1 pr1 = new PR1();
                Name        = pr1.Name;
                Description = pr1.Description;
                Fields      = pr1.Fields;
                break;

            case Segments.PRA:
                PRA pra = new PRA();
                Name        = pra.Name;
                Description = pra.Description;
                Fields      = pra.Fields;
                break;

            case Segments.PRB:
                PRB prb = new PRB();
                Name        = prb.Name;
                Description = prb.Description;
                Fields      = prb.Fields;
                break;

            case Segments.PRC:
                PRC prc = new PRC();
                Name        = prc.Name;
                Description = prc.Description;
                Fields      = prc.Fields;
                break;

            case Segments.PRD:
                PRD prd = new PRD();
                Name        = prd.Name;
                Description = prd.Description;
                Fields      = prd.Fields;
                break;

            case Segments.PSH:
                PSH psh = new PSH();
                Name        = psh.Name;
                Description = psh.Description;
                Fields      = psh.Fields;
                break;

            case Segments.PTH:
                PTH pth = new PTH();
                Name        = pth.Name;
                Description = pth.Description;
                Fields      = pth.Fields;
                break;

            case Segments.PV1:
                PV1 pv1 = new PV1();
                Name        = pv1.Name;
                Description = pv1.Description;
                Fields      = pv1.Fields;
                break;

            case Segments.PV2:
                PV2 pv2 = new PV2();
                Name        = pv2.Name;
                Description = pv2.Description;
                Fields      = pv2.Fields;
                break;

            case Segments.QAK:
                QAK qak = new QAK();
                Name        = qak.Name;
                Description = qak.Description;
                Fields      = qak.Fields;
                break;

            case Segments.QID:
                QID qid = new QID();
                Name        = qid.Name;
                Description = qid.Description;
                Fields      = qid.Fields;
                break;

            case Segments.QPD:
                QPD qpd = new QPD();
                Name        = qpd.Name;
                Description = qpd.Description;
                Fields      = qpd.Fields;
                break;

            case Segments.QRD:
                QRD qrd = new QRD();
                Name        = qrd.Name;
                Description = qrd.Description;
                Fields      = qrd.Fields;
                break;

            case Segments.QRF:
                QRF qrf = new QRF();
                Name        = qrf.Name;
                Description = qrf.Description;
                Fields      = qrf.Fields;
                break;

            case Segments.QRI:
                QRI qri = new QRI();
                Name        = qri.Name;
                Description = qri.Description;
                Fields      = qri.Fields;
                break;

            case Segments.RCP:
                RCP rcp = new RCP();
                Name        = rcp.Name;
                Description = rcp.Description;
                Fields      = rcp.Fields;
                break;

            case Segments.RDF:
                RDF rdf = new RDF();
                Name        = rdf.Name;
                Description = rdf.Description;
                Fields      = rdf.Fields;
                break;

            case Segments.RF1:
                RF1 rf1 = new RF1();
                Name        = rf1.Name;
                Description = rf1.Description;
                Fields      = rf1.Fields;
                break;

            case Segments.RGS:
                RGS rgs = new RGS();
                Name        = rgs.Name;
                Description = rgs.Description;
                Fields      = rgs.Fields;
                break;

            case Segments.RMI:
                RMI rmi = new RMI();
                Name        = rmi.Name;
                Description = rmi.Description;
                Fields      = rmi.Fields;
                break;

            case Segments.ROL:
                ROL rol = new ROL();
                Name        = rol.Name;
                Description = rol.Description;
                Fields      = rol.Fields;
                break;

            case Segments.RQ1:
                RQ1 rq1 = new RQ1();
                Name        = rq1.Name;
                Description = rq1.Description;
                Fields      = rq1.Fields;
                break;

            case Segments.RQD:
                RQD rqd = new RQD();
                Name        = rqd.Name;
                Description = rqd.Description;
                Fields      = rqd.Fields;
                break;

            case Segments.RXA:
                RXA rxa = new RXA();
                Name        = rxa.Name;
                Description = rxa.Description;
                Fields      = rxa.Fields;
                break;

            case Segments.RXC:
                RXC rxc = new RXC();
                Name        = rxc.Name;
                Description = rxc.Description;
                Fields      = rxc.Fields;
                break;

            case Segments.RXD:
                RXD rxd = new RXD();
                Name        = rxd.Name;
                Description = rxd.Description;
                Fields      = rxd.Fields;
                break;

            case Segments.RXE:
                RXE rxe = new RXE();
                Name        = rxe.Name;
                Description = rxe.Description;
                Fields      = rxe.Fields;
                break;

            case Segments.RXG:
                RXG rxg = new RXG();
                Name        = rxg.Name;
                Description = rxg.Description;
                Fields      = rxg.Fields;
                break;

            case Segments.RXO:
                RXO rxo = new RXO();
                Name        = rxo.Name;
                Description = rxo.Description;
                Fields      = rxo.Fields;
                break;

            case Segments.RXR:
                RXR rxr = new RXR();
                Name        = rxr.Name;
                Description = rxr.Description;
                Fields      = rxr.Fields;
                break;

            case Segments.SAC:
                SAC sac = new SAC();
                Name        = sac.Name;
                Description = sac.Description;
                Fields      = sac.Fields;
                break;

            case Segments.SCH:
                SCH sch = new SCH();
                Name        = sch.Name;
                Description = sch.Description;
                Fields      = sch.Fields;
                break;

            case Segments.SFT:
                SFT sft = new SFT();
                Name        = sft.Name;
                Description = sft.Description;
                Fields      = sft.Fields;
                break;

            case Segments.SID:
                SID sid = new SID();
                Name        = sid.Name;
                Description = sid.Description;
                Fields      = sid.Fields;
                break;

            case Segments.SPM:
                SPM spm = new SPM();
                Name        = spm.Name;
                Description = spm.Description;
                Fields      = spm.Fields;
                break;

            case Segments.SPR:
                SPR spr = new SPR();
                Name        = spr.Name;
                Description = spr.Description;
                Fields      = spr.Fields;
                break;

            case Segments.STF:
                STF stf = new STF();
                Name        = stf.Name;
                Description = stf.Description;
                Fields      = stf.Fields;
                break;

            case Segments.TCC:
                TCC tcc = new TCC();
                Name        = tcc.Name;
                Description = tcc.Description;
                Fields      = tcc.Fields;
                break;

            case Segments.TCD:
                TCD tcd = new TCD();
                Name        = tcd.Name;
                Description = tcd.Description;
                Fields      = tcd.Fields;
                break;

            case Segments.TQ1:
                TQ1 tq1 = new TQ1();
                Name        = tq1.Name;
                Description = tq1.Description;
                Fields      = tq1.Fields;
                break;

            case Segments.TQ2:
                TQ2 tq2 = new TQ2();
                Name        = tq2.Name;
                Description = tq2.Description;
                Fields      = tq2.Fields;
                break;

            case Segments.TXA:
                TXA txa = new TXA();
                Name        = txa.Name;
                Description = txa.Description;
                Fields      = txa.Fields;
                break;

            case Segments.UB1:
                UB1 ub1 = new UB1();
                Name        = ub1.Name;
                Description = ub1.Description;
                Fields      = ub1.Fields;
                break;

            case Segments.UB2:
                UB2 ub2 = new UB2();
                Name        = ub2.Name;
                Description = ub2.Description;
                Fields      = ub2.Fields;
                break;

            case Segments.URD:
                URD urd = new URD();
                Name        = urd.Name;
                Description = urd.Description;
                Fields      = urd.Fields;
                break;

            case Segments.URS:
                URS urs = new URS();
                Name        = urs.Name;
                Description = urs.Description;
                Fields      = urs.Fields;
                break;

            case Segments.VAR:
                VAR var = new VAR();
                Name        = var.Name;
                Description = var.Description;
                Fields      = var.Fields;
                break;

            case Segments.VTQ:
                VTQ vtq = new VTQ();
                Name        = vtq.Name;
                Description = vtq.Description;
                Fields      = vtq.Fields;
                break;
            }
        }
Ejemplo n.º 23
0
        public IRace CreateInstance()
        {
            IRace race = new ORC();

            return(race);
        }
Ejemplo n.º 24
0
        /*
         * This is the function to recognize text form a image
         */
        private async void Recognize_Text()
        {
            //Here is where choosen image is saved
            MediaFile file = null;

            try
            {
                //Getting permissions to the storage
                await CrossMedia.Current.Initialize();

                //Checking if picking picture function is available
                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    await DisplayAlert("Not able to pick photo", "Could not make it.", "OK");

                    return;
                }

                //Choosing picture
                file = await CrossMedia.Current.PickPhotoAsync();

                //Checking if a picture was choosen
                if (file == null)
                {
                    await DisplayAlert("Could not load Image", "Try Again", "OK");

                    return;
                }

                //Img is a xamarin image tag. Here I am just loading the choosen image to that tag
                //Img.Source = ImageSource.FromStream(() => file.GetStream());
            }
            catch (Exception exception)
            {
                await DisplayAlert("Access Denied", "Camera Access.\n" + exception.Message, "OK");
            }


            /*
             * Here is where the recognition starts
             */

            //this will be pass as an argument to the API
            byte[] imageAsBytes;

            using (var memoryStream = new MemoryStream())
            {
                file.GetStream().CopyTo(memoryStream);
                file.Dispose();
                imageAsBytes = memoryStream.ToArray();
            }

            //Creating a HTTPClient to make request to the API
            var client = new HttpClient();
            //Setting the content to be sent to the API
            var httpContent = new MultipartFormDataContent();

            //httpContent.Headers.ContentType.MediaType = "multipart/form-data";
            httpContent.Add(new StringContent("5c3aca107b88957"), "apikey"); //This is a special key needed to use the API
            httpContent.Add(new ByteArrayContent(imageAsBytes, 0, imageAsBytes.Length), "image", "image.jpg");

            //Sending the request to the API
            HttpResponseMessage response = await client.PostAsync("https://api.ocr.space/parse/image", httpContent); // This is the API URL

            //Checking if the response is OK
            if (response.IsSuccessStatusCode)
            {
                //Reading the content of the response
                string content = await response.Content.ReadAsStringAsync();

                //This is a class created below just to organize the reponse
                ORC ocrResult = JsonConvert.DeserializeObject <ORC>(content);


                if (ocrResult.OCRExitCode == 1)
                {
                    for (int i = 0; i < ocrResult.ParsedResults.Count(); i++)
                    {
                        //LblResult is a xamarin tag <Editor>. Setting the text to the editor
                        Entry_Title.Text += ocrResult.ParsedResults[i].ParsedText;
                    }
                }
                else
                {
                    //If any error, show it in an alert
                    await DisplayAlert("Http Error", "Error:\n" + content, "OK");
                }
            }
            else
            {
                //If any error with the response, show it in the <Editor>
                await DisplayAlert("Http Error", "Error:\n", "OK");

                //LblResult.Text = "Error HttpRequest";
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Add a new CALLBACKPHONENUMBER to ORC
 /// </summary>
 public static TN AddCALLBACKPHONENUMBER(this ORC message)
 {
     return(message.GetCALLBACKPHONENUMBER(message.CALLBACKPHONENUMBERRepetitionsUsed));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Get all CALLBACKPHONENUMBER Records from ORC
 /// </summary>
 public static List <TN> GetAllCALLBACKPHONENUMBERRecords(this ORC message)
 {
     return(message.GetAllRecords <TN>("CALLBACKPHONENUMBERRepetitionsUsed", "GetCALLBACKPHONENUMBER"));
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Validate - Validate the required fields for the given object
        ///            make this call after the hl7 segment string has been set
        /// </summary>
        /// <param name="seg">ORC object</param>
        /// <returns>list<SegmentError></returns>
        private List <SegmentError> Validate(ORC seg, HL7Encoding _encode)
        {
            const string        fnName    = "Validate";
            List <SegmentError> segErrors = new List <SegmentError>();

            try
            {
                foreach (var rqFld in seg.RequiredFields)
                {
                    if (rqFld.IsRequired)
                    {
                        Object obj = GetField(_encode, seg.SegmentMsg, rqFld.FieldIdx);
                        if (string.IsNullOrEmpty((string)obj))
                        {
                            segErrors.Add(new SegmentError(rqFld.HL7Segment, rqFld.FieldName, string.Format("{0}:{1} - field {2} Value is required cannot be null", modName, fnName, rqFld.FieldName)));
                            break;                              // leave
                        }
                        switch (rqFld.FieldType.ToLower())
                        {
                        case "int":
                            bool bAns = int.TryParse(((string)obj), out int nValue);
                            if (!bAns)
                            {
                                segErrors.Add(new SegmentError(rqFld.HL7Segment, rqFld.FieldName, string.Format("{0}:{1} - field {2} type is 'int' value is required cannot be null", modName, fnName, rqFld.FieldName)));
                            }
                            break;

                        case "string":
                            string sTmp = (string)obj;
                            // check if string is greate than fieldLength
                            if (sTmp.Length > rqFld.FieldLength)
                            {
                                segErrors.Add(new SegmentError(rqFld.HL7Segment, rqFld.FieldName, string.Format("{0}:{1} - field {2} type is 'string' value is greater than max size {3}", modName, fnName, rqFld.FieldName, rqFld.FieldLength)));
                            }
                            if (rqFld.FieldName.Equals(orcElements.OrderControl.ToString()))
                            {
                                // split the string ORM^O01.   Validate ORM is first field
                                if (!"NW".Equals(sTmp))
                                {
                                    segErrors.Add(new SegmentError(rqFld.HL7Segment, rqFld.FieldName, string.Format("{0}:{1} - Order Control value '{3}' is incorrect : (" + (string)obj + ")", modName, fnName, sTmp)));
                                }
                            }
                            break;

                        case "date":
                            // the field is a date field but is a string in the HL7 message
                            switch (((string)obj).Length)
                            {
                            case 8:
                            case 12:
                            case 14:
                                // good
                                break;

                            default:
                                segErrors.Add(new SegmentError(rqFld.HL7Segment, rqFld.FieldName, string.Format("{0}:{1} - field {2} type is 'date' value out of range YYYYMMDD, YYYYMMDDHHMM, YYYYMMDDHHMMSS", modName, fnName, rqFld.FieldName)));
                                break;
                            }
                            break;

                        default:
                            segErrors.Add(new SegmentError(rqFld.HL7Segment, rqFld.FieldName, string.Format("{0}:{1} - FieldType ({2}) is undefined", modName, fnName, rqFld.FieldType.ToLower())));
                            break;
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                string sTmp = string.Format("{0}:{1} - EXCEPTION ({2})", modName, fnName, exp);
                segErrors.Add(new SegmentError(seg.Segment, "N/A", sTmp));
            }
            return(segErrors);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// GetPV1
        ///     Get the HL7 ORC segment and parse into the orc object.
        ///     Also perform field validation of required fields and types
        ///     Verify no errors have been detected during processing
        /// </summary>
        /// <param name="line">HL7 segment to parse</param>
        /// <returns>ORC object</returns>
        public ORC GetORC(HL7Encoding _encode, string line)
        {
            const string        fnName   = "GetORC";
            List <SegmentError> segError = null;
            ORC orc  = new ORC();
            int nIdx = 0;

            try
            {
                orc.SegmentMsg = line;
                orc.Segment    = "ORC";
                segError       = Validate(orc, _encode);

                // var enumCnt = Enum.GetNames(typeof(mshElements)).Length;
                foreach (int i in Enum.GetValues(typeof(orcElements)))
                {
                    nIdx = i;
                    object obj = GetElement(_encode, line, i);
                    if (obj == null)
                    {
                        // check if this a required field
                        string        sTmp1 = ((Gt1Elements)i).ToString();
                        RequiredField rqFld = orc.RequiredFields.Find(x => x.FieldName.Equals(sTmp1));
                        if (rqFld != null && rqFld.IsRequired)
                        {
                            orc.Errors.Add(string.Format("{0}:{1} - WARNING Element ({2}) not found in segment, at field {3}", modName, fnName, ((orcElements)i).ToString(), i));
                        }
                        continue;
                    }
                    switch ((orcElements)i)
                    {
                    case orcElements.Segment:
                        orc.Segment = (string)obj;
                        break;

                    case orcElements.EnteredBy:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.EnteredBy = (string)obj;
                        }
                        break;

                    case orcElements.FillerOrderNumber:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.FillerOrderNumber = (string)obj;
                        }
                        break;

                    case orcElements.OrderControl:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.OrderControl = (string)obj;
                        }
                        break;

                    case orcElements.OrderingPhysician:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.NPI       = GetComponent(_encode, (string)obj, (int)orcProvider.NPI);
                            orc.LastName  = GetComponent(_encode, (string)obj, (int)orcProvider.LastName);
                            orc.FirstName = GetComponent(_encode, (string)obj, (int)orcProvider.FirstName);
                        }
                        break;

                    case orcElements.OrderStatus:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.OrderStatus = (string)obj;
                        }
                        break;

                    case orcElements.Parent:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.Parent = (string)obj;
                        }
                        break;

                    case orcElements.PlacerGroupNumber:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.PlacerGroupNumber = (string)obj;
                        }
                        break;

                    case orcElements.PlacerOrderNumber:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.PlacerOrderNumber = (string)obj;
                        }
                        break;

                    case orcElements.QuantityTiming:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.QuantityTiming = (string)obj;
                        }
                        break;

                    case orcElements.ResponseFlag:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.ResponseFlag = (string)obj;
                        }
                        break;

                    case orcElements.TransactionDateTime:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.TransactionDateTime = (string)obj;
                        }
                        break;

                    case orcElements.VerifiedBy:
                        if (!string.IsNullOrEmpty((string)obj))
                        {
                            orc.VerifiedBy = (string)obj;
                        }
                        break;

                    default:
                        orc.Errors.Add(string.Format("{0}:{1} - Error element ({2}) not found", modName, fnName, (orcElements)i).ToString());
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                string sErr = string.Format("Exception:{0}:{1} - ({2}) {3}", modName, fnName, ((orcElements)nIdx).ToString(), ex);
                orc.Errors.Add(sErr);
                Console.WriteLine(sErr);
            }
            return(orc);
        }
Ejemplo n.º 29
0
 public void PlayORC(ORC orc)
 {
     Console.WriteLine("******************************");
     Console.WriteLine("This is {0} Play War3.{1}", this.Name, orc.GetType().Name);
     orc.ShowKing();
 }
Ejemplo n.º 30
0
        private void button1_Click(object sender, EventArgs e)
        {
            ORM_O01 orm = new ORM_O01();

            #region 组装消息头
            orm.MSH.MessageType.MessageType.Value      = "ORM";
            orm.MSH.MessageType.TriggerEvent.Value     = "O01";
            orm.MSH.MessageType.MessageStructure.Value = "ORM_O01";
            orm.MSH.FieldSeparator.Value = MessageConstant.FieldSeparator;
            orm.MSH.SendingApplication.NamespaceID.Value   = "SSMZ1";
            orm.MSH.SendingFacility.NamespaceID.Value      = "SSMZ1";
            orm.MSH.ReceivingApplication.NamespaceID.Value = "MediII";
            orm.MSH.ReceivingFacility.NamespaceID.Value    = "MediII";
            orm.MSH.EncodingCharacters.Value  = MessageConstant.EncodingCharacters;
            orm.MSH.VersionID.VersionID.Value = MessageConstant.VersionID;
            orm.MSH.DateTimeOfMessage.TimeOfAnEvent.SetLongDateWithSecond(DateTime.Now);
            orm.MSH.MessageControlID.Value          = MediII.Common.GUIDHelper.NewGUID();
            orm.MSH.ProcessingID.ProcessingID.Value = MessageConstant.ProcessingID;

            #endregion
            for (int i = 0; i < messageList.Count; i++)
            {
                MessageNode node = messageList[i];

                #region 组装PID段
                PID pid = orm.PATIENT.PID;
                pid.PatientID.ID.Value = node.PIDList["PatientIdentifier"];
                pid.GetPatientIdentifierList(0).ID.Value = node.PIDList["PatientIdentifier"];
                pid.GetPatientIdentifierList(1).ID.Value = node.PIDList["jiuzhenkh"];
                pid.GetPatientIdentifierList(2).ID.Value = node.PIDList["binganhao"];
                pid.GetPatientIdentifierList(3).ID.Value = node.PIDList["shebaokh"];
                pid.GetPatientIdentifierList(4).ID.Value = node.PIDList["gongfeizh"];
                string bingRenXM = node.PIDList["bingrenxm"];
                #region 姓名转全拼
                StringBuilder sb = new StringBuilder();
                foreach (char c in bingRenXM)
                {
                    if (ChineseChar.IsValidChar(c))
                    {
                        ChineseChar pinYinConvert = new ChineseChar(c);
                        string      pinYin        = pinYinConvert.Pinyins[0];
                        if (!string.IsNullOrEmpty(pinYin))
                        {
                            string word = pinYin.Substring(0, pinYin.Length - 1);
                            //首字母大写,其他小写
                            StringBuilder sbW = new StringBuilder(word.Length);
                            for (int n = 0; n < word.Length; n++)
                            {
                                string s = word.Substring(n, 1);
                                if (n == 0)
                                {
                                    sbW.Append(s.ToUpper());
                                }
                                else
                                {
                                    sbW.Append(s.ToLower());
                                }
                            }
                            sb.Append(sbW.ToString());
                        }
                    }
                    else
                    {
                        sb.Append(c);
                    }
                }
                #endregion
                pid.GetPatientName(0).FamilyName.Surname.Value = sb.ToString();
                pid.GetPatientName(0).GivenName.Value          = bingRenXM;
                DateTime dtCHUSHENGRQ = DateTime.Parse(node.PIDList["chushengrq"]);
                pid.DateTimeOfBirth.TimeOfAnEvent.SetLongDateWithSecond((DateTime)dtCHUSHENGRQ);//出生日期
                //if (string.IsNullOrEmpty(bingRenXx.XINGBIE))    //性别
                //    pid.AdministrativeSex.Value = "O";
                //else if (bingRenXx.XINGBIE == "男")
                //    pid.AdministrativeSex.Value = "M";
                //else if (bingRenXx.XINGBIE == "女")
                pid.AdministrativeSex.Value = node.PIDList["sex"];

                XAD address = pid.GetPatientAddress(0);
                address.City.Value            = node.PIDList["city"];
                address.StateOrProvince.Value = node.PIDList["province"];
                address.StreetAddress.StreetOrMailingAddress.Value = node.PIDList["streetaddress"];
                address.ZipOrPostalCode.Value  = node.PIDList["postcode"];
                address.OtherDesignation.Value = node.PIDList["postcode"];
                pid.GetPhoneNumberHome(0).PhoneNumber.Value     = node.PIDList["homephone"];
                pid.GetPhoneNumberBusiness(0).PhoneNumber.Value = node.PIDList["workphone"];
                pid.MaritalStatus.Text.Value = node.PIDList["hunyin"];
                string hunYinDm = string.Empty;
                //if (bingRenXx.HUNYINDM == "0")
                //    hunYinDm = "S";
                //else if (bingRenXx.HUNYINDM == "1")
                //    hunYinDm = "M";
                //else
                hunYinDm = "O";                                //婚姻代码
                pid.MaritalStatus.Identifier.Value = hunYinDm; //婚姻代码
                pid.PatientAccountNumber.ID.Value  = node.PIDList["yibaokh"];
                pid.SSNNumberPatient.Value         = node.PIDList["idnumber"];

                pid.GetEthnicGroup(0).Identifier.Value = node.PIDList["EthicGroupID"];
                pid.GetEthnicGroup(0).Text.Value       = node.PIDList["EthicGroupName"];
                pid.BirthPlace.Value             = node.PIDList["BirthPlace"];
                pid.Nationality.Identifier.Value = node.PIDList["NationalityID"];
                pid.Nationality.Text.Value       = node.PIDList["NationalityName"];
                #endregion
                #region 组装PV1

                PV1    pv1 = orm.PATIENT.PATIENT_VISIT.PV1;
                string menZhenZhuYuanBZ = node.PV1List["menZhenZhuYuanBZ"];
                if (menZhenZhuYuanBZ == "0")
                {
                    //门诊
                    pv1.SetIDPV1.Value      = node.PV1List["SetID"];
                    pv1.AdmissionType.Value = "R";
                    pv1.PatientClass.Value  = "O"; //门诊O
                    pv1.GetAttendingDoctor(0).IDNumber.Value = node.PV1List["AdmittingDoctorID"];
                    pv1.HospitalService.Value             = node.PV1List["HospitalService"];
                    pv1.PatientType.Value                 = node.PV1List["PatientType"];
                    pv1.VisitNumber.ID.Value              = node.PV1List["VisitNumber"];
                    pv1.ServicingFacility.Value           = node.PV1List["ServicingFacility"]; //上下午标志 0-上午,1-下午,2-晚上
                    pv1.PendingLocation.PointOfCare.Value = node.PV1List["PendingLocation"];
                    DateTime dtZHIDANRQ = DateTime.Parse(node.PV1List["AdmitDate"]);
                    pv1.AdmitDateTime.TimeOfAnEvent.SetLongDateWithSecond((DateTime)dtZHIDANRQ);//制单医生日期 就诊日期
                    pv1.VisitIndicator.Value       = "V";
                    pv1.ChargePriceIndicator.Value = node.PV1List["ChargePriceIndicator"];
                }
                else
                {
                    //住院
                    pid.GetPatientIdentifierList(1).ID.Value = node.PIDList["jiuzhenkh"];
                    pid.GetAlternatePatientIDPID(0).ID.Value = node.PIDList["yingerbz"];//婴儿标志0非婴儿1婴儿
                    pid.GetMotherSIdentifier(0).ID.Value     = node.PIDList["MothersIdentifier"];
                    pv1.VisitNumber.ID.Value = node.PV1List["VisitNumber"];
                    pv1.SetIDPV1.Value       = node.PV1List["AlternateVisitID"]; //住医生院次数
                    pv1.PatientClass.Value   = "I";                              //住院病人
                    pv1.AssignedPatientLocation.PointOfCare.Value = node.PV1List["PointOfCare"];
                    pv1.AssignedPatientLocation.Bed.Value         = node.PV1List["Bed"];
                    pv1.AssignedPatientLocation.Room.Value        = node.PV1List["Room"];
                    if (!String.IsNullOrEmpty(node.PV1List["Facility"]))//当前科室,当前科室名称
                    {
                        pv1.AssignedPatientLocation.Facility.NamespaceID.Value = node.PV1List["Facility"];
                    }
                    pv1.GetAttendingDoctor(0).IDNumber.Value  = node.PV1List["AttendingDoctorID"];
                    pv1.GetAttendingDoctor(0).GivenName.Value = node.PV1List["AttendingDoctorFamilyName"];
                    DateTime dtRuYuanRQ = DateTime.Parse(node.PV1List["AdmitDate"]);
                    pv1.AdmitDateTime.TimeOfAnEvent.SetLongDateWithSecond((DateTime)dtRuYuanRQ); //入院日期
                    pv1.PendingLocation.PointOfCare.Value = node.PV1List["PendingLocation"];     //当前科室
                    pv1.PatientType.Value = node.PV1List["PatientType"];                         //费用类别
                    DateTime dtRuKeRQ = DateTime.Parse(node.PV1List["AdmitDate"]);
                    if (dtRuKeRQ != null)
                    {
                        pv1.GetContractEffectiveDate(0).Value = ((DateTime)dtRuKeRQ).ToString("yyyyMMddHHmmss");//入科日期
                    }
                    pv1.VisitIndicator.Value       = "V";
                    pv1.ChargePriceIndicator.Value = node.PV1List["ChargePriceIndicator"];
                    pv1.AlternateVisitID.ID.Value  = node.PV1List["AlternateVisitID"];//住院次数
                }
                #endregion
                #region 组装检验申请内容
                for (int j = 0; j < node.ORCList.Count; j++)
                {
                    ORC orc = orm.GetORDER(j).ORC;
                    orc.OrderControl.Value = "SC";
                    orc.PlacerOrderNumber.EntityIdentifier.Value = node.ORCList[j]["PlacerOrderNumber"];                                     //申请单ID
                    orc.FillerOrderNumber.EntityIdentifier.Value = node.ORCList[j]["FillterOrderNumber"];                                    //检查号
                    orc.OrderStatus.Value = "SC";
                    orc.DateTimeOfTransaction.TimeOfAnEvent.SetLongDateWithSecond(DateTime.Parse(node.ORCList[j]["DateTimeOfTransaction"])); //登记时间
                    orc.GetEnteredBy(0).IDNumber.Value         = node.ORCList[j]["EnteredBy"];                                               //录入者
                    orc.EnteringOrganization.Identifier.Value  = node.ORCList[j]["EnteringOrganizationIdentifier"];                          //申请科室ID
                    orc.EnteringOrganization.Text.Value        = node.ORCList[j]["EnteringOrganizationText"];                                //申请科室名称
                    orc.GetOrderingProvider(j).IDNumber.Value  = node.ORCList[j]["OrderingProviderID"];                                      //申请医生ID
                    orc.GetOrderingProvider(j).GivenName.Value = node.ORCList[j]["OrderingProviderName"];                                    //申请医生姓名
                    orc.OrderControlCodeReason.Text.Value      = node.ORCList[j]["OrderControlCodeReason"];                                  //检查目的

                    OBR obr = orm.GetORDER(j).ORDER_DETAIL.OBR;
                    obr.SetIDOBR.Value = (j + 1).ToString();
                    obr.PlacerOrderNumber.EntityIdentifier.Value    = node.OBRList[j]["PlacerOrderNumber"];          //申请单ID
                    obr.FillerOrderNumber.EntityIdentifier.Value    = node.OBRList[j]["FillterOrderNumber"];         //检查号
                    obr.UniversalServiceIdentifier.Identifier.Value = node.OBRList[j]["UniversalServiceIdentifier"]; //检查部位ID
                    obr.UniversalServiceIdentifier.Text.Value       = node.OBRList[j]["UniversalServiceText"];       //检查部位名称
                    obr.Priority.Value = node.OBRList[j]["Priority"];                                                //优先级
                    obr.DangerCode.Identifier.Value = node.OBRList[j]["DangerCodeIdentifier"];;                      //执行科室
                    obr.DangerCode.Text.Value       = node.OBRList[j]["DangerCodeText"];                             //执行科室名称
                }
                #endregion
            }
            #region 转换消息对象为字符串
            NHapi.Base.Parser.PipeParser parser = new PipeParser();
            message = parser.Encode(orm);
            this.txtOutput.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            this.txtOutput.AppendText("构建消息内容完成,消息内容如下:");
            this.txtOutput.AppendText(System.Environment.NewLine);
            this.txtOutput.AppendText(message);
            this.txtOutput.AppendText(System.Environment.NewLine);
            #endregion
        }