public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException, UnknownHostException {
		tempRxList = new ArrayList<Medicine>();
		Date EditDate = new Date();
		ArrayList<String> tempPrescriptionID;
		// Prepare Morphia Framework
		Mongo mongo = new Mongo("localhost", 27017);
		Morphia morphia = new Morphia();
		morphia.mapPackage("com.j3ltd.server.entities");
		Datastore ds = morphia.createDatastore(mongo, "dotc");
		Query<Record> qr = ds.createQuery(Record.class).field("RecordID")
				.equal(request.getParameter("RecordID").toString());
		record = qr.get();
		prescription = new Prescription();
		// prescription.setPatientID(request.getParameter("PatientID").toString());
		prescription.setDoctorID(request.getParameter("DoctorID").toString());
		String PostRx = request.getParameter("RxList").toString();
		String[] rawRxList = PostRx.split(";");
		int i = 1;
		temp = "";
		for (String rawRx : rawRxList) {
			Rx = new Medicine();
			String[] RxAttribute = rawRx.split(",");
			Rx.setId(String.valueOf(i));
			Rx.setType(RxAttribute[0].trim());
			Rx.setName(RxAttribute[1].trim());
			Rx.setDose(RxAttribute[2].trim());
			Rx.setAmount(Integer.parseInt(RxAttribute[3].trim()));
			Rx.setUsageDirection(RxAttribute[4].trim());
			Rx.setRawString(notePrescription(Rx));
			tempRxList.add(Rx);
			if (i == 1)
				temp += Rx.getRawString();
			else
				temp += "\n" + Rx.getRawString();
			i++;
		}
		prescription.setMedicineList(tempRxList);
		prescription.setRawStringList(temp);
		Query<Person> qp = ds.createQuery(Person.class).field("citizenid")
				.equal(record.getPatientCitizenID());
		Person patient = qp.get();
		prescription.setPatientID(patient.getCitizenid());
		prescription.setPatientFirstName(patient.getFirstName());
		prescription.setPatientLastName(patient.getLastName());
		Query<Doctor> qd = ds.createQuery(Doctor.class).field("citizenid")
				.equal(prescription.getDoctorID());
		Doctor doctor = qd.get();
		prescription.setDoctorFirstName(doctor.getFirstName());
		prescription.setDoctorLastName(doctor.getLastName());
		// Generating Prescription ID
		if (ds.createQuery(Prescription.class).countAll() == 0)
			prescription.setPrescriptionID("1");
		else {
			Query<Prescription> q = ds.createQuery(Prescription.class).order(
					"-PrescriptionID");
			Prescription temp = q.get();
			long l = Long.parseLong(temp.getPrescriptionID()) + 1;
			prescription.setPrescriptionID(String.valueOf(l));
		}
		// Generating Prescription ID List to Record
		tempP = "";
		if (record.getPrescriptionID() == null) {
			tempPrescriptionID = new ArrayList<String>();
			tempP = prescription.getPrescriptionID().trim();
		} else {
			tempPrescriptionID = record.getPrescriptionID();
			tempP = record.getRawPrescriptionIDList().concat(",")
					.concat(prescription.getPrescriptionID()).trim();
		}
		tempPrescriptionID.add(prescription.getPrescriptionID());
		UpdateOperations<Record> ops = ds.createUpdateOperations(Record.class)
				.set("PrescriptionID", tempPrescriptionID)
				.set("rawPrescriptionIDList", tempP).set("DiagDate", EditDate)
				.set("timestamp", EditDate);
		ds.findAndModify(qr, ops);
		System.out.println("Sent POST request to backBean");
		insertPrescription();
		System.out.println("Finish inserting to MongoDB");
	}