コード例 #1
0
        /// <summary>
        /// Send message MSG_NEGO_REQ
        /// </summary>
        public void SendMsgNegoReq()
        {
            PccrrNegoRequestPacket packet = this.pccrrStack.CreateMsgNegoRequest(this.minSupV, this.maxSupV, this.cryptoAlgo, MsgType_Values.MSG_NEGO_REQ, this.protoVer);

            this.pccrrStack.SendPacket(packet, new TimeSpan(0, 0, this.timeout));

            PccrrPacket respMSG = this.pccrrStack.ExpectPacket();

            PccrrNegoResponsePacket pccrrNegoResponsePacket = respMSG as PccrrNegoResponsePacket;

            MSG_NEGO_RESP             msgNegoResp    = pccrrNegoResponsePacket.MsgNegoResp;
            MESSAGE_HEADER            messageHeader  = pccrrNegoResponsePacket.MessageHeader;
            TRANSPORT_RESPONSE_HEADER transportRespH = pccrrNegoResponsePacket.TransportResponseHeader;
            RESPONSE_MESSAGE          respMessage    = new RESPONSE_MESSAGE();

            respMessage.MESSAGEBODY             = msgNegoResp;
            respMessage.MESSAGEHEADER           = messageHeader;
            respMessage.TRANSPORTRESPONSEHEADER = transportRespH;
            this.uiPayload = Marshal.SizeOf(messageHeader) + Marshal.SizeOf(msgNegoResp);

            this.VerifyHttpResponse();
            PccrrBothRoleCaptureCode.CaptureHttpRequirements();
            this.VerifyMsgNegoResp(msgNegoResp);
            this.VerifyMessageHeader(messageHeader);
            PccrrBothRoleCaptureCode.CaptureMessageHeaderRequirements(messageHeader, this.uiPayload);
            this.VerifyTransportResponseHeader(transportRespH);
            PccrrBothRoleCaptureCode.CaptureMessageRequirements();
            this.VerifyResponseMessage(respMessage);

            this.ReceiveMsgNegoResp();
        }
コード例 #2
0
        private void DataProcessing(byte[] byteMsg)
        {
            try
            {
                msgheader = (MESSAGE_HEADER)sock.RawDeserialize(byteMsg, typeof(MESSAGE_HEADER));
                int Tcode  = Convert.ToInt32(IPAddress.NetworkToHostOrder(msgheader.TransactionCode));
                int msgLen = Convert.ToInt32(IPAddress.NetworkToHostOrder(msgheader.MessageLength));

                // File.AppendAllText(Environment.CurrentDirectory + Path.DirectorySeparatorChar + "testData.txt", Tcode.ToString() +"_"+ "\n");

                switch (Tcode)
                {
                case 7207:
                    DataProcessing_7207(byteMsg);
                    break;

                case 7208:
                    //DataProcessing_7208(byteMsg);
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("DataProcessing  " + ex.ToString());
            }
        }
コード例 #3
0
 public DrugPrescriptionEntity()
 {
     MESSAGE_HEADER         = new MESSAGE_HEADER();
     PATIENT_IDENTIFICATION = new PATIENT_IDENTIFICATION();
     COMMON_ORDER_DETAILS   = new COMMON_ORDER_DETAILS();
     PHARMACY_ENCODED_ORDER = new List <PHARMACY_ENCODED_ORDER>();
 }
コード例 #4
0
        /// <summary>
        /// Send message MSG_NEGO_RESP.
        /// </summary>
        /// <param name="isSupportVersion">If it is true, it is support version, if it is false, it is not support version.</param>
        /// <param name="isWellFormed">If it is true, it is well formed, if it is false, it is not well formed.</param>
        public void SendMsgNegoResp(bool isSupportVersion, bool isWellFormed)
        {
            PccrrNegoResponsePacket pccrrNegoResponsePacket;

            if (!isSupportVersion && isWellFormed)
            {
                pccrrNegoResponsePacket = this.pccrrStackSer.CreateMsgNegoResponse(this.minErrorSupV, this.maxErrorSupV, CryptoAlgoId_Values.AES_128, MsgType_Values.MSG_NEGO_RESP, this.protoErrorVer);
            }
            else if (isSupportVersion && isWellFormed)
            {
                pccrrNegoResponsePacket = this.pccrrStackSer.CreateMsgNegoResponse(this.minSupV, this.maxSupV, CryptoAlgoId_Values.AES_128, MsgType_Values.MSG_NEGO_RESP, this.protoVer);
            }
            else
            {
                pccrrNegoResponsePacket = this.pccrrStackSer.CreateMsgNegoResponse(this.minErrorSupV, this.maxErrorSupV, CryptoAlgoId_Values.AES_128, MsgType_Values.MSG_NEGO_RESP, this.protoErrorVer);
                MSG_NEGO_RESP  msgNegoResp   = new MSG_NEGO_RESP();
                MESSAGE_HEADER messageHeader = new MESSAGE_HEADER();
                messageHeader = pccrrNegoResponsePacket.MessageHeader;
                msgNegoResp.MinSupporteProtocolVersion.MajorVersion = 0;
                msgNegoResp.MinSupporteProtocolVersion.MinorVersion = 0;
                messageHeader.ProtVer.MajorVersion = 1;
                messageHeader.ProtVer.MinorVersion = 0;
                msgNegoResp.MaxSupporteProtocolVersion.MajorVersion = 0;
                msgNegoResp.MaxSupporteProtocolVersion.MinorVersion = 0;

                pccrrNegoResponsePacket.MsgNegoResp   = msgNegoResp;
                pccrrNegoResponsePacket.MessageHeader = messageHeader;
            }

            this.pccrrStackSer.SendPacket(pccrrNegoResponsePacket);
        }
コード例 #5
0
        /// <summary>
        /// Send message MSG_GETBLKLIST.
        /// </summary>
        /// <param name="sid">segment id.</param>
        /// <param name="blockRang">Block ranges client wants to get.</param>
        /// <param name="isVersionSupported">The version in message is supported by server or not.</param>
        public void SendMsgGetBlkList(byte[] sid, BLOCKRANGE[] blockRang, bool isVersionSupported)
        {
            PccrrGETBLKLISTRequestPacket packet;

            BLOCK_RANGE[] blockRanges = Helper.ConvertToStackBLOCKRANGEArray(blockRang);

            if (!isVersionSupported)
            {
                packet = this.pccrrStack.CreateMsgGetBlkListRequest(sid, blockRanges, this.cryptoAlgo, MsgType_Values.MSG_GETBLKLIST, this.protoErrorVer);
            }
            else
            {
                packet = this.pccrrStack.CreateMsgGetBlkListRequest(sid, blockRanges, this.cryptoAlgo, MsgType_Values.MSG_GETBLKLIST, this.protoVer);
            }

            this.pccrrStack.SendPacket(packet, new TimeSpan(0, 0, this.timeout));

            PccrrPacket respMSG = this.pccrrStack.ExpectPacket();

            if (!isVersionSupported)
            {
                PccrrNegoResponsePacket pccrrNegoResponsePacket = respMSG as PccrrNegoResponsePacket;

                if (pccrrNegoResponsePacket != null)
                {
                    this.ReceiveMsgNegoResp();
                }
            }
            else
            {
                PccrrBLKLISTResponsePacket pccrrBLKLISTResponsePacket = respMSG as PccrrBLKLISTResponsePacket;

                MSG_BLKLIST               msgBLKLIST     = pccrrBLKLISTResponsePacket.MsgBLKLIST;
                MESSAGE_HEADER            messageHeader  = pccrrBLKLISTResponsePacket.MessageHeader;
                TRANSPORT_RESPONSE_HEADER transportRespH = pccrrBLKLISTResponsePacket.TransportResponseHeader;
                RESPONSE_MESSAGE          respMessage    = new RESPONSE_MESSAGE();
                respMessage.MESSAGEBODY             = msgBLKLIST;
                respMessage.MESSAGEHEADER           = messageHeader;
                respMessage.TRANSPORTRESPONSEHEADER = transportRespH;

                if (msgBLKLIST.BlockRanges.Length != 0)
                {
                    BLOCK_RANGE blockRange = pccrrBLKLISTResponsePacket.MsgBLKLIST.BlockRanges[0];
                    PccrrBothRoleCaptureCode.CaptureBlockRangeRequirements(blockRange);
                }

                this.VerifyMsgBlkList(msgBLKLIST);
                PccrrBothRoleCaptureCode.CaptureCommonDataTypesRequirements(msgBLKLIST);
                this.VerifyResponseMessage(respMessage);

                BLOCKRANGE[] blkRanges = Helper.ConvertFromStackBLOCKRANGEArray(msgBLKLIST.BlockRanges);
                this.ReceiveMsgBlkList(msgBLKLIST.BlockRangeCount, blkRanges, msgBLKLIST.NextBlockIndex);
            }
        }
コード例 #6
0
        /// <summary>
        /// Convert the messageHeaderStack struct defined in stack to adapter
        /// </summary>
        /// <param name="messageHeaderStack">The messageHeaderStack message</param>
        /// <returns>Return the messageHeaderStack type defined in adapter</returns>
        private static MessageHeader ConvertFromStackForMsgHeader(MESSAGE_HEADER messageHeaderStack)
        {
            MessageHeader messageHeader;

            messageHeader.MajorVersion = messageHeaderStack.MajorVersion;
            messageHeader.MinorVersion = messageHeaderStack.MinorVersion;
            messageHeader.MsgType      = ConvertFromStackForPCHCMsgType(messageHeaderStack.MsgType);
            messageHeader.Padding      = messageHeaderStack.Padding;

            return(messageHeader);
        }
コード例 #7
0
        private async Task <IndexClientMessage> CreatePretestEncounters(MESSAGE_HEADER header,
                                                                        PATIENT_IDENTIFICATION pid, ClientStage stagedClient, ClientPretestStage pretest,
                                                                        params LoadAction[] actions)
        {
            ENCOUNTERS encounter = null;

            //  PLACER_DETAIL
            var placerDetail = PLACER_DETAIL.Create(pretest.UserId, pretest.Id);

            //  PRE_TEST
            PRE_TEST preTest = null;

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Pretest))
            {
                preTest = PRE_TEST.Create(pretest);
            }

            //  HIV_TESTS
            HIV_TESTS hivTests = null;

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Testing))
            {
                var allfinalTests = await _clientFinalTestStageExtractor.Extract(stagedClient.ClientId);

                var alltests = await _clientTestingStageExtractor.Extract();

                var finalTest = allfinalTests.Where(x => x.PretestEncounterId == pretest.Id).ToList()
                                .LastOrDefault();

                var tests = alltests.Where(x => x.PretestEncounterId == pretest.Id).ToList();

                if (null != finalTest && tests.Any())
                {
                    hivTests = HIV_TESTS.Create(tests, finalTest);
                }
            }

            // GET THE LAST ONE


            encounter = ENCOUNTERS.Create(placerDetail, preTest, hivTests, null, new List <NewTracing>(), null);

            return(new IndexClientMessage(header,
                                          new List <NEWCLIENT> {
                NEWCLIENT.Create(pid, encounter)
            }, stagedClient.ClientId));
        }
