Project: Implement Spring Data to LibreHealth Toolkit

@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.

1 Like

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

1 Like

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.

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

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.

@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.

@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.

@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.

2 Likes

@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 org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174) at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getReadValue(MappingCassandraConverter.j

Do you have any idea about this?

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(JsonMappingException.java:391) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:351) at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:316) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:727) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:727) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:719) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319) at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3893) at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3207) at org.librehealth.fhir.platform.converter.ConvertUtils.toString(ConvertUtils.java:21) … 57 common frames omitted Caused by: java.lang.NullPointerException: null at org.hl7.fhir.dstu3.model.DateTimeType.getTzSign(DateTimeType.java:182) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:688) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:719) … 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.

@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.

1 Like

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

@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.

1 Like

@sunbiz @judywawira I’ve completed my final evaluation. Here’s my GSoC 2018 final report https://medium.com/@yashdsaraf/gsoc-librehealth-final-report-210538d56b19

@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?

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

1 Like

@yashdsaraf I’m getting following error in your latest master and merged code with my branch when viewing the patients. Do you have any idea?

There was an unexpected error (type=Internal Server Error, status=500).

JSON encoding error: org.hl7.fhir.dstu3.model.Encounter$EncounterStatus cannot be cast to org.hl7.fhir.dstu3.model.Enumerations$AdministrativeGender; nested exception is com.fasterxml.jackson.databind.JsonMappingException: org.hl7.fhir.dstu3.model.Encounter$EncounterStatus cannot be cast to org.hl7.fhir.dstu3.model.Enumerations$AdministrativeGender (through reference chain: java.util.ArrayList[0]->org.openmrs.model.CPatient[“gender”])

1 Like

The enumeration converter factory is the culprit here. It handles all the Enumeration<?> type data. I faced this issue as well when the data type couldn’t be determined properly and it tried to cast the data to the wrong type.
Here’s the code for enumeration converter factory - link.
I’ll try to fix the error, any inputs on this are welcome. :slight_smile:

1 Like

@yashdsaraf Yes, I wonder why it trying to cast for Encounter type object. I also digging to this problem.