Permalink
Browse files

added theater data form tests

  • Loading branch information...
merovingienne committed Aug 27, 2017
1 parent 0cedcea commit 887749049695acf832b24a2edaa2d064f6fa70cb
@@ -51,8 +51,15 @@ ${project.parent.artifactId}.procedure.button.new=New Procedure
${project.parent.artifactId}.pastProcedure.failedToAdd= Failed to add past procedure.
${project.parent.artifactId}.pastProcedure.invalidName= Invalid procedure name.
${project.parent.artifactId}.pastProcedure.invalidDate= Invalid procedure date.
${project.parent.artifactId}.pastProcedure.invalidComment= Invalid procedure comment.
${project.parent.artifactId}.pastProcedure.successfullyAdded=Successfully saved past procedure record.
${project.parent.artifactId}.drug.failedToAdd= Failed to add drug prescription.
${project.parent.artifactId}.drug.invalidDrug= Invalid drug.
${project.parent.artifactId}.drug.invalidQuantity= Invalid drug quantity.
${project.parent.artifactId}.drug.invalidNote= Invalid prescription notes.
${project.parent.artifactId}.drug.successfullyAdded=Drug prescription successfully added.
${project.parent.artifactId}.procedure.nameDuplicated=Name is duplicated
${project.parent.artifactId}.procedure.longName.errorMessage= Name must have less than 100 characters
@@ -51,7 +51,24 @@
throw new IllegalArgumentException("Surgery doesn't exist");
}
List<Drug> drugList = Drug.getAllDrugs(surgery, Integer.parseInt(workflowPos));
if (workflowPos == null || workflowPos.length() == 0){
throw new IllegalArgumentException("Invalid workflow stage");
}
int workflowPosition;
try {
workflowPosition = Integer.parseInt(workflowPos);
if (workflowPosition != 2 && workflowPosition != 3){
throw new IllegalArgumentException("Invalid workflow stage");
}
} catch (NumberFormatException e){
throw new IllegalArgumentException("Invalid workflow stage");
}
List<Drug> drugList = Drug.getAllDrugs(surgery, workflowPosition);
if (drugList == null){
drugList = Collections.emptyList();
@@ -93,12 +110,24 @@ public FragmentActionResult addTheaterDrugPrescription(UiUtils ui,
return new FailureResult(ui.message("operationtheater.patient.notFound"));
}
if (surgery == null){
return new FailureResult(ui.message("operationtheater.surgery.notFound"));
}
if (!workflowPos.equalsIgnoreCase("2") && !workflowPos.equalsIgnoreCase("3")){
return new FailureResult(ui.message("Wrong surgery workflow position."));
return new FailureResult(ui.message("Invalid workflow position."));
}
if (drugConceptId == null || drugConceptId.length() == 0 || drugConceptId == "undefined"){
return new FailureResult(ui.message("Invalid drug."));
return new FailureResult(ui.message("operationtheater.drug.invalidDrug"));
}
if (drugQuantity == null || drugQuantity.length() == 0){
return new FailureResult(ui.message("operationtheater.drug.invalidQuantity"));
}
if (prescriptionNotes == null || prescriptionNotes.length() == 0){
return new FailureResult(ui.message("operationtheater.drug.invalidNote"));
}
ConceptService conceptService = Context.getConceptService();
@@ -181,6 +210,19 @@ public FragmentActionResult addOrUpdateSurgeryNote(UiUtils ui,
)
{
if (patient == null){
throw new IllegalArgumentException("Patient not found");
}
if (surgery == null){
throw new IllegalArgumentException("Surgery not found");
}
if (surgeryNote == null || surgeryNote.length() == 0){
return new FailureResult("Invalid surgery note.");
}
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
@@ -292,6 +334,12 @@ public FragmentActionResult addOrUpdateSurgeryNote(UiUtils ui,
public SimpleObject getSurgeryNote(UiUtils UI,
@RequestParam("surgery") Surgery surgery){
if (surgery == null){
throw new IllegalArgumentException("Surgery does not exist");
}
ObsService obsService = Context.getObsService();
Obs procedureObs = surgery.getSurgeryObsGroup();
@@ -319,7 +367,7 @@ public SimpleObject getSurgeryNote(UiUtils UI,
/**
*
* Helper Method
* @param patient
* @param conceptId
* @return
@@ -92,6 +92,14 @@ public FragmentActionResult addPastProcedureRecord(UiUtils ui,
return new FailureResult(ui.message("operationtheater.pastProcedure.invalidName"));
}
if (pastProcedureDate == null){
return new FailureResult(ui.message("operationtheater.pastProcedure.invalidDate"));
}
if (pastProcedureComment == null){
return new FailureResult(ui.message("operationtheater.pastProcedure.invalidComment"));
}
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
@@ -213,12 +221,20 @@ public FragmentActionResult addPretheaterDrugPrescription(UiUtils ui,
return new FailureResult(ui.message("operationtheater.patient.notFound"));
}
if (surgery == null){
return new FailureResult(ui.message("operationtheater.surgery.notFound"));
}
if (drugConceptId == null || drugConceptId.length() == 0 || drugConceptId == "undefined"){
return new FailureResult(ui.message("Invalid drug."));
return new FailureResult(ui.message("operationtheater.drug.invalidDrug"));
}
if (drugQuantity == null || drugQuantity.length() == 0){
return new FailureResult(ui.message("Invalid drug quantity"));
return new FailureResult(ui.message("operationtheater.drug.invalidQuantity"));
}
if (prescriptionNotes == null || prescriptionNotes.length() == 0){
return new FailureResult(ui.message("operationtheater.drug.invalidNote"));
}
@@ -231,7 +247,7 @@ public FragmentActionResult addPretheaterDrugPrescription(UiUtils ui,
try {
drug = conceptService.getConcept(Integer.parseInt(drugConceptId));
} catch (NumberFormatException e) {
return new FailureResult(ui.message("Invalid drug."));
return new FailureResult(ui.message("operationtheater.drug.invalidDrug"));
}
Obs surgeryInfoObs = SurgeryObsUtil.getSurgeryObs(surgery, patient);
@@ -283,17 +299,18 @@ public FragmentActionResult addPretheaterDrugPrescription(UiUtils ui,
otService.saveSurgery(surgery);
} catch (Exception e){
System.out.println(e.getMessage());
return new FailureResult(ui.message("Failed to add drug prescription"));
return new FailureResult(ui.message("operationtheater.drug.failedToAdd"));
}
log.info("Pre-theater prescription successfully added.");
return new SuccessResult(ui.message("Drug prescription successfully added."));
return new SuccessResult(ui.message("operationtheater.drug.successfullyAdded"));
}
/**
* Helper method
* Create pre-theater drugs obs group if null.
* @param patient
* @return
@@ -41,31 +41,31 @@
padding: 100px 0px;">
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Name
Name<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px">
<input type="text" id="inTheaterDrugName" name="inTheaterDrugName" required autocomplete="off">
</td>
</tr>
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Quantity
Quantity<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px;">
<input type="number" id="inTheaterDrugQuantity" name="inTheaterDrugQuantity" required>
</td>
</tr>
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Time & Notes
Time & Notes<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px">
<textarea rows="3" id="inTheaterDrugNotes" placeholder="Unit, additional notes etc." required></textarea>
</td>
</tr>
</table>
<button type="button" style="margin: 10px 0px" id="addInTheaterDrug">Add</button>
<p id="inTheaterErrorMsg"></p>
<p id="inTheaterDrugErrorMsg"></p>
</form>
</div>
@@ -41,23 +41,23 @@
padding: 100px 0px;">
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Name
Name<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px">
<input type="text" id="postTheaterDrugName" name="postTheaterDrugName" required>
</td>
</tr>
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Quantity
Quantity<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px;">
<input type="number" id="postTheaterDrugQuantity" name="inTheaterDrugQuantity" required>
</td>
</tr>
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Time & Notes
Time & Notes<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px">
<textarea rows="3" id="postTheaterDrugNotes" placeholder="Time after surgery, additional notes etc." required></textarea>
@@ -66,7 +66,7 @@
</table>
</form>
<button style="margin: 10px 0px" id="addPostTheaterDrug">Add</button>
<p id="postTheaterErrorMsg" style="display: none"></p>
<p id="postTheaterDrugErrorMsg" style="display: none"></p>
</div>
<% } %>
@@ -43,7 +43,7 @@
padding: 100px 0px;">
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Name
Name<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px">
${ui.includeFragment("uicommons", "field/text", [
@@ -57,21 +57,15 @@
</tr>
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Quantity
Quantity<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px;">
${ ui.includeFragment('uicommons', 'field/text', [
label: '',
formFieldName: "preTheaterDrugQuantity",
id : "preTheaterDrugQuantity",
maxLength : 50,
initialValue : ''
]) }
<input type="number" id="preTheaterDrugQuantity" name="inTheaterDrugQuantity" required>
</td>
</tr>
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Time & Notes
Time & Notes<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px">
<textarea rows="3" id="preTheaterDrugNotes" placeholder="Time before surgery, additional notes etc."></textarea>
@@ -80,6 +74,7 @@
</table>
</form>
<button style="margin: 10px 0px" id="addPreTheaterDrug">Add</button>
<p id="preTheaterDrugErrorMsg" style="display: none"></p>
</div>
<% } %>
@@ -132,15 +132,15 @@ ${ ui.includeFragment('operationtheater', 'surgeryHeader', [
padding: 100px 0px;">
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Procedure name
Procedure name<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px">
<input type="text" id="pastProcedureName">
</td>
</tr>
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Procedure date
Procedure date<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px;">
${ ui.includeFragment('uicommons', 'field/datetimepicker', [
@@ -153,7 +153,7 @@ ${ ui.includeFragment('operationtheater', 'surgeryHeader', [
</tr>
<tr style="border: none; background-color: #F2F2F2">
<td style="border: none; min-width: 60px;">
Procedure comment
Procedure comment<span style="color: red;">*</span>
</td>
<td style="border: none; min-width: 100px">
<textarea rows="3" id="pastProcedureComment" placeholder="Comments, diagnosis etc."></textarea>
@@ -120,7 +120,7 @@
var drug = drugConceptMap[jq('#' + table + 'DrugName').val()];
var quantity = jq('#' + table + 'DrugQuantity').val();
var notes = jq('#' + table + 'DrugNotes').val();
var error = jq('#' + table + 'ErrorMsg');
var error = jq('#' + table + 'DrugErrorMsg');
error.hide();
if (jq('#' + table + 'DrugName').val() == 0){
@@ -138,10 +138,7 @@
error.show();
return;
}
console.log("Request data");
console.log('drug: ', drug);
console.log('quantity: ', quantity);
@@ -69,10 +69,27 @@
preTheaterDrugs.add = function(){
var drug = drugConceptMap[jq('#preTheaterDrug-field').val()];
var quantity = jq('#preTheaterDrugQuantity-field').val();
var quantity = jq('#preTheaterDrugQuantity').val();
var notes = jq('#preTheaterDrugNotes').val();
var error = jq('#preTheaterDrugErrorMsg');
error.hide();
if (jq('#preTheaterDrug-field').val() == 0){
error.text("Please enter a drug.");
error.show();
return;
}
else if (quantity.length == 0){
error.text("Please enter a quantity.");
error.show();
return;
}
else if (notes == "") {
error.text("Please enter notes (unit of quantity etc.)");
error.show();
return;
}
console.log("Request data");
console.log('drug: ', drug);
Oops, something went wrong.

0 comments on commit 8877490

Please sign in to comment.