forked from eRegister/bahmni_config092
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformConditions.js
1823 lines (1454 loc) · 88.9 KB
/
formConditions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Bahmni.ConceptSet.FormConditions.rules = {
//////////////////////////////////////////////////////////////////////////
/////////////////////////// Tuberculosis - Intake Form ///////////////////
/////////////////////////////////////////////////////////////////////////
'Genotypic test type performed': function (formName, formFieldValues) {
var genexpertTest = formFieldValues['Genotypic test type performed'];
var conditions = { show: [], hide: [] };
switch (genexpertTest) {
case "GeneXpert test type":
conditions.show.push("GeneXpert results");
conditions.hide.push("Line Probe Assay results");
break;
case "Line Probe Assay test type":
conditions.show.push("Line Probe Assay results");
conditions.hide.push("GeneXpert results");
break;
default:
conditions.hide.push("GeneXpert results", "Line Probe Assay results");
}
return conditions;
},
'TB Transfer in': function (formName, formFieldValues) {
var conditionConcept = formFieldValues['TB Transfer in'];
var conditions = { show: [], hide: [] };
if (conditionConcept == "Transfer In") {
conditions.show.push("HIVTC, Transferred in from");
} else {
conditions.hide.push("HIVTC, Transferred in from");
}
return conditions;
},
'Phase of TB Treatment': function (formName, formFieldValues) {
var result = formFieldValues['Phase of TB Treatment'];
var conditions = { enable: [], disable: []};
if (!result || result != 'Initial Treatment Phase') {
conditions.enable.push("TB Treatment outcome");
} else {
conditions.disable.push("TB Treatment outcome");
// conditions.disable.push("TB Action taken for treatment Failures and/or Drug resistant patients");
}
return conditions;
},
'Phenotypic Test type performed': function (formName, formFieldValues) {
var phenotipicTest = formFieldValues['Phenotypic Test type performed'];
var conditions = { show: [], hide: [] };
if (phenotipicTest) {
conditions.show.push("Phenotypic Test Results (ZN or C)");
} else {
conditions.hide.push("Phenotypic Test Results (ZN or C)");
}
return conditions;
},
'TB, HIV Status': function (formName, formFieldValues) {
var result = formFieldValues['TB, HIV Status'];
var conditions = { show: [], hide: [] };
if (!result || result == 'New Negative' || result == 'Known Negative') {
conditions.hide.push("TB, HIV Management");
} else {
conditions.show.push("TB, HIV Management");
}
return conditions;
},
'Site : P/EP': function (formName, formFieldValues) {
var result = formFieldValues['Site : P/EP'];
var conditions = { show: [], hide: [] };
if (!result || result != 'Extra Pulmonary') {
conditions.hide.push("TB, Site of Extra-pulmonary TB");
} else {
conditions.show.push("TB, Site of Extra-pulmonary TB");
}
return conditions;
},
'HIVTC, TB Screened': function (formName, formFieldValues) {
var result = formFieldValues['HIVTC, TB Screened'];
var conditions = { show: [], hide: [] };
if (result == 'Yes') {
conditions.show.push("TB Status");
} else {
conditions.hide.push("TB Status");
}
return conditions;
},
'HIVTC, Prior ART': function (formName, formFieldValues) {
var conditionConcept = formFieldValues['HIVTC, Prior ART'];
var conditions = { show: [], hide: [] };
if (conditionConcept == "Transfer In") {
conditions.show.push("HIVTC, Transferred in");
//conditions.hide.push("HIVTC, ART start date");
} else {
conditions.hide.push("HIVTC, Transferred in");
//conditions.show.push("HIVTC, ART start date");
}
return conditions;
},
'Refer or Consult': function (formName, formFieldValues) {
var conditionConcept = formFieldValues['Refer or Consult'];
var conditions = { show: [], hide: [] };
if (conditionConcept == "Provide nutritional support or infant feeding") {
conditions.show.push("HIVTC, Nutritional products");
} else {
//conditions.hide.push("HIVTC, Nutritional products");
}
return conditions;
},
'HTS, Referral': function (formName, formFieldValues) {
var result = formFieldValues['HTS, Referral'];
var conditions = { show: [], hide: [] };
if (result == "Referred") {
conditions.show.push("HTC, Referred Facility");
} else {
conditions.hide.push("HTC, Referred Facility");
}
return conditions;
},
/*--------------------------MCH Programme------------------------------*/
'Delivery Note, Delivery location': function (formName, formFieldValues) {
var DeliveryPlace = formFieldValues['Delivery Note, Delivery location'];
if ((formName == "PostNatal Care Register") || (formName == "Delivery Information") || (formName == "Lesotho Obstetric Record")) {
var conditions = { show: [], hide: [] };
if ((DeliveryPlace == "Institutional Delivery") || (DeliveryPlace == "Home Delivery")) {
conditions.show.push("Mode of Delivery");
} else {
conditions.hide.push("Mode of Delivery");
}
}
return conditions;
},
'ANC, Parity': function (formName, formFieldValues) {
var ANCGravida1 = formFieldValues['ANC, Gravida'];
var ANCParity = formFieldValues['ANC, Parity'];
var conditions = { show: [], hide: [], disable: [], enable: [] };
if (formName == "ANC, Obstetric History") {
if (ANCParity >= ANCGravida1) {
alert("Parity should be less than Gravida");
conditions.disable.push("ANC, Alive");
conditions.disable.push("ANC, Number of Miscarriages");
return conditions;
}
if (ANCParity < ANCGravida1) {
conditions.enable.push("ANC, Alive");
conditions.enable.push("ANC, Number of Miscarriages");
return conditions;
}
}
},
'ANC, Alive': function (formName, formFieldValues) {
var ANCAlive = formFieldValues['ANC, Alive'];
var ANCParity = formFieldValues['ANC, Parity'];
var conditions = { show: [], hide: [], disable: [], enable: [] };
if (formName == "ANC, Obstetric History") {
if (ANCAlive > ANCParity) {
alert("Children alive should be less or equal to number of parities");
conditions.disable.push("ANC, Number of Miscarriages");
return conditions;
}
if (ANCParity >= ANCAlive) {
conditions.enable.push("ANC, Number of Miscarriages");
return conditions;
}
}
},
'ANC, Gravida': function (formName, formFieldValues) {
var ANCGravida = formFieldValues['ANC, Gravida'];
if (formName == "ANC, Obstetric History") {
var conditions = { show: [], hide: [], disable: [] };
if (ANCGravida < "2") {
conditions.hide.push("ANC, Alive");
}
if (ANCGravida < "2") {
conditions.hide.push("ANC, Number of Miscarriages");
}
if (ANCGravida < "2") {
conditions.hide.push("ANC, Parity");
} else {
conditions.show.push("ANC, Parity");
conditions.show.push("ANC, Alive");
conditions.show.push("ANC, Number of Miscarriages");
}
}
return conditions;
},
'ANC, Family Planning Ever Used': function (formName, formFieldValues) {
var FPUsed = formFieldValues['ANC, Family Planning Ever Used'];
if (formName == "ANC, Gynaecological History") {
var conditions = { show: [], hide: [] };
if (FPUsed == "Yes") {
conditions.show.push("ANC, Family Planning Method")
conditions.show.push("ANC, Date Family Planning Stopped");
}
else {
conditions.hide.push("ANC, Family Planning Method");
conditions.hide.push("ANC, Date Family Planning Stopped");
}
}
return conditions;
},
'ANC, History of STI': function (formName, formFieldValues) {
var STIScreening = formFieldValues['ANC, History of STI'];
if (formName == "ANC, Gynaecological History") {
var conditions = { show: [], hide: [] };
if (STIScreening == "Yes") {
conditions.show.push("STI Treated");
conditions.show.push("ANC, Date STI Treated");
}
else {
conditions.hide.push("STI Treated");
conditions.hide.push("ANC, Date STI Treated");
}
}
return conditions;
},
'ANC, History of Miscarriages': function (formName, formFieldValues) {
var HistoryMis = formFieldValues['ANC, History of Miscarriages'];
if (formName == "ANC, Gynaecological History") {
var conditions = { show: [], hide: [] };
if (HistoryMis == "Yes") {
conditions.show.push("ANC, When")
conditions.show.push("Delivery Note, Gestation period");
conditions.show.push("Dilation and Curettage");
}
else {
conditions.hide.push("ANC, When");
conditions.hide.push("Delivery Note, Gestation period");
conditions.hide.push("Dilation and Curettage");
}
}
return conditions;
},
'ANC, TB': function (formName, formFieldValues) {
var TBHistory = formFieldValues['ANC, TB'];
if (formName == "ANC, Previous Medical History") {
var conditions = { show: [], hide: [] };
if (TBHistory == "Yes") {
conditions.show.push("ANC, Year");
conditions.show.push("ANC, TB Treatment Completed");
conditions.show.push("ANC, Date Completed");
}
else {
conditions.hide.push("ANC, Year");
conditions.hide.push("ANC, TB Treatment Completed");
conditions.hide.push("ANC, Date Completed");
}
}
return conditions;
},
'Any Surgery': function (formName, formFieldValues) {
var anySurgery = formFieldValues['Any Surgery'];
var conditions = { show: [], hide: [] };
if (anySurgery == "Yes") {
conditions.show.push("ANC, Type of Surgery");
} else if (!anySurgery || anySurgery != "Yes") {
conditions.hide.push("ANC, Type of Surgery");
}
return conditions;
},
'ANC, Type of Surgery': function (formName, formFieldValues) {
var typeOfSurgery = formFieldValues['ANC, Type of Surgery'];
var conditions = { show: [], hide: [] };
if (typeOfSurgery == "Surgery, Other") {
conditions.show.push("ANC, Surgery Specify");
} else if (!typeOfSurgery || typeOfSurgery != "Surgery, Other") {
conditions.hide.push("ANC, Surgery Specify");
}
return conditions;
},
'ANC, Came together': function (formName, formFieldValues) {
var MalePartner = formFieldValues['ANC, Came together'];
if (formName == "Male Partner Involvement") {
var conditions = { show: [], hide: [] };
if (MalePartner == "Yes") {
conditions.show.push("ANC, Partner HIV Status");
}
else {
conditions.hide.push("ANC, Partner HIV Status");
}
}
return conditions;
},
'ANC, Tested as Couple': function (formName, formFieldValues) {
var CoupleTest = formFieldValues['ANC, Tested as Couple'];
if (formName == "LOR, PMTCT") {
var conditions = { show: [], hide: [] };
if (CoupleTest == "Yes") {
conditions.show.push("ANC, Partner HIV Status");
}
else {
conditions.hide.push("ANC, Partner HIV Status");
}
}
return conditions;
},
'ANC, Syphilis Screening Results': function (formName, formFieldValues) {
var SyphilisScreening = formFieldValues['ANC, Syphilis Screening Results'];
if (formName == "ANC, Investigations and Immunisations") {
var conditions = { show: [], hide: [] };
if (SyphilisScreening == "Reactive") {
conditions.show.push("ANC, Syphilis Screening Treatment");
}
else {
conditions.hide.push("ANC, Syphilis Screening Treatment");
}
}
return conditions;
},
'ANC, Ever Had Pap Smear': function (formName, formFieldValues) {
var PapSmear = formFieldValues['ANC, Ever Had Pap Smear'];
if (formName == "ANC, Gynaecological History") {
var conditions = { show: [], hide: [] };
if (PapSmear == "Yes") {
conditions.show.push("Results of Pap Smear");
conditions.show.push("ANC, Pap Smear Date");
}
else {
conditions.hide.push("Results of Pap Smear");
conditions.hide.push("ANC, Pap Smear Date");
}
}
return conditions;
},
'ANC, Type of Mother Baby Pack': function (formName, formFieldValues) {
var MBPack = formFieldValues['ANC, Type of Mother Baby Pack'];
if (formName == "ANC Register") {
var conditions = { show: [], hide: [] };
if (MBPack == "ANC, No Pack Given") {
conditions.hide.push("ANC, Adherence level to MBP");
} else {
conditions.show.push("ANC, Adherence level to MBP");
}
}
return conditions;
},
'Tested in PNC': function (formName, formFieldValues) {
var TestedInPNC = formFieldValues['Tested in PNC'];
if ((formName == "PostNatal Care Register") || (formName == "HIV Prevention, Care, and Treatment")) {
var conditions = { show: [], hide: [] };
if (TestedInPNC == "Positive") {
conditions.show.push("PMTCT, WHO clinical staging")
conditions.show.push("PNC, On ART Treatment");
} else {
conditions.hide.push("PMTCT, WHO clinical staging")
conditions.hide.push("PNC, On ART Treatment");
}
}
return conditions;
},
'ANC, Visit Types': function (formName, formFieldValues) {
var AncVisits = formFieldValues['ANC, Visit Types'];
if (formName == "ANC, ANC Program") {
var conditions = { show: [], hide: [], disable: [] };
if (AncVisits == "ANC, First Visit") {
conditions.show.push("Lesotho Obstetric Record")
conditions.hide.push("ANC Register");
//conditions.disable.push("ANC, Estimated Date of Delivery");
return conditions;
}
else if (AncVisits == "ANC, Subsequent Visit") {
conditions.show.push("ANC Register")
conditions.hide.push("Lesotho Obstetric Record");
return conditions;
}
else {
conditions.hide.push("Lesotho Obstetric Record")
conditions.hide.push("ANC Register");
return conditions;
}
}
},
'PNC, HIV Status Known Before Visit': function (formName, formFieldValues) {
var knownStatus = formFieldValues['PNC, HIV Status Known Before Visit'];
if (formName == "LOR, PMTCT") {
var conditions = { show: [], hide: [] };
if (knownStatus == "Positive") {
conditions.hide.push("HTC, Final HIV status");
}
else {
conditions.show.push("HTC, Final HIV status");
}
}
return conditions;
},
'HTC, Final HIV status': function (formName, formFieldValues) {
var finalStatus = formFieldValues['HTC, Final HIV status'];
if (formName == "LOR, PMTCT") {
var conditions = { show: [], hide: [] };
if (finalStatus == "Negative") {
conditions.hide.push("ANC, CD4 Count Date")
conditions.hide.push("HIVTC, ART Regimen")
conditions.hide.push("PMTCT, ART start date");
}
else {
conditions.show.push("ANC, CD4 Count Date")
conditions.show.push("HIVTC, ART Regimen")
conditions.show.push("PMTCT, ART start date");
}
}
return conditions;
},
/*-----
'HTC, Partner Testing and Counseling' : function (formName, formFieldValues) {
var coupleTest = formFieldValues['HTC, Partner Testing and Counseling'];
if(formName == "LOR, PMTCT") {
var conditions = {show: [], hide: [], enable: [], disable: []};
if(coupleTest == "Yes") {
conditions.show.push("Partner HIV Status");
}
else {
conditions.hide.push("Partner HIV Status");
}
return conditions;
},
-----*/
'PNC, Initiated on Family Planning': function (formName, formFieldValues) {
var InitiatedFP = formFieldValues['PNC, Initiated on Family Planning'];
if (formName == "PostNatal Care Register") {
var conditions = { show: [], hide: [] };
if (InitiatedFP == "Yes") {
conditions.show.push("FP, Family Planning Method");
} else {
conditions.hide.push("FP, Family Planning Method");
}
}
return conditions;
},
/*--------------------------------CERVICAL CANCER SCREENING----------------------------------------------------------*/
'Cervical Cancer Screening': function (formName, formFieldValues) {
var CancerScreened = formFieldValues['Cervical Cancer Screening'];
if (formName == "PostNatal Care Register") {
var conditions = { show: [], hide: [] };
if (CancerScreened == "Yes") {
conditions.show.push("Cervical Cancer Assessment Method");
} else {
conditions.hide.push("Cervical Cancer Assessment Method")
conditions.hide.push("VIA Test")
conditions.hide.push("Results of Pap Smear");
}
}
return conditions;
},
'Cervical Cancer Screening Register': function (formName, formFieldValues, patient) {
if (formName == "Cervical Cancer Screening Register") {
//var conditionConcept = formFieldValues['HTC, Pregnancy Status'];
var patientAge = patient['age'];
var patientGender = patient['gender'];
var conditions = { show: [], hide: [], enable: [], disable: [] };
if (patientGender == "F" && patientAge > 12) {
conditions.enable.push("Cervical Cancer Screening Register");
}
else {
conditions.hide.push("Level of Education");
}
return conditions;
}
},
'Previous Screening for CACX': function (formName, formFieldValues) {
var PreviousCancer = formFieldValues['Previous Screening for CACX'];
var conditions = { show: [], hide: [] };
if (formName == "Previous Cancer Screening") {
if (PreviousCancer == "Yes") {
conditions.show.push("CACX Screening Date");
conditions.show.push("CACX Screening Results");
}
else {
conditions.hide.push("CACX Screening Date");
conditions.hide.push("CACX Screening Results");
}
}
return conditions;
},
'Type of Screening Offered': function (formName, formFieldValues) {
var CancerAssessment = formFieldValues['Type of Screening Offered'];
var conditions = { show: [], hide: [] };
if (formName == "Cervical Cancer Screening Register") {
if (CancerAssessment == "VIA Test") {
conditions.show.push("VIA Test");
conditions.hide.push("Results of Pap Smear");
}
else if (CancerAssessment == "Pap Smear") {
conditions.show.push("Results of Pap Smear");
conditions.hide.push("VIA Test");
}
else if (CancerAssessment == "Both") {
conditions.show.push("Results of Pap Smear");
conditions.show.push("VIA Test");
}
else {
conditions.hide.push("VIA Test");
conditions.hide.push("Results of Pap Smear");
}
}
return conditions;
},
'HIV Status': function (formName, formFieldValues) {
var Cancerhivstatusresults = formFieldValues['HIV Status'];
var conditions = { show: [], hide: [] };
if (formName == "Cervical Cancer Screening Register") {
if (Cancerhivstatusresults == "Positive") {
conditions.hide.push("PITC Offered");
conditions.hide.push("PITC Results");
}
else {
conditions.show.push("PITC Offered");
conditions.show.push("PITC Results");
}
}
return conditions;
},
'Cervical Cancer Assessment Method': function (formName, formFieldValues) {
var CancerAssessment = formFieldValues['Cervical Cancer Assessment Method'];
if (formName == "PostNatal Care Register") {
var conditions = { show: [], hide: [] };
if (CancerAssessment == "VIA") {
conditions.show.push("VIA Test")
conditions.hide.push("Results of Pap Smear");
}
else if (CancerAssessment == "Pap Smear") {
conditions.show.push("Results of Pap Smear")
conditions.hide.push("VIA Test");
}
else {
conditions.hide.push("VIA Test")
conditions.hide.push("Results of Pap Smear");
}
}
return conditions;
},
'Refer or Consult': function (formName, formFieldValues) {
var conditionConcept = formFieldValues['Refer or Consult'];
var conditions = { show: [], hide: [] };
if (conditionConcept == "Provide nutritional support or infant feeding") {
conditions.show.push("HIVTC, Nutritional products");
} else {
//conditions.hide.push("HIVTC, Nutritional products");
}
return conditions;
},
/*-----
'HIVTC, Treatment substituted date' : function (formName, formFieldValues) {
var conditionConcept = formFieldValues['HIVTC, Treatment substituted date'];
var conditions = {enable: [], disable: [], show: [], hide: []};
if (conditionConcept){
conditions.enable.push("HIVTC, Adult 1st Line Regimen")
conditions.enable.push("HIVTC, Adult 2nd Line Regimen")
conditions.enable.push("HIVTC, Children 1st Line Regimen")
conditions.enable.push("HIVTC, Children 2nd Line Regimen")
conditions.enable.push("HIVTC, Adult 3rd Line Regimen")
conditions.enable.push("HIVTC, Children 3rd Line Regimen")
conditions.enable.push("HIVTC, Reason for treatment substitution");
}else {
conditions.disable.push("HIVTC, Reason for treatment substitution")
conditions.disable.push("HIVTC, Adult 1st Line Regimen")
conditions.disable.push("HIVTC, Adult 2nd Line Regimen")
conditions.disable.push("HIVTC, Adult 3rd Line Regimen")
conditions.disable.push("HIVTC, Children 1st Line Regimen")
conditions.disable.push("HIVTC, Children 2nd Line Regimen")
conditions.disable.push("HIVTC, Children 3rd Line Regimen");
}
return conditions;
},
-----*/
'HIVTC, Treatment switched date': function (formName, formFieldValues) {
var conditionConcept = formFieldValues['HIVTC, Treatment switched date'];
var conditions = { enable: [], disable: [] };
if (conditionConcept) {
conditions.enable.push("HIVTC, Reason for treatment switch")
conditions.enable.push("HIVTC, Name of Switched Regimen");
} else {
conditions.disable.push("HIVTC, Reason for treatment switch")
conditions.disable.push("HIVTC, Name of Switched Regimen");
}
return conditions;
},
'HIVTC, Viral Load Result': function (formName, formFieldValues, ViralLoadDate) {
var conditionConcept = formFieldValues['HIVTC, Viral Load Result'];
var viralloadDate = ViralLoadDate['HIVTC, Viral load blood results return date'];
var conditions = { show: [], hide: [] };
if (conditionConcept == 'Greater or equals to 20' || 'Less than 20' || 'Undetectable') {
//conditions.show.push("HIVTC, Date VL Results received");
if (conditionConcept == 'Greater or equals to 20') {
conditions.show.push("HIVTC, Viral Load");
conditions.show.push("HIVTC, Viral Load Data");
}
else {
conditions.hide.push("HIVTC, Viral Load");
conditions.hide.push("HIVTC, Viral Load Data");
}
}
else {
//condition.hide.push("HIVTC, Date VL Results received");
}
return conditions;
},
'HIVTC, Action to Record Viral Load Results': function (formName, formFieldValues, patient) {
var conditionConcept = formFieldValues['HIVTC, Action to Record Viral Load Results'];
var patientAge = patient['age'];
var patientGender = patient['gender'];
var conditions = { show: [], hide: [], enable: [], disable: [] };
if (conditionConcept.includes('Viral Load Result') && !conditionConcept.includes('HIVTC, Draw Blood for VL Test')) {
// Visible fields
conditions.show.push("HIVTC, Viral Load Result");
conditions.show.push("HIVTC, Viral Load Data");
conditions.show.push("HIVTC, Viral load blood results return date");
conditions.show.push("HIVTC, Date VL Result given to patient");
// Hidden fields
conditions.hide.push("HIVTC, Viral Load Blood drawn date");
conditions.hide.push("HIVTC, VL Pregnancy Status");
conditions.hide.push("HIVTC, VL Breastfeeding Status");
conditions.hide.push("HIVTC, Viral Load Monitoring Type");
// Hide Pregnancy and Breastfeeding fields for Males and Young children
if (patientAge < 12 || patientAge > 49 || patientGender == "M") {
conditions.hide.push("HIVTC, VL Pregnancy Status");
conditions.hide.push("HIVTC, VL Breastfeeding Status");
}
} else if (conditionConcept.includes('HIVTC, Draw Blood for VL Test') && !conditionConcept.includes('Viral Load Result')) {
conditions.show.push("HIVTC, Viral Load Blood drawn date");
conditions.show.push("HIVTC, VL Pregnancy Status");
conditions.show.push("HIVTC, VL Breastfeeding Status");
conditions.show.push("HIVTC, Viral Load Monitoring Type");
// Hidden fields
conditions.hide.push("HIVTC, Viral Load Result");
conditions.hide.push("HIVTC, Viral Load Data");
conditions.hide.push("HIVTC, Viral load blood results return date");
conditions.hide.push("HIVTC, Date VL Result given to patient");
// Hide Pregnancy and Breastfeeding fields for Males and Young children
if (patientAge < 12 || patientAge > 49 || patientGender == "M") {
conditions.hide.push("HIVTC, VL Pregnancy Status");
conditions.hide.push("HIVTC, VL Breastfeeding Status");
}
} else if (conditionConcept.includes('HIVTC, Draw Blood for VL Test') && conditionConcept.includes('Viral Load Result')) {
// Visible fields
conditions.show.push("HIVTC, Viral Load Result");
conditions.show.push("HIVTC, Viral Load Data");
conditions.show.push("HIVTC, Viral load blood results return date");
conditions.show.push("HIVTC, Date VL Result given to patient");
conditions.show.push("HIVTC, Viral Load Blood drawn date");
conditions.show.push("HIVTC, VL Pregnancy Status");
conditions.show.push("HIVTC, VL Breastfeeding Status");
conditions.show.push("HIVTC, Viral Load Monitoring Type");
// Hide Pregnancy and Breastfeeding fields for Males and Young children
if (patientAge < 12 || patientAge > 49 || patientGender == "M") {
conditions.hide.push("HIVTC, VL Pregnancy Status");
conditions.hide.push("HIVTC, VL Breastfeeding Status");
}
} else {
// Hide everything except Record Viral Load Results field
conditions.hide.push("HIVTC, Viral Load Data");
conditions.hide.push("HIVTC, Viral load blood results return date");
conditions.hide.push("HIVTC, Date VL Result given to patient");
conditions.hide.push("HIVTC, Viral Load Blood drawn date");
conditions.hide.push("HIVTC, VL Pregnancy Status");
conditions.hide.push("HIVTC, VL Breastfeeding Status");
conditions.hide.push("HIVTC, Viral Load Monitoring Type");
conditions.hide.push("HIVTC, Viral Load Result");
}
return conditions;
},
'HTC, Pregnancy Status': function (formName, formFieldValues, patient) {
if ((formName == "HIV Treatment and Care Progress Template") || (formName == "HIVTC, Patient Register")) {
var conditionConcept = formFieldValues['HTC, Pregnancy Status'];
var patientAge = patient['age'];
var patientGender = patient['gender'];
var conditions = { show: [], hide: [], enable: [], disable: [] };
if (patientGender == "F" && conditionConcept == "Pregnancy") {
conditions.show.push("HIVTC, Pregnancy Estimated Date of Delivery");
conditions.hide.push("Currently on FP");
conditions.hide.push("HIVTC, FP methods used by the patient");
}
else if ((patientGender == "F" && patientAge > 12 && conditionConcept == "Pregnancy") || patientAge < 5) {
conditions.show.push("IMAM, MUAC");
if (patientAge < 5) {
conditions.hide.push("HIVTC, Pregnancy Estimated Date of Delivery");
conditions.hide.push("Currently on FP");
conditions.hide.push("HIVTC, FP methods used by the patient");
conditions.hide.push("PMTCT, Referred if the status is unknown");
}
}
else {
conditions.hide.push("IMAM, MUAC");
conditions.hide.push("HIVTC, Pregnancy Estimated Date of Delivery");
conditions.hide.push("Currently on FP");
conditions.hide.push("HIVTC, FP methods used by the patient");
conditions.hide.push("PMTCT, Referred if the status is unknown");
}
return conditions;
}
},
'TB Status': function (formName, formFieldValues) {
var conditionConcept = formFieldValues['TB Status'];
var conditions = { show: [], hide: [] };
if (conditionConcept == "Suspected / Probable") {
conditions.show.push("TB Suspect signs");
} else {
conditions.hide.push("TB Suspect signs");
}
return conditions;
},
'PNC, HIV Status Known Before Visit': function (formName, formFieldValues) {
var conditionConcept = formFieldValues['PNC, HIV Status Known Before Visit'];
var conditions = { show: [], hide: [] };
if (formName == "HIV Prevention, Care, and Treatment") {
if (conditionConcept == "Positive") {
conditions.hide.push("Tested in PNC");
} else {
conditions.show.push("Tested in PNC");
}
return conditions;
}
},
/*---------------------HIV Care and Treatment-------------------*/
'Transfer Out to another site': function (formName, formFieldValues) {
var conditionConcept = formFieldValues['Transfer Out to another site'];
var conditions = { show: [], hide: [] };
if (conditionConcept == "Yes") {
conditions.show.push("HIVTC, Transferred out");
} else {
conditions.hide.push("HIVTC, Transferred out");
}
return conditions;
},
'Type of client': function (formName, formFieldValues, patient) {
var conditionConcept = formFieldValues['Type of client'];
var conditions = { show: [], hide: [], enable: [], disable: [] };
var patientAge = patient['age'];
var patientGender = patient['gender'];
/*-- Ensure that the ART regimen field is always disabled --*/
conditions.disable.push("HIVTC, ART Regimen");
if (conditionConcept == "Treatment Buddy") {
conditions.hide.push("HTC, Pregnancy Status");
conditions.hide.push("Function");
conditions.hide.push("HIVTC, HIV care WHO Staging");
conditions.hide.push("HIVTC, Treatment Staging");
conditions.hide.push("TB Status");
conditions.hide.push("TB Suspect signs");
conditions.hide.push("Sexually Transmitted Infection");
conditions.hide.push("Potential Side Effects");
conditions.hide.push("OI, Opportunistic infections");
conditions.hide.push("Refer or Consult");
conditions.hide.push("Number of days hospitalised");
} else {
conditions.show.push("HTC, Pregnancy Status");
conditions.show.push("Function");
conditions.show.push("HIVTC, HIV care WHO Staging");
conditions.show.push("HIVTC, Treatment Staging");
conditions.show.push("TB Status");
conditions.show.push("TB Suspect signs");
conditions.show.push("Sexually Transmitted Infection");
conditions.show.push("Potential Side Effects");
conditions.show.push("OI, Opportunistic infections");
conditions.show.push("Refer or Consult");
conditions.show.push("Number of days hospitalised");
}
if ((patientGender == "F") && (patientAge > 12 || patientAge < 50)) {
conditions.show.push("HTC, Pregnancy Status");
} else {
conditions.hide.push("HTC, Pregnancy Status");
}
return conditions;
},
/*--- ARV Drug days and drug supply duration generic autocalculations---- */
'ART, Follow-up date' : function (formName, formFieldValues) {
if(formName=="HIVTC, Patient Register") {
var followUpDate = formFieldValues['ART, Follow-up date'];
var conditions = { assignedValues: [], error: [] };
var dateUtil = Bahmni.Common.Util.DateUtil;
var retrospectiveDate = $.cookie(Bahmni.Common.Constants.retrospectiveEntryEncounterDateCookieName);
if(followUpDate) {
var daysDispesed;
if(!retrospectiveDate) {
daysDispensed = dateUtil.diffInDaysRegardlessOfTime(dateUtil.now(), followUpDate);
} else {
daysDispensed = dateUtil.diffInDaysRegardlessOfTime(dateUtil.parse(retrospectiveDate.substr(1, 10)), followUpDate);
}
// if(daysDispensed <= 0) {
// conditions.error.push("Invalid input for Follow-up Date, must be a date in the future. Please correct.");
// conditions.assignedValues.push({ field: "ARV drugs No. of days dispensed", fieldValue: daysDispensed });
// } else {
var drugSupplyPeriod = "";
if(daysDispensed >= 10 && daysDispensed < 21) {
// Providing 3 days slack from 2 weeks, in case of weekends or other reasons
drugSupplyPeriod = "HIVTC, Two weeks supply";
} else if (daysDispensed >= 28 && daysDispensed < 56) {
drugSupplyPeriod = "HIVTC, One month supply";
} else if (daysDispensed >= 56 && daysDispensed < 84 ) {
drugSupplyPeriod = "HIVTC, Two months supply";
} else if (daysDispensed >= 84 && daysDispensed < 112) {
drugSupplyPeriod = "HIVTC, Three months supply";
} else if (daysDispensed >= 112 && daysDispensed < 140) {
drugSupplyPeriod = "HIVTC, Four months supply";
} else if (daysDispensed >= 140 && daysDispensed < 168) {
drugSupplyPeriod = "HIVTC, Five months supply";
} else if (daysDispensed >= 168 && daysDispensed < 196) {
drugSupplyPeriod = "HIVTC, Six months supply";
} else if (daysDispensed >= 196) {
drugSupplyPeriod = "HIVTC, Seven+ months supply";
} else {
// No action
}
conditions.assignedValues.push({ field: "ARV drugs No. of days dispensed", fieldValue: daysDispensed, autocalculate:true });
conditions.assignedValues.push({ field: "HIVTC, ARV drugs supply duration", fieldValue: drugSupplyPeriod, autocalculate:true });
// }
}
return conditions;
}
},
/*--- TB number of days dispensed generic autocalculation----*/
'TB, Next appointment/refill date' : function (formName, formFieldValues) {
if(formName=="Tuberculosis Followup Template") {
var followUpDate = formFieldValues['TB, Next appointment/refill date'];
var conditions = { assignedValues: [], error: [] };
var dateUtil = Bahmni.Common.Util.DateUtil;
var retrospectiveDate = $.cookie(Bahmni.Common.Constants.retrospectiveEntryEncounterDateCookieName);