gov.va.medora.mdws.MedsLib.getPrescriptionsHL7 C# (CSharp) Method

getPrescriptionsHL7() public method

public getPrescriptionsHL7 ( string pwd, string sitecode, string mpiPid ) : TaggedMedicationArrays
pwd string
sitecode string
mpiPid string
return gov.va.medora.mdws.dto.TaggedMedicationArrays
        public TaggedMedicationArrays getPrescriptionsHL7(string pwd, string sitecode, string mpiPid)
        {
            TaggedMedicationArrays result = new TaggedMedicationArrays();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (String.IsNullOrEmpty(sitecode))
            {
                result.fault = new FaultTO("Missing site ID");
            }
            else if (String.IsNullOrEmpty(mpiPid))
            {
                result.fault = new FaultTO("Missing patient ID");
            }

            if (result.fault != null)
            {
                return result;
            }

            try
            {
                Site hl7Site = mySession.SiteTable.getSite(sitecode);
                DataSource hl7Src = null;
                foreach (DataSource src in hl7Site.Sources)
                {
                    if (String.Equals(src.Protocol, "HL7", StringComparison.CurrentCultureIgnoreCase))
                    {
                        hl7Src = src;
                        break;
                    }
                }
                if (hl7Src == null)
                {
                    throw new gov.va.medora.mdo.exceptions.MdoException("No HL7 data source in site table for that site ID");
                }
                HL7Connection cxn = new HL7Connection(hl7Src);
                cxn.connect();
                cxn.Pid = mpiPid;
                result = new TaggedMedicationArrays(new MedsApi().getAllMeds(new ConnectionSet(cxn)));
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }