public void save(){
        if(this.getOrganization() == null){
            try{
                String query = "SELECT id FROM organizations LIMIT 1";
                PreparedStatement preparedStatement =
                        AmbulanceSQL.getInstance().getConnection().prepareStatement(
                                query,
                                ResultSet.TYPE_FORWARD_ONLY
                        );
                ResultSet resultSet = preparedStatement.executeQuery();
                if(resultSet.next()){
                    this.setOrganization(
                            new Organization(resultSet.getInt("id"))
                    );
                }else{
                    JOptionPane.showMessageDialog(
                            null,
                            "Ошибка базы данных(неверно заданна организация)!"
                    );
                }
            }catch (SQLException e){
                e.printStackTrace();
            }
        }
        if(this.getId() != null){
            try {
                PreparedStatement preparedStatement = Call.getConnection().prepareStatement(
                        Call.selectString,
                        ResultSet.TYPE_FORWARD_ONLY,
                        ResultSet.CONCUR_UPDATABLE
                );
                preparedStatement.setInt(1, this.getId());
                ResultSet resultSet = preparedStatement.executeQuery();
                if(resultSet.next()){
                    resultSet.updateInt("organization", this.getOrganization().getId());
                    resultSet.updateInt("worker", this.getWorker().getId());
                    resultSet.updateTimestamp("call_datetime", new Timestamp(this.getDateReceived().getTime()));
                    resultSet.updateTimestamp("passed_to_crew_time", new Timestamp(this.getDatePassed().getTime()));
                    resultSet.updateString("complaints", this.getComplaints());
                    resultSet.updateString("address_kladr", this.getAddress().getCode());
                    resultSet.updateString("address_house", this.getAddress().getHouse());
                    resultSet.updateString("address_apt", this.getAddress().getApt());
                    resultSet.updateString("comments", this.getComments());
                    resultSet.updateInt("patient", this.getPatient().getId());
                    resultSet.updateString("caller", this.getCallerName());
                    resultSet.updateString("diacrisis", this.getDiacrisis());
                    resultSet.updateString("result", this.getResult());
                    resultSet.updateInt("crew", this.getCrew().getId());
                    resultSet.updateTimestamp("crew_start_time", new Timestamp(this.getCrewStartTime().getTime()));
                    resultSet.updateTimestamp("crew_off_time", new Timestamp(this.getCrewOffTime().getTime()));
                    resultSet.updateTimestamp("trip_time", new Timestamp(this.getCrewArrivalTime().getTime()));
                    resultSet.updateInt("call_reason", this.getCallReason().getId());
                    resultSet.updateInt("call_type", this.getCallType().getId());
                    resultSet.updateRow();
                }
            } catch (SQLException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        }else{
            try {
                PreparedStatement preparedStatement = Call.getConnection().prepareStatement(
                        Call.insertString,
                        Statement.RETURN_GENERATED_KEYS
                );
                preparedStatement.setInt(1, this.getOrganization().getId());
                preparedStatement.setInt(2, this.getWorker().getId());
                preparedStatement.setTimestamp(3, new Timestamp(this.getDateReceived().getTime()));
                preparedStatement.setTimestamp(4, new Timestamp(this.getDatePassed().getTime()));
                preparedStatement.setString(5, this.getComplaints());
                preparedStatement.setString(6, this.getAddress().getCode());
                preparedStatement.setString(7, this.getAddress().getHouse());
                preparedStatement.setString(8, this.getAddress().getApt());
                preparedStatement.setString(9, this.getComments());
                preparedStatement.setInt(10, this.getPatient().getId());
                preparedStatement.setString(11, this.getCallerName());
                preparedStatement.setString(12, this.getDiacrisis());
                preparedStatement.setString(13, this.getResult());
                preparedStatement.setInt(14, this.getCrew().getId());
                preparedStatement.setTimestamp(15, new Timestamp(this.getCrewStartTime().getTime()));
                preparedStatement.setTimestamp(16, new Timestamp(this.getCrewOffTime().getTime()));
                preparedStatement.setTimestamp(17, new Timestamp(this.getCrewArrivalTime().getTime()));
                preparedStatement.setInt(18, this.getCallReason().getId());
                preparedStatement.setInt(19, this.getCallType().getId());
                preparedStatement.executeUpdate();
                ResultSet resultSet = preparedStatement.getGeneratedKeys();
                if(resultSet.next()){
                    this.setId(resultSet.getInt(1));
                }
                resultSet.close();
            } catch (SQLException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        }
    }