Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions app/femr/business/services/core/IUpdatesService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
fEMR - fast Electronic Medical Records
Copyright (C) 2014 Team fEMR

fEMR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

fEMR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with fEMR. If not, see <http://www.gnu.org/licenses/>. If
you have any questions, contact <[email protected]>.
*/
package femr.business.services.core;

import femr.common.dtos.ServiceResponse;
import femr.data.models.core.IKitStatus;
import femr.data.models.core.INetworkStatus;
import femr.data.models.core.IDatabaseStatus;

import java.util.List;

public interface IUpdatesService {

/**
* Retrieve network statuses.
*
* @return a list of current network statues.
*/
ServiceResponse<List<? extends INetworkStatus>> retrieveNetworkStatuses();

/**
* Update network statuses.
*
* @return a list of network statues after the update (update by running a script).
*/
ServiceResponse<List<? extends INetworkStatus>> updateNetworkStatuses();

/**
* Retrieve network statuses.
*
* @return a list of current network statues.
*/
ServiceResponse<List<? extends IKitStatus>> retrieveKitStatuses();

/**
* Update kit statuses.
*
* @return a list of kit statuses after the update (update by running a script?).
*/
ServiceResponse<List<? extends IKitStatus>> updateKitStatuses();

/**
* Retrieve database last update.
*
* @return a list of current database status.
*/
ServiceResponse<List<? extends IDatabaseStatus>> retrieveDatabaseStatuses();

/**
* Update database last update and do the backup via script.
*
* @return a list of kit database status.
*/
ServiceResponse<List<? extends IDatabaseStatus>> updateDatabaseStatuses();
}
160 changes: 160 additions & 0 deletions app/femr/business/services/system/UpdatesService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
fEMR - fast Electronic Medical Records
Copyright (C) 2014 Team fEMR

fEMR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

fEMR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with fEMR. If not, see <http://www.gnu.org/licenses/>. If
you have any questions, contact <[email protected]>.
*/
package femr.business.services.system;

import com.google.inject.Inject;
import femr.business.services.core.IUpdatesService;
import femr.common.dtos.ServiceResponse;
import femr.data.daos.IRepository;
import femr.data.models.core.IKitStatus;
import femr.data.models.core.INetworkStatus;
import femr.data.models.core.IDatabaseStatus;
import femr.data.models.mysql.KitStatus;
import femr.data.models.mysql.NetworkStatus;
import femr.data.models.mysql.DatabaseStatus;

import java.util.List;

