Project: Implement Spring Data to LibreHealth Toolkit


(Yash D. Saraf) #81

@sunbiz Here’s the blog post for my last week’s progress
There are a couple of serialization issues left and then CRUD for patient would be complete.

(Yash D. Saraf) #82

@sunbiz I’ve added all the Patient’s attributes to the primitive search mechanism I wrote. Also the error for primitive types getting detected as JSON is fixed, though I’m sure the fix can be optimised.
After a lot of trial I still haven’t figured out how to handle the Resource type using spring converters.
The culprit property in this case is contained which is of type List<Resource>. The problem here is if I write a converter for Resource I get a PersistentEntity not found error, and if I write a converter for List<Resource>, due to how the type is handled in Spring Data Cassandra, the generic type is erased and this converter is used for all the List<?> type properties. Any ideas?
P.S this means that if we ignore the contained property, complete CRUD for Patient works.

(Yash D. Saraf) #83

@sunbiz The Resource serialization has finally been fixed, I had to extend the CassandraMappingContext and tell it to ignore all the classes annotated with @Table. I’ll describe the issue and its fix more thoroughly in a blog post beside my weekly post.
I’m checking out @prashadi’s project now and trying to figure out which way to go to make our projects work together. Next I’ll work on adding more resources (specifically the ones mentioned in @prashadi’s blog post).

(Prashadi) #84

@yashdsaraf i’m going through your code base to merge with my code base. Shall we change the package name openmrs to librehealth?

(Yash D. Saraf) #85

@prashadi Let me merge the patient-crud branch into master then we can go on to renaming the package. Also I kept the name org.openmrs since that’s what is used in the original toolkit as well - see here.

(Prashadi) #86

@yashdsaraf since we building the platform from the beginning, I think we can use librehealth.

(Yash D. Saraf) #87

Alright, I’ve merged the patient-crud branch. Master is now up to date, we can make the changes now. I’ve also added you as a developer on the repository on gitlab.

(Prashadi) #88

@yashdsaraf thank you. One more question. Is your module require cassandra 3.x and is it a must?

(Yash D. Saraf) #89

I’m using SASI indexing to create secondary indexes for using LIKE operations on certain fields. I believe SASI support was introduced in Cassandra 3. Although I’m not sure if it works on earlier versions as well.

(Yash D. Saraf) #90

@sunbiz I’ve got the minimal properties of Observation model up and running, I’ll be able to push the complete model by tomorrow. I’ve also started working on the Encounter model, CRUD (without search) for both of these models should be ready in a couple of days.

(Yash D. Saraf) #91

@sunbiz I’ve encountered an obstacle in implementing Observation, this issue is that Observation has a property status with data type Enumeration<ObservationStatus> and again due to type erasure in Spring Cassandra’s conversion mechanism it is passed to the Enumeration<AdministrativeGender> converter instead.
I tried temporarily disabling the property by marking its getter/setters with @Transient but that doesn’t seem to work either.
I’ve tried other types of converters (ConverterFactory and GenericConverter) but none of them worked due to type erasure. (i.e Even though I write type specific converter say Enumeration<ObservationStatus>, the conversion mechanism passes all the Enumeration<?> data to it.)
We need a way for instructing the mechanism to use property specific converters or to notice the generic types.

(Yash D. Saraf) #92

@sunbiz I’ve pushed the Observation model and will be pushing the Encounter model today. My next step will be to migrate the existing routerfunctions to controllers and making the code mergeable for @prashadi 's project.

(Prashadi) #93

@yashdsaraf I have successfully configured your project to insert patient data with some minor modifications. After my demo data is inserted for patient, I’m getting following error when retrieving the patient list.

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [org.hl7.fhir.dstu3.model.HumanName] at at at at

Do you have any idea about this?

(Prashadi) #94

Also I got following exception while demo data is getting insert.

Caused by: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.hl7.fhir.dstu3.model.Attachment[“creationElement”]->org.hl7.fhir.dstu3.model.DateTimeType[“tzSign”]) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath( at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath( at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow( at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields( at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize( at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField( at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields( at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize( at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize( at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue( at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue( at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString( at org.librehealth.fhir.platform.converter.ConvertUtils.toString( … 57 common frames omitted Caused by: java.lang.NullPointerException: null at org.hl7.fhir.dstu3.model.DateTimeType.getTzSign( at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke( at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField( at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields( … 66 common frames omitted

And I change the converter as follow which might not be the right option.

public String toString(Object object) { try { return JacksonConfig.mapper.writeValueAsString(object); } catch (JsonProcessingException e) { return “”; } }

Do you think any other suggestion that we can overcome the above error? I have committed the code to master branch if you need to look at it.

(Yash D. Saraf) #95

@prashadi I fixed this error in one of my recent commits, see here

This can be fixed by adding a mixin for Attachment class and annotating the getCreationElement() function with @JsonIgnore. I think I can make a merge request for this, but it’ll take some time since I’m not near my setup right now.

(Prashadi) #96

That’s great. Thanks for the clarification @yashdsaraf.

(Yash D. Saraf) #97

@sunbiz I’ve pushed the Encounter model as well and @prashadi I’ve migrated all the existing handlers to restcontrollers. I also added the fixes for issues you mentioned in the last post. I couldn’t do extensive testing of the CRUD operations after migrating to restcontrollers, I will make sure it’s done by the end of the day.

(Yash D. Saraf) #98

@sunbiz @judywawira I’ve completed my final evaluation. Here’s my GSoC 2018 final report

(Prashadi) #99

@yashdsaraf that’s great. I was away for few days. I think we need to merge the new code from your branch and stabilize the modules. Is there any more changes that will come from you?

(Yash D. Saraf) #100

@prashadi I won’t be adding any new features for now, let’s first focus on getting the two projects to work together.