use of de.symeda.sormas.app.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class SampleDtoHelper method fillInnerFromAdo.
@Override
public void fillInnerFromAdo(SampleDto target, Sample source) {
if (source.getAssociatedCase() != null) {
Case associatedCase = DatabaseHelper.getCaseDao().queryForId(source.getAssociatedCase().getId());
target.setAssociatedCase(CaseDtoHelper.toReferenceDto(associatedCase));
} else {
target.setAssociatedCase(null);
}
if (source.getReportingUser() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
target.setReportingUser(UserDtoHelper.toReferenceDto(user));
} else {
target.setReportingUser(null);
}
if (source.getLab() != null) {
Facility lab = DatabaseHelper.getFacilityDao().queryForId(source.getLab().getId());
target.setLab(FacilityDtoHelper.toReferenceDto(lab));
} else {
target.setLab(null);
}
if (source.getReferredToUuid() != null) {
target.setReferredTo(new SampleReferenceDto(source.getReferredToUuid()));
} else {
target.setReferredTo(null);
}
target.setLabDetails(source.getLabDetails());
target.setLabSampleID(source.getLabSampleID());
target.setFieldSampleID(source.getFieldSampleID());
target.setSampleDateTime(source.getSampleDateTime());
target.setReportDateTime(source.getReportDateTime());
target.setSampleMaterial(source.getSampleMaterial());
target.setSampleMaterialText(source.getSampleMaterialText());
target.setSamplePurpose(source.getSamplePurpose());
target.setShipmentDate(source.getShipmentDate());
target.setShipmentDetails(source.getShipmentDetails());
target.setReceivedDate(source.getReceivedDate());
target.setSpecimenCondition(source.getSpecimenCondition());
target.setNoTestPossibleReason(source.getNoTestPossibleReason());
target.setComment(source.getComment());
target.setSampleSource(source.getSampleSource());
target.setShipped(source.isShipped());
target.setReceived(source.isReceived());
target.setPathogenTestResult(source.getPathogenTestResult());
target.setPathogenTestingRequested(source.getPathogenTestingRequested());
target.setAdditionalTestingRequested(source.getAdditionalTestingRequested());
target.setRequestedPathogenTests(source.getRequestedPathogenTests());
target.setRequestedAdditionalTests(source.getRequestedAdditionalTests());
target.setRequestedOtherPathogenTests(source.getRequestedOtherPathogenTests());
target.setRequestedOtherAdditionalTests(source.getRequestedOtherAdditionalTests());
target.setReportLat(source.getReportLat());
target.setReportLon(source.getReportLon());
target.setReportLatLonAccuracy(source.getReportLatLonAccuracy());
target.setSamplingReason(source.getSamplingReason());
target.setSamplingReasonDetails(source.getSamplingReasonDetails());
if (source.getSormasToSormasOriginInfo() != null) {
target.setSormasToSormasOriginInfo(sormasToSormasOriginInfoDtoHelper.adoToDto(source.getSormasToSormasOriginInfo()));
}
target.setPseudonymized(source.isPseudonymized());
}
use of de.symeda.sormas.app.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class ReportFragment method showReportData.
protected void showReportData() {
User user = ConfigProvider.getUser();
EpiWeek epiWeek = getEpiWeek();
EpiWeekFilterOption filterOption = getEpiWeekFilterOption();
if (epiWeek == null || !ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE)) {
setVisibilityForNoData();
} else {
WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().queryByEpiWeekAndUser(epiWeek, user);
if (EpiWeekFilterOption.THIS_WEEK.equals(filterOption)) {
// table is shown if the report for the last week has been confirmed; no buttons
reportDate = getResources().getString(R.string.hint_report_not_submitted);
setVisibilityForTable(false);
showPendingReport();
} else if (EpiWeekFilterOption.LAST_WEEK.equals(filterOption)) {
// table is shown, buttons are shown if the report has not been confirmed yet
if (weeklyReport == null) {
setVisibilityForTable(true);
reportDate = getResources().getString(R.string.hint_report_not_submitted);
showPendingReport();
} else {
setVisibilityForTable(false);
reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
showWeeklyReport(weeklyReport);
}
} else {
// any other week;
if (weeklyReport == null) {
if (DateHelper.isEpiWeekAfter(DateHelper.getEpiWeek(new Date()), epiWeek)) {
// 'no data' hint is shown for dates in the future
setVisibilityForNoData();
reportDate = "";
showNoReport();
} else {
// table is shown for dates in the past
setVisibilityForTable(true);
reportDate = getResources().getString(R.string.hint_report_not_submitted);
showPendingReport();
}
} else {
setVisibilityForTable(false);
reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
showWeeklyReport(weeklyReport);
}
}
}
}
use of de.symeda.sormas.app.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class RetroProvider method buildRetrofit.
public static Retrofit buildRetrofit(String serverUrl) {
Gson gson = initGson();
// Basic auth as explained in https://futurestud.io/tutorials/android-basic-authentication-with-retrofit
String authToken = Credentials.basic(ConfigProvider.getUsername(), ConfigProvider.getPassword());
AuthenticationInterceptor interceptor = new AuthenticationInterceptor(authToken);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.connectTimeout(20, TimeUnit.SECONDS);
httpClient.readTimeout(300, TimeUnit.SECONDS);
httpClient.writeTimeout(60, TimeUnit.SECONDS);
// adds "Accept-Encoding: gzip" by default
httpClient.addInterceptor(interceptor);
// adds "mobile-sync: true" by default
httpClient.addInterceptor(chain -> {
Request original = chain.request();
Request.Builder builder = original.newBuilder().header("mobile-sync", String.valueOf(true));
Request request = builder.build();
return chain.proceed(request);
});
// header for logging purposes
httpClient.addInterceptor(chain -> {
Request original = chain.request();
Request.Builder builder = original.newBuilder();
User user = ConfigProvider.getUser();
if (user != null) {
builder.header("User", DataHelper.getShortUuid(user.getUuid()));
// not sure if this is a good solution
builder.header("Connection", String.valueOf(lastConnectionId));
}
builder.method(original.method(), original.body());
return chain.proceed(builder.build());
});
return new Retrofit.Builder().baseUrl(serverUrl).addConverterFactory(GsonConverterFactory.create(gson)).client(httpClient.build()).build();
}
use of de.symeda.sormas.app.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class AggregateReportsFragment method showReportData.
private void showReportData() {
User user = ConfigProvider.getUser();
EpiWeek epiWeek = (EpiWeek) contentBinding.aggregateReportsWeek.getValue();
reports = DatabaseHelper.getAggregateReportDao().getReportsByEpiWeekAndUser(epiWeek, user);
contentBinding.reportContent.removeAllViews();
Date latestLocalChangeDate = null;
for (AggregateReport report : reports) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RowReportAggregateLayoutBinding binding = DataBindingUtil.inflate(inflater, R.layout.row_report_aggregate_layout, contentBinding.reportContent, true);
binding.setData(report);
if (latestLocalChangeDate == null || (report.getLocalChangeDate() != null && latestLocalChangeDate.before(report.getLocalChangeDate()))) {
latestLocalChangeDate = report.getLocalChangeDate();
}
}
Resources r = getResources();
if (latestLocalChangeDate == null) {
getSubHeadingHandler().updateSubHeadingTitle(r.getString(R.string.hint_case_numbers_not_submitted));
} else {
getSubHeadingHandler().updateSubHeadingTitle(String.format(r.getString(R.string.caption_latest_submission), DateFormatHelper.formatLocalDateTime(latestLocalChangeDate)));
}
}
use of de.symeda.sormas.app.backend.user.User in project SORMAS-Project by hzi-braunschweig.
the class ReportOverviewFragment method showWeeklyReportOverview.
/**
* Shows an overview of all informant reports for the user's district
*/
private void showWeeklyReportOverview() {
if (ConfigProvider.getUser() == null) {
return;
}
if (!(ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE) && ConfigProvider.getUser().hasJurisdictionLevel(JurisdictionLevel.DISTRICT))) {
return;
}
getContentBinding().noWeeklyReportData.setVisibility(GONE);
loadReportTask = new DefaultAsyncTask(getContext()) {
@Override
public void onPreExecute() {
getBaseReportActivity().showPreloader();
}
@Override
public void doInBackground(TaskResultHolder resultHolder) {
List<WeeklyReportOverviewListItem> list = new ArrayList<>();
Disease disease = (Disease) getContentBinding().weeklyReportEntryDisease.getValue();
// confirmed reports
List<User> informants = DatabaseHelper.getUserDao().getUsersByAssociatedOfficer(ConfigProvider.getUser(), UserRight.WEEKLYREPORT_CREATE);
for (User informant : informants) {
WeeklyReport report = DatabaseHelper.getWeeklyReportDao().queryByEpiWeekAndUser(getEpiWeek(), informant);
if (report != null) {
if (disease != null) {
WeeklyReportEntry entry = report.getReportEntry(disease);
list.add(new WeeklyReportOverviewListItem(report.getHealthFacility(), report.getCommunity(), report.getReportingUser(), entry != null ? entry.getNumberOfCases() : 0, report.getReportDateTime()));
} else {
list.add(new WeeklyReportOverviewListItem(report.getHealthFacility(), report.getCommunity(), report.getReportingUser(), report.getTotalNumberOfCases(), report.getReportDateTime()));
}
} else {
int numberOfCases;
if (disease != null) {
numberOfCases = DatabaseHelper.getCaseDao().getNumberOfCasesForEpiWeekAndDisease(getEpiWeek(), disease, informant);
} else {
numberOfCases = DatabaseHelper.getCaseDao().getNumberOfCasesForEpiWeek(getEpiWeek(), informant);
}
list.add(new WeeklyReportOverviewListItem(informant.getHealthFacility(), informant.getCommunity(), informant, numberOfCases, null));
}
}
resultHolder.forOther().add(list);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
super.onPostExecute(taskResult);
getBaseActivity().hidePreloader();
if (taskResult.getResult() == null) {
return;
}
List<WeeklyReportOverviewListItem> list = new ArrayList<>();
ITaskResultHolderIterator otherIterator = taskResult.getResult().forOther().iterator();
if (otherIterator.hasNext())
list = otherIterator.next();
weeklyReportOverviewAdapter = new WeeklyReportOverviewAdapter(getContext(), list);
getContentBinding().reportContent.setLayoutManager(linearLayoutManager);
getContentBinding().reportContent.setAdapter(weeklyReportOverviewAdapter);
getContentBinding().reportContentFrame.setVisibility(View.VISIBLE);
weeklyReportOverviewAdapter.notifyDataSetChanged();
}
}.executeOnThreadPool();
}
Aggregations