public class UpdatesService implements IUpdatesService {

private final IRepository<INetworkStatus> networkStatusRepository;
private final IRepository<IKitStatus> kitStatusRepository;
private final IRepository<IDatabaseStatus> databaseStatusRepository;

@Inject
public UpdatesService(IRepository<INetworkStatus> networkStatusRepository,
IRepository<IKitStatus> kitStatusRepository,
IRepository<IDatabaseStatus> databaseStatusRepository) {
this.networkStatusRepository = networkStatusRepository;
this.kitStatusRepository = kitStatusRepository;
this.databaseStatusRepository = databaseStatusRepository;
}

/**
* {@inheritDoc}
*/
@Override
public ServiceResponse<List<? extends INetworkStatus>> retrieveNetworkStatuses() {
ServiceResponse<List<? extends INetworkStatus>> response = new ServiceResponse<>();
try {
List<? extends INetworkStatus> networkStatuses = networkStatusRepository.findAll(NetworkStatus.class);
response.setResponseObject(networkStatuses);

} catch (Exception ex) {
response.addError("", ex.getMessage());
}
return response;
}

/**
* {@inheritDoc}
*/
@Override
public ServiceResponse<List<? extends INetworkStatus>> updateNetworkStatuses() {
ServiceResponse<List<? extends INetworkStatus>> response = new ServiceResponse<>();
//TODO: Lemur Team update the database with the right values
return response;
}

/**
* {@inheritDoc}
*/
@Override
public ServiceResponse<List<? extends IKitStatus>> retrieveKitStatuses() {
ServiceResponse<List<? extends IKitStatus>> response = new ServiceResponse<>();
try {
List<? extends IKitStatus> kitStatuses = kitStatusRepository.findAll(KitStatus.class);
response.setResponseObject(kitStatuses);

} catch (Exception ex) {
response.addError("", ex.getMessage());
}
return response;
}

/**
* {@inheritDoc}
*/
@Override
public ServiceResponse<List<? extends IKitStatus>> updateKitStatuses() {
ServiceResponse<List<? extends IKitStatus>> response = new ServiceResponse<>();
//TODO: Lemur Team update the database with the right values
return response;
}

/**
* {@inheritDoc}
*/
@Override
public ServiceResponse<List<? extends IDatabaseStatus>> retrieveDatabaseStatuses() {
ServiceResponse<List<? extends IDatabaseStatus>> response = new ServiceResponse<>();
try {
List<? extends IDatabaseStatus> kitStatuses = databaseStatusRepository.findAll(DatabaseStatus.class);
response.setResponseObject(kitStatuses);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t this variable be named databaseStatuses?

Copy link
Author

@siriwans siriwans Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sir, gotta change this... done!


} catch (Exception ex) {
response.addError("", ex.getMessage());
}
return response;
}

/**
* {@inheritDoc}
*/
@Override
public ServiceResponse<List<? extends IDatabaseStatus>> updateDatabaseStatuses() {
ServiceResponse<List<? extends IDatabaseStatus>> response = new ServiceResponse<>();
//TODO: Feather Team backup database ---> run script to see if it successsfully return if it succeeds or not

String updated_date = java.time.LocalDate.now().toString().replace("-", ".");
DatabaseStatus databaseStatus = new DatabaseStatus();
databaseStatus.setName("Last Backup");
databaseStatus.setValue(updated_date);
databaseStatusRepository.update(databaseStatus);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this code?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding the date in two places was a backup thing?

/*List<? extends ISystemSetting> allSystemSettings = systemSettingRepository.findAll(SystemSetting.class);

try {
if(systemSettings == null){
//If systemSettings is null, that means that all settings buttons were unchecked.
for (ISystemSetting ss: allSystemSettings){
ss.setActive(false);
systemSettingRepository.update(ss);
}
} else {
for (ISystemSetting ss : allSystemSettings) {
if (systemSettings.contains(ss.getName())) {
ss.setActive(true);
systemSettingRepository.update(ss);
} else {
ss.setActive(false);
systemSettingRepository.update(ss);
}
}
response.setResponseObject(allSystemSettings);
}
} catch (Exception ex) {
response.addError("", ex.getMessage());
}*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code if no longer needed

return response;
}


}

33 changes: 33 additions & 0 deletions app/femr/data/models/core/IDatabaseStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
fEMR - fast Electronic Medical Records
Copyright (C) 2014 Team fEMR

fEMR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

fEMR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with fEMR. If not, see <http://www.gnu.org/licenses/>. If
you have any questions, contact <[email protected]>.
*/
package femr.data.models.core;

public interface IDatabaseStatus {
int getId();

void setId(int id);

String getName();

void setName(String name);

String getValue();

void setValue(String value);
}
34 changes: 34 additions & 0 deletions app/femr/data/models/core/IKitStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
fEMR - fast Electronic Medical Records
Copyright (C) 2014 Team fEMR

fEMR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

fEMR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with fEMR. If not, see <http://www.gnu.org/licenses/>. If
you have any questions, contact <[email protected]>.
*/
package femr.data.models.core;


public interface IKitStatus {
int getId();

void setId(int id);

String getName();

void setName(String name);

String getValue();

void setValue(String value);
}
33 changes: 33 additions & 0 deletions app/femr/data/models/core/IKitUpdate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
fEMR - fast Electronic Medical Records
Copyright (C) 2014 Team fEMR

fEMR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

fEMR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with fEMR. If not, see <http://www.gnu.org/licenses/>. If
you have any questions, contact <[email protected]>.
*/
package femr.data.models.core;

public interface IKitUpdate {
int getId();

void setId(int id);

String getName();

void setName(String name);

String getValue();

void setValue(String value);
}
33 changes: 33 additions & 0 deletions app/femr/data/models/core/INetworkStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
fEMR - fast Electronic Medical Records
Copyright (C) 2014 Team fEMR

fEMR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

fEMR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with fEMR. If not, see <http://www.gnu.org/licenses/>. If
you have any questions, contact <[email protected]>.
*/
package femr.data.models.core;

public interface INetworkStatus {
int getId();

void setId(int id);

String getName();

void setName(String name);

String getValue();

void setValue(String value);
}
Loading