Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AC-450 Created Admission simple #696

Merged
merged 16 commits into from
Jun 18, 2020
Merged

Conversation

rishabh-997
Copy link
Collaborator

Description of what I changed

I added a separate activity for the admission form with the following features:

  1. To get a provider detail list.
  2. Create an encounter to save it locally and in the server as well.

Issue I worked on

JIRA Issue: https://issues.openmrs.org/browse/AC-450

Checklist: I completed these to help reviewers :)

  • My pull request only contains ONE single commit
    (the number above, next to the 'Commits' tab is 1).
  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)
  • All new and existing tests passed.
  • My pull request is based on the latest changes of the master branch.

@codecov-io
Copy link

codecov-io commented Feb 3, 2020

Codecov Report

Merging #696 into master will decrease coverage by 0.12%.
The diff coverage is 2.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #696      +/-   ##
==========================================
- Coverage   12.36%   12.23%   -0.13%     
==========================================
  Files         236      239       +3     
  Lines       10857    10975     +118     
  Branches     1002     1011       +9     
==========================================
+ Hits         1342     1343       +1     
- Misses       9434     9550     +116     
- Partials       81       82       +1
Impacted Files Coverage Δ
...mobile/activities/introduction/SplashActivity.java 0% <ø> (ø) ⬆️
...ies/visitdashboard/VisitExpandableListAdapter.java 0% <0%> (ø) ⬆️
...tivities/formadmission/FormAdmissionPresenter.java 0% <0%> (ø)
...tivities/formdisplay/FormDisplayMainPresenter.java 0% <0%> (ø) ⬆️
...ctivities/formadmission/FormAdmissionFragment.java 0% <0%> (ø)
...s/mobile/activities/formlist/FormListFragment.java 0% <0%> (ø) ⬆️
...ctivities/formadmission/FormAdmissionActivity.java 0% <0%> (ø)
.../mobile/activities/formlist/FormListPresenter.java 74.5% <60%> (-2.58%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cac05ed...6580a0c. Read the comment docs.

@rishabh-997
Copy link
Collaborator Author

is there any API to fetch data to where the patient must be admitted to ??? Or should I hardcode it as
ImpatientWard and IsolationWard ??? @f4ww4z sir

@rishabh-997
Copy link
Collaborator Author

Almost there but facing a big error. When I am sending encounter to the server, I am receiving an error:
400 Bad Request - The Resource Does not Support the Requested Operation [null]
Is there any documentation for an object that needs to be sent to admission_forms or JSON response it is expecting. I tried the way it is done n vitals and visits but failed...
@f4ww4z

@codecov-commenter
Copy link

codecov-commenter commented May 20, 2020

Codecov Report

Merging #696 into master will increase coverage by 0.13%.
The diff coverage is 19.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #696      +/-   ##
==========================================
+ Coverage   11.72%   11.86%   +0.13%     
==========================================
  Files         249      254       +5     
  Lines       10770    11010     +240     
  Branches     1036     1062      +26     
==========================================
+ Hits         1263     1306      +43     
- Misses       9424     9616     +192     
- Partials       83       88       +5     
Impacted Files Coverage Δ
...s/mobile/activities/dashboard/DashboardFragment.kt 0.00% <0.00%> (ø)
...ctivities/formadmission/FormAdmissionActivity.java 0.00% <0.00%> (ø)
...le/activities/formdisplay/FormDisplayActivity.java 0.00% <0.00%> (ø)
...tivities/formdisplay/FormDisplayMainPresenter.java 0.00% <0.00%> (ø)
...s/mobile/activities/formlist/FormListFragment.java 0.00% <0.00%> (ø)
...s/mobile/activities/introduction/SplashActivity.kt 0.00% <ø> (ø)
...ivities/visitdashboard/VisitDashboardFragment.java 0.00% <0.00%> (ø)
...ies/visitdashboard/VisitExpandableListAdapter.java 0.00% <0.00%> (ø)
.../java/org/openmrs/mobile/api/EncounterService.java 0.00% <0.00%> (ø)
...main/java/org/openmrs/mobile/dao/EncounterDAO.java 0.69% <0.00%> (-0.02%) ⬇️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54187c2...a2235cb. Read the comment docs.

@rishabh-997
Copy link
Collaborator Author

rishabh-997 commented May 21, 2020

I am getting the following error every time I create an admission encounter. It is saved in the server but the app crashes and I not able to debug the reason...

Can you look into it @f4ww4z sir

java.io.FileNotFoundException: /data/logswitch/switch.xml: open failed: EACCES (Permission denied)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:496)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at java.io.FileInputStream.<init>(FileInputStream.java:159)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at java.io.FileReader.<init>(FileReader.java:72)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.readString(InputLog.java:394)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.getCurrentLogSwitchValue(InputLog.java:420)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.startWatching(InputLog.java:126)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.<clinit>(InputLog.java:77)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.startWatching(InputLog.java:126)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at android.app.ActivityThread.attach(ActivityThread.java:7530)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7759)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
2020-05-27 01:49:56.020 6882-6882/? W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at libcore.io.Linux.open(Native Method)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
2020-05-27 01:49:56.021 6882-6882/? W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
2020-05-27 01:49:56.021 6882-6882/? W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
2020-05-27 01:49:56.021 6882-6882/? W/System.err:     at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7671)
2020-05-27 01:49:56.021 6882-6882/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:482)
2020-05-27 01:49:56.021 6882-6882/? W/System.err: 	... 12 more
2020-05-22 01:52:28.391 24304-24304/? W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:496)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:235)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.openFile(FileOutput.java:67)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.startup(FileOutput.java:49)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Agent.startup(Agent.java:122)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Agent.getInstance(Agent.java:50)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Offline.<clinit>(Offline.java:31)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Offline.getProbes(Offline.java:51)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.openmrs.mobile.application.OpenMRS.$jacocoInit(Unknown Source:13)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.openmrs.mobile.application.OpenMRS.<clinit>(Unknown Source:0)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at java.lang.Class.newInstance(Native Method)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:47)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.Instrumentation.newApplication(Instrumentation.java:1156)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.LoadedApk.makeApplication(LoadedApk.java:1258)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6779)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.ActivityThread.access$1700(ActivityThread.java:240)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2061)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:107)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.os.Looper.loop(Looper.java:228)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7772)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
2020-05-22 01:52:28.393 24304-24304/? W/System.err: Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.Linux.open(Native Method)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7671)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:482)
2020-05-22 01:52:28.393 24304-24304/? W/System.err: 	... 23 more

