Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
Merge branch 'dev' into feature/232-exposure-contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
wobkenh authored May 11, 2020
2 parents 7ed93da + e28ee9a commit a483ea6
Show file tree
Hide file tree
Showing 27 changed files with 698 additions and 46 deletions.
74 changes: 44 additions & 30 deletions client/src/api/SwaggerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ export interface CreatePatientDTO {
preIllnesses?: string[];
quarantineUntil?: string;
riskAreas?: string[];
riskOccupation?: "NO_RISK_OCCUPATION" | "FIRE_FIGHTER" | "DOCTOR" | "CAREGIVER" | "NURSE";
riskOccupation?:
| "NO_RISK_OCCUPATION"
| "FIRE_FIGHTER_POLICE"
| "TEACHER"
| "PUBLIC_ADMINISTRATION"
| "STUDENT"
| "DOCTOR"
| "CAREGIVER"
| "NURSE";
speedOfSymptomsOutbreak?: string;
stayCity?: string;
stayCountry?: string;
Expand Down Expand Up @@ -346,7 +354,15 @@ export interface Patient {
preIllnesses?: string[];
quarantineUntil?: string;
riskAreas?: string[];
riskOccupation?: "NO_RISK_OCCUPATION" | "FIRE_FIGHTER" | "DOCTOR" | "CAREGIVER" | "NURSE";
riskOccupation?:
| "NO_RISK_OCCUPATION"
| "FIRE_FIGHTER_POLICE"
| "TEACHER"
| "PUBLIC_ADMINISTRATION"
| "STUDENT"
| "DOCTOR"
| "CAREGIVER"
| "NURSE";
speedOfSymptomsOutbreak?: string;
stayCity?: string;
stayCountry?: string;
Expand Down Expand Up @@ -1047,72 +1063,70 @@ export class Api<SecurityDataType = any> extends HttpClient<SecurityDataType> {
error = {
/**
* @tags basic-error-controller
* @name errorUsingGET
* @summary error
* @name errorHtmlUsingGET
* @summary errorHtml
* @request GET:/error
* @secure
*/
errorUsingGet: (params?: RequestParams) =>
this.request<Record<string, object>, any>(`/error`, "GET", params, null, true),
errorHtmlUsingGet: (params?: RequestParams) => this.request<ModelAndView, any>(`/error`, "GET", params, null, true),

/**
* @tags basic-error-controller
* @name errorUsingHEAD
* @summary error
* @name errorHtmlUsingHEAD
* @summary errorHtml
* @request HEAD:/error
* @secure
*/
errorUsingHead: (params?: RequestParams) =>
this.request<Record<string, object>, any>(`/error`, "HEAD", params, null, true),
errorHtmlUsingHead: (params?: RequestParams) =>
this.request<ModelAndView, any>(`/error`, "HEAD", params, null, true),

/**
* @tags basic-error-controller
* @name errorUsingPOST
* @summary error
* @name errorHtmlUsingPOST
* @summary errorHtml
* @request POST:/error
* @secure
*/
errorUsingPost: (params?: RequestParams) =>
this.request<Record<string, object>, any>(`/error`, "POST", params, null, true),
errorHtmlUsingPost: (params?: RequestParams) =>
this.request<ModelAndView, any>(`/error`, "POST", params, null, true),

/**
* @tags basic-error-controller
* @name errorUsingPUT
* @summary error
* @name errorHtmlUsingPUT
* @summary errorHtml
* @request PUT:/error
* @secure
*/
errorUsingPut: (params?: RequestParams) =>
this.request<Record<string, object>, any>(`/error`, "PUT", params, null, true),
errorHtmlUsingPut: (params?: RequestParams) => this.request<ModelAndView, any>(`/error`, "PUT", params, null, true),

/**
* @tags basic-error-controller
* @name errorUsingDELETE
* @summary error
* @name errorHtmlUsingDELETE
* @summary errorHtml
* @request DELETE:/error
* @secure
*/
errorUsingDelete: (params?: RequestParams) =>
this.request<Record<string, object>, any>(`/error`, "DELETE", params, null, true),
errorHtmlUsingDelete: (params?: RequestParams) =>
this.request<ModelAndView, any>(`/error`, "DELETE", params, null, true),

/**
* @tags basic-error-controller
* @name errorUsingOPTIONS
* @summary error
* @name errorHtmlUsingOPTIONS
* @summary errorHtml
* @request OPTIONS:/error
* @secure
*/
errorUsingOptions: (params?: RequestParams) =>
this.request<Record<string, object>, any>(`/error`, "OPTIONS", params, null, true),
errorHtmlUsingOptions: (params?: RequestParams) =>
this.request<ModelAndView, any>(`/error`, "OPTIONS", params, null, true),

/**
* @tags basic-error-controller
* @name errorUsingPATCH
* @summary error
* @name errorHtmlUsingPATCH
* @summary errorHtml
* @request PATCH:/error
* @secure
*/
errorUsingPatch: (params?: RequestParams) =>
this.request<Record<string, object>, any>(`/error`, "PATCH", params, null, true),
errorHtmlUsingPatch: (params?: RequestParams) =>
this.request<ModelAndView, any>(`/error`, "PATCH", params, null, true),
};
}
10 changes: 9 additions & 1 deletion client/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ export type PatientStatus = 'REGISTERED'
| 'PATIENT_DEAD'
| 'DOCTORS_VISIT'
| 'QUARANTINE_MANDATED';
export type RiskOccupation = 'NO_RISK_OCCUPATION' | 'FIRE_FIGHTER' | 'DOCTOR' | 'CAREGIVER' | 'NURSE'
export type RiskOccupation =
'NO_RISK_OCCUPATION'
| 'FIRE_FIGHTER_POLICE'
| 'TEACHER'
| 'PUBLIC_ADMINISTRATION'
| 'STUDENT'
| 'DOCTOR'
| 'CAREGIVER'
| 'NURSE'

export interface Option {
label: string;
Expand Down
5 changes: 4 additions & 1 deletion client/src/models/risk-occupation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export interface RiskOccupationOption {
}

export const RISK_OCCUPATIONS: RiskOccupationOption[] = [
{ value: 'FIRE_FIGHTER', label: 'Feuerwehrmann/frau' },
{ value: 'PUBLIC_ADMINISTRATION', label: 'Öffentliche Verwaltung' },
{ value: 'STUDENT', label: 'Schüler' },
{ value: 'TEACHER', label: 'Lehrer' },
{ value: 'FIRE_FIGHTER_POLICE', label: 'Gefahrenabwehr (Polizei, Feuerwehr usw.)' },
{ value: 'DOCTOR', label: 'Arzt/Ärztin' },
{ value: 'NURSE', label: 'Pflegepersonal' },
{ value: 'CAREGIVER', label: 'Altenpflege' },
Expand Down
1 change: 1 addition & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'org.springframework.cloud:spring-cloud-gcp-starter-storage'
implementation 'org.postgresql:postgresql:42.2.11'
compile group: 'org.hibernate', name: 'hibernate-envers', version: '5.4.14.Final'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.coronavirus.imis.api.dto.RequestLabTestDTO;
import de.coronavirus.imis.domain.PatientEvent;
import de.coronavirus.imis.services.IncidentService;
import de.coronavirus.imis.services.PatientEventService;
import de.coronavirus.imis.services.PatientService;
import lombok.RequiredArgsConstructor;
Expand All @@ -18,10 +19,12 @@
public class DoctorController {
private final PatientEventService eventService;
private final PatientService patientService;
private final IncidentService incidentService;

@PostMapping("/create_appointment")
public PatientEvent addScheduledEvent(@RequestBody RequestLabTestDTO dto) {
var patient = patientService.findPatientById(dto.getPatientId()).orElseThrow();
incidentService.addIncident(patient, dto.getLaboratoryId(), dto.getDoctorId());
return eventService.createScheduledEvent(patient, dto.getLaboratoryId(), dto.getDoctorId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package de.coronavirus.imis.api;

/*
To ease migration, incidents are currently automatically created when
- Creating Tests
- Updating Tests
- Sending to Quarantine
- Creating Patients (equivalent to Initial Patient Event)
- Scheduling appointments (implemented, not tested. Could not find frontend feature)
*/

import de.coronavirus.imis.domain.Incident;
import de.coronavirus.imis.domain.IncidentType;
import de.coronavirus.imis.services.IncidentService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/incidents")
@AllArgsConstructor
public class IncidentController {

private final IncidentService incidentService;

@GetMapping("/{id}")
public Incident getIncident(@PathVariable("id") String incidentId) {
return incidentService.getCurrent(incidentId);
}

@GetMapping("/{id}/log")
public List<Incident> getLog(@PathVariable("id") String incidentId) {
return incidentService.getLog(incidentId, false);
}

@GetMapping("/patient/{id}")
public List<Incident> getPatientCurrent(@PathVariable("id") String patientId) {
return incidentService.getCurrentByPatient(patientId);
}

@GetMapping("/{type}/patient/{id}")
public List<Incident> getPatientCurrentByType(@PathVariable("type") IncidentType incidentType, @PathVariable("id") String patientId) {
return incidentService.getCurrentByPatient(patientId, incidentType);
}

@GetMapping("/patient/{id}/log")
public List<Incident> getPatientLog(@PathVariable("id") String patientId) {
return incidentService.getLog(patientId, true);
}

@GetMapping("/{type}/patient/{id}/log")
public List<Incident> getPatientLogByType(@PathVariable("type") IncidentType incidentType, @PathVariable("id") String patientId) {
return incidentService.getLog(incidentType.IMPLEMENTATION, patientId, true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.coronavirus.imis.api.dto.CreateLabTestDTO;
import de.coronavirus.imis.api.dto.UpdateTestStatusDTO;
import de.coronavirus.imis.domain.LabTest;
import de.coronavirus.imis.services.IncidentService;
import de.coronavirus.imis.services.LabTestService;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -17,9 +18,11 @@
public class LabTestController {

private final LabTestService service;
private final IncidentService incidentService;

@PostMapping
public ResponseEntity<LabTest> createTestForPatient(@RequestBody CreateLabTestDTO createLabTestRequest) {
incidentService.addIncident(createLabTestRequest);
return ResponseEntity.ok(
service.createLabTest(createLabTestRequest)
);
Expand All @@ -37,6 +40,7 @@ public Set<LabTest> getLabTestForPatient(@PathVariable("id") String patientId) {

@PutMapping("/{laboratoryId}")
public ResponseEntity<LabTest> updateTestStatus(@PathVariable("laboratoryId") String laboratoryId, @RequestBody UpdateTestStatusDTO statusDTO) {
incidentService.updateIncident(laboratoryId, statusDTO);
return ResponseEntity.ok(service.updateTestStatus(
laboratoryId, statusDTO
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.coronavirus.imis.api.dto.PatientSimpleSearchParamsDTO;
import de.coronavirus.imis.api.dto.SendToQuarantineDTO;
import de.coronavirus.imis.domain.Patient;
import de.coronavirus.imis.services.IncidentService;
import de.coronavirus.imis.domain.PatientEvent;
import de.coronavirus.imis.services.PatientEventService;
import de.coronavirus.imis.services.PatientService;
Expand All @@ -24,6 +25,7 @@
public class PatientController {

private final PatientService patientService;
private final IncidentService incidentService;
private final PatientEventService eventService;

@PostMapping
Expand Down Expand Up @@ -81,6 +83,7 @@ public Long countQueryPatients(@RequestBody final PatientSearchParamsDTO patient
@PostMapping("/quarantine/{id}")
@PreAuthorize("hasAnyRole('DEPARTMENT_OF_HEALTH')")
public ResponseEntity<Patient> sendToQuarantine(@PathVariable("id") String patientId, @RequestBody SendToQuarantineDTO statusDTO) {
incidentService.addOrUpdateIncident(patientId, statusDTO);
return ResponseEntity.ok(patientService.sendToQuaratine(patientId, statusDTO));
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.coronavirus.imis.config;

import org.hibernate.envers.AuditReader;
import org.hibernate.envers.AuditReaderFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.persistence.EntityManagerFactory;


@Configuration
public class AuditConfiguration {

private final EntityManagerFactory entityManagerFactory;

AuditConfiguration(EntityManagerFactory entityManagerFactory) {
this.entityManagerFactory = entityManagerFactory;
}

@Bean
AuditReader auditReader() {
return AuditReaderFactory.get(entityManagerFactory.createEntityManager());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.coronavirus.imis.config;

import de.coronavirus.imis.config.domain.User;
import org.springframework.data.domain.AuditorAware;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import java.util.Optional;

public class AuditorAwareImpl implements AuditorAware<User> {
@Override
public Optional<User> getCurrentAuditor() {

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

if(authentication != null && SecurityContextHolder.getContext().getAuthentication().isAuthenticated())
{
var user = (User) authentication.getPrincipal();
Optional<User> opt = Optional.of(user);
return opt;
}

return Optional.empty();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.coronavirus.imis.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import de.coronavirus.imis.config.domain.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement
@EnableJpaAuditing (auditorAwareRef = "auditorAware")
class PersistenceConfig {

@Bean
public AuditorAware<User> auditorAware() {
return new AuditorAwareImpl();
}

@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}

}
Loading

0 comments on commit a483ea6

Please sign in to comment.