7
7
import org .openmrs .Patient ;
8
8
import org .openmrs .PatientProgram ;
9
9
import org .openmrs .Program ;
10
+ import org .openmrs .api .AdministrationService ;
10
11
import org .openmrs .api .ProgramWorkflowService ;
11
12
import org .openmrs .api .context .Context ;
12
13
import org .openmrs .module .appframework .domain .AppDescriptor ;
13
14
import org .openmrs .module .emrapi .patient .PatientDomainWrapper ;
15
+ import org .openmrs .ui .framework .UiFrameworkConstants ;
14
16
import org .openmrs .ui .framework .annotation .FragmentParam ;
15
17
import org .openmrs .ui .framework .annotation .InjectBeans ;
16
18
import org .openmrs .ui .framework .annotation .SpringBean ;
25
27
public class ProgramHistoryFragmentController {
26
28
27
29
public void controller (FragmentConfiguration config , @ FragmentParam ("app" ) AppDescriptor app , @ InjectBeans PatientDomainWrapper patientWrapper ,
28
- @ SpringBean ("programWorkflowService" ) ProgramWorkflowService programWorkflowService ) throws IOException {
30
+ @ SpringBean ("programWorkflowService" ) ProgramWorkflowService programWorkflowService ,
31
+ @ SpringBean ("adminService" )AdministrationService adminService
32
+ ) throws IOException {
29
33
30
34
ObjectMapper mapper = new ObjectMapper ();
31
35
@@ -51,6 +55,13 @@ public void controller(FragmentConfiguration config, @FragmentParam("app") AppDe
51
55
ObjectNode appConfig = app .getConfig ();
52
56
appConfig .put ("patientUuid" , patientWrapper .getPatient ().getUuid ());
53
57
58
+ if (appConfig .get ("dateFormat" ) == null ) {
59
+ appConfig .put ("dateFormat" , adminService .getGlobalProperty (UiFrameworkConstants .GP_FORMATTER_DATE_FORMAT , "yyyy-MM-dd" ));
60
+ }
61
+ if (appConfig .get ("JSDateFormat" ) == null ) {
62
+ appConfig .put ("JSDateFormat" , adminService .getGlobalProperty (UiFrameworkConstants .GP_FORMATTER_JS_DATE_FORMAT , "YYYY-MMM-DD" ));
63
+ }
64
+
54
65
if (appConfig .get ("program" ) == null || StringUtils .isEmpty (appConfig .get ("program" ).getTextValue ())) {
55
66
throw new MissingPropertyException ("Program must be specified" );
56
67
}
@@ -82,6 +93,7 @@ public void controller(FragmentConfiguration config, @FragmentParam("app") AppDe
82
93
Map <String , Object > appConfigMap = mapper .convertValue (appConfig , Map .class );
83
94
config .merge (appConfigMap );
84
95
config .addAttribute ("programJson" , programJson );
96
+
85
97
}
86
98
87
99
}
0 commit comments