Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 3975

Show
Ignore:
Timestamp:
04/21/08 01:00:16 (7 months ago)
Author:
bmckown
Message:

Clinical Summary Module: Small change to CD4 count reminder messages.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/clinicalsummary/src/org/openmrs/module/clinicalsummary/SummaryExportFunctions.java

    r3884 r3975  
    254254     */ 
    255255    public String getCD4CountReminder() throws Exception { 
     256        // days in milliseconds; 
     257        long ONE_DAY = 86400000; 
     258        long THREE_DAYS = ONE_DAY * 3; 
     259        // duplicate cd4 count flag. 
    256260        boolean duplicateCD4Obs = false; 
     261        // output format for date 
    257262        DateFormat reminderFormat = new SimpleDateFormat("MMMMM yyyy"); 
    258263        DateFormat obsFormat = new SimpleDateFormat("dd-MMM-yyyy"); 
     264        // tomorrow 
    259265        GregorianCalendar tomorrow = new GregorianCalendar(); 
    260266        tomorrow.add(Calendar.DAY_OF_MONTH, 1); 
    261         GregorianCalendar sixMosAgo = new GregorianCalendar(); 
    262         sixMosAgo.add(Calendar.MONTH, -6); 
    263         GregorianCalendar conceptDatetime = new GregorianCalendar(); 
     267        // five months ago 
     268        GregorianCalendar fiveMosAgo = new GregorianCalendar(); 
     269        fiveMosAgo.add(Calendar.MONTH, -5); 
     270        // the time of this obs 
     271        GregorianCalendar obsDatetime = new GregorianCalendar(); 
    264272        Concept cd4 = getConcept("5497"); // name='CD4, BY FACS' 
    265273        Set<Obs> obs = Context.getObsService().getObservations(getPatient(), 
    266274                cd4, false); 
    267         // No CD4 count. 
     275        /*  
     276         * No CD4 count. 
     277         */ 
    268278        if (obs.isEmpty()) { 
    269279            return "Please order CD4 count now (no prior CD4 count on record)."; 
    270280        } 
    271         // More than one CD4 count 
     281        /* 
     282         * More than one CD4 count 
     283         */ 
    272284        else if (obs.size() > 1) { 
    273285            GregorianCalendar firstCD4 = new GregorianCalendar(); 
     
    285297            } 
    286298            if (Math 
    287                     .abs(lastCD4.getTimeInMillis() - firstCD4.getTimeInMillis()) < 86400000) { 
    288                 // All CD4's have been taken within the same 24 hour time span. 
    289                 // Consider them the same day. 
     299                    .abs(lastCD4.getTimeInMillis() - firstCD4.getTimeInMillis()) < THREE_DAYS) { 
     300                // All CD4's taken within this time frame can be considered just one CD4 count taken.  
    290301                duplicateCD4Obs = true; 
    291302            } else { 
     
    293304            } 
    294305        } 
    295         // Exactly one CD4 count 
     306        /* 
     307         * Exactly one CD4 count 
     308         */ 
    296309        if (obs.size() == 1 || duplicateCD4Obs) { 
    297310            for (Obs o : obs) { 
    298                 conceptDatetime.setTime(o.getObsDatetime()); 
    299                 if (conceptDatetime.before(sixMosAgo)) { 
    300                     return "Please order CD4 count now (last CD4 count over 6 months ago)."; 
    301                 } else if (conceptDatetime.after(sixMosAgo) 
    302                         && conceptDatetime.before(tomorrow)) { 
    303                     Calendar nextCD4 = (Calendar) conceptDatetime.clone(); 
     311                obsDatetime.setTime(o.getObsDatetime()); 
     312                if (obsDatetime.before(fiveMosAgo)) { 
     313                    // Maybe sometime give a more intelligent message. 
     314                    // int months = tomorrow.get(Calendar.MONTH) - obsDatetime.get(Calendar.MONTH); 
     315                    // int years = tomorrow.get(Calendar.YEAR) - obsDatetime.get(Calendar.YEAR); 
     316                    // String mosAgo = (months > 1) ? months + " months" : months + " month"; 
     317                    // String yrsAgo = (years > 1) ? years + " years" : years + " year"; 
     318                    // Right now this will suffice: 
     319                    return "Please order CD4 count now (last CD4 count over 5 months ago)."; 
     320                } else if (obsDatetime.after(fiveMosAgo) 
     321                        && obsDatetime.before(tomorrow)) { 
     322                    Calendar nextCD4 = (Calendar) obsDatetime.clone(); 
    304323                    nextCD4.add(Calendar.MONTH, 6); 
    305324                    return new String("Next CD4 count due in " 
     
    307326                            + " (last CD4 count was " + o.getValueNumeric() 
    308327                            + " on " 
    309                             + obsFormat.format(conceptDatetime.getTime()) 
     328                            + obsFormat.format(obsDatetime.getTime()) 
    310329                            + ")."); 
    311330                } else {