/// <summary> /// Connect to Thord and change status of referrals to "MOTTAGEN" /// </summary> /// <param name="refs">Array of referrals</param> public void sendTransferedReferrals(Referral[] refs) { referralupdates refupdate = new referralupdates(); ReferralUpdateDefinition[] refdef = new ReferralUpdateDefinition[refs.Length]; int i = 0; if (refs.Length != 0) { foreach (Referral rf in refs) { ReferralUpdateDefinition rd = new ReferralUpdateDefinition(); rd.referralnumber = rf.remissid; rd.statusSpecified = true; rd.status = ReferralStatusValues.MOTTAGEN; refdef[i] = rd; i++; } try { refupdate.referralupdate = refdef; tdProxy.UpdateReferrals(refupdate); } catch { } } }
/// <summary> /// Connect to Thord and update referrals with new data /// </summary> /// <param name="refs">Array of Referrals</param> /// <param name="garpaids">Array of New Aid Definitions</param> public bool sendReferral(Referral referral) { referralupdates refupdate = new referralupdates(); ReferralUpdateDefinition[] ru = new ReferralUpdateDefinition[1]; AidsUpdateDefinition aids = new AidsUpdateDefinition(); referrals refReturned; OrderRowFunc oOR = new OrderRowFunc(); // If aids exists if (referral.aids.Length > 0) { if (referral.aids[0].CreatedInThord) { aids.aidupdate = createAidUpdateObject(referral.aids[0]); } else { aids.newaid = createAidNewObject(referral.aids[0]); } } ru[0] = new ReferralUpdateDefinition(); ru[0].referralnumber = referral.remissid; ru[0].aids = aids; refupdate.referralupdate = ru; try { // Talk to the old man refReturned = tdProxy.UpdateReferrals(refupdate); foreach (AidDefinition ad in refReturned.referral[0].aids.aid) { if ((referral.aids[0].orderno.PadRight(6, '_') + referral.aids[0].row.Trim()).Equals(ad.externalaidid)) { oOR.updateOid(ad.externalaidid.Substring(0, 6).Replace("_", ""), ad.externalaidid.Substring(6), ad.aidoid.ToString(), "0"); // If any parts are present if (ad.parts != null) { foreach (PartDefinition p in ad.parts.part) { oOR.updateOid(p.externalpartid.Substring(0, 6).Replace("_", ""), p.externalpartid.Substring(6), ad.aidoid.ToString(), p.partoid.ToString()); } } } // If whole aid should be removed // OBS! This code must exists after ordinary UpdateReferrals, all parts must be // removed before vi can remove the aid. if (referral.aids[0].RemoveMe) { aids = new AidsUpdateDefinition(); ru[0] = new ReferralUpdateDefinition(); ru[0].referralnumber = referral.remissid; ru[0].aids = aids; refupdate.referralupdate = ru; aids.removeaid = createAidRemoveObject(referral.aids[0]); // Talk to the old man try { refReturned = tdProxy.UpdateReferrals(refupdate); MessageBox.Show("Hjälpmedlet (" + referral.aids[0].aidoid.ToString() + ") har tagits bort från Thord", "Meddelande från Thord"); } catch (Exception ex) { MessageBox.Show("Vid radering av hjälpmedel uppstod ett fel:\n" + ex.Message, "Meddelande från Thord"); Log4Net.Logger.loggError(ex, "THORD: SendReferral/RemoveReferral:", Config.User, "ThordFunction.sendReferral"); } } } return true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Meddelande från Thord"); Log4Net.Logger.loggError(ex, "THORD: SendReferral", Config.User, ""); return false; } }