@rishabh-997
Copy link
Collaborator Author

rishabh-997 commented May 22, 2020

Entire PR is ready with the following changes:

  1. Added FormAdmission MVP
  2. Updated Encounter.kt and added two model classes for EncounterProviders List
  3. Updated DataBaseHelper class to store LocationUUID and ProviderUUID locally
  4. Added a query function in LocationDAO and written test for it too
  5. Created a new Rest API call to fetch EncounterRoles List
  6. Created test for FormAdmissionPresenter

The following two things are left:

  1. I am displaying EncounterLocation in the VisitDashboard page, I will show the EncounterProvider in the dashboard, once Offline support for Providers is ready for which I will create the issue afterward...
  2. I have to add tests for createEncounter() but there are no tests for Visit or Vitals in FormDisplayMainPresenter.java previously...

Here is the screenshot of the result:
WhatsApp Image 2020-05-23 at 2 47 06 AM

@rishabh-997
Copy link
Collaborator Author

rishabh-997 commented May 26, 2020

I am getting the following error every time I create an admission encounter. It is saved in the server but the app crashes and I not able to debug the reason...

Can you look into it @f4ww4z sir

java.io.FileNotFoundException: /data/logswitch/switch.xml: open failed: EACCES (Permission denied)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:496)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at java.io.FileInputStream.<init>(FileInputStream.java:159)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at java.io.FileReader.<init>(FileReader.java:72)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.readString(InputLog.java:394)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.getCurrentLogSwitchValue(InputLog.java:420)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.startWatching(InputLog.java:126)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.<clinit>(InputLog.java:77)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.oppo.debug.InputLog.startWatching(InputLog.java:126)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at android.app.ActivityThread.attach(ActivityThread.java:7530)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7759)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
2020-05-27 01:49:56.020 6882-6882/? W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at libcore.io.Linux.open(Native Method)
2020-05-27 01:49:56.020 6882-6882/? W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
2020-05-27 01:49:56.021 6882-6882/? W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
2020-05-27 01:49:56.021 6882-6882/? W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
2020-05-27 01:49:56.021 6882-6882/? W/System.err:     at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7671)
2020-05-27 01:49:56.021 6882-6882/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:482)
2020-05-27 01:49:56.021 6882-6882/? W/System.err: 	... 12 more
2020-05-22 01:52:28.391 24304-24304/? W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:496)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:235)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.openFile(FileOutput.java:67)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.startup(FileOutput.java:49)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Agent.startup(Agent.java:122)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Agent.getInstance(Agent.java:50)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Offline.<clinit>(Offline.java:31)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Offline.getProbes(Offline.java:51)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.openmrs.mobile.application.OpenMRS.$jacocoInit(Unknown Source:13)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at org.openmrs.mobile.application.OpenMRS.<clinit>(Unknown Source:0)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at java.lang.Class.newInstance(Native Method)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:47)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.Instrumentation.newApplication(Instrumentation.java:1156)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.LoadedApk.makeApplication(LoadedApk.java:1258)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6779)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.ActivityThread.access$1700(ActivityThread.java:240)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2061)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:107)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.os.Looper.loop(Looper.java:228)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7772)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
2020-05-22 01:52:28.392 24304-24304/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
2020-05-22 01:52:28.393 24304-24304/? W/System.err: Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.Linux.open(Native Method)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7671)
2020-05-22 01:52:28.393 24304-24304/? W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:482)
2020-05-22 01:52:28.393 24304-24304/? W/System.err: 	... 23 more