コード例 #8
0
        /// <summary>
        /// Capture MESSAGE_HEADER structure related requirements.
        /// </summary>
        /// <param name="messageHeader">Message header object</param>
        private void VerifyMessageHeader(MESSAGE_HEADER messageHeader)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R67");

            // Verify MS-PCCRR requirement: MS-PCCRR_R67
            bool isVerifyR67 = messageHeader.CryptoAlgoId == CryptoAlgoId_Values.V1 ||
                               messageHeader.CryptoAlgoId == CryptoAlgoId_Values.AES_128 ||
                               messageHeader.CryptoAlgoId == CryptoAlgoId_Values.AES_192 ||
                               messageHeader.CryptoAlgoId == CryptoAlgoId_Values.AES_256;

            Site.CaptureRequirementIfIsTrue(
                isVerifyR67,
                67,
                @"[In MESSAGE_HEADER][CryptoAlgoId (4 bytes)]MUST be one of the following values[0x00000000,AES_128 
                0x00000001,AES_192 0x00000002,AES_256 0x00000003].<3>");
        }
コード例 #9
0
        /// <summary>
        /// Verify the received message from client.
        /// </summary>
        /// <param name="remoteAddr">The remote address.</param>
        /// <param name="pccrrPacket">The pccrrPacket.</param>
        private void RetrievalTransport_Receive(IPEndPoint remoteAddr, PccrrPacket pccrrPacket)
        {
            PccrrGETBLKSRequestPacket pccrrGETBLKSRequestPacket = pccrrPacket as PccrrGETBLKSRequestPacket;

            if (pccrrGETBLKSRequestPacket != null)
            {
                MSG_GETBLKS    msgGETBLKS    = pccrrGETBLKSRequestPacket.MsgGetBLKS;
                MESSAGE_HEADER messageHEADER = pccrrGETBLKSRequestPacket.MessageHeader;
                this.sid = msgGETBLKS.SegmentID;
                REQUEST_MESSAGE requestMESSAGE = new REQUEST_MESSAGE();
                requestMESSAGE.MESSAGEBODY   = msgGETBLKS;
                requestMESSAGE.MESSAGEHEADER = messageHEADER;
                this.uiPayload = Marshal.SizeOf(messageHEADER) + Marshal.SizeOf(msgGETBLKS) + 24;

                PccrrBothRoleCaptureCode.CaptureBlockRangeRequirements(msgGETBLKS.ReqBlockRanges[0]);
                PccrrBothRoleCaptureCode.CaptureMessageHeaderRequirements(messageHEADER, this.uiPayload);
                this.VerifyGetBlocks(msgGETBLKS);
                this.VerifyRequestMessage(requestMESSAGE);
                PccrrBothRoleCaptureCode.CaptureSegmentIdRequirements(msgGETBLKS.SegmentID);
                PccrrBothRoleCaptureCode.CaptureHttpRequirements();
                PccrrBothRoleCaptureCode.CaptureMessageRequirements();

                this.ReceiveMsgGetBlk(msgGETBLKS.ReqBlockRanges[0].Index);
            }
            else
            {
                PccrrGETBLKLISTRequestPacket pccrrGETBLKLISTRequestPacket = pccrrPacket as PccrrGETBLKLISTRequestPacket;

                if (pccrrGETBLKLISTRequestPacket != null)
                {
                    MSG_GETBLKLIST msgGETBLKLIST = pccrrGETBLKLISTRequestPacket.MsgGetBLKLIST;
                    this.sid = msgGETBLKLIST.SegmentID;

                    this.VerifyGetBlkList(msgGETBLKLIST);
                    PccrrBothRoleCaptureCode.CaptureCommonDataTypesRequirements(msgGETBLKLIST);
                    _BLOCKRANGE[] blockRanges = ClientHelper.ConvertFromStackBLOCKRANGEArray(msgGETBLKLIST.NeededBlockRanges);

                    this.ReceiveMsgGetBlkList(blockRanges);
                }
                else
                {
                    this.ReceiveMsgNegoReq();
                }
            }
        }
コード例 #10
0
 private TracingMessage(MESSAGE_HEADER messageHeader, Guid clientId, List <INTERNAL_PATIENT_ID> patientIds, PLACER_DETAIL placerDetail, List <NewTracing> tracings) : base(messageHeader, clientId)
 {
     INTERNAL_PATIENT_ID = patientIds;
     PLACER_DETAIL       = placerDetail;
     TRACING             = tracings;
 }
コード例 #11
0
 protected ClientMessage(MESSAGE_HEADER messageHeader, Guid clientId)
 {
     MESSAGE_HEADER = messageHeader;
     ClientId       = clientId;
 }
コード例 #12
0
 public PartnerClientMessage(MESSAGE_HEADER messageHeader, List <PARTNER> partners, Guid clientId)
 {
     MESSAGE_HEADER = messageHeader;
     PARTNERS       = partners;
     ClientId       = clientId;
 }
コード例 #13
0
 private PartnerMessage(MESSAGE_HEADER messageHeader, Guid clientId, List <NEWPARTNER> clients) : base(messageHeader, clientId)
 {
     PARTNERS = clients;
 }
