Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Oh2 102 adjust get opd by dates params #57

Open
wants to merge 22 commits into
base: staging3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MYSQL_TAG=8.0.25
MYSQL_DATABASE=oh
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=root
MYSQL_USER=isf
MYSQL_PASSWORD=isf123

GITHUB_ORG=SteveGT96
OH_CORE_BRANCH=staging3
OH_API_BRANCH=staging3-upgrade-2.6.7
API_VERSION=0.0.1
API_PORT:8080
22 changes: 22 additions & 0 deletions Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM maven:3.8-jdk-8

ARG GITHUB_ORG
ARG OH_CORE_BRANCH
ARG OH_API_BRANCH
ARG OH_VERSION

RUN mkdir /oh_web
RUN apt-get update
RUN apt-get install -y git
WORKDIR /oh_web
RUN git clone https://github.com/${GITHUB_ORG}/openhospital-core.git --depth=1 -b ${OH_CORE_BRANCH}
WORKDIR ./openhospital-core
RUN mvn clean install -DskipTests=true
WORKDIR /oh_web
RUN git clone https://github.com/${GITHUB_ORG}/openhospital-api.git --depth=1 -b ${OH_API_BRANCH}
WORKDIR ./openhospital-api
# Database connection must be changed in order to work in docker network
RUN sed -i 's/localhost/database/g' src/main/resources/database.properties
RUN mvn clean install -DskipTests=true

CMD mvn spring-boot:run
18 changes: 18 additions & 0 deletions Dockerfile.database
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mysql:5.7.9

ARG GITHUB_ORG
ARG OH_CORE_BRANCH

ENV MYSQL_DATABASE=oh
ENV MYSQL_ROOT_PASSWORD=root
ENV MYSQL_USER=isf
ENV MYSQL_PASSWORD=isf123

RUN mkdir /oh_web
RUN apt-get update
RUN apt-get install -y git
WORKDIR /oh_web
RUN git clone https://github.com/${GITHUB_ORG}/openhospital-core.git --depth=1 -b ${OH_CORE_BRANCH}
WORKDIR ./openhospital-core

EXPOSE 3306
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ For the moment, to build this project you should

Service available on localhost:8080

## How to deploy backend in docker environment

Make sure you have docker with docker-compose installed, then run the following commands:

- DOCKER_BUILDKIT=0 docker-compose build [--no-cache]
- docker-compose up
- docker-compose exec database /bin/bash
- cd sql/
- mysql -u isf -p
- source create_all_demo.sql;

When done successfully, head over at http://localhost:[API_PORT]/oh-api/swagger-ui.html

You can change the deployment branch and the repository organization in the .env file.

## How to contribute

You can find the contribution guidelines in the [Open Hospital wiki][contribution-guide].
Expand Down
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3.8'
services:
database:
container_name: database
restart: always
command: --lower_case_table_names=1
environment:
- "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}"
- "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
- "MYSQL_USER=${MYSQL_USER}"
- "MYSQL_DATABASE=${MYSQL_DATABASE}"
build:
context: .
dockerfile: Dockerfile.database
args:
OH_CORE_BRANCH: ${OH_CORE_BRANCH}
GITHUB_ORG: ${GITHUB_ORG}
ports:
- "${MYSQL_PORT}:3306"
backend:
container_name: backend
build:
context: .
dockerfile: Dockerfile.backend
args:
API_VERSION: ${API_VERSION}
OH_CORE_BRANCH: ${OH_CORE_BRANCH}
OH_API_BRANCH: ${OH_API_BRANCH}
GITHUB_ORG: ${GITHUB_ORG}
restart: always
ports:
- "${API_PORT}:8080"
depends_on:
- database
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "10"

33 changes: 30 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.22.RELEASE</version>
<version>2.6.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.isf</groupId>
Expand All @@ -16,6 +16,7 @@

