Skip to content

Commit e644f1d

Browse files
dragos-dobremngoemalinowskikamhirensoni913jdolkowski
authored
Release/23.04 (openimis#167)
* ajustement 5_base/data * OP-975 Added additional filters to uspAPIGetClaims (openimis#157) * OP-1066: modular IMIS: time correlations don't work (openimis#158) * SubmitSingleClaim SP is now includes historical timestamp for ProductItems/ProductServices * SubmitSingleClaim SP is now taking historical data for items/services * Historical Price lists are taken care while processing claims * OTC-780: update business logic (openimis#160) * OTC-780: update business logic: items/serives left is now being calculate as a sum of quantity in all valid claims assigned to insuree * OTC-780: refactor the code * Update openmis-module-test.yml * Devision by 0 while calculating Allocated amount (openimis#159) * change encoding to UTF-8 * UTF-8 + LF * Merge docker and fix SQL * remove run that never stops * to unblock CI on other repo * fix end date for batch process the old code does a process date between start and stop date BUT processdate is a DateTime so any datetime after 0.00 on the last day was NOT taken into account * Capitation : Wrong formula to calculate allocation is fixed * Change type of env INIT_MODE from 'empty' to empty * Update Dockerfile * Update Dockerfile * Fixed the INIT_MODE variable * utf-8 * Update docker.yml --------- Co-authored-by: mngoe <[email protected]> Co-authored-by: Kamil Malinowski <[email protected]> Co-authored-by: Hiren Soni <[email protected]> Co-authored-by: Jan <[email protected]> Co-authored-by: Patrick Delcroix <[email protected]> Co-authored-by: Patrick Delcroix <[email protected]> Co-authored-by: Hiren Soni <[email protected]> Co-authored-by: Damian Borowiecki <[email protected]>
1 parent b34fd20 commit e644f1d

20 files changed

+6101
-4540
lines changed

Diff for: .github/workflows/docker.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: publish
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
default: latest
8+
description: build tag
9+
required: false
10+
jobs:
11+
publish-docker-image:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Login to GitHub Container Registry
16+
uses: docker/login-action@v1
17+
with:
18+
registry: ghcr.io
19+
username: ${{ github.actor }}
20+
password: ${{ secrets.GITHUB_TOKEN }}
21+
- name: Build the hello-docker Docker image
22+
run: |
23+
TAG_INPUT=${{ github.event.inputs.tag }}
24+
docker build . --tag ghcr.io/openimis/openimis-mssql:${TAG_INPUT:-"latest"}
25+
docker push ghcr.io/openimis/openimis-mssql:${TAG_INPUT:-"latest"}

Diff for: .github/workflows/file-merge.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: Merge me!
18-
run : bash concatenate_files.sh
18+
run : bash script/concatenate_files.sh
1919
- name: Publish artifact
2020
uses: actions/upload-artifact@master
2121
with:

Diff for: .github/workflows/openmis-module-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
run_test:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-20.04
1515
services:
1616
mssql:
1717
image: mcr.microsoft.com/mssql/server:2017-latest
@@ -34,7 +34,7 @@ jobs:
3434
path: './new'
3535
- name: generate new files
3636
working-directory: ./new
37-
run: bash concatenate_files.sh
37+
run: bash script/concatenate_files.sh
3838
- name: install linux packages
3939
run: |
4040
mkdir ./oldMain

Diff for: Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM mcr.microsoft.com/mssql/server:2017-latest
2+
ARG ACCEPT_EULA=Y
3+
ENV ACCEPT_EULA=N
4+
ARG SA_PASSWORD=IMISuserP@s
5+
ENV SA_PASSWORD=IMISuserP@s
6+
ENV DB_USER_PASSWORD=IMISuserP@s
7+
ENV DB_NAME=IMIS
8+
ENV DB_USER=IMISUser
9+
ENV INIT_MODE=empty
10+
RUN mkdir -p /app
11+
COPY script/* /app/
12+
COPY sql /app/sql
13+
WORKDIR /app
14+
RUN chmod a+x /app/*.sh
15+
CMD /bin/bash ./entrypoint.sh

Diff for: README.md

+62
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,68 @@ For deployment please read the [installation manual](http://openimis.readthedocs
4141
Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.
4242
-->
4343

44+
## openIMIS dockerized database
45+
46+
47+
48+
| :bomb: Disclaimer : NOT FOR PRODUCTION USE :bomb: |
49+
| --- |
50+
| This repository provides a dockerized openIMIS database. It provides a quick setup for development, testing or demoing. ***It is NOT INTENDED FOR PRODUCTION USE.*** |
51+
52+
53+
### ENV
54+
55+
- INIT_MODE if set to demo will init the database to demo (works only if not yet init)
56+
- SQL_SCRIPT_URL url to init scripts
57+
- **ACCEPT_EULA** must be set to Y to accept MS SQL EULA
58+
- SA_PASSWORD default: IMISuserP@s
59+
- DB_USER_PASSWORD defautl: IMISuserP@s
60+
- DB_NAMEdefautl: IMIS
61+
- DB_USER defautl: IMISUser
62+
63+
64+
### gettingstarted
65+
66+
Please look for the directions on the openIMIS Wiki: https://openimis.atlassian.net/wiki/spaces/OP/pages/963182705/MO1.1+Install+the+modular+openIMIS+using+Docker
67+
68+
Using the provided docker file, you can build a docker image running a SQL Server 2017, with a restored openIMIS backup database.
69+
This is done by giving the following ARGs to the docker build command:
70+
```
71+
docker build \
72+
--build-arg ACCEPT_EULA=Y \
73+
--build-arg SA_PASSWORD=<your secret password> \
74+
. \
75+
-t openimis-db
76+
```
77+
78+
optinnaly
79+
```
80+
--build-arg SQL_SCRIPT_URL=<url to the sql script to create the database> \
81+
--build-arg DB_USER_PASSWORD=StrongPassword
82+
--build-arg DB_USER=IMISUser
83+
--build-arg DB_NAME=IMIS
84+
```
85+
***Notes***:
86+
* by setting the ACCEPT_EULA=Y, you explicitely accept [Microsoft EULA](https://go.microsoft.com/fwlink/?linkid=857698) for the dockerized SQL Server 2017. Please ensure you read it and use the provided software according to the terms of that license.
87+
* choose a strong password (at least 8 chars,...)... or SQL Server will complain
88+
89+
90+
To start the image in a docker container: `docker run -p 1433:1433 openimis-db`
91+
To restore the backup inside the container:
92+
* To spot the ID of the container: `docker container ls` (spot the row with openimis-db IMAGE name)
93+
94+
95+
***Note:***
96+
the container will check if the database exist, if it doesnot it will take the latest demo release version and deploy it , SQL_SCRIPT_URL is per defautl set to "https://github.com/openimis/database_ms_sqlserver/releases/latest/download/sql-files.zip"
97+
to have data retention when container are recreated volums need to be configured as microsoft docs suggest
98+
* <host directory>/data:/var/opt/mssql/data : database files
99+
* <host directory>/log:/var/opt/mssql/log : logs files
100+
* <host directory>/secrets:/var/opt/mssql/secrets : secrets
101+
102+
The database is writen within the container. If you want to keep your data between container execution, stop/start the container via `docker stop <CONTAINER ID>` / `docker start <CONTAINER ID>` (using `docker run ... ` recreates a new container from the image... thus without any data)
103+
104+
105+
44106
## Versioning
45107

46108
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/openimis/web_app_vb/tags).

Diff for: concatenate_files.ps1

-6
This file was deleted.

Diff for: script/concatenate_files.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
mkdir output
4+
cat sql/migrations/1_migration_latest.sql sql/stored_procedures/*.sql > output/fullMigrationScipt.sql
5+
cat sql/base/*.sql sql/stored_procedures/*.sql > output/fullEmptyDatabase.sql
6+
cat sql/base/*.sql sql/stored_procedures/*.sql sql/demo/*.sql> output/fullDemoDatabase.sql
7+
cat sql/base/*.sql sql/stored_procedures/*.sql sql/offline/central.sql > output/fullOfflineCentralDatabase.sql
8+
cat sql/base/*.sql sql/stored_procedures/*.sql sql/offline/hf.sql > output/fullOfflineHFDatabase.sql

Diff for: script/entrypoint.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://www.softwaredeveloper.blog/initialize-mssql-in-docker-container
2+
3+
# Run Microsoft SQl Server and initialization script (at the same time)
4+
/app/run-initialization.sh & /opt/mssql/bin/sqlservr

Diff for: script/healthcheck.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
data=$(/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "SELECT COUNT(*) FROM master.dbo.sysdatabases WHERE name = N'$DB_NAME'" | tr -dc '0-9'| cut -c1 )
3+
if [ ${data} -eq "1" ]; then
4+
exit 0
5+
else
6+
exit 1
7+
fi

Diff for: script/run-initialization.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
4+
# Wait to be sure that SQL Server came up
5+
sleep 60s
6+
7+
8+
# DATABSE initialisation
9+
10+
echo "Database initialisaton"
11+
# if the table does not exsit it will create the table
12+
13+
# get "1" if the database exist : tr get only the integer, cut only the first integer (the second is the number of row affected)
14+
data=$(/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "SELECT COUNT(*) FROM master.dbo.sysdatabases WHERE name = N'$DB_NAME'" | tr -dc '0-9'| cut -c1 )
15+
if [ ${data} -eq "0" ]; then
16+
echo 'download full demo database'
17+
echo 'create database user'
18+
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "CREATE LOGIN $DB_USER WITH PASSWORD='${SA_PASSWORD}', CHECK_POLICY = OFF"
19+
echo "merging files"
20+
./concatenate_files.sh
21+
echo 'create database'
22+
#/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "DROP DATABASE IF EXISTS $DB_NAME"
23+
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "CREATE DATABASE $DB_NAME"
24+
25+
if [ "$INIT_MODE" = "demo" ]; then
26+
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -i output/fullDemoDatabase.sql -d $DB_NAME | grep . | uniq -c
27+
else
28+
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -i output/fullEmptyDatabase.sql -d $DB_NAME | grep . | uniq -c
29+
fi
30+
echo ' give to the user the access to the database'
31+
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "EXEC sp_changedbowner '$DB_USER'" -d $DB_NAME
32+
else
33+
echo "database already existing, nothing to do"
34+
fi
35+
36+
# manual cleaning command
37+
# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "DROP DATABASE $DB_NAME"
38+
# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -Q "DROP LOGIN $DB_USER"

Diff for: sql/base/5_base_data.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ INSERT [dbo].[tblIdentificationTypes] ([IdentificationCode], [IdentificationType
9191
INSERT [dbo].[tblIdentificationTypes] ([IdentificationCode], [IdentificationTypes], [AltLanguage], [SortOrder]) VALUES (N'V', N'Voter Card', N'Carte d''électeur', NULL)
9292
SET IDENTITY_INSERT [dbo].[tblIMISDefaults] ON
9393

94-
INSERT [dbo].[tblIMISDefaults] ([DefaultID], [PolicyRenewalInterval], [FTPHost], [FTPUser], [FTPPassword], [FTPPort], [FTPEnrollmentFolder], [AssociatedPhotoFolder], [FTPClaimFolder], [FTPFeedbackFolder], [FTPPolicyRenewalFolder], [FTPPhoneExtractFolder], [FTPOffLineExtractFolder], [AppVersionBackEnd], [AppVersionEnquire], [AppVersionEnroll], [AppVersionRenewal], [AppVersionFeedback], [AppVersionClaim], [OffLineHF], [WinRarFolder], [DatabaseBackupFolder], [OfflineCHF], [SMSLink], [SMSIP], [SMSUserName], [SMSPassword], [SMSSource], [SMSDlr], [SMSType], [AppVersionFeedbackRenewal], [AppVersionImis]) VALUES (1, 14, N'', N'', N'', 0, N'/Images/Submitted', N'/Images/Updated', N'', N'', N'', N'', N'', CAST(1.2 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), 0, N'C:\Program Files (x86)\WinRAR\', N'', 0, N'', N'', N'', N'', N'', 1, 1, CAST(1.2 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)))
94+
INSERT [dbo].[tblIMISDefaults] ([DefaultID], [PolicyRenewalInterval], [FTPHost], [FTPUser], [FTPPassword], [FTPPort], [FTPEnrollmentFolder], [AssociatedPhotoFolder], [FTPClaimFolder], [FTPFeedbackFolder], [FTPPolicyRenewalFolder], [FTPPhoneExtractFolder], [FTPOffLineExtractFolder], [AppVersionBackEnd], [AppVersionEnquire], [AppVersionEnroll], [AppVersionRenewal], [AppVersionFeedback], [AppVersionClaim], [OffLineHF], [WinRarFolder], [DatabaseBackupFolder], [OfflineCHF], [SMSLink], [SMSIP], [SMSUserName], [SMSPassword], [SMSSource], [SMSDlr], [SMSType], [AppVersionFeedbackRenewal], [AppVersionImis]) VALUES (1, 14, N'', N'', N'', 0, N'/Images/Submitted', N'Images/Updated', N'', N'', N'', N'', N'', CAST(1.2 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)), 0, N'C:\Program Files (x86)\WinRAR\', N'', 0, N'', N'', N'', N'', N'', 1, 1, CAST(1.2 AS Decimal(3, 1)), CAST(0.0 AS Decimal(3, 1)))
9595
SET IDENTITY_INSERT [dbo].[tblIMISDefaults] OFF
9696
INSERT [dbo].[tblIMISDefaultsPhone] ([RuleName], [RuleValue], [Usage]) VALUES (N'AllowInsureeWithoutPhoto', 0, 'Allow synchronization of Insurees without a Photo.')
9797
INSERT [dbo].[tblIMISDefaultsPhone] ([RuleName], [RuleValue], [Usage]) VALUES (N'AllowFamilyWithoutPolicy', 0, 'Allow synchronization of Families without a Policy.')

0 commit comments

Comments
 (0)