Advertisement
Guest User

Untitled

a guest
Nov 27th, 2023
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. #set($patientClass = "org.openmrs.Patient")
  2. #set($personNameClass = "org.openmrs.PersonName")
  3. #set($encounterClass = "org.openmrs.Encounter")
  4. #set($patientIdentifierClass = "org.openmrs.PatientIdentifier")
  5. #set($personAttributeClass = "org.openmrs.PersonAttribute")
  6. #set($calendarClass = $util.loadClass("java.util.Calendar"))
  7. #set($personAddressClass = "org.openmrs.PersonAddress")
  8. #set($personPhoneAttributeTypeName = "Telephone Number")
  9. #set($personLanguageAttributeTypeName = "personLanguage")
  10. #set($patientIdentifierTypeClass = "org.openmrs.PatientIdentifierType")
  11. #set($locationClass = "org.openmrs.Location")
  12. #set($encounterProviderClass = "org.openmrs.EncounterProvider")
  13. #set($encounterType = "org.openmrs.EncounterType")
  14. #set($obs = "org.openmrs.Obs")
  15.  
  16. #foreach($row in $rows)
  17.  
  18. #*Encounter *#
  19. #set($encounter = $util.newObject($encounterClass))
  20.  
  21. #set($CONCEPT_UUIDS_FOR_PREDICTION_VALUE = [])
  22. $CONCEPT_UUIDS_FOR_PREDICTION_VALUE.add("1066")
  23. $CONCEPT_UUIDS_FOR_PREDICTION_VALUE.add("1065")
  24.  
  25. //generate new encouter id
  26.  
  27. #* patient *#
  28. #set($patient = $util.newObject($patientClass))
  29. //create all patient details
  30. #set($patientId = $row.patientId)
  31. //$ patient id from the db
  32. #set($patient = $patientService.getPatientById($patientId))
  33. #set($logFactory = $portal.getClass().forName('com.liferay.portal.kernel.log.LogFactoryUtil'))
  34. #set($log = $logFactory.getLog($patientId))
  35. //setting patient with only patient id
  36. $encounter.patient($patient)
  37.  
  38. #*Calendar*#
  39. #set($calendar = $util.newObject($calendarClass))
  40. #set($encounter.encounterDateTime= $row.visitDate)
  41.  
  42. #*location *#
  43. #set($location = $util.newObject("org.openmrs.Location"))
  44. #set($locationUuid = "3b7617c9-778f-4f48-83e7-5514eb6ed946")
  45. #set($encounter.location = $locationService.getLocationByUuid($locationUuid))
  46.  
  47. #*encounter type *#
  48. #set($encounterType = $util.newObject("org.openmrs.EncounterType"))
  49. #set($encounterTypeUuid = "43c3630f-abfe-4fe1-8c92-b73b65199a3d")
  50. #set($encounter.encounterType = $encounterService.getEncounterTypeByUuid($encounterTypeUuid))
  51.  
  52. // use set instead of arrayList
  53. #set($obsList = [])
  54. #set($obsDiarrhoea = $util.newObject("org.openmrs.Obs"))
  55. #set($obsDiarrhoea.concept = $ConceptService.getConceptByName("Diarrhoea"))
  56. #set($obsDiarrhoea.valueCoded = $CONCEPT_UUIDS_FOR_PREDICTION_VALUE)
  57. $obsList.add($obsDiarrhoea)
  58.  
  59. #set($obsParaparesis = $util.newObject("org.openmrs.Obs"))
  60. #set($obsParaparesis.concept = $ConceptService.getConceptByName("Paraparesis"))
  61. #set($obsParaparesis.valueCoded = $CONCEPT_UUIDS_FOR_PREDICTION_VALUE)
  62. $obsList.add($obsParaparesis)
  63.  
  64. #set($obsDiabetesMellitus = $util.newObject("org.openmrs.Obs"))
  65. #set($Concept = $util.newObject("org.openmrs.Concept"))
  66. #set($obsDiabetesMellitus.concept = $ConceptService.getConceptByName("Diabetes Mellitus"))
  67. #set($obsDiabetesMellitus.valueCoded = $CONCEPT_UUIDS_FOR_PREDICTION_VALUE)
  68. $obsList.add($obsDiabetesMellitus)
  69.  
  70. #set($obsRash = $util.newObject("org.openmrs.Obs"))
  71. #set($obsRash.concept = $ConceptService.getConceptByName("Rash"))
  72. #set($obsRash.valueCoded = $CONCEPT_UUIDS_FOR_PREDICTION_VALUE)
  73. $obsList.add($obsRash)
  74. $encounter.setObs($obsList)
  75.  
  76. $encounterService.saveEncounter($encounter)
  77.  
  78. #if($encounterService == $null)
  79. #log("Encounter Service is null")
  80. #end
  81. #end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement