Esempio n. 1
0
        /// <summary>
        /// Parse a COR state machine from a MIF state machine
        /// </summary>
        internal static MohawkCollege.EHR.gpmr.COR.StateMachine Parse(MohawkCollege.EHR.HL7v3.MIF.MIF20.StateMachine StateMachine)
        {
            MohawkCollege.EHR.gpmr.COR.StateMachine retVal = new MohawkCollege.EHR.gpmr.COR.StateMachine();

            retVal.Transitions = new List <MohawkCollege.EHR.gpmr.COR.StateTransition>();
            Dictionary <String, MohawkCollege.EHR.gpmr.COR.State> tStates = new Dictionary <String, MohawkCollege.EHR.gpmr.COR.State>();

            retVal.States = new Dictionary <string, MohawkCollege.EHR.gpmr.COR.State>();

            // Sort each state
            StateMachine.SubState.Sort(new MohawkCollege.EHR.HL7v3.MIF.MIF20.State.Comparator());

            // Parse States
            foreach (MohawkCollege.EHR.HL7v3.MIF.MIF20.State st in StateMachine.SubState)
            {
                MohawkCollege.EHR.gpmr.COR.State nst = Parse(st);
                tStates.Add(nst.Name, nst);
            }

            // Sort parent/child states
            foreach (KeyValuePair <String, MohawkCollege.EHR.gpmr.COR.State> kv in tStates)
            {
                if (kv.Value.ParentStateName == null) // No parent? Its at the root
                {
                    retVal.States.Add(kv.Key, kv.Value);
                }
                else
                {
                    if (tStates[kv.Value.ParentStateName].ChildStates == null)
                    {
                        tStates[kv.Value.ParentStateName].ChildStates = new Dictionary <string, State>();
                    }
                    tStates[kv.Value.ParentStateName].ChildStates.Add(kv.Key, kv.Value);
                }
            }

            // Parse Transitions
            foreach (MohawkCollege.EHR.HL7v3.MIF.MIF20.Transition tx in StateMachine.Transition)
            {
                retVal.Transitions.Add(Parse(tx, tStates));
            }

            return(retVal);
        }
Esempio n. 2
0
        /// <summary>
        /// Parse a COR state machine from a MIF state machine
        /// </summary>
        internal static MohawkCollege.EHR.gpmr.COR.StateMachine Parse(MohawkCollege.EHR.HL7v3.MIF.MIF20.StateMachine StateMachine)
        {
            MohawkCollege.EHR.gpmr.COR.StateMachine retVal = new MohawkCollege.EHR.gpmr.COR.StateMachine();

            retVal.Transitions = new List<MohawkCollege.EHR.gpmr.COR.StateTransition>();
            Dictionary<String, MohawkCollege.EHR.gpmr.COR.State> tStates = new Dictionary<String, MohawkCollege.EHR.gpmr.COR.State>();
            retVal.States = new Dictionary<string, MohawkCollege.EHR.gpmr.COR.State>();

            // Sort each state
            StateMachine.SubState.Sort(new MohawkCollege.EHR.HL7v3.MIF.MIF20.State.Comparator());

            // Parse States
            foreach (MohawkCollege.EHR.HL7v3.MIF.MIF20.State st in StateMachine.SubState)
            {
                MohawkCollege.EHR.gpmr.COR.State nst = Parse(st);
                tStates.Add(nst.Name, nst);
            }

            // Sort parent/child states
            foreach (KeyValuePair<String, MohawkCollege.EHR.gpmr.COR.State> kv in tStates)
            {
                if (kv.Value.ParentStateName == null) // No parent? Its at the root
                    retVal.States.Add(kv.Key, kv.Value);
                else
                {
                    if (tStates[kv.Value.ParentStateName].ChildStates == null) tStates[kv.Value.ParentStateName].ChildStates = new Dictionary<string, State>();
                    tStates[kv.Value.ParentStateName].ChildStates.Add(kv.Key, kv.Value);
                }
            }

            // Parse Transitions
            foreach (MohawkCollege.EHR.HL7v3.MIF.MIF20.Transition tx in StateMachine.Transition)
                retVal.Transitions.Add(Parse(tx, tStates));

            return retVal;
        }