-
Notifications
You must be signed in to change notification settings - Fork 0
/
MEL_Functions.js
1261 lines (1161 loc) · 63.3 KB
/
MEL_Functions.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
/*=========================================================================
* @author Derry Everson
*
* Personal:
** https://www.arachnidserver.com
** dneverson@lcmail.lcsc.edu
*
* Sources for this can be found at:
** https://github.com/dneverson/CentricityAPILibrary
* Date: 03/28/2019
*========================================================================*/
/*=========================================================================
* **** FUNCTIONS ****
*========================================================================*/
/*=========================================================================
* ActiveObservations();
* Output: "Observations"
* Tested: true
*========================================================================*/
function ActiveObservations(){
return EvaluateMel('{ACTIVE_OBSERVATIONS}');
};
/*=========================================================================
* Example: {MEL_ADD_ALLERGY("ADVIL","severe vomiting",str(._TODAYSDATE),"557", 40,"","","C","Drug")}
* AddAllergy("ADVIL","severe vomiting","01/21/2019","557", 40,"","","C","Drug");
* (desc, (256 char)), (ID, DDID),
* code: reaction code(RASH = 1, SHOCK = 2, RESP = 4, GI = 8, HEME = 16, OTHER = 32) NOTE: Rash and GI = 1 + 8 = 9
* crit: severe reaction = S, moderate reaction = N, mild reaction = I
* Output: N/A
* Tested: true
*========================================================================*/
function AddAllergy(name, desc, startDate, ID, code, stopDate, crit, classification){
var result = EvaluateMel("{MEL_ADD_ALLERGY('"+name+"','"+desc+"','"+startDate+"','"+ID+"',"+code+",'"+stopDate+"','"+crit+"','"+classification+"')}", true);
if(result=="") ErrorMessage("Success","MEL_ADD_ALLERGY");
else ErrorMessage("Error: unsuccessful in adding the new allergy OR unable to acquire the allergy lock","MEL_ADD_ALLERGY");
};
/*=========================================================================
* Example: {MEL_ADD_ASSESSMENT(‘DX OF’,’CHOLERA’,’ICD10-S34.9’,’C’,’Pt traveled abroad recently’)}
* AddAssessment("DX OF","CHOLERA","ICD10-A00.9","C","Pt traveled abroad recently");
* type: DX OF = Diagnosis of (DEFAULT), MDXOF = Minor Diagnosis of (only for historical references)
* H/F = Hospitalized for, HX OF = History of, S/P = Status Post, R/O = Rule out, ? OF = Question of
* SX OF = Symptom of, RS OF = Risk of, NOTE: = Take Note of, FH OF = Family History of
* asmt: New or N, Improved or I, Unchanged or U, Deteriorated or D, Comment only or C
* Output: N/A
* Tested: true
*========================================================================*/
function AddAssessment(type, desc, codeIcd10, asmt, comm){
var result = EvaluateMel("{MEL_ADD_ASSESSMENT('"+type+"','"+desc+"','"+codeIcd10+"','"+asmt+"','"+comm+"')}", true);
if(result>="0") ErrorMessage("Success","MEL_ADD_ASSESSMENT");
else if(result=="-1") ErrorMessage("Problem type not provided","MEL_ADD_ASSESSMENT");
else if(result=="-2") ErrorMessage("Problem description not provided","MEL_ADD_ASSESSMENT");
else if(result=="-3") ErrorMessage("Assessment not provided or invalid","MEL_ADD_ASSESSMENT");
else if(result=="-4") ErrorMessage("The assessment is N (new), but the problem is not a new problem","MEL_ADD_ASSESSMENT");
else if(result=="-5") ErrorMessage("Can't match the problem for this assessment","MEL_ADD_ASSESSMENT");
else if(result=="-6") ErrorMessage("Can't get the clinical list lock","MEL_ADD_ASSESSMENT");
else if(result=="-7") ErrorMessage("Assessment comment exceeds maximum length","MEL_ADD_ASSESSMENT");
else if(result=="-8") ErrorMessage("Can't add the assessment for some other reason","MEL_ADD_ASSESSMENT");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_ADD_ASSESSMENT");
};
/*=========================================================================
* Example: {MEL_ADD_CARE_PLAN("Exercise to lose weight","289169006","Reduce 20 pounds","Walk daily for one hour. Have a light dinner.","2013/05/10","","123|234")}
* AddCarePlan("Exercise to lose weight","289169006","Reduce 20 pounds","Walk daily for one hour. Have a light dinner.","2013/05/10","","1848065703239670");
* optional: (SNOMEDCTCODE, (20 char)), (target,(255 char)), (instruct, (2000 char)), (endDate)
* Date formats: MM/DD/YYYY or YYYY/MM/DD
* Output: N/A
* Tested: true
*========================================================================*/
function AddCarePlan(goal, SNOMEDCTCODE, target, instruct, setDate, endDate, PRID){
var result = EvaluateMel("{MEL_ADD_CARE_PLAN('"+goal+"','"+SNOMEDCTCODE+"','"+target+"','"+instruct+"','"+setDate+"','"+endDate+"','"+PRID+"')}", true);
if(result>="0") ErrorMessage("Success","MEL_ADD_CARE_PLAN");
else if(result=="-1") ErrorMessage("Description is blank or too long","MEL_ADD_CARE_PLAN");
else if(result=="-2") ErrorMessage("Code is too long","MEL_ADD_CARE_PLAN");
else if(result=="-3") ErrorMessage("Target is too long","MEL_ADD_CARE_PLAN");
else if(result=="-4") ErrorMessage("Instruction is too long","MEL_ADD_CARE_PLAN");
else if(result=="-5") ErrorMessage("GoalSetDate is invalid","MEL_ADD_CARE_PLAN");
else if(result=="-6") ErrorMessage("GoalMetDate is invalid or less than GoalSetDate","MEL_ADD_CARE_PLAN");
else if(result=="-7") ErrorMessage("Invalid PRID","MEL_ADD_CARE_PLAN");
else if(result=="-8") ErrorMessage("Cannot add Care Plan for some other reason","MEL_ADD_CARE_PLAN");
else if(result=="-21") ErrorMessage("Service layer error","MEL_ADD_CARE_PLAN");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_ADD_CARE_PLAN");
};
/*=========================================================================
* Example: {MEL_ADD_DIRECTIVE("Donor-Cornea",str(._TODAYSDATE))}
* AddDirective("Donor-Cornea TEST","10/12/2018");
* Date formats: MM/DD/YYYY
* Output: N/A
* Tested: true
*========================================================================*/
function AddDirective(desc, startDate, endDate){
EvaluateMel("{MEL_ADD_DIRECTIVE('"+desc+"','"+startDate+"','"+endDate+"')}", true);
};
/*=========================================================================
* Example: {MEL_ADD_FHX("FH: Mitral Valve Regurgitation","1", "430730004","Had this for 2 years and then repaired through surgical procedure")}
* AddFHX("FH: Mitral Valve Regurgitation","1", "","Had this for 2 years and then repaired through surgical procedure");
* (desc, (255 char)), (ID, relationship code), (SNOMEDCTCODE, optional), (comm, (4000 char))
* Output: N/A
* Tested: true
*========================================================================*/
function AddFHX(desc, ID, SNOMEDCTCODE, comm){
var result = EvaluateMel("{MEL_ADD_FHX('"+desc+"','"+ID+"','"+SNOMEDCTCODE+"','"+comm+"')}", true);
if(result>="0") ErrorMessage("Success","MEL_ADD_FHX");
else if(result=="-1") ErrorMessage("Description is blank or too long","MEL_ADD_FHX");
else if(result=="-2") ErrorMessage("Relationship ID is invalid, empty, or too long","MEL_ADD_FHX");
else if(result=="-3") ErrorMessage("Invalid code or code is too long","MEL_ADD_FHX");
else if(result=="-4") ErrorMessage("Comment is too long","MEL_ADD_FHX");
else if(result=="-5") ErrorMessage("Cannot get the clinical list lock","MEL_ADD_FHX");
else if(result=="-6") ErrorMessage("Cannot add FHX for some other reason","MEL_ADD_FHX");
else if(result=="-21") ErrorMessage("Service layer error","MEL_ADD_FHX");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_ADD_FHX");
};
/*=========================================================================
* Example: {MEL_ADD_MEDICATION("Aspirin 500mg Tab", "1 po tid","03/01/2004",1926,"06/30/2006",250,3,"Y","Must use specific brand as indicated","ICD10-R45.8|ICD-401.1","ACUTE MI|HYPERTENSION","false","4005742")}
* AddMedication("Aspirin 500mg Tab", "1 po tid","03/01/2004",1926,"06/30/2006",250,3,"Y","Must use specific brand as indicated","ICD10-R45.8|ICD-401.1","ACUTE MI|HYPERTENSION","false","4005742");
* (ID, (DDID or NDCNUM)), (comm, (2000 char))
* Date formats: MM/DD/YYYY
* Output: N/A
* Tested: true
*========================================================================*/
function AddMedication(desc, instruct, startDate, ID, endDate, quanity, refills, BMN, comm, diagCode, codeDesc, printDx, RxNorm){
var result = EvaluateMel("{MEL_ADD_MEDICATION('"+desc+"','"+instruct+"','"+startDate+"','"+ID+"','"+endDate+"','"+quanity+"','"+refills+"','"+BMN+"','"+comm+"','"+diagCode+"','"+codeDesc+"','"+printDx+"','"+RxNorm+"')}", true);
if(result=="") ErrorMessage("Success","MEL_ADD_MEDICATION");
else ErrorMessage("Error: unable to acquire the medication lock OR unsuccessful in inserting the new medication","MEL_ADD_ALLERGY");
};
/*=========================================================================
Type ID Description
1 Provide TOC Referral Summary
2 Provide Clinical Visit Summary to Patient
3 Patient Reminder Sent
4 Initiated TOC with Patient
5 Patient Declined Clinical Visit Summary
12 Provide Patient Education
13 Reconciled TOC Medications
509 Successful unlink of patient validation from Patient Portal
510 Patient Portal Access Available
511 Chart summary viewed in Patient Portal
512 Chart summary downloaded from Patient Portal
513 Chart summary transmitted from Patient Portal
514 TOC/Referral Summary received by HISP
519 Clinical Visit Summary Sent to Patient
520 Secure Message sent by patient
521 Patient Care Reminder Sent
// window.alert(EvaluateMel('{GET_MUACTIVITY_LOG()}'));
*========================================================================*/
function AddMUActivityLog(activityID, loginName, description){
var result = EvaluateMel('{ADD_MUACTIVITY_LOG('+activityID+',"'+loginName+'","'+description+'")}', true);
if(result=="") ErrorMessage("Success","ADD_MUACTIVITY_LOG");
else if(result=="-1") ErrorMessage("Not enough parameters","ADD_MUACTIVITY_LOG");
else if(result=="-2") ErrorMessage("Invalid type for a parameter","ADD_MUACTIVITY_LOG");
else if(result=="-3") ErrorMessage("Too many parameters","ADD_MUACTIVITY_LOG");
else if(result=="-4") ErrorMessage("Invalid mu activity type log id","ADD_MUACTIVITY_LOG");
else if(result=="-5") ErrorMessage("Not in an active document","ADD_MUACTIVITY_LOG");
else if(result=="-6") ErrorMessage("There is not a current patient","ADD_MUACTIVITY_LOG");
else if(result=="-7") ErrorMessage("Invalid loginname","ADD_MUACTIVITY_LOG");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"ADD_MUACTIVITY_LOG");
};
/*=========================================================================
* Needs Work: Error: Invalid order category
* Example: {MEL_ADD_ORDER("S","Cardiology Fee Ticket","Dual Chamber Electronic Analysis with reprogramming","26","ICD10-R45.8|ICD-401.1","ACUTE MI|HYPERTENSION","Include interpretation","1","S","smitchell","08/22/2003")}
* AddOrder("S","Cardiology Fee Ticket","Dual Chamber Electronic Analysis with reprogramming","26","ICD10-R45.8|ICD-401.1","ACUTE MI|HYPERTENSION","Include interpretation","1","S","smitchell","08/22/2003");
* (type: T = Test, S = Service), (comm, (2000 char)), (units, optional)
* (priority, optional | N = normal, U = urgent, or S = stat)
* (auth: authorizing provider's login user name), (date, optional), (NDC, optional)
* Output: N/A
* Tested: true
*========================================================================*/
function AddOrder(type, cat, desc, mod, diagCode, codeDesc, comm, units, priority, auth, date, NDC){
var result = EvaluateMel("{MEL_ADD_ORDER('"+type+"','"+cat+"','"+desc+"','"+mod+"','"+diagCode+"','"+codeDesc+"','"+comm+"','"+units+"','"+priority+"','"+auth+"','"+date+"','"+NDC+"')}", true);
if(result=="0") ErrorMessage("Success","MEL_ADD_ORDER");
else if(result=="-1") ErrorMessage("Invalid Order Type","MEL_ADD_ORDER");
else if(result=="-2") ErrorMessage("Invalid order category","MEL_ADD_ORDER");
else if(result=="-3") ErrorMessage("Invalid Description","MEL_ADD_ORDER");
else if(result=="-4") ErrorMessage("Order obsolete","MEL_ADD_ORDER");
else if(result=="-5") ErrorMessage("Invalid Diagnosis Code","MEL_ADD_ORDER");
else if(result=="-6") ErrorMessage("Comments field too long","MEL_ADD_ORDER");
else if(result=="-7") ErrorMessage("Invalid Priority","MEL_ADD_ORDER");
else if(result=="-8") ErrorMessage("Invalid or obsolete authorizing provider","MEL_ADD_ORDER");
else if(result=="-9") ErrorMessage("Invalid order date","MEL_ADD_ORDER");
else if(result=="-10") ErrorMessage("Invalid Modifier","MEL_ADD_ORDER");
else if(result=="-11") ErrorMessage("Additional information is required for this order","MEL_ADD_ORDER");
else if(result=="-12") ErrorMessage("Unequal number of diagnosis codes and diagnosis code descriptions","MEL_ADD_ORDER");
else if(result=="-13") ErrorMessage("Invalid quantity or units","MEL_ADD_ORDER");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_ADD_ORDER");
};
/*=========================================================================
* Example: {MEL_ADD_PROBLEM(‘DX OF’,’Cholera’,’ICD-001.9’,str(._todaysdate),’’,’Pt. traveled in Africa’,’N’,’monitor for improvement’)}
* AddProblem("DX OF","Cholera", "ICD-001.9", "09/15/2012", "", "Pt. traveled in Africa" , "N", "monitor for improvement");
* type: DX OF = Diagnosis of (DEFAULT), MDXOF = Minor Diagnosis of (only for historical references)
* H/F = Hospitalized for, HX OF = History of, S/P = Status Post, R/O = Rule out, ? OF = Question of
* SX OF = Symptom of, RS OF = Risk of, NOTE: = Take Note of, FH OF = Family History of
* Date formats: MM/DD/YYYY or YYYY/MM/DD
* asmt: New or N, Improved or I, Unchanged or U, Deteriorated or D, Comment only or C
* comm, optional (2000 char)
* Output: N/A
* Tested: true
*========================================================================*/
function AddProblem(type, desc, code, startDate, endDate, annotate, asmt, comm){
var result = EvaluateMel("{MEL_ADD_PROBLEM('"+type+"','"+desc+"','"+code+"','"+startDate+"','"+endDate+"','"+annotate+"','"+asmt+"','"+comm+"')}", true);
if(result=="0") ErrorMessage("Success","MEL_ADD_PROBLEM");
else if(result=="-1") ErrorMessage("PRID is not valid","MEL_ADD_PROBLEM");
else if(result=="-2") ErrorMessage("description is too long","MEL_ADD_PROBLEM");
else if(result=="-3") ErrorMessage("code is not valid or the wrong code type","MEL_ADD_PROBLEM");
else if(result=="-4") ErrorMessage("startDate is not in the correct format","MEL_ADD_PROBLEM");
else if(result=="-5") ErrorMessage("startDate is not valid (for example, the date represents a future date)","MEL_ADD_PROBLEM");
else if(result=="-6") ErrorMessage("approxStart argument is not valid","MEL_ADD_PROBLEM");
else if(result=="-7") ErrorMessage("stopDate is not valid (for example, the date is earlier than the onset date)","MEL_ADD_PROBLEM");
else if(result=="-8") ErrorMessage("approxStop argument is not valid","MEL_ADD_PROBLEM");
else if(result=="-9") ErrorMessage("comment is not valid or too long","MEL_ADD_PROBLEM");
else if(result=="-10") ErrorMessage("clinical list lock cannot be obtained","MEL_ADD_PROBLEM");
else if(result=="-11") ErrorMessage("problem cannot be changed for some other reason","MEL_ADD_PROBLEM");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_ADD_PROBLEM");
};
/*=========================================================================
* Example: {MEL_CHANGE_ALLERGY("1684162535020210","severe vomiting", "str(._TODAYSDATE)","","S","DRUG")}
* ChangeAllergy('1848734265874110','severe vomiting', '01/12/2019','','S','DRUG');
* (ID, Allergy ID), (desc, optional, reation description (256 char))
* crit: C = Critical, S = Severe, N = Moderate, I = Mild
* classification: Drug, Food, Environmental
* Output: N/A
* Tested: true
*========================================================================*/
function ChangeAllergy(ID, desc, startDate, stopDate, crit, classification){
var result = EvaluateMel("{MEL_CHANGE_ALLERGY('"+ID+"','"+desc+"','"+startDate+"','"+stopDate+"','"+crit+"','"+classification+"')}", true);
if(result=="0") ErrorMessage("Success","MEL_CHANGE_ALLERGY");
else if(result=="-1") ErrorMessage("ID is not valid","MEL_CHANGE_ALLERGY");
else if(result=="-2") ErrorMessage("description is too long","MEL_CHANGE_ALLERGY");
else if(result=="-4") ErrorMessage("startDate is not in the correct format","MEL_CHANGE_ALLERGY");
else if(result=="-5") ErrorMessage("startDate is not valid (for example, the date represents a future date)","MEL_CHANGE_ALLERGY");
else if(result=="-6") ErrorMessage("stopDate is not in the correct format","MEL_CHANGE_ALLERGY");
else if(result=="-7") ErrorMessage("stopDate is not valid (for example, the date is earlier than the onset date)","MEL_CHANGE_ALLERGY");
else if(result=="-8") ErrorMessage("crit is not valid","MEL_CHANGE_ALLERGY");
else if(result=="-9") ErrorMessage("classification not valid","MEL_CHANGE_ALLERGY");
else if(result=="-10") ErrorMessage("clinical list lock cannot be obtained","MEL_CHANGE_ALLERGY");
else if(result=="-11") ErrorMessage("allergy cannot be changed for some other reason","MEL_CHANGE_ALLERGY");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_CHANGE_ALLERGY");
};
/*=========================================================================
* Needs Work: Error MID is not valid.
* Example: {MEL_CHANGE_MEDICATION ('1778144549000730', 'NITROGLYCERIN','Take 1 every hour', '2013/05/07', '2013/05/10', '51', '3', 'Y', 'Must use as indicated','ICD-253.9|ICD10-E23.3', 'ICD-253.9|ICD10-E23.3',True,5,"dispense as written","P",1225652472001060,"NY",'2013/05/06', "00590032496")}
* ChangeMedication("1848298730224840","NITROGLYCERIN","Take 1 every hour","2013/05/07","2013/05/10","51","3","Y","Must use as indicated","ICD-253.9|ICD10-E23.3","ICD-253.9|ICD10-E23.3",true,5,"dispense as written","P",1225652472001060,"NY","2013/05/06", "00590032496");
* (MID, medication ID), (desc, optional (80 char)), (instruct, optional), (quanity, optional), (refills, optional), (BMN, optional(Y = This prescription requires a brand medically necessary medication.
* (medComm, (2000 char)), (diagCode, optional), (codeDesc, optional), (printDx, required (true, false)), (pharmID, optional), (pharmComm, optional)
* (authID, optional), (RxState, optional), (RxDate, optional), (ID, DDID or NDCNUM)
* RxType: E = Electronic, W = Handwritten, H = Historical, F = Fax to Pharmacy, Q = Print then Fax to Pharmacy, P = Print then Give to Patient
* M = Print then Mail to Patient, L = Print then Mail to Pharmacy, S = Samples Given, T = Telephone, R = Reprint
* Date formats: MM/DD/YYYY
* Output: N/A
* Tested: true
*========================================================================*/
function ChangeMedication(MID, desc, instruct, startDate, stopDate, quanity, refills, BMN, medComm, diagCode, codeDesc, printDx, pharmID, pharmComm, RxType, authID, RxState, RxDate, ID){
var result = EvaluateMel("{MEL_CHANGE_MEDICATION('"+MID+"','"+desc+"','"+instruct+"','"+startDate+"','"+stopDate+"','"+quanity+"','"+refills+"','"+BMN+"','"+medComm+"','"+diagCode+"','"+codeDesc+"',"+printDx+",'"+pharmID+"','"+pharmComm+"','"+RxType+"','"+authID+"','"+RxState+"','"+RxDate+"','"+ID+"')}", true);
if(result=="0") ErrorMessage("Success","MEL_CHANGE_MEDICATION");
else if(result=="-1") ErrorMessage("MID is not valid","MEL_CHANGE_MEDICATION");
else if(result=="-2") ErrorMessage("description is too long","MEL_CHANGE_MEDICATION");
else if(result=="-3") ErrorMessage("code is not valid or wrong code type used","MEL_CHANGE_MEDICATION");
else if(result=="-4") ErrorMessage("startDate is not in the correct format","MEL_CHANGE_MEDICATION");
else if(result=="-5") ErrorMessage("startDate is not valid (for example, the date represents a future date)","MEL_CHANGE_MEDICATION");
else if(result=="-6") ErrorMessage("stopDate is not in the correct format","MEL_CHANGE_MEDICATION");
else if(result=="-7") ErrorMessage("stopDate is not valid (for example, the date is earlier than the onset date)","MEL_CHANGE_MEDICATION");
else if(result=="-8") ErrorMessage("quantity, refills, or BMN is not valid","MEL_CHANGE_MEDICATION");
else if(result=="-9") ErrorMessage("medication comment is too long","MEL_CHANGE_MEDICATION");
else if(result=="-10") ErrorMessage("clinical list lock cannot be obtained","MEL_CHANGE_MEDICATION");
else if(result=="-11") ErrorMessage("medication cannot be changed for some other reason","MEL_CHANGE_MEDICATION");
else if(result=="-12") ErrorMessage("invalid NDCNUM","MEL_CHANGE_MEDICATION");
else if(result=="-13") ErrorMessage("invalid DDID","MEL_CHANGE_MEDICATION");
else if(result=="-14") ErrorMessage("medication not in reference list","MEL_CHANGE_MEDICATION");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_CHANGE_MEDICATION");
};
/*=========================================================================
* Example: {MEL_CHANGE_PROBLEM(PRID, “Hypercholesterolemia”, “ICD10-E78.8”, “09/15/2012”, false, , , “Diet controlled”)}
* ChangeProblem(PRID, “Hypercholesterolemia”, “ICD10-E78.8”, “09/15/2012”, false, , , “Diet controlled”);
* Date formats: MM/DD/YYYY or YYYY/MM/DD
* Output: N/A
* Tested: true
*========================================================================*/
function ChangeProblem(ID, desc, code, startDate, approxStart, stopDate, approxStop, comm){
var result = EvaluateMel("{MEL_CHANGE_PROBLEM("+ID+",'"+desc+"','"+code+"','"+startDate+"',"+approxStart+",'"+stopDate+"',"+approxStop+",'"+comm+"')}", true);
if(result=="0") ErrorMessage("Success","MEL_CHANGE_PROBLEM");
else if(result=="-1") ErrorMessage("PRID is not valid","MEL_CHANGE_PROBLEM");
else if(result=="-2") ErrorMessage("description is too long","MEL_CHANGE_PROBLEM");
else if(result=="-3") ErrorMessage("code is not valid or the wrong code type","MEL_CHANGE_PROBLEM");
else if(result=="-4") ErrorMessage("startDate is not in the correct format","MEL_CHANGE_PROBLEM");
else if(result=="-5") ErrorMessage("startDate is not valid (for example, the date represents a future date)","MEL_CHANGE_PROBLEM");
else if(result=="-6") ErrorMessage("approxStart argument is not valid","MEL_CHANGE_PROBLEM");
else if(result=="-7") ErrorMessage("stopDate is not valid (for example, the date is earlier than the onset date)","MEL_CHANGE_PROBLEM");
else if(result=="-8") ErrorMessage("approxStop argument is not valid","MEL_CHANGE_PROBLEM");
else if(result=="-9") ErrorMessage("comment is not valid or too long","MEL_CHANGE_PROBLEM");
else if(result=="-10") ErrorMessage("clinical list lock cannot be obtained","MEL_CHANGE_PROBLEM");
else if(result=="-11") ErrorMessage("problem cannot be changed for some other reason","MEL_CHANGE_PROBLE");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_CHANGE_PROBLEM");
};
/*=========================================================================
* ErrorMessage("Invalid format specified","MEL_LIST_CARE_PLAN");
* Output: Launches error message box
* Tested: true
*========================================================================*/
function ErrorMessage(message, title){
//window.external.ShowErrorMessageBox(message, title);
};
/*=========================================================================
* Example: EvaluateMel("{GET_UNIQUE_WORLDID()};", true);
* Output: Varies
* Tested: true
*========================================================================*/
function EvaluateMel(melStatement, showWait, callback){
if(showWait){
if(callback) return window.external.EvaluateMelCallback(melStatement, showWait, callback);
else return window.external.EvaluateMel(melStatement, showWait);
}else{
if(callback) return window.external.EvaluateMelCallback(melStatement, false, callback);
else return window.external.EvaluateMel(melStatement, false);
}
};
/*=========================================================================
* Output: unknown
* Tested: false
*========================================================================*/
function EvaluateMelCallback(melStatement, showWait, callback){
window.external.EvaluateMelCallback(melStatement, showWait, callback);
};
/*=========================================================================
* Output: object array
* Tested: true
*========================================================================*/
function GetFormList(){
var ls = EvaluateMel("{GET_FORM_LIST()}");
var result = ParseDelimList2(ls);
return result;
};
/*=========================================================================
* Get the value of the observation
* GetObsNow("BMI");
* Output: string
* Tested: true
*========================================================================*/
function GetObsNow(obs){
return EvaluateMel('{OBSNOW("' + obs.replace(/\\([\s\S])|(")/g, "\\$1$2") + '")}');
};
/*=========================================================================
* Output: "Arizona"
* Tested: true
*========================================================================*/
function GetPharmacyState(pharmacyId){
return EvaluateMel('{MEL_PHARM_STATE('+pharmacyId+')}');
};
/*=========================================================================
* Output: "5131-32973-7145"
* Tested: true
*========================================================================*/
function GetWorldID(pid){
return EvaluateMel('{GET_UNIQUE_WORLDID()}');
};
/*=========================================================================
* Output: "42"
* Tested: true
*========================================================================*/
function GetServerID(pid){
return EvaluateMel('{GET_UNIQUE_SERVERID()}');
};
/*=========================================================================
* Output: String - needs to be parsed to JSON
* Tested: true
*========================================================================*/
function ListCarePlan(){
var result = EvaluateMel("{MEL_LIST_CARE_PLAN ('delim','all','all')}", true);
if(result=="-1") ErrorMessage("Invalid format specified","MEL_LIST_CARE_PLAN");
else if(result=="-2") ErrorMessage("Invalid type specified","MEL_LIST_CARE_PLAN");
else return result;
};
/*=========================================================================
* Output: String - needs to be parsed to JSON
* Tested: true
*========================================================================*/
function ListFHX(){
var result = EvaluateMel("{MEL_LIST_FHX ('delim','all')}", true);
if(result=="-1") ErrorMessage("Invalid format specified","MEL_LIST_FHX");
else if(result=="-2") ErrorMessage("Invalid type specified","MEL_LIST_FHX");
else return result;
};
/*=========================================================================
* Output: String - needs to be parsed to JSON
* Tested: true
*========================================================================*/
function ListFHXAfter(){
var result = EvaluateMel("{MEL_LIST_FHX_AFTER ('delim','all')}", true);
if(result=="-1") ErrorMessage("Invalid format specified","MEL_LIST_FHX_AFTER");
else if(result=="-2") ErrorMessage("Invalid type specified","MEL_LIST_FHX_AFTER");
else return result;
};
/*=========================================================================
* Output: String - needs to be parsed to JSON
* Tested: true
*========================================================================*/
function ListFHXNew(){
var result = EvaluateMel("{MEL_LIST_FHX_NEW ('delim')}", true);
if(result=="-1") ErrorMessage("Invalid format specified","MEL_LIST_FHX");
else return result;
};
/*=========================================================================
* LastSignedObsDate("BMI");
* Output: 09/12/2018
* Tested: true
*========================================================================*/
function LastSignedObsDate(obs){
return EvaluateMel('{LAST_SIGNED_OBS_DATE("'+obs+'")}');
};
/*=========================================================================
* LastSignedObsDate("BMI");
* Output: 09/12/2018 9:04:21 AM
* Tested: true
*========================================================================*/
function LastSignedObsDateTime(obs){
return EvaluateMel('{LAST_SIGNED_OBS_DATETIME("'+obs+'")}');
};
/*=========================================================================
* LastSignedObsValue("BMI");
* Output: 16.93
* Tested: true
*========================================================================*/
function LastSignedObsValue(obs){
return EvaluateMel('{LAST_SIGNED_OBS_VALUE("'+obs+'")}');
};
/*=========================================================================
* LastSignedObsValue("BMI");
* Output: 16.93 (09/12/2018 9:04:21 AM)
* Tested: true
*========================================================================*/
function LastSignedObsValueDate(obs){
return EvaluateMel('{LAST_SIGNED_OBS_VALUEDATE("'+obs+'")}');
};
/*=========================================================================
* LastObsDate("BMI");
* Output: 09/12/2018
* Tested: true
*========================================================================*/
function LastObsDate(obs){
return EvaluateMel('{LASTOBSDATE("'+obs+'")}');
};
/*=========================================================================
* LastObsDateTime("BMI");
* Output: 09/12/2018 9:04:21 AM
* Tested: true
*========================================================================*/
function LastObsDateTime(obs){
return EvaluateMel('{LASTOBSDATETIME("'+obs+'")}');
};
/*=========================================================================
* LastObsValue("BMI");
* Output: 16.93
* Tested: true
*========================================================================*/
function LastObsValue(obs){
return EvaluateMel('{LASTOBSVALUE("'+obs+'")}');
};
/*=========================================================================
* LastObsValueByLoc("BMI");
* Output: 16.93
* Tested: true
*========================================================================*/
function LastObsValueByLoc(obs){
return EvaluateMel('{LASTOBSVALUEBYLOC("'+obs+'")}');
};
/*=========================================================================
* LastObsValueByUser("BMI");
* Output: 16.93
* Tested: true
*========================================================================*/
function LastObsValueByUser(obs){
return EvaluateMel('{LASTOBSVALUEBYUSER("'+obs+'")}');
};
/*=========================================================================
* LastObsValueDate("BMI");
* Output: 16.93 (09/12/2018 9:04:21 AM)
* Tested: true
*========================================================================*/
function LastObsValueDate(obs){
return EvaluateMel('{LASTOBSVALUEDATE("'+obs+'")}');
};
/*=========================================================================
* ListObsValueByLoc("BMI");
* Output: 16.93
* Tested: true
*========================================================================*/
function ListObsValueByLoc(obs){
return EvaluateMel('{LISTOBSVALUEBYLOC("'+obs+'")}');
};
/*=========================================================================
* ListObsValueByUser("BMI");
* Output:
* Tested: true
*========================================================================*/
function ListObsValueByUser(obs){
return EvaluateMel('{LISTOBSVALUEBYUSER("'+obs+'")}');
};
/*=========================================================================
* ObsAny("BMI");
* Output: 16.93
* Tested: true
*========================================================================*/
function ObsAny(obs){
return EvaluateMel('{OBSANY("'+obs+'")}');
};
/*=========================================================================
* ObsListChanges();
* Output: "Added new observation of BMI: (03/08/2019 9:05)"
* Tested: true
*========================================================================*/
function ObsListChanges(){
return EvaluateMel('{OBS_LIST_CHANGES()}');
};
/*=========================================================================
* ObsModifierAny("BMI");
* Output: 16.93
* Tested: true
*========================================================================*/
function ObsModifierAny(obs){
return EvaluateMel('{OBSMODIFIERANY("'+obs+'")}');
};
/*=========================================================================
* ObsModifierNow("BMI","19.63");
* Output: 16.93
* Tested: true
*========================================================================*/
function ObsModifierNow(obs,val){
if(!val) return EvaluateMel('{OBSMODIFIERNOW("'+obs+'")}');
else return EvaluateMel('{OBSMODIFIERNOW("'+obs+'","'+val+'")}');
};
/*=========================================================================
* ObsModifierPrev("BMI");
* Output:
* Tested: true
*========================================================================*/
function ObsModifierPrev(obs){
return EvaluateMel('{OBSMODIFIERPREV("'+obs+'")}');
};
/*=========================================================================
* ObsNow("weight","155","02/01/2001");
* Output: 16.93
* Tested: true
*========================================================================*/
function ObsNow(obs,val,date){
return EvaluateMel('{OBSNOW("'+obs+'","'+val+'","'+date+'")}');
};
/*=========================================================================
* ObsModifierPrev("BMI");
* Output:
* Tested: true
*========================================================================*/
function ObsPrev(obs){
return EvaluateMel('{OBSPREV("'+obs+'")}');
};
/*=========================================================================
* ObsTagAny("BMI");
* Output:
* Tested: true
*========================================================================*/
function ObsTagAny(obs){
return EvaluateMel('{OBSTAGANY("'+obs+'")}');
};
/*=========================================================================
* ObsTagNow("BMI","high");
* Output: high
* Tested: true
*========================================================================*/
function ObsTagNow(obs,val){
return EvaluateMel('{OBSTAGNOW("'+obs+'","'+val+'")}');
};
/*=========================================================================
* ObsTagPrev("BMI");
* Output:
* Tested: true
*========================================================================*/
function ObsTagPrev(obs){
return EvaluateMel('{OBSTAGPREV("'+obs+'")}');
};
/*=========================================================================
* ObsUnit("BMI");
* Output: kg/m2
* Tested: true
*========================================================================*/
function ObsUnit(obs){
return EvaluateMel('{OBSUNIT("'+obs+'")}');
};
/*=========================================================================
* Output: Opens Update Alleriegs or Adverse Reactions Dialog Window
* Tested: true
*========================================================================*/
function OpenAllergiesDiag(){
return EvaluateMel('{ADD_ALLERGIES}');
};
/*=========================================================================
* Output: Opens Update Directives Dialog Window
* Tested: true
*========================================================================*/
function OpenDirectivesDiag(){
return EvaluateMel('{ADD_DIRECTIVES}');
};
/*=========================================================================
* Output: Opens the specified form component in the current update
* tab = open indicated tab on form component, blank = default first tab
* Tested: true
*========================================================================*/
function OpenFormComp(path,tab){
if(!tab) EvaluateMel('{OPEN_FORM_COMP("'+path+'")}');
else return EvaluateMel('{OPEN_FORM_COMP("'+path+'","'+tab+'")}');
};
/*=========================================================================
* Output: Opens the specified handout specified by the str
* Tested: true
* Returns: url for the description in AddMUActivityLog
*========================================================================*/
function OpenHandout(str){
var desc = ("Handout - " + str);
var url = "https://www.micromedexsolutions.com/carenotes/librarian/accessv3?mainSearchCriteria.v.c=&mainSearchCriteria.v.cs=&mainSearchCriteria.v.dn="+str+"&holder.assignedEntity.n=GEC&holder.assignedEntity.certificateText=T46020";
//showHtmlFormDialog(url,desc);
window.open(url,desc,"menubar=1,location=1,toolbar=1,titlebar=1,status=1,scrollbars=1,resizable=1");
return url;
};
/*=========================================================================
* Output: Opens New Medication Dialog Window
* Tested: true
*========================================================================*/
function OpenMedicationDiag(str){
if(typeof str == 'undefined') return EvaluateMel('{NEWMED("")}');
else return EvaluateMel('{NEWMED('+str+')}');
};
/*=========================================================================
* Output: Opens Drug Interactions and Contraindications Dialog Window
* Tested: true
*========================================================================*/
function OpenOverridesDiag(){
return EvaluateMel('{MEL_SHOW_INTERACTIONOVERRIDE_DLG()}', false);
};
/*=========================================================================
* Output: Opens New Problem Dialog Window
* Tested: true
*========================================================================*/
function OpenProblemDiag(str){
if(typeof str == 'undefined') return EvaluateMel('{NEWPROBLEM("DX OF","")}');
else return EvaluateMel('{NEWPROBLEM("DX OF",'+str+')}');
};
/*=========================================================================
* Output: Opens New QMAF Dialog Window
* Tested: true
*========================================================================*/
function OpenQMAFDiag(){
return EvaluateMel('{SHOW_HTML_FORM("//localserver/EncounterForms/HtmlForms/QualityMeasures/QualityMeasures.html","Quality Measures - Valley Medical Center, PLLC")}', true);
};
/*=========================================================================
* PotentObservations();
* Output: ViewPencilObs
* Tested: true
*========================================================================*/
function PotentObservations(){
return EvaluateMel('{POTENT_OBSERVATIONS}');
};
/*=========================================================================
* Example: {MEL_REMOVE_ALLERGY("1226006769001060", "03/12/2013","Allergy disproved")}
* RemoveAllergy(1863698602852300, '01/21/2019','Allergy disproved');
* Date formats: MM/DD/YYYY or YYYY/MM/DD
* reason: Entered in error, Patient corrected, Allergy disproved, Other
* Output: N/A
* Tested: true
*========================================================================*/
function RemoveAllergy(ID, stopDate, reason){
var result = EvaluateMel("{MEL_REMOVE_ALLERGY('"+ID+"','"+stopDate+"','"+reason+"')}", true);
if(result=="0") ErrorMessage("Success","MEL_REMOVE_ALLERGY");
else if(result=="-1") ErrorMessage("Allergy not found","MEL_REMOVE_ALLERGY");
else if(result=="-2") ErrorMessage("Allergy found, but already inactive","MEL_REMOVE_ALLERGY");
else if(result=="-3") ErrorMessage("The end_date is not valid (for example, the date is earlier than the startDate)","MEL_REMOVE_ALLERGY");
else if(result=="-5") ErrorMessage("Reason is Invalid","MEL_REMOVE_ALLERGY");
else if(result=="-6") ErrorMessage("clinical list lock cannot be obtained","MEL_CHANGE_ALLERGY");
else if(result=="-7") ErrorMessage("allergy cannot be removed for some other reason","MEL_REMOVE_ALLERGY");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_REMOVE_ALLERGY");
};
/*=========================================================================
* Example: {MEL_REMOVE_FHX (FHXID,"Entered in Error")}
* RemoveFHX("1863774213861820", "Testing");
* (reason, (25 char))
* Output: N/A
* Tested: true
*========================================================================*/
function RemoveFHX(FHXID, reason){
var result = EvaluateMel("{MEL_REMOVE_FHX('"+FHXID+"','"+reason+"')}", true);
if(result=="0") ErrorMessage("Successfully removed","MEL_REMOVE_FHX");
else if(result=="-1") ErrorMessage("FHXID contains an invalid numeric value, the value is empty, or too long","MEL_REMOVE_FHX");
else if(result=="-2") ErrorMessage("Removal reason is too long, or empty","MEL_REMOVE_FHX");
else if(result=="-3") ErrorMessage("Cannot acquire clinical list lock","MEL_REMOVE_FHX");
else if(result=="-4") ErrorMessage("Cannot remove FHx due to unknown reason","MEL_REMOVE_FHX");
else if(result=="-21") ErrorMessage("Service layer error","MEL_REMOVE_FHX");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_REMOVE_FHX");
};
/*=========================================================================
* Example: {MEL_REMOVE_PROBLEM(PRID, “09/15/2012”, false, “Resolved”)}
* RemoveProblem(1830777798699680, "09/15/2018", false, "Correction");
* Date formats: MM/DD/YYYY or YYYY/MM/DD
* Reasons: "Resolved", "Inactive", "Ruled out" or "Correction". Default is "Resolved".
* Output: N/A
* Tested: true
*========================================================================*/
function RemoveProblem(PRID, endDate, approx, reason){
var result = EvaluateMel("{MEL_REMOVE_PROBLEM("+PRID+",'"+endDate+"','"+approx+"','"+reason+"')}", true);
if(result=="0") ErrorMessage("Success","MEL_REMOVE_PROBLEM");
else if(result=="-1") ErrorMessage("problem is not found","MEL_REMOVE_PROBLEM");
else if(result=="-2") ErrorMessage("problem is found and it is already inactive","MEL_REMOVE_PROBLEM");
else if(result=="-3") ErrorMessage("endDate is not valid","MEL_REMOVE_PROBLEM");
else if(result=="-4") ErrorMessage("approx argument is not either true or false","MEL_REMOVE_PROBLEM");
else if(result=="-5") ErrorMessage("Reason is Invalid","MEL_REMOVE_PROBLEM");
else if(result=="-6") ErrorMessage("data symbol cannot obtain the clinical list lock","MEL_REMOVE_PROBLEM");
else if(result=="-7") ErrorMessage("other problem is encountered","MEL_REMOVE_PROBLEM");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_REMOVE_PROBLEM");
};
/*=========================================================================
* SetObsValue("BMI","99");
* Output: N/A
* Tested: true
*========================================================================*/
function SetObsValue(obs, value) {
EvaluateMel('{OBSNOW("' + obs + '","' + value.replace(/\\([\s\S])|(")/g, "\\$1$2") + '")}');
};
/*=========================================================================
* PotentObservations();
* Output: "Observations"
* Tested: true
*========================================================================*/
function SumActiveObservations(){
return EvaluateMel('{SUM_ACTIVE_OBSERVATIONS}');
};
/*=========================================================================
* ISSUE: documentation is wrong about intake varibles
* Example: {MEL_UPDATE_CARE_PLAN(123,"Exercise to lose weight","289169006","Reduce 20 pounds","Walk daily for one hour. Eat a light dinner.","2013/05/10","","123|234")}
* optional: (SNOMEDCTCODE, (20 char)), (target,(255 char)), (instruct, (2000 char)), (endDate)
* Date formats: MM/DD/YYYY or YYYY/MM/DD
* Output: N/A
* Tested: true
*========================================================================*/
function UpdateCarePlan(ID, date, goal, SNOMEDCTCODE, target, instruct, setDate, endDate, PRID){
var result = EvaluateMel("{MEL_UPDATE_CARE_PLAN('"+ID+"','"+date+"','"+goal+"','"+SNOMEDCTCODE+"','"+target+"','"+instruct+"','"+setDate+"','"+endDate+"','"+PRID+"')}", true);
if(result=="0") ErrorMessage("Success","MEL_UPDATE_CARE_PLAN");
else if(result=="-1") ErrorMessage("Invalid care plan ID","MEL_UPDATE_CARE_PLAN");
else if(result=="-2") ErrorMessage("Description is blank or too long","MEL_UPDATE_CARE_PLAN");
else if(result=="-3") ErrorMessage("Instruction is too long","MEL_UPDATE_CARE_PLAN");
else if(result=="-4") ErrorMessage("Code is too long","MEL_UPDATE_CARE_PLAN");
else if(result=="-5") ErrorMessage("Target is too long","MEL_UPDATE_CARE_PLAN");
else if(result=="-6") ErrorMessage("GoalSetDate is invalid","MEL_UPDATE_CARE_PLAN");
else if(result=="-7") ErrorMessage("GoalMetDate is invalid or less than GoalSetDate","MEL_UPDATE_CARE_PLAN");
else if(result=="-9") ErrorMessage("Invalid PRID","MEL_UPDATE_CARE_PLAN");
else if(result=="-10") ErrorMessage("Cannot add care plan for some other reason","MEL_UPDATE_CARE_PLAN");
else if(result=="-11") ErrorMessage("Another user is updating this care plan. You cannot update until the changes are saved or cancelled.","MEL_UPDATE_CARE_PLAN");
else if(result=="-12") ErrorMessage("The care plan being modified is NOT CURRENT.","MEL_UPDATE_CARE_PLAN");
else if(result=="-21") ErrorMessage("Service layer error","MEL_UPDATE_CARE_PLAN");
else ErrorMessage("Error: unkown reason, returned value: "+ result,"MEL_UPDATE_CARE_PLAN");
};
/*=========================================================================
* Invoke the Update Medications dialog
* Utilize $timeout since this displays a modal dialog and shouldn't be done during digest cycle
* Output: N/A
* Tested: true
*========================================================================*/
function UpdateMedications() {
EvaluateMel("{UPDATE_MEDS(true)}");
};
/*=========================================================================
* Invoke the Update Orders dialog
* Utilize $timeout since this displays a modal dialog and shouldn't be done during digest cycle
* Output: N/A
* Tested: true
*========================================================================*/
function UpdateOrders() {
EvaluateMel("{UPDATE_ORDERS(true)}");
};
/*=========================================================================
* Invoke the Update Problems dialog
* Utilize $timeout since this displays a modal dialog and shouldn't be done during digest cycle
* Output: N/A
* Tested: true
*========================================================================*/
function UpdateProblems() {
EvaluateMel("{UPDATE_PROBLEMS(true)}");
};
/*=========================================================================
* **** NEEDS TESTING / FURTHER TESTING ****
*========================================================================*/
/*=========================================================================
* Arguments: 1 - medicationId, 2 - Parmacy Name, 3 - RxType, 4 - Quantity,
5 - Refill, 6 - DAW.
* Output: returns 0
* Tested: needs further testing
*========================================================================*/
function approveERXRequest(request){
return EvaluateMel('{MEL_ERX_APPROV("'+request+'")}', true);
};
/*=========================================================================
* Output:
* Tested: needs testing
*========================================================================*/
function changePrescriptionPharmacy(ptid, pharmacyId, rxType){
return EvaluateMel('{MEL_CHANGE_MEDICATION_RX('+ptid+','+pharmacyId+',"'+rxType+'")}', true);
};
/*=========================================================================
* Output:
* Tested: needs testing
*========================================================================*/
function changePrescriptionOrderNumber(prescriptionId, prescriptionOrderNumber){
return EvaluateMel('{MEL_UPDATE_PRESCRIPTIONORDERNUMBER('+prescriptionId+',"'+prescriptionOrderNumber+'")}', true);
};
/*=========================================================================
* Arguments: 1 - medicationId, 2 - Parmacy Id, 3 - RxType, 4 - Quantity,
5 - Refill, 6 - DAW., 7 - PrintDx, 8 - Rx Comments, 9 - Force Create New Rx,
10 - clinical date, 11 - ptid, 12 - prescriberid, 13 - ShouldLockacquire,
14 - displayUnit
* Output:
* Tested: needs further testing
*========================================================================*/
function changePrescription(medicationId, pharmacyId, rxType, quantity, refills, daw, prescriptionComments, createNewRx, ShouldLockAcquire, clinicalDate, prescriptionId, prescriberId, displayUnit){
return EvaluateMel('{MEL_ADD_RX("'+medicationId+'","'+pharmacyId+'","'+rxType+'",\"'+quantity+'\",\"'+refills+'\","'+daw+'",false,\"'+formatDataForMEL(prescriptionComments)+'\",'+forceCreate+',"'+rxClinicalDate+'","'+ptid+'","'+authProvider+'",'+ShouldLockAcquire+',"'+displayUnitLookup+'")}', true);
};
/*=========================================================================
* Arguments: 1 - medicationId, 2 - Parmacy Name, 3 - RxType, 4 - Quantity,
5 - Refill, 6 - DAW.
* Output: returns 0
* Tested: needs further testing
*========================================================================*/
function denyERXRequest(request){
return EvaluateMel('{MEL_ERX_DENY("'+request+'")}', true);
};
/*=========================================================================
* Arguments: 1 - medicationId, 2 - Parmacy Name, 3 - RxType, 4 - Quantity,
5 - Refill, 6 - DAW.
* Output: returns 0
* Tested: needs further testing
*========================================================================*/
function dntfERXRequest(request, modifiedRequest){
return EvaluateMel('{MEL_ERX_DNTF("'+request+'","'+modifiedRequest+'")}', true);
};
/*=========================================================================
* Arguments: 1 - medicationId, 2 - Parmacy Name, 3 - RxType, 4 - Quantity,
5 - Refill, 6 - DAW.
* Output: returns 0
* Tested: needs further testing
*========================================================================*/
function dnERXRequest(request, modifiedRequest){
return EvaluateMel('{MEL_ERX_DN("'+request+'","'+modifiedRequest+'")}', true);
};
/*=========================================================================
* Output:
* Tested: needs testing
*========================================================================*/
function doPatientEducationLookup(sdid, genericName, ddid, desc){
return EvaluateMel('{MEL_PATIENTEDUCATION_FORMEDICATION("'+sdid+'","'+genericName+'","'+ddid+'","'+desc+'")}', true);
};
/*=========================================================================
* Output:
* Tested: needs testing
*========================================================================*/
function doClinicalDecisionSupportLookup(sdid, genericName, ddid, desc){
return EvaluateMel('{MEL_CDS_FORMEDICATION("'+sdid+'","'+genericName+'","'+ddid+'","'+desc+'")}', true);
};
/*=========================================================================
* Output: "T"
* Tested: true
*========================================================================*/
function eRxEnabled(){
return EvaluateMel('{Clinic._EnableOnlineRx}', true);
};
/*=========================================================================
* Output:
* Tested: needs testing
*========================================================================*/
function formatDataForMEL(formatData){
if(formatData != null){
formatData = formatData.replace(/\\/g, '\\\\');
formatData = formatData.replace(/"/g, '\\"');
formatData = formatData.replace(/'/g, '\\\'');
}
return formatData;
};
/*=========================================================================
* Output: ??
* Tested: true
*========================================================================*/
function getPrescriptionState(){
return EvaluateMel('{DOCUMENT._ML_RX_STATE}', true);
};
/*=========================================================================
* Output: "FLASE"
* Tested: true
*========================================================================*/
function gotoChartModule(pid){
return EvaluateMel('{GOTO_CHART_MODULE("'+pid+'")}', true);
};
/*=========================================================================
* Output: returns 0
* Tested: needs further testing
*========================================================================*/
function removeMedication(medId){
return EvaluateMel('{MEL_UNDO_MEDICATION('+medId+')}', true);
};
/*=========================================================================
* Delete the prescription. If this is a renewal request do not ignore rxType so
cleanup of any DN rows can be performed
* Output: returns -3
* Tested: needs further testing
*========================================================================*/
function removePrescription(ptid, ignoreRxType){
if(ignoreRxType) return EvaluateMel('{MEL_DELETE_ERX("'+ptid+'",true)}', true);
else return EvaluateMel('{MEL_DELETE_ERX("'+ptid+'",false)}', true);
};
/*=========================================================================
* sdid == $window.external.ActiveSdid
* Output:
* Tested: true
*========================================================================*/
function showHtmlFormDialog(formUrl, formName, sdid, width, height, parentFormId){
return EvaluateMel('{SHOW_HTML_FORM("'+formUrl+'","'+formName+'")}', true);
};