コード例 #14
0
        public async Task <IEnumerable <IndexClientMessage> > Load(Guid?htsClientId = null, params LoadAction[] actions)
        {
            var messages = new List <IndexClientMessage>();

            if (!actions.Any())
            {
                actions = new[] { LoadAction.All }
            }
            ;

            var facs = _practiceRepository.GetAllDefault().ToList();

            //  Set Facility
            var facility = facs.FirstOrDefault(x => x.IsDefault);

            if (null == facility)
            {
                throw new Exception($"Default Faciltity Not found");
            }

            //      MESSAGE_HEADER

            var facilityCode = facility.Code;
            var header       = MESSAGE_HEADER.Create(facilityCode);

            //      NEWCLIENT

            var stagedIndexClients = _clientStageRepository.GetIndexClients();

            if (!htsClientId.IsNullOrEmpty())
            {
                stagedIndexClients = stagedIndexClients.Where(x => x.ClientId == htsClientId);
            }

            foreach (var stagedClient in stagedIndexClients)
            {
                header.UpdateMfl(stagedClient.SiteCode);

                #region PATIENT_IDENTIFICATION

                var pid = PATIENT_IDENTIFICATION.Create(stagedClient);

                #endregion

                ENCOUNTERS encounter = null;
                if (!actions.Contains(LoadAction.RegistrationOnly))
                {
                    var pretests = _clientPretestStageRepository.GetByClientId(stagedClient.ClientId).ToList();

                    //    PRETEST AND TESTING

                    if (pretests.Any())
                    {
                        var lastPretest = pretests.OrderByDescending(x => x.EncounterDate).FirstOrDefault();

                        foreach (var pretest in pretests)
                        {
                            var pretestEncounter =
                                await CreatePretestEncounters(header, pid, stagedClient, pretest, actions);

                            messages.Add(pretestEncounter);
                        }

                        if (null != lastPretest)
                        {
                            var nonPretest =
                                await CreateNonPretestEncounters(header, pid, stagedClient, lastPretest, actions);

                            if (null != nonPretest)
                            {
                                messages.Add(nonPretest);
                            }
                        }
                    }
                    else
                    {
                        var registration = CreateRegistration(header, pid, stagedClient, encounter);
                        messages.Add(registration);
                    }
                }
                else
                {
                    messages.Add(new IndexClientMessage(header,
                                                        new List <NEWCLIENT> {
                        NEWCLIENT.Create(pid, encounter)
                    }, stagedClient.ClientId));
                }
            }

            return(messages);
        }
コード例 #15
0
 private DemographicMessage(MESSAGE_HEADER messageHeader, Guid clientId, List <NEWAFYAMOBILECLIENT> clients) : base(messageHeader, clientId)
 {
     CLIENTS = clients;
 }
コード例 #16
0
        public async Task <IEnumerable <FamilyClientMessage> > Load(Guid?htsClientId = null, params LoadAction[] actions)
        {
            var messages = new List <FamilyClientMessage>();

            if (!actions.Any())
            {
                actions = new[] { LoadAction.All }
            }
            ;

            //  Set Facility
            var facility = _practiceRepository.GetDefault();

            if (null == facility)
            {
                throw new Exception($"Default Faciltity Not found");
            }

            //      MESSAGE_HEADER

            var facilityCode = facility.Code;
            var header       = MESSAGE_HEADER.Create(facilityCode);

            //      CLIENT

            var familyMembers = _clientStageRelationshipRepository.GetAll(x => !x.IsPartner);

            if (!htsClientId.IsNullOrEmpty())
            {
                familyMembers = familyMembers.Where(x => x.SecondaryClientId == htsClientId);
            }

            foreach (var familyMember in familyMembers)
            {
                var stagedClient = _clientStageRepository.GetQueued(familyMember.SecondaryClientId);

                if (null != stagedClient && !stagedClient.IsIndex)
                {
                    header.UpdateMfl(stagedClient.SiteCode);

                    #region PATIENT_IDENTIFICATION

                    var pid = PARTNER_FAMILY_PATIENT_IDENTIFICATION.Create(stagedClient, familyMember.IndexClientId,
                                                                           familyMember.Relation);

                    #endregion

                    FAMILY_ENCOUNTER encounter = null;

                    if (!actions.Contains(LoadAction.RegistrationOnly))
                    {
                        PLACER_DETAIL         placerDetail    = null;
                        FAMILY_SCREENING      familyScreening = null;
                        List <FAMILY_TRACING> familyTracings  = new List <FAMILY_TRACING>();

                        #region ENCOUNTERS

                        var screening = await _clientFamilyScreeningStageExtractor.Extract(stagedClient.ClientId);

                        var screeningStage = screening.OrderBy(x => x.ScreeningDate).LastOrDefault();

                        //  PLACER_DETAIL

                        if (null != screeningStage)
                        {
                            placerDetail = PLACER_DETAIL.Create(screeningStage.UserId, screeningStage.Id);

                            //  FAMILY_SCREENING

                            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.ContactScreenig))
                            {
                                familyScreening = FAMILY_SCREENING.Create(screeningStage);
                            }
                        }

                        //  FAMILY_TRACING

                        if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.ContactTracing))
                        {
                            var allTracing = await _clientFamilyTracingStageExtractor.Extract(stagedClient.ClientId);

                            if (allTracing.Any())
                            {
                                familyTracings = FAMILY_TRACING.Create(allTracing.ToList());
                            }
                        }

                        #endregion

                        encounter = new FAMILY_ENCOUNTER(placerDetail, familyScreening, familyTracings);
                    }

                    messages.Add(new FamilyClientMessage(header,
                                                         new List <FAMILY> {
                        new FAMILY(pid, encounter)
                    }, stagedClient.ClientId));
                }
            }

            return(messages);
        }
コード例 #17
0
 public IndexClientMessage(MESSAGE_HEADER messageHeader, List <NEWCLIENT> clients, Guid clientId)
 {
     ClientId       = clientId;
     MESSAGE_HEADER = messageHeader;
     CLIENTS        = clients;
 }
コード例 #18
0
 public PartnerScreening(MESSAGE_HEADER messageHeader, Guid clientId, List <INTERNAL_PATIENT_ID> patientIds, PLACER_DETAIL placerDetail, PARTNER_SCREENING familyScreening) : base(messageHeader, clientId)
 {
     INTERNAL_PATIENT_ID = patientIds;
     PLACER_DETAIL       = placerDetail;
     PARTNER_SCREENING   = familyScreening;
 }
コード例 #19
0
 public PartnerTracing(MESSAGE_HEADER messageHeader, Guid clientId, List <INTERNAL_PATIENT_ID> patientIds, PLACER_DETAIL placerDetail, List <PARTNER_TRACING> tracings) : base(messageHeader, clientId)
 {
     INTERNAL_PATIENT_ID = patientIds;
     PLACER_DETAIL       = placerDetail;
     TRACING             = tracings;
 }
コード例 #20
0
 private ReferralMessage(MESSAGE_HEADER messageHeader, Guid clientId, List <INTERNAL_PATIENT_ID> patientIds, PLACER_DETAIL placerDetail, NewReferral referral) : base(messageHeader, clientId)
 {
     INTERNAL_PATIENT_ID = patientIds;
     PLACER_DETAIL       = placerDetail;
     REFERRAL            = referral;
 }
コード例 #21
0
 public FamilyClientMessage(MESSAGE_HEADER messageHeader, List <FAMILY> family, Guid clientId)
 {
     MESSAGE_HEADER = messageHeader;
     FAMILY         = family;
     ClientId       = clientId;
 }
コード例 #22
0
 private FamilyMessage(MESSAGE_HEADER messageHeader, Guid clientId, List <NEWFAMILY> clients) : base(messageHeader, clientId)
 {
     FAMILY = clients;
 }
コード例 #23
0
 private PretestMessage(MESSAGE_HEADER messageHeader, Guid clientId, List <INTERNAL_PATIENT_ID> patientIds, PLACER_DETAIL placerDetail, PRE_TEST preTest) : base(messageHeader, clientId)
 {
     INTERNAL_PATIENT_ID = patientIds;
     PLACER_DETAIL       = placerDetail;
     PRE_TEST            = preTest;
 }
コード例 #24
0
        private async Task <IndexClientMessage> CreateNonPretestEncounters(MESSAGE_HEADER header, PATIENT_IDENTIFICATION pid, ClientStage stagedClient, ClientPretestStage lastPretest, params LoadAction[] actions)
        {
            ENCOUNTERS encounter = null;

            //  PLACER_DETAIL

            var lastplacerDetail = PLACER_DETAIL.Create(lastPretest.UserId, lastPretest.Id);

            //  NewReferral
            NewReferral newReferral = null;

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Referral))
            {
                var allReferrals = await _clientReferralStageExtractor.Extract(stagedClient.ClientId);

                if (allReferrals.Any())
                {
                    var referrall = allReferrals.LastOrDefault();
                    newReferral = NewReferral.Create(referrall);
                }
            }

            //  NewTracing
            var newTracings = new List <NewTracing>();

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Tracing))
            {
                var allTracing = await _clientTracingStageExtractor.Extract(stagedClient.ClientId);

                if (allTracing.Any())
                {
                    newTracings = NewTracing.Create(allTracing.ToList());
                }
            }

            // NewLinkage
            NewLinkage newLinkage = null;

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Linkage))
            {
                var allLinkages = await _clientLinkageStageExtractor.Extract(stagedClient.ClientId);

                if (allLinkages.Any())
                {
                    var linkage = allLinkages.LastOrDefault();
                    newLinkage = linkage.HasData ? NewLinkage.Create(linkage) : null;
                }
            }

            if (null == newReferral && !newTracings.Any() && null == newLinkage)
            {
                return(null);
            }

            encounter = ENCOUNTERS.Create(lastplacerDetail, null, null, newReferral, newTracings, newLinkage);

            return(new IndexClientMessage(header,
                                          new List <NEWCLIENT> {
                NEWCLIENT.Create(pid, encounter)
            }, stagedClient.ClientId));
        }
コード例 #25
0
 private TestsMessage(MESSAGE_HEADER messageHeader, Guid clientId, List <INTERNAL_PATIENT_ID> patientIds, PLACER_DETAIL placerDetail, HIV_TESTS tests) : base(messageHeader, clientId)
 {
     INTERNAL_PATIENT_ID = patientIds;
     PLACER_DETAIL       = placerDetail;
     HIV_TESTS           = tests;
 }
コード例 #26
0
        /// <summary>
        /// Send message MSG_GETBLKS
        /// </summary>
        /// <param name="sid">segment id.</param>
        /// <param name="blockRang">Block ranges client wants to get</param>
        /// <param name="isVersionSupported">The version in this message is supported in server.</param>
        public void SendMsgGetBlks(byte[] sid, BLOCKRANGE[] blockRang, bool isVersionSupported)
        {
            PccrrGETBLKSRequestPacket packet;

            BLOCK_RANGE[] blockRanges = Helper.ConvertToStackBLOCKRANGEArray(blockRang);

            if (!isVersionSupported)
            {
                packet = this.pccrrStack.CreateMsgGetBlksRequest(sid, this.cryptoAlgo, MsgType_Values.MSG_GETBLKS, this.protoErrorVer);
            }
            else
            {
                packet = this.pccrrStack.CreateMsgGetBlksRequest(sid, this.cryptoAlgo, MsgType_Values.MSG_GETBLKS, this.protoVer);
            }

            for (int i = 0; i < blockRanges.Length; i++)
            {
                if (blockRanges.Length == 1)
                {
                    packet.MsgGetBLKS.ReqBlockRanges[i].Index = blockRanges[i].Index;
                    packet.MsgGetBLKS.ReqBlockRanges[i].Count = blockRanges[i].Count;
                }
                else
                {
                    MSG_GETBLKS msgGETBLKS = packet.MsgGetBLKS;
                    msgGETBLKS.ReqBlockRanges     = new BLOCK_RANGE[blockRanges.Length];
                    msgGETBLKS.ReqBlockRangeCount = (uint)blockRanges.Length;
                    packet.MsgGetBLKS             = msgGETBLKS;

                    packet.MsgGetBLKS.ReqBlockRanges[i].Index = blockRanges[i].Index;
                    packet.MsgGetBLKS.ReqBlockRanges[i].Count = blockRanges[i].Count;
                }
            }

            this.pccrrStack.SendPacket(packet, new TimeSpan(0, 0, this.timeout));

            PccrrPacket respMSG = this.pccrrStack.ExpectPacket();

            if (!isVersionSupported)
            {
                PccrrNegoResponsePacket pccrrNegoResponsePacket = respMSG as PccrrNegoResponsePacket;

                if (pccrrNegoResponsePacket != null)
                {
                    this.ReceiveMsgNegoResp();
                }
            }
            else
            {
                PccrrBLKResponsePacket pccrrBLKResponsePacket = respMSG as PccrrBLKResponsePacket;

                MSG_BLK                   msgBLK         = pccrrBLKResponsePacket.MsgBLK;
                MESSAGE_HEADER            messageHeader  = pccrrBLKResponsePacket.MessageHeader;
                TRANSPORT_RESPONSE_HEADER transportRespH = pccrrBLKResponsePacket.TransportResponseHeader;
                RESPONSE_MESSAGE          respMessage    = new RESPONSE_MESSAGE();
                respMessage.MESSAGEBODY             = msgBLK;
                respMessage.MESSAGEHEADER           = messageHeader;
                respMessage.TRANSPORTRESPONSEHEADER = transportRespH;

                this.VerifyMsgBlk(msgBLK);
                PccrrBothRoleCaptureCode.CaptureSegmentIdRequirements(msgBLK.SegmentId);
                this.VerifyResponseMessage(respMessage);

                bool isSizeOfBlockZero = false;

                if (msgBLK.SizeOfBlock == 0)
                {
                    isSizeOfBlockZero = true;
                }
                else
                {
                    isSizeOfBlockZero = false;
                }

                bool isBlockEmpty = false;

                if (msgBLK.Block.Length == 0)
                {
                    isBlockEmpty = true;
                }
                else
                {
                    isBlockEmpty = false;
                }

                CryptoAlgoIdValues crypAlgoId = Helper.ConvertFromStackCryptoAlgoIdValues(pccrrBLKResponsePacket.MessageHeader.CryptoAlgoId);
                this.ReceiveMsgBlk(msgBLK.BlockIndex, msgBLK.NextBlockIndex, isSizeOfBlockZero, isBlockEmpty, crypAlgoId);
            }
        }
コード例 #27
0
        /// <summary>
        /// Validate the MESSAGE_HEADER of request message.
        /// </summary>
        /// <param name="messageHeader">A MESSAGE_HEADER in the request message.</param>
        private void ValidateRequestMessageHeader(MESSAGE_HEADER messageHeader)
        {
            // Capture MS-PCHC R15
            string typeofMinorVersion = messageHeader.MinorVersion.GetType().ToString();
            string typeofMajorVersion = messageHeader.MajorVersion.GetType().ToString();
            int    versionSize        = 0;

            if (typeofMinorVersion.Equals("System.Byte") && typeofMajorVersion.Equals("System.Byte"))
            {
                versionSize = 2;
            }

            Site.CaptureRequirementIfAreEqual <int>(
                2,
                versionSize,
                15,
                @"[In MESSAGE_HEADER] Version (2 bytes): The message version, 
                expressed as major and minor values.");

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-PCHC_R17, capture it directly for the message header is unmarshalled correctly from stack.");

            // Capture MS-PCHC R17
            Site.CaptureRequirement(
                17,
                @"[In MESSAGE_HEADER] Note that the order of the subfields[MinorVersion,MajorVersion] 
                is reversed; the MinorVersion subfield occurs first.");

            // Capture MS-PCHC R18
            Site.CaptureRequirementIfAreEqual <byte>(
                0x00,
                messageHeader.MinorVersion,
                18,
                "[In MESSAGE_HEADER] MinorVersion (1 byte):  The minor part of the version, which MUST be 0x00.");

            // Capture MS-PCHC R19
            Site.CaptureRequirementIfAreEqual <byte>(
                0x01,
                messageHeader.MajorVersion,
                19,
                "[In MESSAGE_HEADER] MajorVersion (1 byte):  The major part of the version, which MUST be 0x01.");

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-PCHC_R16:The Version is 1.0. The minor version is 0x00 and verified in MS-PCHC_R18,
                major version is 0x01 and verified in MS-PCHC_R19,
                the actual minor versionis {0} and the actual major version is{1}",
                (int)messageHeader.MajorVersion,
                (int)messageHeader.MinorVersion);

            // Capture MS-PCHC R16
            Site.CaptureRequirement(
                16,
                "[In MESSAGE_HEADER] The version[expressed as major and minor values] MUST be 1.0.");

            // Capture MS-PCHC R20
            int messageTypeSize = sizeof(PCHCMessageType);

            Site.CaptureRequirementIfAreEqual <int>(
                2,
                messageTypeSize,
                20,
                "[In MESSAGE_HEADER] Type (2 bytes):  A 16-bit unsigned integer .");

            // Capture MS-PCHC R23
            Site.CaptureRequirementIfAreEqual <int>(
                4,
                messageHeader.Padding.Length,
                23,
                "[In MESSAGE_HEADER] Padding (4 bytes).");

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-PCHC_R14:The messageHeader is an instance of MESSAGE_HEADER.
                Above requirements about Version, Type, Padding are already valideted.");

            // Capture MS-PCHC R14
            Site.CaptureRequirement(
                14,
                @"[In MESSAGE_HEADER] All Peer Content Caching and Retrieval: 
                Hosted Cache Protocol [MS-PCHC] request messages use a common header, 
                which consists of the following fields[Version, Type, Padding].");
        }
コード例 #28
0
 private IndexClientMessage CreateRegistration(MESSAGE_HEADER header, PATIENT_IDENTIFICATION pid, ClientStage stagedClient, ENCOUNTERS encounter)
 {
     return(new IndexClientMessage(header, new List <NEWCLIENT> {
         NEWCLIENT.Create(pid, encounter)
     }, stagedClient.ClientId));
 }
コード例 #29
0
        /// <summary>
        /// Capture MESSAGE_HEADER structure releated requirements.
        /// </summary>
        /// <param name="messageHeader">Message header object</param>
        /// <param name="uiPayload">The length of http content body.</param>
        public static void CaptureMessageHeaderRequirements(MESSAGE_HEADER messageHeader, int uiPayload)
        {
            // The protocol version of the server-peer, which is configured in ptfconfig file.
            ushort uiMajor = ushort.Parse(
                site.Properties.Get(
                    "PCCRR.Protocol.MSG_NEGO_REQ.MinSupportedProtocolVersion.MajorVer"));
            ushort uiMinor = ushort.Parse(
                site.Properties.Get(
                    "PCCRR.Protocol.MSG_NEGO_REQ.MinSupportedProtocolVersion.MinorVer"));

            ProtoVersion protVer = messageHeader.ProtVer;

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R47");

            // Verify MS-PCCRR requirement: MS-PCCRR_R47
            // If the following types are verified, means those fields are the layout of message header.
            bool isVerifyR47 = messageHeader.GetType() == typeof(MESSAGE_HEADER) &&
                               messageHeader.ProtVer.GetType() == typeof(ProtoVersion) &&
                               messageHeader.MsgType.GetType() == typeof(MsgType_Values) &&
                               messageHeader.MsgSize.GetType() == typeof(uint) &&
                               messageHeader.CryptoAlgoId.GetType() == typeof(CryptoAlgoId_Values);

            site.CaptureRequirementIfIsTrue(
                isVerifyR47,
                47,
                @"[In MESSAGE_HEADER]The layout of the message header is as follows
                [ProtVer,MsgType,MsgSize,CryptoAlgoId].");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R48");

            bool isVerifyR48 = messageHeader.ProtVer.GetType() == typeof(ProtoVersion) &&
                               messageHeader.ProtVer.MajorVersion.GetType() == typeof(ushort) &&
                               messageHeader.ProtVer.MinorVersion.GetType() == typeof(ushort);

            // Verify MS-PCCRR requirement: MS-PCCRR_R48
            site.CaptureRequirementIfIsTrue(
                isVerifyR48,
                48,
                @"[MESSAGE_HEADER]ProtVer (4 bytes):  Protocol version number, formed by concatenating the
                protocol major version number and protocol minor version number, encoded as follows (where MSB
                is Most Significant Byte and LSB is Least Significant Byte): 1st Byte (Addr: X) is Minor version
                MSB;2nd Byte (Addr: X+1) is Minor version LSB;3rd Byte (Addr: X+2) is Major version MSB;4th Byte
                (Addr: X+3) is Major version LSB.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R49");

            // Verify MS-PCCRR requirement: MS-PCCRR_R49
            // The protVer field will be set in HttpTransport_Receive method when receive a response message
            // Verify its low byte
            site.CaptureRequirementIfAreEqual <ushort>(
                uiMajor,
                protVer.MajorVersion,
                49,
                @"[In MESSAGE_HEADER][ProtVer (4 bytes)]The major version number is encoded in the least
                significant word of the protocol version's DWORD.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R50");

            // Verify MS-PCCRR requirement: MS-PCCRR_R50
            // Verify its high byte
            site.CaptureRequirementIfAreEqual <ushort>(
                uiMinor,
                protVer.MinorVersion,
                50,
                @"[In MESSAGE_HEADER][ProtVer (4 bytes)]The minor version number is encoded in the most significant
                word of the protocol version's DWORD.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R51");

            // Verify MS-PCCRR requirement: MS-PCCRR_R51
            // This is a bug, Major  version number is 2 bytes.
            bool isVerifyR51 = uiMajor >= 0x0000 && uiMajor <= 0xFFFF;

            site.CaptureRequirementIfIsTrue(
                isVerifyR51,
                51,
                @"[In MESSAGE_HEADER][ProtVer (4 bytes)]Major  version number can express the version range of
                0x00000000 to 0xFFFFFFFF.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R5100");

            // Verify MS-PCCRR requirement: MS-PCCRR_R5100
            // This is a bug, Minor version number is 2 bytes.
            bool isVerifyR5100 = uiMinor >= 0x0000 && uiMinor <= 0xFFFF;

            site.CaptureRequirementIfIsTrue(
                isVerifyR5100,
                5100,
                @"[In MESSAGE_HEADER][ProtVer (4 bytes)]Minor version number can express the version range of
                0x00000000 to 0xFFFFFFFF.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R52");

            // Verify MS-PCCRR requirement: MS-PCCRR_R52
            bool isVerifyR52 = ((uint)protVer.MajorVersion & 0x0000FFFF) == 0x00000001 &&
                               ((uint)protVer.MinorVersion & 0xFFFF0000) == 0x00000000;

            site.CaptureRequirementIfIsTrue(
                isVerifyR52,
                52,
                @"[In MESSAGE_HEADER][ProtVer (4 bytes)]Currently, the protocol[MS-PCCRR] version number MUST be
                set to {major=1 (0x0001), minor=0 (0x0000)}.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R54");

            // Verify MS-PCCRR requirement: MS-PCCRR_R54
            bool isVerifyR54 = messageHeader.MsgType == MsgType_Values.MSG_NEGO_REQ ||
                               messageHeader.MsgType == MsgType_Values.MSG_NEGO_RESP ||
                               messageHeader.MsgType == MsgType_Values.MSG_GETBLKLIST ||
                               messageHeader.MsgType == MsgType_Values.MSG_GETBLKS ||
                               messageHeader.MsgType == MsgType_Values.MSG_BLKLIST ||
                               messageHeader.MsgType == MsgType_Values.MSG_BLK;

            site.CaptureRequirementIfIsTrue(
                isVerifyR54,
                54,
                @"[In MESSAGE_HEADER][MsgType (4 bytes)]MUST be set to one of the following values
                [MSG_NEGO_REQ 0x00000000,MSG_NEGO_RESP 0x00000001,MSG_GETBLKLIST 0x00000002,MSG_GETBLKS 0x00000003,
                MSG_BLKLIST0x00000004,MSG_BLK 0x00000005].");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R318");

            // Verify MS-PCCRR requirement: MS-PCCRR_R318
            bool isVerifyR318 = messageHeader.CryptoAlgoId == CryptoAlgoId_Values.V1 ||
                                messageHeader.CryptoAlgoId == CryptoAlgoId_Values.AES_128 ||
                                messageHeader.CryptoAlgoId == CryptoAlgoId_Values.AES_192 ||
                                messageHeader.CryptoAlgoId == CryptoAlgoId_Values.AES_256;

            site.CaptureRequirementIfIsTrue(
                isVerifyR318,
                318,
                @"[In Appendix A: Product Behavior]<3> Section 2.2.3: Windows supports: no encryption, AES_128,
                    AES_ 192, and AES_256.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R64");

            // Verify MS-PCCRR requirement: MS-PCCRR_R64
            site.CaptureRequirementIfAreEqual <uint>(
                (uint)uiPayload,
                messageHeader.MsgSize,
                64,
                @"[In MESSAGE_HEADER]MsgSize (4 bytes):  Protocol message total size including MESSAGE_HEADER,
                but not including the Transport Header.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R65");

            // Verify MS-PCCRR requirement: MS-PCCRR_R65
            bool isVerifyR65 = messageHeader.MsgSize >= 16 && messageHeader.MsgSize <= 98304;

            site.CaptureRequirementIfIsTrue(
                isVerifyR65,
                65,
                @"[In MESSAGE_HEADER][MsgSize (4 bytes)]The valid range of the total message size MUST be from
                16 bytes to 98,304 bytes (or 96 KB).");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R66");

            // Verify MS-PCCRR requirement: MS-PCCRR_R66
            site.CaptureRequirementIfAreEqual <int>(
                4,
                sizeof(CryptoAlgoId_Values),
                66,
                @"[In MESSAGE_HEADER]CryptoAlgoId (4 bytes):  Encryption algorithm used by the server-role peer
                to encrypt data.");

            //
            // Add the debug information
            //
            site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R317");

            if (messageHeader.MsgType == MsgType_Values.MSG_GETBLKS)
            {
                bool isVerifyR317 = messageHeader.CryptoAlgoId == CryptoAlgoId_Values.AES_128;

                // Verify MS-PCCRR requirement: MS-PCCRR_R317
                site.CaptureRequirementIfIsTrue(
                    isVerifyR317,
                    317,
                    @"[In Appendix A: Product Behavior]<3> Section 2.2.3: Windows uses AES_128 as the default encryption
                    algorithm.");

                // Verify MS-PCCRR requirement: MS-PCCRR_R19
                bool isFourBytesAlign = messageHeader.MsgSize % 4 == 0;
                CaptureFieldAlignRequirements(isFourBytesAlign);
            }
        }
コード例 #30
0
 private LinkageMessage(MESSAGE_HEADER messageHeader, Guid clientId, List <INTERNAL_PATIENT_ID> patientIds, PLACER_DETAIL placerDetail, NewLinkage linkage) : base(messageHeader, clientId)
 {
     INTERNAL_PATIENT_ID = patientIds;
     PLACER_DETAIL       = placerDetail;
     LINKAGE             = linkage;
 }