Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5043

Show
Ignore:
Timestamp:
07/25/08 04:50:38 (6 months ago)
Author:
mseaton
Message:

simplelabentry: Javascript fixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/simplelabentry/web/module/portlets/orderEntry.jsp

    r5032 r5043  
    2727                                if (msg.objs[0].patientId) { 
    2828                                        var patient = msg.objs[0]; 
     29 
     30                                        DWRSimpleLabEntryService.getPatient(patient.patientId, function(labPatient) { loadPatient(labPatient) }); 
     31                                        clearPatientAndSearchFields(); 
    2932                                        _selectedPatientId = patient.patientId; 
    3033                                        $j("#otherIdentifier").text($j("#patientIdentifier").val()); 
    31                                         DWRSimpleLabEntryService.getPatient(patient.patientId, function(labPatient) { loadPatient(labPatient) }); 
    32                                         showDiv('createOrderSection'); 
    33                                         hideDiv('patientSearchBox'); 
    34                                         $j(".idMatch").hide(); 
     34                                        $j("#matchedPatientSection").show(); 
    3535                                        $j(".nameMatch").show(); 
    36                                         $j(".createdPatientMatch").hide(); 
    37                                         dojo.widget.manager.getWidgetById("pSearch").clearSearch(); 
     36                                         
    3837                                } else if (msg.objs[0].href) 
    3938                                        document.location = msg.objs[0].href; 
     
    5756        } 
    5857 
    59         function clearPatientSearchFields() { 
    60                 hideDiv('createOrderSection'); 
    61                 $j("#orderDetailSection").hide(); 
    62                 hideDiv('nameMatchSection'); 
    63                 hideDiv('createPatientSection'); 
     58        function clearPatientAndSearchFields() { 
     59                _selectedPatientId = null;; 
     60                clearSearchFields(); 
     61        } 
     62 
     63        function clearSearchFields() { 
     64                $j("#otherIdentifier").text(''); 
     65                $j("#nameMatchSection").hide(); 
     66                $j("#matchedPatientSection").hide(); 
    6467                $j(".idMatch").hide(); 
    6568                $j(".nameMatch").hide(); 
    6669                $j(".createdPatientMatch").hide(); 
    67                 _selectedPatientId = null; 
     70                $j("#createPatientSection").hide(); 
     71                $j(".orderDetailSection").remove(); 
     72                dojo.widget.manager.getWidgetById("pSearch").clearSearch(); 
    6873        } 
    6974 
    7075        function clearFormFields() { 
    7176                $j(".orderField").val(''); 
    72                dojo.widget.manager.getWidgetById("pSearch").clearSearch(); 
     77               clearPatientAndSearchFields(); 
    7378        } 
    7479 
    7580        function showCreatePatient() { 
    76                 clearPatientSearchFields(); 
    77                 showDiv('createPatientSection'); 
    78                 _selectedPatientId = null; 
    79         } 
    80  
    81         function showAddOrder() { 
    82                 $j("#newIdentifierAddSection").hide(); 
    83                 $j("#nameMatchSection").hide(); 
    84                 $j("#orderDetailSection").show(); 
     81                clearSearchFields(); 
     82                $j("#createPatientSection").show(); 
    8583        } 
    8684 
     
    8886         
    8987                function findNewPatient() { 
    90                         _selectedPatientId = null; 
    91                         showDiv('nameMatchSection'); 
    92                         showDiv('patientSearchBox'); 
     88                        clearPatientAndSearchFields(); 
    9389                        dojo.widget.manager.getWidgetById("pSearch").inputNode.select(); 
    9490                        dojo.widget.manager.getWidgetById("pSearch").inputNode.focus(); 
    9591                } 
    96                  
     92 
     93                function showNewOrder() { 
     94                        $j("#newIdentifierAddSection").hide(); 
     95                        $j(".orderDetailTemplate").clone().removeClass("orderDetailTemplate").appendTo($j("#newOrderSection")).addClass("orderDetailSection").show(); 
     96                        $j(".orderDetailSection input[name='startDate']").val('${model.orderDate}'); 
     97                        $j(".orderDetailSection select[name='location']").val('${model.orderLocation}'); 
     98                        $j(".orderDetailSection select[name='concept']").val('${model.orderConcept}'); 
     99                        $j(".orderDetailSection :button[name='CreateOrderButton']").click( function() { createOrder(); } ); 
     100                } 
     101 
    97102                function matchPatientById(patIdType, patId) { 
    98                         clearPatientSearchFields(); 
     103                        clearPatientAndSearchFields(); 
    99104                        DWRSimpleLabEntryService.getPatientByIdentifier(patIdType, patId, function(patient) { 
    100                                         if (patient.patientId == null) { 
    101                                                 showDiv('nameMatchSection'); 
    102                                                 showDiv('patientSearchBox'); 
    103                                         } 
    104                                         else { 
    105                                                 _selectedPatientId = patient.patientId; 
    106                                                 loadPatient(patient); 
    107                                                 $j(".idMatch").show(); 
    108                                                 $j(".nameMatch").hide(); 
    109                                                 $j(".createdPatientMatch").hide(); 
    110                                                 $j("#orderDetailSection").show(); 
    111                                                 $j("#createOrderSection").show();                
    112                                         } 
    113                                         $('newPatientIdentifier').innerHTML = patId; 
    114                                 }); 
     105                                if (patient.patientId == null) { 
     106                                        $j("#nameMatchSection").show(); 
     107                                } 
     108                                else { 
     109                                        _selectedPatientId = patient.patientId; 
     110                                        loadPatient(patient); 
     111                                        $j(".idMatch").show(); 
     112                                        $j("#matchedPatientSection").show(); 
     113                                        $j("#newOrderSection").show(); 
     114                                        showNewOrder(); 
     115                                } 
     116                                $('newPatientIdentifier').innerHTML = patId; 
     117                        }); 
    115118                } 
    116119         
     
    121124                        var newFirstName = $('newFirstName').value; 
    122125                        var newLastName = $('newLastName').value; 
    123                         var newGender = $j("input[@name='newGender']:checked").val(); 
     126                        var newGender = $j("input[name='newGender']:checked").val(); 
    124127                        var newAge = $('newAge').value; 
    125128                        var newCountyDistrict = $('newCountyDistrict').value; 
     
    130133                                                                                                        newCountyDistrict, newCityVillage, newNeighborhoodCell, newAddress1,  
    131134                                                                                                        {       callback:function(createdPatient) { 
     135                                                                                                                        clearPatientAndSearchFields(); 
    132136                                                                                                                        _selectedPatientId = createdPatient.patientId; 
    133137                                                                                                                        $j("#matchedIdentifier").text(newIdent); 
     
    139143                                                                                                                        $j("#matchedCell").text(createdPatient.neighborhoodCell); 
    140144                                                                                                                        $j("#matchedAddress1").text(createdPatient.address1); 
    141                                                                                                                         showDiv('createOrderSection'); 
    142                                                                                                                         hideDiv('createPatientSection'); 
    143                                                                                                                         $j(".idMatch").hide(); 
    144                                                                                                                         $j(".nameMatch").hide(); 
    145                                                                                                                         $j(".createdPatientMatch").show(); 
     145                                                                                                                        $j("#matchedPatientSection").show(); 
     146                                                                                                                        $j(".createdPatientMatch").show(); 
     147                                                                                                                        showNewOrder(); 
    146148                                                                                                                }, 
    147149                                                                                                                errorHandler:function(errorString, exception) { 
     
    153155         
    154156                function createOrder() { 
    155                         var orderLoc = $j("#matchedOrderLocation").val(); 
    156                         var orderConcept = $j("#matchedOrderConcept").val(); 
    157                         var orderDate = $j("#matchedOrderDate").val(); 
    158                         var accessionNum = $j("#matchedShortId").val(); 
     157                        var orderLoc = $j(".orderDetailSection select[name='location']").val(); 
     158                        var orderConcept = $j(".orderDetailSection select[name='concept']").val(); 
     159                        var orderDate = $j(".orderDetailSection input[name='startDate']").val(); 
     160                        var accessionNum = $j(".orderDetailSection input[name='accessionNumber']").val(); 
    159161                        DWRSimpleLabEntryService.createLabOrder(_selectedPatientId, orderConcept, orderLoc, orderDate, accessionNum,  
    160162                                        {       callback:function(createdOrder) { 
     
    171173                        matchPatientById('${patientIdType}',$('patientIdentifier').value);  
    172174                }); 
    173                  
    174                 $j("#ClearSearchButton").click( function() { 
    175                         clearFormFields(); 
    176                         clearPatientSearchFields(); 
    177                 }); 
    178                 $j("#ClearSearchButton2").click( function() { 
    179                         clearFormFields(); 
    180                         clearPatientSearchFields(); 
    181                 }); 
    182                 $j("#ClearPatientResultsButton").click( function() { 
    183                         clearFormFields(); 
    184                         clearPatientSearchFields(); 
    185                 }); 
    186  
    187                 $j("#ShowCreatePatientButton").click( function() { 
    188                         showCreatePatient(); 
    189                 }); 
    190  
    191                 $j("#CreateOrderFromIdButton").click( function() { 
    192                         createOrder(); 
    193                 }); 
     175 
    194176                $j("#CreateOrderFromNameButton").click( function() { 
    195177                        createOrder(); 
     
    205187                                        {       callback:function(revisedPatient) { 
    206188                                                        loadPatient(revisedPatient); 
    207                                                         showAddOrder(); 
     189                                                        showNewOrder(); 
    208190                                                }, 
    209191                                                errorHandler:function(errorString, exception) { 
     
    214196                }); 
    215197                $j("#NoIdentifierYesOrderButton").click( function() { 
    216                         showAddOrder(); 
     198                        showNewOrder(); 
    217199                }); 
    218200                $j("#NoIdentifierCancelButton").click( function() { 
    219                         clearPatientSearchFields(); 
    220                 }); 
    221                  
     201                        clearSearchFields(); 
     202                }); 
    222203                $j("#FindNewPatientButton").click( function() { 
    223204                        findNewPatient(); 
     
    235216 
    236217<b class="boxHeader">Add New Order</b> 
    237 <div id="findPatientSection" style="align:left;" class="box" > 
     218<div style="align:left;" class="box" > 
     219 
    238220        Enter IMB ID (Long ID):  
    239221        <input type="text" id="patientIdentifier" class="orderField" name="patientIdentifier" /> 
    240222        <input type="button" value="Search" id="SearchByIdButton" /> 
    241         <input type="button" value="Clear" id="ClearSearchButton" /> 
     223        <input type="button" value="Clear" onclick="clearFormFields();" /> 
    242224        <br/><br/> 
    243          
    244         <div id="createOrderSection" class="searchSection" style="display:none;"> 
    245                 <span id="confirmPatientSection"
    246                         <span style="color:blue; display:none;" class="idMatch">The following patient matches this ID.</span>  
    247                         <span style="color:blue; display:none;" class="nameMatch">You have selected the following patient.</span>  
    248                         <span style="color:blue; display:none;" class="createdPatientMatch">The following patient has been created.</span>  
     225 
     226        <div id="matchedPatientSection" class="searchSection" style="display:none;"> 
     227                <span id="confirmPatientSection" style="color:blue;"
     228                        <span style="display:none;" class="idMatch">The following patient matches this ID.</span>  
     229                        <span style="display:none;" class="nameMatch">You have selected the following patient.</span>  
     230                        <span style="display:none;" class="createdPatientMatch">The following patient has been created.</span>  
    249231                </span> 
    250                 <table
     232                <table id="matchedPatientTable"
    251233                        <tr> 
    252234                                <th>Long ID</th> 
     
    279261                </b> 
    280262                <br/> 
    281                 <div id="orderDetailSection" style="display:none;"> 
    282                         <b>Order Details</b> 
    283                         <table> 
    284                                 <tr> 
    285                                         <th>Short ID:</th> 
    286                                         <td><input type="text" class="orderField" id="matchedShortId" name="matchedShortId" /></td> 
    287                                         <th><spring:message code="simplelabentry.orderLocation" />:</td> 
    288                                         <td><openmrs_tag:locationField formFieldName="matchedOrderLocation" initialValue="${param.orderLocation}"/></td> 
    289                                         <th><spring:message code="simplelabentry.orderType" />:</td> 
    290                                         <td> 
    291                                                 <select id="matchedOrderConcept" class="orderField" name="matchedOrderConcept"> 
    292                                                         <option value=""></option> 
    293                                                         <c:forEach items="${model.labSets}" var="labSet" varStatus="labSetStatus"> 
    294                                                                 <option value="${labSet.conceptId}" <c:if test="${param.orderConcept == labSet.conceptId}">selected</c:if>> 
    295                                                                         ${empty labSet.name.shortName ? labSet.name.name : labSet.name.shortName} 
    296                                                                 </option> 
    297                                                         </c:forEach> 
    298                                                 </select> 
    299                                         </td> 
    300                                         <th><spring:message code="simplelabentry.orderDate" />: </td> 
    301                                         <td><input type="text" class="orderField" id="matchedOrderDate" name="matchedOrderDate" size="10" value="${param.orderDate}" onFocus="showCalendar(this)" /></td> 
    302                                 </tr> 
    303                         </table>         
    304                         <br/> 
    305                         <div id="orderResultsSection" style="display:none;"> 
    306                                 <b>Results</b> 
    307                                 <c:forEach items="${model.labSets}" var="labSet" varStatus="labSetStatus"> 
    308                                         <div id="labResultSection${labSet.conceptId}" style="display:none;"> 
    309                                                 <form action="#"> 
    310                                                         <table> 
    311                                                                 <tr> 
    312                                                                         <openmrs:forEachRecord name="conceptSet" conceptSet="${labSet.conceptId}"> 
    313                                                                                 <th>${empty record.name.shortName ? record.name.name : record.name.shortName}</th> 
    314                                                                         </openmrs:forEachRecord> 
    315                                                                 </tr> 
    316                                                                 <tr> 
    317                                                                         <openmrs:forEachRecord name="conceptSet" conceptSet="${labSet.conceptId}"> 
    318                                                                                 <td><openmrs_tag:obsValueField conceptId="${record.conceptId}" formFieldName="test" size="5" /> 
    319                                                                         </openmrs:forEachRecord> 
    320                                                                 </tr> 
    321                                                         </table> 
    322                                                 </form> 
    323                                         </div> 
    324                                 </c:forEach> 
    325                         </div> 
    326                         <br/> 
    327                         <input type="button" id="CreateOrderFromIdButton" value="Create Order" /> 
    328                         <input type="button" id="ClearPatientResultsButton" value="Cancel, Do not Create" /> 
    329                 </div> 
     263                <div id="newOrderSection"></div> 
    330264        </div> 
    331265         
     
    369303                                <td> 
    370304                                        <input type="button" value="Create Patient" id="CreatePatientButton" /> 
    371                                         <input type="button" value="Cancel" id="ClearSearchButton2"> 
     305                                        <input type="button" value="Cancel" onclick="clearFormFields();"> 
    372306                                </td> 
    373307                        </tr> 
     
    375309        </div> 
    376310</div> 
     311 
     312<div class="orderDetailTemplate" style="display:none;"> 
     313        <b>Order Details</b> 
     314        <form action=""> 
     315                <input type="hidden" name="patientId" value="" /> 
     316                <input type="hidden" name="orderId" value="" /> 
     317                <table> 
     318                        <tr> 
     319                                <th>Short ID:</th> 
     320                                <td><input type="text" class="accessionNumber" name="accessionNumber" /></td> 
     321                                <th><spring:message code="simplelabentry.orderLocation" />:</td> 
     322                                <td><openmrs_tag:locationField formFieldName="location" /></td> 
     323                                <th><spring:message code="simplelabentry.orderType" />:</td> 
     324                                <td> 
     325                                        <select name="concept"> 
     326                                                <option value=""></option> 
     327                                                <c:forEach items="${model.labSets}" var="labSet" varStatus="labSetStatus"> 
     328                                                        <option value="${labSet.conceptId}">${empty labSet.name.shortName ? labSet.name.name : labSet.name.shortName}</option> 
     329                                                </c:forEach> 
     330                                        </select> 
     331                                </td> 
     332                                <th><spring:message code="simplelabentry.orderDate" />: </td> 
     333                                <td><input type="text" name="startDate" size="10" onFocus="showCalendar(this)" /></td> 
     334                        </tr> 
     335                </table>         
     336                <br/> 
     337                <div class="orderResultsSection" style="display:none;"> 
     338                        <b>Results</b> 
     339                        <c:forEach items="${model.labSets}" var="labSet" varStatus="labSetStatus"> 
     340                                <div id="labResultSection${labSet.conceptId}" style="display:none;"> 
     341                                        <table> 
     342                                                <tr> 
     343                                                        <openmrs:forEachRecord name="conceptSet" conceptSet="${labSet.conceptId}"> 
     344                                                                <th>${empty record.name.shortName ? record.name.name : record.name.shortName}</th> 
     345                                                        </openmrs:forEachRecord> 
     346                                                </tr> 
     347                                                <tr> 
     348                                                        <openmrs:forEachRecord name="conceptSet" conceptSet="${labSet.conceptId}"> 
     349                                                                <td><openmrs_tag:obsValueField conceptId="${record.conceptId}" formFieldName="test" size="5" /> 
     350                                                        </openmrs:forEachRecord> 
     351                                                </tr> 
     352                                        </table> 
     353                                </div> 
     354                        </c:forEach> 
     355                </div> 
     356                <br/> 
     357                <input type="button" name="CreateOrderButton" value="Create Order" /> 
     358                <input type="button" value="Cancel, Do not Create" onclick="clearFormFields();" /> 
     359        </form> 
     360</div> 
  • openmrs-modules/specimentracking/web/src/org/openmrs/module/specimentracking/web/dwr/DWRSimpleLabEntryService.java

    r5032 r5043  
    3030        // ******************* 
    3131         
     32        // TODO: Add comments 
     33         
    3234        public LabPatientListItem getPatient(Integer patientId) { 
    3335                log.warn("Getting patient: " + patientId);