-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from tsowa48/dev
dev -> master
- Loading branch information
Showing
99 changed files
with
5,177 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package gcg.dent.controller; | ||
|
||
import gcg.dent.entity.*; | ||
import gcg.dent.repository.*; | ||
import io.micronaut.http.HttpResponse; | ||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Get; | ||
import io.micronaut.views.View; | ||
|
||
import javax.inject.Inject; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
@Controller("/patient") | ||
public class PatientController { | ||
|
||
@Inject | ||
PatientRepository patientRepository; | ||
|
||
@Inject | ||
ClientRepository clientRepository; | ||
|
||
@Inject | ||
FindOutRepository findOutRepository; | ||
|
||
@Inject | ||
DocumentRepository documentRepository; | ||
|
||
@Inject | ||
ActTypeRepository actTypeRepository; | ||
|
||
@Inject | ||
EmployeeRepository employeeRepository; | ||
|
||
@View("patients") | ||
@Get | ||
public HttpResponse<Map<String, Object>> getAllPatient() { | ||
Map<String, Object> params = new HashMap<>(); | ||
List<Patient> allPatients = patientRepository.getAll(); | ||
List<Client> unattachedClients = clientRepository.getUnattached(); | ||
List<FindOut> allFindOut = findOutRepository.getAll(); | ||
params.put("patients", allPatients); | ||
params.put("clients", unattachedClients); | ||
params.put("findOut", allFindOut); | ||
return HttpResponse.ok(params); | ||
} | ||
|
||
@View("patient") | ||
@Get("/{id}") | ||
public HttpResponse<Map<String, Object>> getPatient(Long id) { | ||
Map<String, Object> params = new HashMap<>(); | ||
Patient patient = patientRepository.findById(id); | ||
|
||
List<Document> docs = documentRepository.getAll(); | ||
List<Document> otherDocs = docs.stream() | ||
.filter(d -> "other".equals(d.getType())) | ||
.collect(Collectors.toList()); | ||
Document actUid = docs.stream() | ||
.filter(d -> "act".equals(d.getType())) | ||
.findFirst() | ||
.orElse(null); | ||
Document cardUid = docs.stream() | ||
.filter(d -> "card".equals(d.getType())) | ||
.findFirst() | ||
.orElse(null); | ||
Document contractUid = docs.stream() | ||
.filter(d -> "contract".equals(d.getType())) | ||
.findFirst() | ||
.orElse(null); | ||
|
||
List<ActType> actTypes = actTypeRepository.getAll(); | ||
List<Employee> employee = employeeRepository.getScheduled(); | ||
|
||
params.put("patient", patient); | ||
|
||
params.put("act_uid", actUid); | ||
params.put("card_uid", cardUid); | ||
params.put("contract_uid", contractUid); | ||
params.put("docs", otherDocs); | ||
|
||
params.put("act_type", actTypes); | ||
params.put("employee", employee); | ||
return HttpResponse.ok(params); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/gcg/dent/controller/StatisticsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package gcg.dent.controller; | ||
|
||
import gcg.dent.repository.StatisticsRepository; | ||
import io.micronaut.http.HttpResponse; | ||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Get; | ||
import io.micronaut.views.View; | ||
|
||
import javax.inject.Inject; | ||
import java.util.Map; | ||
|
||
@Controller("/statistics") | ||
public class StatisticsController { | ||
|
||
@Inject | ||
StatisticsRepository statisticsRepository; | ||
|
||
@View("statistics") | ||
@Get | ||
public HttpResponse<Map<String, Object>> getStatistics() { | ||
//Map<String, Object> params = statisticsRepository.getAll(); | ||
|
||
return HttpResponse.ok();//return HttpResponse.ok(params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package gcg.dent.controller.api; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import gcg.dent.entity.*; | ||
import gcg.dent.repository.*; | ||
import io.micronaut.http.MediaType; | ||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Post; | ||
|
||
import javax.inject.Inject; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
@Controller("/api/act") | ||
public class ActController { | ||
|
||
@Inject | ||
ActRepository actRepository; | ||
|
||
@Inject | ||
EmployeeRepository employeeRepository; | ||
|
||
@Inject | ||
ActTypeRepository actTypeRepository; | ||
|
||
@Inject | ||
ContractRepository contractRepository; | ||
|
||
@Inject | ||
ServiceRepository serviceRepository; | ||
|
||
@Post(produces = MediaType.APPLICATION_JSON) | ||
public Act add(JsonNode rawAct) throws ParseException { | ||
Act act = new Act(); | ||
Long aid = rawAct.get("aid").asLong(); | ||
Long did = rawAct.get("did").asLong(); | ||
Long atid = rawAct.get("atid").asLong(); | ||
Long doc = rawAct.get("doc").asLong(); | ||
Long number = rawAct.get("number").asLong(); | ||
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(rawAct.get("date").asText()); | ||
Iterator<JsonNode> services = rawAct.get("services").elements(); | ||
|
||
Employee doctor = employeeRepository.findById(doc); | ||
ActType actType = actTypeRepository.findById(atid); | ||
Contract contract = contractRepository.findById(did); | ||
|
||
if(aid != 0) { | ||
act.setId(aid); | ||
} | ||
act.setContract(contract); | ||
act.setActType(actType); | ||
act.setDoctor(doctor); | ||
act.setNumber(number); | ||
act.setDate(date); | ||
final Act result = actRepository.update(act); | ||
|
||
List<ActService> actServices = new ArrayList<>(); | ||
services.forEachRemaining(s -> { | ||
Long sid = s.get("sid").asLong(); | ||
Integer count = s.get("count").asInt(); | ||
Service service = serviceRepository.findById(sid); | ||
ActService actService = new ActService(); | ||
actService.setAmount(count); | ||
actService.setService(service); | ||
actService.setDate(result.getDateAsDate()); | ||
actService.setAct(result); | ||
actServices.add(actService); | ||
}); | ||
actRepository.batchUpdate(actServices); | ||
return result; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/gcg/dent/controller/api/ActTypeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package gcg.dent.controller.api; | ||
|
||
import gcg.dent.entity.ActType; | ||
import gcg.dent.repository.ActTypeRepository; | ||
import io.micronaut.http.HttpResponse; | ||
import io.micronaut.http.MediaType; | ||
import io.micronaut.http.annotation.*; | ||
|
||
import javax.inject.Inject; | ||
import java.util.List; | ||
|
||
@Controller("/api/act_type") | ||
public class ActTypeController { | ||
|
||
@Inject | ||
ActTypeRepository actTypeRepository; | ||
|
||
@Get(uri = "/{id}", produces = MediaType.APPLICATION_JSON) | ||
public ActType get(Long id) { | ||
return actTypeRepository.findById(id); | ||
} | ||
|
||
@Get(produces = MediaType.APPLICATION_JSON) | ||
public List<ActType> getAll() { | ||
return actTypeRepository.getAll(); | ||
} | ||
|
||
@Post(produces = MediaType.APPLICATION_JSON) | ||
public ActType add(ActType actType) { | ||
return actTypeRepository.addActType(actType); | ||
} | ||
|
||
@Put(produces = MediaType.APPLICATION_JSON) | ||
public ActType change(ActType actType) { | ||
return actTypeRepository.update(actType); | ||
} | ||
|
||
@Delete(uri = "/{id}", produces = MediaType.APPLICATION_JSON) | ||
public HttpResponse remove(Long id) { | ||
actTypeRepository.removeById(id); | ||
return HttpResponse.ok(); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
src/main/java/gcg/dent/controller/api/DocumentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package gcg.dent.controller.api; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import gcg.dent.entity.Document; | ||
import gcg.dent.repository.DocumentRepository; | ||
import gcg.dent.util.Templates; | ||
import io.micronaut.http.HttpResponse; | ||
import io.micronaut.http.MediaType; | ||
import io.micronaut.http.annotation.*; | ||
import io.micronaut.http.server.types.files.StreamedFile; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.inject.Inject; | ||
import java.io.OutputStreamWriter; | ||
import java.io.PipedInputStream; | ||
import java.io.PipedOutputStream; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Controller("/api/document") | ||
public class DocumentController { | ||
|
||
@Inject | ||
DocumentRepository documentRepository; | ||
|
||
@Inject | ||
Templates templates; | ||
|
||
/*@Get(uri = "/{id}", produces = MediaType.APPLICATION_JSON) | ||
public Document get(Long id) { | ||
return documentRepository.findById(id); | ||
}*/ | ||
|
||
@Get(produces = MediaType.APPLICATION_JSON) | ||
public List<Document> getAll() { | ||
return documentRepository.getAll(); | ||
} | ||
|
||
@Post(produces = MediaType.APPLICATION_JSON) | ||
public Document add(Document document) { | ||
return documentRepository.addDocument(document); | ||
} | ||
|
||
@Put(produces = MediaType.APPLICATION_JSON) | ||
public Document change(Document document) { | ||
return documentRepository.update(document); | ||
} | ||
|
||
@Delete(uri = "/{id}", produces = MediaType.APPLICATION_JSON) | ||
public HttpResponse remove(Long id) { | ||
documentRepository.removeById(id); | ||
return HttpResponse.ok(); | ||
} | ||
|
||
@Get(uri = "/download") | ||
public HttpResponse<byte[]> download(Long uid, | ||
@Nullable Long act, | ||
@Nullable Long card, | ||
@Nullable Long client, | ||
@Nullable Long contract, | ||
@Nullable Long employee, | ||
@Nullable Long history, | ||
@Nullable Long patient) | ||
throws Exception { | ||
Document document = documentRepository.findById(uid); | ||
String fileName = URLEncoder.encode(document.getName(), "UTF-8").replace("+", "%20") + ".doc"; | ||
|
||
Map<String, Object> params = new HashMap<>(); | ||
params.put("act", act); | ||
params.put("card", card); | ||
params.put("client", client); | ||
params.put("contract", contract); | ||
params.put("employee", employee); | ||
params.put("history", history); | ||
params.put("patient", patient); | ||
|
||
String content = templates.load(document, params); | ||
|
||
return HttpResponse.ok(content.getBytes()) | ||
.header("Content-type", "application/octet-stream") | ||
.header("Content-disposition", "attachment; filename=\"" + fileName + "\""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.