VB predefined function

Coba.Gupth
Posted by Coba.Gupth under Windows Forms category on | Points: 40 | Views : 1307
public List<ArrayList> CollectRequests(DataSet dsRequests)
{
List<ArrayList> ls1 = new List<ArrayList>();
List<ArrayList> retSampleReqsProto = new List<ArrayList>();
System.IFormatProvider frmt = new System.Globalization.CultureInfo("en-US");
int sequencecount = 0;
string paramcode = null;
bool status = false;
string strNameLength = null;
string strGender = null;
#region Sample Protocol From the manual
/***
H|\^&|||||||||||E1394-97
P|1|||100|^Carol^Thomas||20010820|F|||||^Dr. N||||||||||||^^^East
O|1|^^123-4567-890123^C||^^^^WBC\^^^^RBC\····^^^^NEUT#||20010807101000|||||N||||||||||||||Q
L|1|N
***/
#endregion
ArrayList Requestdetails = new ArrayList();
string[] patientRecord = new string[26];
string[] testOrderRecord = new string[26];
DataSet ds = new DataSet();
char[] cspace = new char[] { ' ' };
// string[] name = dsRequests.Tables[0].Rows[0]["PATIENTFIRSTNAME"].ToString().Split(cspace, StringSplitOptions.RemoveEmptyEntries);
sequencecount++;
patientRecord[0] = "P";
patientRecord[1] = sequencecount.ToString();
string firstname = dsRequests.Tables[0].Rows[0]["PATIENTFIRSTNAME"].ToString();
string lastname = dsRequests.Tables[0].Rows[0]["PATIENTMIDDLENAME"].ToString();
string middlename = dsRequests.Tables[0].Rows[0]["PATIENTLASTNAME"].ToString();
strNameLength = firstname + middlename;
//string[] name = firstname + middlename + lastname;
if (strNameLength.Length > 20)
{
strNameLength = strNameLength.Substring(0, 20);
}
else
{
strNameLength = strNameLength;

}
if (lastname.Length > 20)
{
lastname = lastname.Substring(0, 20);

}
else
{
lastname = lastname;

}
patientRecord[5] = "^" + strNameLength + "^" + lastname;
DateTime datetime = DateTime.ParseExact(dsRequests.Tables[0].Rows[0]["BIRTHDATE"].ToString(), "dd-MMM-yy", frmt);
patientRecord[7] = datetime.ToString("yyyyMMdd");
strGender = dsRequests.Tables[0].Rows[0]["SEX"].ToString();
if (strGender.Length == 4)
{
patientRecord[8] = strGender.Substring(0, 1);

}
else if (strGender.Length == 6)
{
patientRecord[8] = strGender.Substring(0, 1);

}
else
{
patientRecord[8] = "U";
}
// patientRecord[8] = dsRequests.Tables[0].Rows[0]["BIRTHDATE"].ToString();
//string strbirthdate=Convert.ToString(DateTime.ParseExact("20-Jun-10"
//switch (name.Length)
// case 1:
// firstname = name[0];
// patientRecord[5] = lastname + "^" + firstname;
// break;
// case 2:
// firstname = name[0];
// lastname = name[1];
// patientRecord[5] = lastname + "^" + firstname;
// break;
// case 3:
// firstname = name[0];
// lastname = name[1];
// middlename = name[2];
// patientRecord[5] = lastname + "^" + firstname + "^" + middlename;
// break;
// default:
// patientRecord[5] = dsRequests.Tables[0].Rows[0]["PATIENTNAME"].ToString().Substring(0, 20);
// break;
//}
patientRecord[2] = dsRequests.Tables[0].Rows[0]["PATIENTSERVICENO"].ToString();
patientRecord[3] = patientRecord[2];
testOrderRecord[0] = "O";
testOrderRecord[1] = sequencecount.ToString();
testOrderRecord[2] = dsRequests.Tables[0].Rows[0]["SAMPLEID"].ToString();
for (int k = 0; k < dsRequests.Tables[0].Rows.Count; k++)
{
if (k == dsRequests.Tables[0].Rows.Count - 1)
{
paramcode += "^^^" + dsRequests.Tables[0].Rows[k]["EQP_PARAM_REF_CD"].ToString();
}
else
{
paramcode += "^^^" + dsRequests.Tables[0].Rows[k]["EQP_PARAM_REF_CD"].ToString() + @"\";
}
}
testOrderRecord[4] = paramcode;
testOrderRecord[7] = DateTime.Now.ToString("yyyyMMddhhmmss");
testOrderRecord[11] = "A";
testOrderRecord[15] = "serum";
testOrderRecord[25] = "Q";
testOrderRecord[5] = null;
Requestdetails.Add(patientRecord);
Requestdetails.Add(testOrderRecord);
RequestList.Add(Requestdetails);
ArrayList Requestheaders = new ArrayList();
string[] headerRecord = new string[13];
headerRecord[0] = "H";
headerRecord[1] = @"\^&";
headerRecord[4] = "";
headerRecord[11] = "P";
headerRecord[12] = "1";
Requestheaders.Add(headerRecord);
RequestList.Insert(0, Requestheaders);
ArrayList RequestRecord = new ArrayList();
string[] messageTerminatorRecord = new string[3];
messageTerminatorRecord[0] = "L";
messageTerminatorRecord[1] = "1";
messageTerminatorRecord[1] = "N";
RequestRecord.Add(messageTerminatorRecord);
RequestList.Add(RequestRecord);
return FormProtocol(RequestList);
}
private string CalChkSum(string dataCollected)
{
string hexdec = null;
int cal = 0;
string calChkSum = null;

calChkSum = dataCollected.Remove(0, (dataCollected.IndexOf(Strings.Chr((int)CommonControls.STX)) + 1));

foreach (char c in calChkSum.ToCharArray())
{
cal += (int)c;

}
hexdec = cal.ToString("X");
hexdec = hexdec.Remove(0, hexdec.Length - 2);
return hexdec;
}
}

Comments or Responses

Posted by: Sheonarayan on: 7/14/2013 Level:HonoraryPlatinum | Status: [Administrator] | Points: 10
Dear Coba,

Thanks for the post however submitti

Login to post response