@@ -40,15 +40,15 @@ 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, ReferralCode TEXT, PatientCondition TEXT,PreAuthorization Int );" ;
4443 private static final String createTableClaimItems = "CREATE TABLE IF NOT EXISTS tblClaimItems(ClaimUUID TEXT, ItemId TEXT, ItemCode TEXT, ItemPrice TEXT, ItemQuantity TEXT);" ;
44+ 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, PrescriberUuid TEXT, PrescriberNIN TEXT );" ;
4545 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, ManualPrice Int);" ;
4848 private static final String CreateTableItems = "CREATE TABLE IF NOT EXISTS tblItems(Id text, Code text, Name text, Type text, Price text);" ;
4949 private static final String CreateTableSubServices = "CREATE TABLE IF NOT EXISTS tblSubServices(ServiceId text, ServiceLinked text, Quantity text, Price text);" ;
5050 private static final String CreateTableSubItems = "CREATE TABLE IF NOT EXISTS tblSubItems(ItemId text, ServiceId text, Quantity text, Price text);" ;
51- private static final String CreateTableHealthFacilities = "CREATE TABLE IF NOT EXISTS tblHealthFacilities(Id TEXT, Code TEXT, Name TEXT);" ;
51+ private static final String CreateTableHealthFacilities = "CREATE TABLE IF NOT EXISTS tblHealthFacilities(Id TEXT, Uuid TEXT, Code TEXT, Name TEXT);" ;
5252
5353 public final String REFERENCE_UNKNOWN ;
5454
@@ -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" , "ReferralCode" , "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" , "PrescriberUuid" , "PrescriberNIN" },
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, ReferalHF, ReferralCode, PatientCondition, PreAuthorization " +
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, PrescriberUuid, PrescriberNIN " +
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 }
@@ -934,10 +934,11 @@ public JSONObject getItem(String itemId) {
934934 return resultSet ;
935935 }
936936
937- public void InsertHealthFacilities (String Id , String Code , String Name ) {
937+ public void InsertHealthFacilities (String Id , String Uuid , String Code , String Name ) {
938938 try {
939939 ContentValues cv = new ContentValues ();
940940 cv .put ("Id" , Id );
941+ cv .put ("Uuid" , Uuid );
941942 cv .put ("Code" , Code );
942943 cv .put ("Name" , Name );
943944 db .insert ("tblHealthFacilities" , null , cv );
@@ -961,4 +962,36 @@ public String getHfId(String code) {
961962 }
962963 return id ;
963964 }
965+
966+ public String getHfUuid (String code ) {
967+ String uuid = "" ;
968+ try (Cursor c = db .query ("tblHealthFacilities" , new String []{"Uuid" }, "LOWER(Code) = LOWER(?)" , new String []{code }, null , null , null , "1" )) {
969+ c .moveToFirst ();
970+ if (!c .isAfterLast ()) {
971+ String result = c .getString (0 );
972+ if (!TextUtils .isEmpty (result )) {
973+ uuid = result ;
974+ }
975+ }
976+ } catch (SQLException e ) {
977+ Log .d ("ErrorOnFetchingData" , String .format ("Error while getting price of %s" , code ), e );
978+ }
979+ return uuid ;
980+ }
981+
982+ public String getPrescriberUuidByNIN (String nin ) {
983+ String uuid = "" ;
984+ try (Cursor c = db .query ("tblClaimDetails" , new String []{"PrescriberUuid" }, "LOWER(PrescriberNIN) = LOWER(?)" , new String []{nin }, null , null , null , "1" )) {
985+ c .moveToFirst ();
986+ if (!c .isAfterLast ()) {
987+ String result = c .getString (0 );
988+ if (!TextUtils .isEmpty (result )) {
989+ uuid = result ;
990+ }
991+ }
992+ } catch (SQLException e ) {
993+ Log .d ("ErrorOnFetchingData" , String .format ("Error while getting prescriber UUID for NIN %s" , nin ), e );
994+ }
995+ return uuid ;
996+ }
964997}
0 commit comments