Everything is working fine, just when I hit the submit button, this pops up and crashes the app. But on syncing, the admission data is displayed all right... I have been trying to solve this error but nothing seems to work... Can you look into this one @f4ww4z sir. This happened only in admission form, is there any special permission required???

@f4ww4z
Copy link
Collaborator

f4ww4z commented May 28, 2020

@rishabh-997 sorry I got busy with univ assignments, I will look into this and let you know.

@rishabh-997
Copy link
Collaborator Author

rishabh-997 commented May 28, 2020

@rishabh-997 sorry I got busy with univ assignments, I will look into this and let you know.

I can totally understand that. My whole semester examination are cancelled and all the evaluation and grading are to be done by assignments being given nowadays. You take your time, I'll also look into this one thoroughly again and get other issues prepared locally meanwhile 😀😀

@f4ww4z
Copy link
Collaborator

f4ww4z commented May 30, 2020

@rishabh-997 When building this PR or the latest master branch, I got this error. We should resolve that first.

@rishabh-997
Copy link
Collaborator Author

Hey @LuGO0, since you and @f4ww4z sir are not getting this error while running apps, can you please verify the reason behind the app crash during admission forms, ie, can you please check the logs behind the crash. There might be a different reason for this crash.

@LuGO0
Copy link
Collaborator

LuGO0 commented Jun 8, 2020

Hey @LuGO0, since you and @f4ww4z sir are not getting this error while running apps, can you please verify the reason behind the app crash during admission forms, ie, can you please check the logs behind the crash. There might be a different reason for this crash.

@rishabh-997 sorry I didnt get a notification regarding your mention , I will do this could you please pinpoint the error which comes up for you I didnt follow the conversation from the starting !!

@rishabh-997
Copy link
Collaborator Author

Hey @LuGO0, since you and @f4ww4z sir are not getting this error while running apps, can you please verify the reason behind the app crash during admission forms, ie, can you please check the logs behind the crash. There might be a different reason for this crash.

@rishabh-997 sorry I didnt get a notification regarding your mention , I will do this could you please pinpoint the error which comes up for you I didnt follow the conversation from the starting !!

#696 (comment)
this one, actually this error comes up everytime when app is started and I am not even sure if it is an error. But after app crashes, this is the only logs that appears. I am still trying to figure out the reason behin the crash

@LuGO0
Copy link
Collaborator

LuGO0 commented Jun 8, 2020

Ohkk @rishabh-997 I will look into, btw I looked up the converstation above and it seems data is getting synced to the server and then the crash is happening is it the case @rishabh-997??

@rishabh-997
Copy link
Collaborator Author

Ohkk @rishabh-997 I will look into, btw I looked up the converstation above and it seems data is getting synced to the server and then the crash is happening is it the case @rishabh-997??

yeah. the data is sent to server successfully, the crash seem to occur either while saving it locally or syncing database with server. Not able to figure out much from logs

@LuGO0
Copy link
Collaborator

