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

refillPrescription() public method

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

            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");
            }
            else if (String.IsNullOrEmpty(rxId))
            {
                result.fault = new FaultTO("Missing Rx 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 MedicationTO(new MedsApi().refillPrescription(cxn, rxId));
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }