Skip to content

Commit

Permalink
csu and vih app product filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jobil committed Nov 2, 2023
1 parent c7d5258 commit a49c28f
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ android {
resValue "string", "app_name_policies", "Enrolement CSU"
dimension = 'std'
}
csuVIHDev {
applicationId "org.openimis.imispolicies.csuVIHDev"
buildConfigField "String", "API_BASE_URL", '"https://dev-csuapps.minsante.cm/"'
resValue "string", "app_name_policies", "Enrolement CSU VIH"
dimension = 'std'
}
mvDev {
applicationId "org.openimis.imispolicies.mv"
buildConfigField "String", "API_BASE_URL", '"http://imis-mv.swisstph-mis.ch/"'
Expand Down Expand Up @@ -174,6 +180,9 @@ android {
csuDev.java.srcDir 'src/csu/java'
csuDev.res.srcDirs = ['src/csu/res', 'src/localeCsu/res']

csuVIHDev.java.srcDir 'src/csuVIH/java'
csuVIHDev.res.srcDirs = ['src/csuVIH/res', 'src/localeCsuVIH/res']

niger.java.srcDir 'src/niger/java'
niger.res.srcDir 'src/niger/res'
niger.assets.srcDir 'src/niger/assets'
Expand Down
47 changes: 47 additions & 0 deletions app/src/csuVIH/java/org/openimis/imispolicies/Escape.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//Copyright (c) 2016-%CurrentYear% Swiss Agency for Development and Cooperation (SDC)
//
//The program users must agree to the following terms:
//
//Copyright notices
//This program is free software: you can redistribute it and/or modify it under the terms of the GNU AGPL v3 License as published by the
//Free Software Foundation, version 3 of the License.
//This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL v3 License for more details www.gnu.org.
//
//Disclaimer of Warranty
//There is no warranty for the program, to the extent permitted by applicable law; except when otherwise stated in writing the copyright
//holders and/or other parties provide the program "as is" without warranty of any kind, either expressed or implied, including, but not
//limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and
//performance of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
//
//Limitation of Liability
//In no event unless required by applicable law or agreed to in writing will any copyright holder, or any other party who modifies and/or
//conveys the program as permitted above, be liable to you for damages, including any general, special, incidental or consequential damages
//arising out of the use or inability to use the program (including but not limited to loss of data or data being rendered inaccurate or losses
//sustained by you or third parties or a failure of the program to operate with any other programs), even if such holder or other party has been
//advised of the possibility of such damages.
//
//In case of dispute arising out or in relation to the use of the program, it is subject to the public law of Switzerland. The place of jurisdiction is Berne.

package org.openimis.imispolicies;

public class Escape {
public int CheckInsuranceNumber(String InsuranceNumber){

if (InsuranceNumber.length() == 0){
return R.string.MissingInsuranceNumber;
}

if (!isValidInsuranceNumber(InsuranceNumber)){
return R.string.InvalidInsuranceNumber;

}

return 0;
}

private boolean isValidInsuranceNumber(String InsuranceNumber){
return true;
}

}
Binary file modified app/src/main/assets/database/IMIS.db3
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/assets/pages/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function LoadOfficers(LocationId, EnrolmentDate) {

}
function LoadProduct(RegionId, DistrictId, EnrolmentDate) {
var $Products = Android.getProducts(parseInt(RegionId), parseInt(DistrictId), EnrolmentDate);
var $Products = Android.getCSUProducts(parseInt(RegionId), parseInt(DistrictId), EnrolmentDate);
bindDropdown('ddlProduct', $Products, 'ProdId', 'ProductNameCombined', 0, Android.getString('SelectProduct'));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ public String getOfficers(int LocationId, String EnrolmentDate) {
@SuppressWarnings("unused")
public String getProducts(int RegionId, int DistrictId, String EnrolmentDate) {
@Language("SQL")
String ProductQuery = "SELECT ProdId, ProductCode, ProductName, ProductCode ||\" - \"|| ProductName ProductNameCombined \n" +
String ProductQuery = "SELECT ProdId, ProductCode, ProductName, Program, ProductCode ||\" - \"|| ProductName ProductNameCombined \n" +
"FROM tblProduct P\n" +
"INNER JOIN uvwLocations L ON (P.LocationId = L.LocationId) \n" +
"WHERE ((L.RegionId = " + RegionId + " OR L.RegionId ='null') AND (L.DistrictId = " + DistrictId + " OR L.DistrictId ='null') OR L.LocationId='null') AND " +
Expand All @@ -1609,6 +1609,53 @@ public String getProducts(int RegionId, int DistrictId, String EnrolmentDate) {
return Products.toString();
}

@JavascriptInterface
@SuppressWarnings("unused")
public String getCSUProducts(int RegionId, int DistrictId, String EnrolmentDate){
JSONArray products = new JSONArray();
String idVIH ="";
String appName = BuildConfig.FLAVOR;

try{
JSONArray ProductArray = new JSONArray(getProducts(RegionId, DistrictId, EnrolmentDate));
JSONArray ProgramsArray = new JSONArray(getProgram());


for(int j = 0; j < ProgramsArray.length(); j++ ){
JSONObject objProgram = ProgramsArray.getJSONObject(j);
if(objProgram.get("Name").equals("VIH")){
idVIH = objProgram.getString("idProgram");
}
}

if(idVIH != ""){

if(appName.equals("csuDev")){
for (int i = 0; i<ProductArray.length(); i++){
JSONObject objProduct = ProductArray.getJSONObject(i);
if(!objProduct.getString("Program").equals(idVIH)){
products.put(objProduct);
}
}
}else if(appName.equals("csuVIHDev")){
for (int i = 0; i<ProductArray.length(); i++){
JSONObject objProduct = ProductArray.getJSONObject(i);
if(objProduct.getString("Program").equals(idVIH)){
products.put(objProduct);
}
}
}
}else{
Log.e("error", "pas de programme VIH");
}

} catch(JSONException e){
e.printStackTrace();
}

return products.toString();
}

public String getProductsRD() {
JSONArray Products = null;
int RegionId = 0, DistrictId = 0;
Expand Down

0 comments on commit a49c28f

Please sign in to comment.