LuGO0 commented Jun 9, 2020

@rishabh-997 do you get this crash/error on register patient activity?? after simply registering a patient?

E/Service Task: Running W/IInputConnectionWrapper: finishComposingText on inactive InputConnection finishComposingText on inactive InputConnection W/art: Before Android 4.1, method double java.util.concurrent.ThreadLocalRandom.internalNextDouble(double, double) would have incorrectly overridden the package-private method in java.util.Random Before Android 4.1, method int java.util.concurrent.ThreadLocalRandom.internalNextInt(int, int) would have incorrectly overridden the package-private method in java.util.Random Before Android 4.1, method long java.util.concurrent.ThreadLocalRandom.internalNextLong(long, long) would have incorrectly overridden the package-private method in java.util.Random E/OpenMRS: #47 OpenMRSLogger.lambda$new$0$OpenMRSLogger() : Uncaught exception is: java.lang.IllegalStateException: Exception thrown on Scheduler.Worker thread. AddonErrorhandling. at rx.android.schedulers.LooperScheduler$ScheduledAction.run(LooperScheduler.java:112) at android.os.Handler.handleCallback(Handler.java:754) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:165) at android.app.ActivityThread.main(ActivityThread.java:6375) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802) Caused by: rx.exceptions.OnErrorNotImplementedException: table patients has no column named encounters: , while compiling: INSERT INTO patients(display,synced,uuid,identifier,givenName,middleName,familyName,gender,birthDate,deathDate,causeOfDeath,age,photo,address1,address2,postalCode,country,state,city,encounters)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:386) at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:383) at rx.internal.util.ActionSubscriber.onError(ActionSubscriber.java:44) at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:153) at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:115) at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.checkTerminated(OperatorObserveOn.java:273) at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:216) at rx.android.schedulers.LooperScheduler$ScheduledAction.run(LooperScheduler.java:107) at android.os.Handler.handleCallback(Handler.java:754)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:165)  at android.app.ActivityThread.main(ActivityThread.java:6375)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)  Caused by: net.sqlcipher.database.SQLiteException: table patients has no column named encounters: , while compiling: INSERT INTO patients(display,synced,uuid,identifier,givenName,middleName,familyName,gender,birthDate,deathDate,causeOfDeath,age,photo,address1,address2,postalCode,country,state,city,encounters)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method) at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91) at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64) at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:89) at net.sqlcipher.database.SQLiteStatement.<init>(SQLiteStatement.java:39) at net.sqlcipher.database.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1702) at org.openmrs.mobile.databases.DBOpenHelper.insertPatient(DBOpenHelper.java:110) at org.openmrs.mobile.databases.tables.PatientTable.insert(PatientTable.java:93) at org.openmrs.mobile.dao.PatientDAO.lambda$savePatient$0(PatientDAO.java:42) at org.openmrs.mobile.dao.-$$Lambda$PatientDAO$RKpUgSXDFF3yONYsrEKXe_Gvk0s.call(lambda) at rx.internal.operators.OnSubscribeFromCallable.call(OnSubscribeFromCallable.java:48) at rx.internal.operators.OnSubscribeFromCallable.call(OnSubscribeFromCallable.java:33) at rx.Observable.unsafeSubscribe(Observable.java:10256) at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.call(OperatorSubscribeOn.java:100) at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:230) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:760) E/OpenMRS: #47 OpenMRSLogger.lambda$new$0$OpenMRSLogger() : Uncaught exception is: java.lang.IllegalStateException: Exception thrown on Scheduler.Worker thread. AddonErrorhandling. at rx.android.schedulers.LooperScheduler$ScheduledAction.run(LooperScheduler.java:112) at android.os.Handler.handleCallback(Handler.java:754) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:165) at android.app.ActivityThread.main(ActivityThread.java:6375) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802) Caused by: rx.exceptions.OnErrorNotImplementedException: table patients has no column named encounters: , while compiling: INSERT INTO patients(display,synced,uuid,identifier,givenName,middleName,familyName,gender,birthDate,deathDate,causeOfDeath,age,photo,address1,address2,postalCode,country,state,city,encounters)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:386) at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:383) at rx.internal.util.ActionSubscriber.onError(ActionSubscriber.java:44) at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:153) at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:115) at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.checkTerminated(OperatorObserveOn.java:273) at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:216) at rx.android.schedulers.LooperScheduler$ScheduledAction.run(LooperScheduler.java:107) at android.os.Handler.handleCallback(Handler.java:754)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:165)  at android.app.ActivityThread.main(ActivityThread.java:6375)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)  Caused by: net.sqlcipher.database.SQLiteException: table patients has no column named encounters: , while compiling: INSERT INTO patients(display,synced,uuid,identifier,givenName,middleName,familyName,gender,birthDate,deathDate,causeOfDeath,age,photo,address1,address2,postalCode,country,state,city,encounters)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method) at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91) at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64) at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:89) at net.sqlcipher.database.SQLiteStatement.<init>(SQLiteStatement.java:39) at net.sqlcipher.database.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1702) at org.openmrs.mobile.databases.DBOpenHelper.insertPatient(DBOpenHelper.java:110) at org.openmrs.mobile.databases.tables.PatientTable.insert(PatientTable.java:93) at org.openmrs.mobile.dao.PatientDAO.lambda$savePatient$0(PatientDAO.java:42) at org.openmrs.mobile.dao.-$$Lambda$PatientDAO$RKpUgSXDFF3yONYsrEKXe_Gvk0s.call(lambda) at rx.internal.operators.OnSubscribeFromCallable.call(OnSubscribeFromCallable.java:48) at rx.internal.operators.OnSubscribeFromCallable.call(OnSubscribeFromCallable.java:33) at rx.Observable.unsafeSubscribe(Observable.java:10256) at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.call(OperatorSubscribeOn.java:100) at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:230) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:760) D/OpenMRS: #62 OpenMRSLogger.<init>() : Start logging to file I/Timeline: Timeline: Activity_launch_request time:30332219 intent:Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=org.openmrs.mobile cmp=org.openmrs.mobile/.activities.introduction.SplashActivity (has extras) } I/Process: Sending signal. PID: 29101 SIG: 9 Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'