<properties>
<oh.version>2.0.0</oh.version>
<oh-core.version>1.12.0-SNAPSHOT</oh-core.version>
<java.version>1.8</java.version>
<spring-boot-admin.version>2.1.3</spring-boot-admin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -37,6 +38,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<!-- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -73,10 +79,21 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>7.0.4.Final</version>
</dependency>
<dependency>
<groupId>org.isf</groupId>
<artifactId>OH-core</artifactId>
<version>${oh.version}</version>
<version>${oh-core.version}</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
Expand All @@ -91,7 +108,7 @@
<dependency>
<groupId>org.isf</groupId>
<artifactId>OH-core</artifactId>
<version>${oh.version}</version>
<version>${oh-core.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
Expand Down Expand Up @@ -143,6 +160,16 @@
<artifactId>java-jwt</artifactId>
<version>3.18.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
63 changes: 39 additions & 24 deletions src/main/java/org/isf/accounting/rest/BillController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
package org.isf.accounting.rest;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
Expand Down Expand Up @@ -209,25 +211,30 @@ public ResponseEntity<List<BillDTO>> searchBills(@RequestParam(value = "datefrom
@RequestParam(value = "dateto") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") Date dateTo,
@RequestParam(value = "patient_code", required = false, defaultValue = "") Integer code) throws OHServiceException {

GregorianCalendar datefrom = new GregorianCalendar();
datefrom.setTime(dateFrom);

GregorianCalendar dateto = new GregorianCalendar();
dateto.setTime(dateTo);

LocalDateTime dateF = null;
if(dateFrom != null) {
dateF = dateFrom.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}

LocalDateTime dateT = null;
if(dateTo != null) {
dateT = dateTo.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}

List<Bill> bills;

List<BillDTO> billDTOS;

if (code == null) {
LOGGER.info("Get payments datefrom: {} dateTo: {}", datefrom, dateto);
bills = billManager.getBills(datefrom, dateto);
LOGGER.info("Get payments datefrom: {} dateTo: {}", dateF, dateT);
bills = billManager.getBills(dateF, dateT);
} else {
Patient pat = patientManager.getPatientById(code);

LOGGER.info("Get Bills datefrom: {} dateTo: {} patient: {}", datefrom, dateto, pat);
LOGGER.info("Get Bills datefrom: {} dateTo: {} patient: {}", dateF, dateT, pat);

bills = billManager.getBills(datefrom, dateto, pat);
bills = billManager.getBills(dateF, dateT, pat);
}

billDTOS = billMapper.map2DTOList(bills);
Expand Down Expand Up @@ -257,19 +264,23 @@ public ResponseEntity<List<BillPaymentsDTO>> searchBillsPayments(

List<BillPaymentsDTO> paymentsDTOS;

GregorianCalendar datefrom = new GregorianCalendar();
datefrom.setTime(dateFrom);

GregorianCalendar dateto = new GregorianCalendar();
dateto.setTime(dateTo);
LocalDateTime dateF = null;
if(dateFrom != null) {
dateF = dateFrom.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}

LocalDateTime dateT = null;
if(dateTo != null) {
dateT = dateTo.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}

LOGGER.info("Get getPayments datefrom: {} dateTo: {}", datefrom, dateto);
LOGGER.info("Get getPayments datefrom: {} dateTo: {}", dateF, dateT);

if (code == null) {
payments = billManager.getPayments(datefrom, dateto);
payments = billManager.getPayments(dateF, dateT);
} else {
Patient pat = patientManager.getPatientById(code);
payments = billManager.getPayments(datefrom, dateto, pat);
payments = billManager.getPayments(dateF, dateT, pat);
}

paymentsDTOS = billPaymentsMapper.map2DTOList(payments);
Expand Down Expand Up @@ -401,17 +412,21 @@ public ResponseEntity<List<BillDTO>> searchBills(@RequestParam(value="datefrom")
@RequestParam(value="dateto")@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") Date dateTo,
@RequestBody BillItemsDTO billItemDTO) throws OHServiceException {

GregorianCalendar datefrom = new GregorianCalendar();
datefrom.setTime(dateFrom);

GregorianCalendar dateto = new GregorianCalendar();
dateto.setTime(dateTo);
LocalDateTime dateF = null;
if(dateFrom != null) {
dateF = dateFrom.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}

LocalDateTime dateT = null;
if(dateTo != null) {
dateT = dateTo.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}

BillItems billItem = billItemsMapper.map2Model(billItemDTO);

LOGGER.info("Get Bills datefrom: {} dateTo: {} Bill ITEM ID: {}", datefrom, dateto, billItem.getId());
LOGGER.info("Get Bills datefrom: {} dateTo: {} Bill ITEM ID: {}", dateF, dateT, billItem.getId());

List<Bill> bills = billManager.getBills(datefrom, dateto, billItem);
List<Bill> bills = billManager.getBills(dateF, dateT, billItem);

List<BillDTO> billDTOS = billMapper.map2DTOList(bills);

Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/isf/admission/dto/AdmissionDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public class AdmissionDTO {
@ApiModelProperty(notes = "lock", example = "0", position = 31)
private int lock;

@NotNull
@ApiModelProperty(notes = "flag record deleted, values are 'Y' OR 'N' ", example = "N", position = 32)
private String deleted;

Expand Down
Loading