@@ -40,9 +40,9 @@ public class SQLHandler extends SQLiteOpenHelper {
4040 private static final String CreateTableControls = "CREATE TABLE IF NOT EXISTS tblControls(FieldName TEXT, Adjustability TEXT);" ;
4141 private static final String CreateTableClaimAdmins = "CREATE TABLE IF NOT EXISTS tblClaimAdmins(Code TEXT, HFCode TEXT ,Name TEXT);" ;
4242 private static final String CreateTableReferences = "CREATE TABLE IF NOT EXISTS tblReferences(Code TEXT, Name TEXT, Type TEXT, Price TEXT);" ;
43- private static final String createTableClaimDetails = "CREATE TABLE IF NOT EXISTS tblClaimDetails(ClaimUUID TEXT, ClaimDate TEXT, HFCode TEXT, ClaimAdmin TEXT, ClaimCode TEXT, GuaranteeNumber TEXT, InsureeNumber TEXT, StartDate TEXT, EndDate TEXT, ICDCode TEXT, Comment TEXT, Total TEXT, ICDCode1 TEXT, ICDCode2 TEXT, ICDCode3 TEXT, ICDCode4 TEXT, VisitType TEXT, ReferalHF TEXT, PatientCondition TEXT,PreAuthorization Int );" ;
44- private static final String createTableClaimItems = "CREATE TABLE IF NOT EXISTS tblClaimItems(ClaimUUID TEXT, ItemCode TEXT, ItemPrice TEXT, ItemQuantity TEXT);" ;
45- private static final String createTableClaimServices = "CREATE TABLE IF NOT EXISTS tblClaimServices(ClaimUUID TEXT, ServiceCode TEXT, ServicePrice TEXT, ServiceQuantity TEXT, ServicePackageType TEXT, SubServicesItems TEXT);" ;
43+ private static final String createTableClaimDetails = "CREATE TABLE IF NOT EXISTS tblClaimDetails(ClaimUUID TEXT, ClaimDate TEXT, HFCode TEXT, ClaimAdmin TEXT, ClaimCode TEXT, GuaranteeNumber TEXT, InsureeNumber TEXT, StartDate TEXT, EndDate TEXT, ICDCode TEXT, Comment TEXT, Total TEXT, ICDCode1 TEXT, ICDCode2 TEXT, ICDCode3 TEXT, ICDCode4 TEXT, VisitType TEXT, ReferalHF TEXT, ReferralCode TEXT, PatientCondition TEXT,PreAuthorization Int );" ;
44+ private static final String createTableClaimItems = "CREATE TABLE IF NOT EXISTS tblClaimItems(ClaimUUID TEXT, ItemId TEXT, ItemCode TEXT, ItemPrice TEXT, ItemQuantity TEXT);" ;
45+ private static final String createTableClaimServices = "CREATE TABLE IF NOT EXISTS tblClaimServices(ClaimUUID TEXT,ServiceId TEXT, ServiceCode TEXT, ServicePrice TEXT, ServiceQuantity TEXT, ServicePackageType TEXT, SubServicesItems TEXT);" ;
4646 private static final String createTableClaimUploadStatus = "CREATE TABLE IF NOT EXISTS tblClaimUploadStatus(ClaimUUID TEXT, UploadDate TEXT, UploadStatus TEXT, UploadMessage TEXT);" ;
4747 private static final String CreateTableServices = "CREATE TABLE IF NOT EXISTS tblServices(Id text, Code text, Name text, Type text, Price text, PackageType text);" ;
4848 private static final String CreateTableItems = "CREATE TABLE IF NOT EXISTS tblItems(Id text, Code text, Name text, Type text, Price text);" ;
@@ -431,7 +431,7 @@ public void deleteClaim(String claimUUID) {
431431
432432 public JSONObject getClaim (String claimUUID ) {
433433 JSONArray claimDetails = getQueryResultAsJsonArray ("tblClaimDetails" ,
434- new String []{"ClaimUUID" , "ClaimDate" , "HFCode" , "ClaimAdmin" , "ClaimCode" , "GuaranteeNumber" , "InsureeNumber" , "StartDate" , "EndDate" , "ICDCode" , "Comment" , "Total" , "ICDCode1" , "ICDCode2" , "ICDCode3" , "ICDCode4" , "VisitType" , "ReferalHF" , "PatientCondition" , "PreAuthorization" },
434+ new String []{"ClaimUUID" , "ClaimDate" , "HFCode" , "ClaimAdmin" , "ClaimCode" , "GuaranteeNumber" , "InsureeNumber" , "StartDate" , "EndDate" , "ICDCode" , "Comment" , "Total" , "ICDCode1" , "ICDCode2" , "ICDCode3" , "ICDCode4" , "VisitType" , "ReferalHF" , "ReferralCode" , " PatientCondition" , "PreAuthorization" },
435435 "LOWER(ClaimUUID) = ?" ,
436436 new String []{claimUUID .toLowerCase (Locale .ROOT )});
437437
@@ -463,7 +463,7 @@ public JSONArray getAllPendingClaims() {
463463 // Rename InsureeNumber to CHFID
464464 // This is required to support legacy Rest API and Web App
465465 JSONArray claims = getQueryResultAsJsonArray (
466- "SELECT ClaimUUID, ClaimDate, HFCode, ClaimAdmin, ClaimCode, GuaranteeNumber, InsureeNumber AS CHFID, StartDate, EndDate, ICDCode, Comment, Total, ICDCode1, ICDCode2, ICDCode3, ICDCode4, VisitType" +
466+ "SELECT ClaimUUID, ClaimDate, HFCode, ClaimAdmin, ClaimCode, GuaranteeNumber, InsureeNumber AS CHFID, StartDate, EndDate, ICDCode, Comment, Total, ICDCode1, ICDCode2, ICDCode3, ICDCode4, VisitType, ReferalHF, ReferralCode, PatientCondition, PreAuthorization " +
467467 " FROM tblClaimDetails cd" +
468468 " WHERE NOT EXISTS (SELECT cus.ClaimUUID FROM tblClaimUploadStatus cus WHERE cus.ClaimUUID = cd.ClaimUUID AND cus.UploadStatus != ?)" ,
469469 new String []{CLAIM_UPLOAD_STATUS_ERROR }
@@ -500,7 +500,7 @@ public JSONArray getAllPendingClaims() {
500500 public JSONArray getClaimItems (String claimUUID ) {
501501 return getQueryResultAsJsonArray (
502502 "tblClaimItems" ,
503- new String []{"ItemCode" , "ItemPrice" , "ItemQuantity" },
503+ new String []{"ItemId" , " ItemCode" , "ItemPrice" , "ItemQuantity" },
504504 "ClaimUUID = ?" ,
505505 new String []{claimUUID }
506506 );
@@ -510,7 +510,7 @@ public JSONArray getClaimItems(String claimUUID) {
510510 public JSONArray getClaimServices (String claimUUID ) {
511511 return getQueryResultAsJsonArray (
512512 "tblClaimServices" ,
513- new String []{"ServiceCode" , "ServicePrice" , "ServiceQuantity" ,"ServicePackageType" ,"SubServicesItems" },
513+ new String []{"ServiceId" , " ServiceCode" , "ServicePrice" , "ServiceQuantity" ,"ServicePackageType" ,"SubServicesItems" },
514514 "ClaimUUID = ?" ,
515515 new String []{claimUUID }
516516 );
@@ -718,6 +718,22 @@ public String getServiceId(String code) {
718718 return id ;
719719 }
720720
721+ public String getItemId (String code ) {
722+ String id = "" ;
723+ try (Cursor c = db .query ("tblItems" , new String []{"Id" }, "LOWER(Code) = LOWER(?)" , new String []{code }, null , null , null , "1" )) {
724+ c .moveToFirst ();
725+ if (!c .isAfterLast ()) {
726+ String result = c .getString (0 );
727+ if (!TextUtils .isEmpty (result )) {
728+ id = result ;
729+ }
730+ }
731+ } catch (SQLException e ) {
732+ Log .d ("ErrorOnFetchingData" , String .format ("Error while getting price of %s" , code ), e );
733+ }
734+ return id ;
735+ }
736+
721737 public void InsertService (String Id , String Code , String Name , String Type , String Price , String PackageType ) {
722738 try {
723739 ContentValues cv = new ContentValues ();
@@ -912,4 +928,20 @@ public void InsertHealthFacilities(String Id, String Code, String Name) {
912928 e .printStackTrace ();
913929 }
914930 }
931+
932+ public String getHfId (String code ) {
933+ String id = "" ;
934+ try (Cursor c = db .query ("tblHealthFacilities" , new String []{"Id" }, "LOWER(Code) = LOWER(?)" , new String []{code }, null , null , null , "1" )) {
935+ c .moveToFirst ();
936+ if (!c .isAfterLast ()) {
937+ String result = c .getString (0 );
938+ if (!TextUtils .isEmpty (result )) {
939+ id = result ;
940+ }
941+ }
942+ } catch (SQLException e ) {
943+ Log .d ("ErrorOnFetchingData" , String .format ("Error while getting price of %s" , code ), e );
944+ }
945+ return id ;
946+ }
915947}
0 commit comments