@rishabh-997
Copy link
Collaborator Author

I ain't getting any such error while registering patients. What I see is **table patients has no column named encounters**. I'll look into this also but haven't got any such error. Strange behavior.

@LuGO0
Copy link
Collaborator

LuGO0 commented Jun 10, 2020

@rishabh-997 did you find any such errors?? should I try again !!

@rishabh-997
Copy link
Collaborator Author

@rishabh-997 did you find any such errors?? should I try again !!

Nopes. I did not face any such error. Instead of registering patients, try downloading them instead so you can proceed.

@rishabh-997
Copy link
Collaborator Author

The admission form is finally complete. I have done some weird changes because the SQL database gets corrupted and the app becomes inaccessible as soon as Provider Data is saved. It is because we are not using SQLCipher while adding providers to the database.

IMAGE ALT TEXT HERE

@@ -206,7 +207,7 @@ class DashboardFragment : ACBaseFragment<DashboardContract.Presenter>(), Dashboa
R.id.registryPatientView -> startNewActivity(AddEditPatientActivity::class.java)
R.id.captureVitalsView -> startNewActivity(FormEntryPatientListActivity::class.java)
R.id.activeVisitsView -> startNewActivity(ActiveVisitsActivity::class.java)
R.id.dashboardProviderManagementView -> startNewActivity(ProviderManagerDashboardActivity::class.java)
R.id.dashboardProviderManagementView -> ToastUtil.error(getString(R.string.failed_to_open_vitals_form));
Copy link
Collaborator Author

@rishabh-997 rishabh-997 Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that users can't corrupt the database accidentally. Will be removed in the PR which will remove this error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment it @rishabh-997 it will help

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we dont give any warning, user will keep pressing icon. And the encoded string here is An error occured, Invalid or Corrupt file which is very apt

