public void run() {
		try {
			PrintWriter out = null;
			BufferedReader in = null;
			out = new PrintWriter(socket.getOutputStream(), true);
			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

			String clientMsg = null;
			while ((clientMsg = in.readLine()) != null) {

				int type = -1;
				try {
					Request request = gson.fromJson(clientMsg, Request.class);
					type = request.getType();

					switch (type) {
					case Request.GET_RECORDS:
						out.println(gson.toJson(monitor.getRecordsOfPatient(identity, request.getData())));
						break;
					case Request.CREATE_RECORD:
						Record createRecord = gson.fromJson(request.getData(), Record.class);
						out.println(monitor.createRecord(identity, createRecord));
						break;
					case Request.UPDATE_RECORD:
						Record updateRecord = gson.fromJson(request.getData(), Record.class);
						out.println(monitor.updateRecord(identity, updateRecord));
						break;
					case Request.DELETE_RECORD:
						Record deleteRecord = gson.fromJson(request.getData(), Record.class);
						out.println(monitor.deleteRecord(identity, deleteRecord));
						break;
					}
				} catch (JsonSyntaxException e) {
					continue;
				}
				out.flush();
			}
			in.close();
			out.close();
			socket.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}