private void AddId(INTERNALPATIENTID internalpatientid)
        {
            var existing = INTERNAL_PATIENT_ID.FirstOrDefault(x => x.IDENTIFIER_TYPE == internalpatientid.IDENTIFIER_TYPE);
            if (null != existing)
                INTERNAL_PATIENT_ID.Remove(existing);

            INTERNAL_PATIENT_ID.Add(internalpatientid);
        }
        public PrescriptionSourceDto PreparePrescriptionSourceDto(int ptntpk, int orderId, int patientMasterVisitId)
        {
            try
            {
                var drugPrescriptionSourceData = _drugPrescriptionManager.GetPatientPrescriptionMessage(ptntpk, orderId, patientMasterVisitId);

                // prescriptionDtoMessage = prescriptionDtoMessage.All();

                //instantiate new PrescriptionDto
                PrescriptionSourceDto prescriptionSourceDto = new PrescriptionSourceDto();

                ////todo -- MesasgeHeader-Automap
                prescriptionSourceDto.MESSAGE_HEADER.MESSAGE_TYPE          = "RDE^001";
                prescriptionSourceDto.MESSAGE_HEADER.MESSAGE_DATETIME      = Convert.ToDateTime(drugPrescriptionSourceData[0].TRANSACTION_DATETIME);
                prescriptionSourceDto.MESSAGE_HEADER.PROCESSING_ID         = "P";
                prescriptionSourceDto.MESSAGE_HEADER.RECEIVING_APPLICATION = "IL";
                prescriptionSourceDto.MESSAGE_HEADER.RECEIVING_FACILITY    = drugPrescriptionSourceData[0].SENDING_FACILITY;
                prescriptionSourceDto.MESSAGE_HEADER.SECURITY            = "";
                prescriptionSourceDto.MESSAGE_HEADER.SENDING_APPLICATION = "IQCARE";
                prescriptionSourceDto.MESSAGE_HEADER.SENDING_FACILITY    = drugPrescriptionSourceData[0].SENDING_FACILITY;


                ////todo - automap
                prescriptionSourceDto.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.IDENTIFIER_TYPE = drugPrescriptionSourceData[0].EXT_IDENTIFIER_TYPE;
                prescriptionSourceDto.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ID = drugPrescriptionSourceData[0].EXT_ID;
                prescriptionSourceDto.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ASSIGNING_AUTHORITY = drugPrescriptionSourceData[0].EXT_ASSIGNING_AUTHOURITY;

                // var internalIdentifiers = new List<INTERNALPATIENTID>();
                var internalIdentity = new INTERNAL_PATIENT_ID()
                {
                    ASSIGNING_AUTHORITY = drugPrescriptionSourceData[0].ASSIGNING_AUTHORITY,
                    IDENTIFIER_TYPE     = drugPrescriptionSourceData[0].IDENTIFIER_TYPE,
                    ID = drugPrescriptionSourceData[0].Id
                };

                prescriptionSourceDto.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Add(internalIdentity);

                var internalIdentityId = new INTERNAL_PATIENT_ID()
                {
                    ASSIGNING_AUTHORITY = drugPrescriptionSourceData[0].ASSIGNING_AUTHORITY2,
                    ID = drugPrescriptionSourceData[0].Id2,
                    IDENTIFIER_TYPE = drugPrescriptionSourceData[0].IDENTIFIER_TYPE2
                };
                prescriptionSourceDto.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Add(internalIdentityId);


                prescriptionSourceDto.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME  = drugPrescriptionSourceData[0].FIRST_NAME;
                prescriptionSourceDto.PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME = drugPrescriptionSourceData[0].MIDDLE_NAME;
                prescriptionSourceDto.PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME   = drugPrescriptionSourceData[0].LAST_NAME;

                prescriptionSourceDto.COMMON_ORDER_DETAILS.NOTES        = drugPrescriptionSourceData[0].NOTES;
                prescriptionSourceDto.COMMON_ORDER_DETAILS.ORDER_STATUS = drugPrescriptionSourceData[0].ORDER_STATUS;

                prescriptionSourceDto.COMMON_ORDER_DETAILS.ORDERING_PHYSICIAN.FIRST_NAME  = drugPrescriptionSourceData[0].ORDERING_PHYSICIAN_FIRST_NAME;
                prescriptionSourceDto.COMMON_ORDER_DETAILS.ORDERING_PHYSICIAN.MIDDLE_NAME = "";
                prescriptionSourceDto.COMMON_ORDER_DETAILS.ORDERING_PHYSICIAN.LAST_NAME   = drugPrescriptionSourceData[0].ORDERING_PHYSICIAN_LAST_NAME;

                prescriptionSourceDto.COMMON_ORDER_DETAILS.TRANSACTION_DATETIME = drugPrescriptionSourceData[0].TRANSACTION_DATETIME;
                prescriptionSourceDto.COMMON_ORDER_DETAILS.ORDER_CONTROL        = drugPrescriptionSourceData[0].ORDER_CONTROL;

                prescriptionSourceDto.COMMON_ORDER_DETAILS.PLACER_ORDER_NUMBER.ENTITY = drugPrescriptionSourceData[0].ENTITY;
                prescriptionSourceDto.COMMON_ORDER_DETAILS.PLACER_ORDER_NUMBER.NUMBER = drugPrescriptionSourceData[0].NUMBER.ToString();

                var pharmacyEncodedOrder = new List <PHARMACY_ENCODED_ORDER>();

                foreach (var entity in drugPrescriptionSourceData)
                {
                    PHARMACY_ENCODED_ORDER drugLoadOrder = new PHARMACY_ENCODED_ORDER()
                    {
                        DRUG_NAME             = entity.DRUG_NAME,
                        DOSAGE                = entity.DOSAGE.ToString(),
                        CODING_SYSTEM         = entity.CODING_SYSTEM,
                        DURATION              = Convert.ToInt32(entity.DURATION),
                        FREQUENCY             = entity.FREQUENCY,
                        INDICATION            = entity.INDICATION,
                        PHARMACY_ORDER_DATE   = entity.PHARMACY_ORDER_DATE,
                        QUANTITY_PRESCRIBED   = entity.QUANTITY_PRESCRIBED.ToString(),
                        STRENGTH              = entity.STRENGTH,
                        TREATMENT_INSTRUCTION = entity.TREATMENT_INSTRUCTION,
                        PRESCRIPTION_NOTES    = entity.PRESCRIPTION_NOTES
                    };
                    pharmacyEncodedOrder.Add(drugLoadOrder);
                    // prescriptionSourceDto.PHARMACY_ENCODED_ORDER.Add(drugLoadOrder);
                }
                prescriptionSourceDto.PHARMACY_ENCODED_ORDER = pharmacyEncodedOrder;
                return(prescriptionSourceDto);
                // return drugPrescriptionSourceData;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Esempio n. 3
0
        public PrescriptionSourceDto DrugPrescriptionRaised(DrugPrescriptionEntity entity)
        {
            // Patient Identification
            var internalIdentifiers = new List <INTERNAL_PATIENT_ID>();

            foreach (var identifier in entity.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID)
            {
                var internalIdentity = new INTERNAL_PATIENT_ID()
                {
                    IDENTIFIER_TYPE = identifier.IDENTIFIER_TYPE,
                    ID = identifier.ID,
                    ASSIGNING_AUTHORITY = identifier.ASSIGNING_AUTHORITY
                };

                internalIdentifiers.Add(internalIdentity);
            }

            var pharmacyEncodedOrders = new List <PHARMACY_ENCODED_ORDER>();

            foreach (var order in entity.PHARMACY_ENCODED_ORDER)
            {
                var prescriptionOrder = new PHARMACY_ENCODED_ORDER()
                {
                    DRUG_NAME             = order.DRUG_NAME,
                    CODING_SYSTEM         = order.CODING_SYSTEM,
                    STRENGTH              = order.STRENGTH,
                    DOSAGE                = order.DOSAGE.ToString(),
                    FREQUENCY             = order.FREQUENCY,
                    DURATION              = Convert.ToInt32(order.DURATION),
                    QUANTITY_PRESCRIBED   = order.QUANTITY_PRESCRIBED.ToString(),
                    INDICATION            = order.INDICATION,
                    PHARMACY_ORDER_DATE   = Convert.ToDateTime(order.PHARMACY_ORDER_DATE),
                    TREATMENT_INSTRUCTION = order.PRESCRIPTION_NOTES
                };
                pharmacyEncodedOrders.Add(prescriptionOrder);
            }

            var patientName = new PATIENT_NAME()
            {
                FIRST_NAME  = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME,
                LAST_NAME   = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME,
                MIDDLE_NAME = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME
            };

            var prescriptionSourceDto = new PrescriptionSourceDto()
            {
                MESSAGE_HEADER =
                {
                    SENDING_APPLICATION   = "IQCARE",
                    SENDING_FACILITY      = entity.MESSAGE_HEADER.SENDING_FACILITY,
                    RECEIVING_APPLICATION = entity.MESSAGE_HEADER.RECEIVING_APPLICATION,
                    RECEIVING_FACILITY    = entity.MESSAGE_HEADER.RECEIVING_FACILITY,
                    MESSAGE_DATETIME      = Convert.ToDateTime(entity.MESSAGE_HEADER.MESSAGE_DATETIME), //DateTime.Now.ToString("yyyyMMddHHmmss");
                    SECURITY      = entity.MESSAGE_HEADER.SECURITY,
                    MESSAGE_TYPE  = entity.MESSAGE_HEADER.MESSAGE_TYPE,
                    PROCESSING_ID = entity.MESSAGE_HEADER.PROCESSING_ID
                },
                PATIENT_IDENTIFICATION =
                {
                    EXTERNAL_PATIENT_ID     =
                    {
                        ASSIGNING_AUTHORITY = entity.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ASSIGNING_AUTHORITY,
                        ID                  = entity.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ID,
                        IDENTIFIER_TYPE     = entity.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.IDENTIFIER_TYPE
                    },
                    INTERNAL_PATIENT_ID = internalIdentifiers,
                    PATIENT_NAME        =
                    {
                        FIRST_NAME  = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME,
                        MIDDLE_NAME = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME,
                        LAST_NAME   = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME
                    }
                },
                COMMON_ORDER_DETAILS =
                {
                    ORDER_CONTROL       = entity.COMMON_ORDER_DETAILS.ORDER_CONTROL,
                    PLACER_ORDER_NUMBER =
                    {
                        NUMBER = entity.COMMON_ORDER_DETAILS.PLACER_ORDER_NUMBER.ToString(),
                        ENTITY = entity.COMMON_ORDER_DETAILS.PLACER_ORDER_NUMBER.ENTITY
                    },
                    ORDER_STATUS       = entity.COMMON_ORDER_DETAILS.ORDER_STATUS,
                    ORDERING_PHYSICIAN =
                    {
                        FIRST_NAME  = entity.COMMON_ORDER_DETAILS.ORDERING_PHYSICIAN.FIRST_NAME,
                        MIDDLE_NAME = entity.COMMON_ORDER_DETAILS.ORDERING_PHYSICIAN.MIDDLE_NAME,
                        LAST_NAME   = entity.COMMON_ORDER_DETAILS.ORDERING_PHYSICIAN.LAST_NAME
                    },
                    TRANSACTION_DATETIME = Convert.ToDateTime(entity.COMMON_ORDER_DETAILS.TRANSACTION_DATETIME),
                    NOTES                = entity.COMMON_ORDER_DETAILS.NOTES.ToString()
                },
                PHARMACY_ENCODED_ORDER = pharmacyEncodedOrders
            };

            return(prescriptionSourceDto);
        }