if (displayableEncounterTypesArray.contains(encounterTypeDisplay)) {
encounter.getEncounterType().setDisplay(encounterTypeDisplay.split("\\(")[0].trim());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the server sends Admission(Simple) but we add Admission only.

@@ -158,8 +158,7 @@ private void linkvisit(Long patientid, String formname, Encounter encounter, Enc
encounterList.add(encounter);
visitDAO.saveOrUpdate(visit, patientid)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(id ->
ToastUtil.success(getString(R.string.form_data_saved_successfully, formname)));
Copy link
Collaborator Author

@rishabh-997 rishabh-997 Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was throwing callback error at rx.internals.OnSubscribeFromCallable. So I removed the return here as it was not being used as well, also it resolved error at AC-786

@@ -110,6 +110,42 @@ public void onFailure(@NotNull Call<Results<Provider>> call, @NotNull Throwable
return providerLiveData;
}

public LiveData<List<Provider>> getProvidersWithoutStorage(RestApi restApi) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I wanted to fetch data without storing and corrupting database so...

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created Relative Layout coz I designed this way back in february but I will create another issue for improving UI for forms where I will convert it to Constraint.

Copy link
Collaborator Author

@rishabh-997 rishabh-997 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasons behind some weird changes

Copy link
Collaborator

@LuGO0 LuGO0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishabh-997 I know you wont risk changing things again after it works after so long but should we try and remove the Tables slowly, maybe creating a seperate issue I know that will really be a tough task !! thoughts @rishabh-997 @f4ww4z Sir??

@LuGO0
Copy link
Collaborator

LuGO0 commented Jun 12, 2020

Reasons behind some weird changes

thats really some work @rishabh-997 💯 !! cant find that on stack overflow I searched for it I coudnt get it 😅

@rishabh-997
Copy link
Collaborator Author

@rishabh-997 I know you wont risk changing things again after it works after so long but should we try and remove the Tables slowly, maybe creating a seperate issue I know that will really be a tough task !! thoughts @rishabh-997 @f4ww4z Sir??

Before that, we need to solve AC-478. After that, we will remove ActiveAndroid tables which are not being used as such. Then we will remove SQL functions one by one and replace the corresponging codes with room functions...

@LuGO0
Copy link
Collaborator

LuGO0 commented Jun 12, 2020

@rishabh-997 I know you wont risk changing things again after it works after so long but should we try and remove the Tables slowly, maybe creating a seperate issue I know that will really be a tough task !! thoughts @rishabh-997 @f4ww4z Sir??

Before that, we need to solve AC-478. After that, we will remove ActiveAndroid tables which are not being used as such. Then we will remove SQL functions one by one and replace the corresponging codes with room functions...

but @rishabh-997 AC-478 hasnt been done yet because from the conversation I can gather is that it requires the room migration to be complete means removing tables before implementing SQLCipher??

@rishabh-997 rishabh-997 changed the title AC 450 Created Admission simple AC-450 Created Admission simple Jun 13, 2020
Copy link
Collaborator

@f4ww4z f4ww4z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishabh-997 I'm not able to access any forms during a patient's visit, it was working fine before this PR. Tested on API level 21. Maybe you need to re-display the 3 forms?

https://streamable.com/js9hgi

@f4ww4z
Copy link
Collaborator

f4ww4z commented Jun 18, 2020

but @rishabh-997 AC-478 hasnt been done yet because from the conversation I can gather is that it requires the room migration to be complete means removing tables before implementing SQLCipher??

@LuGO0 Room migration doesn't necessarily mean removing the ActiveAndroid tables, we can just transfer the database functionality to Room first, including encryption, then remove ActiveAndroid-related things from the codebase.

@rishabh-997
Copy link
Collaborator Author

@rishabh-997 I'm not able to access any forms during a patient's visit, it was working fine before this PR. Tested on API level 21. Maybe you need to re-display the 3 forms?

https://streamable.com/js9hgi

actually what i observed is the forms appear after the second or third run of the app after a clean install. Can you close the app completely and try again. Or I will look into it

@f4ww4z
Copy link
Collaborator

f4ww4z commented Jun 18, 2020

image

Excellent work @rishabh-997 , seems stable to me.

What we can do is to add a message when the patient visit activity is blank, telling the user to click 'Form Entry'. Also when the list of forms are blank, we should display a 'try restarting the app' message. We can file new JIRA issues for this.

Otherwise, this PR looks good to me.

@rishabh-997
Copy link
Collaborator Author

rishabh-997 commented Jun 18, 2020

Thanks, was definitely one of the most challenging tasks. I guess a code review is all that's left to merge it. Will create a new issue as said and ping u there
download

@f4ww4z f4ww4z merged commit 6093f65 into openmrs:master Jun 18, 2020
@LuGO0
Copy link
Collaborator

LuGO0 commented Jun 18, 2020

@rishabh-997 I felt the same after provider Module PR was merged 😄😄😋

@rishabh-997 rishabh-997 deleted the admission_simple branch July 14, 2020 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants