Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
37 views

Assignment #1 (Database Unix Prog)

This document provides requirements for an assignment to write a Unix/bash script to search a medication list file and output matching results. The script must prompt the user, search the specified column of a formatted text file for medication codes, and return the corresponding generic name or dose based on the user's input. Comments are required answering questions about concepts learned and difficulties encountered.

Uploaded by

deyepiw524
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Assignment #1 (Database Unix Prog)

This document provides requirements for an assignment to write a Unix/bash script to search a medication list file and output matching results. The script must prompt the user, search the specified column of a formatted text file for medication codes, and return the corresponding generic name or dose based on the user's input. Comments are required answering questions about concepts learned and difficulties encountered.

Uploaded by

deyepiw524
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

CCPS 393 - Assignment #1 (database)

Write a Unix /bin/bash program to search a medication list and produce a report as requested by
the user.

The file medslist is a flat plain text file with the following format shown in the table below.

Columns Data field

01 - 04 Category

05 - 18 Dose

19 - 26 Medication Code

27 - 39 Generic Name

40 - 46 On-Hand (inventory)

Example of the " medslist " file... (The first two lines represent columns numbers, not in file)

0 1 2 3 4 5 6
123456789012345678901234567890123456789012345678901234567890
comm 30A6314 ifosfamide 12
home6314 5341209 urokinase 37

...
etc.

Program Requirements
● Continually prompt the user to enter a Medication Code or portion thereof (should not
have to re-run program for each search). Use “ZZZ” (upper case only) to exit program
from the "Enter Medication Code" prompt.
● Ask the user if they wish to see the corresponding Generic Name (G) or Dose (D); reject
any other input with an error message (“Please enter only G or D.”) and re-prompt user
continually if necessary.
● Search only the Medication Code field of the data file displaying the all occurrences of
matching Medication Code (s) and corresponding Generic Name or Dose.
○ E.g. A search for the Medication Code "6314", should not display any information
about Medication Code "5341209". i.e. the search must be restricted to the
information in the Medication Code field.
● Print a separator character (e.g. colon) between the information fields (see sample
output).
● Include partial matches of Medication Code (e.g. 234 is contained in Medication Code
12345). Keep the search case-sensitive.
● Use the sample data file from the course website. Sample file is not exhaustive or
representative of all situations. For example, don't expect particular values in the
Category field (only letters, etc.) to limit your search of the Medication Code field.
● If no match is found, output "No such Medication Code."
● If you create any temporary files, they must be cleaned up by your program before it
terminates.
● Your program must perform its search and report strictly based on column numbers.
The data file may contain any type of character in any field. (e.g. do not assume that the
Medication Code consists of only numbers or that the Dose must contain letters)
● Your script must be directly executable (i.e. run with "./search" not "bash search")
● Your program must not use any text processing utilities like awk, sed, or perl.
● You must not modify the given data file. Your program must work on any data file of the
format given above - not just the given sample data file.

Comprehensive section (mandatory):


● Add a section of comments in the file containing your code (The # (hash/number sign)
character introduces a comment in Unix scripts) in which you answer the following
questions:
1. Name two Unix or programming concepts which this assignment helped you
learn or become more comfortable.
2. Describe two difficulties or problems which you encountered in completing the
assignment. These could be academic, technical, or non-technical.
● Answer each question in a few sentences.
● See sample comment block below. You can paste this and fill in your own words.
# This is a comment in Unix
#
# Comprehensive section:
#
# 1. This assignment helped ...
#
# 2. My two difficulties were ...
#

Sample execution (not exhaustive testing):

$ ./search
Enter Medication Code? 6314
See Generic Name (G/g) or Dose (D/d)? G
A6314 : ifosfamide
Enter Medication Code? 23
See Generic Name (G/g) or Dose (D/d)? j
Please enter only G or D.
See Generic Name (G/g) or Dose (D/d)? d
12345 : ug 200
9230 : pg 6000
Enter Medication Code? foo
See Generic Name (G/g) or Dose (D/d)? D
No such Medication Code.
Enter Medication Code? ZZZ
Good bye.
$

Recommendations on getting started


This assignment is designed to be completed using course material (lecture, lab exercises, OER
ebook Productivity in Common Operating Systems, etc.). You should not need to access
external resources. If you do use external resources, you must provide citations as a code
comment.

Short-cut easy approach: Do all the lab exercises first, in particular Lab 4, Lab 5, and Lab 6.
Review your notes on loops. Apply lessons learned. Design your program structure ahead of
time. Program incrementally -- code a few lines at a time and get it working.
School of Hard Knocks long way: Skip the labs and start coding! Type in your whole
program, pray, then try running it. Stumble, get stuck, be prepared to waste a lot of time
"discovering" things covered in the lab exercises. Expect on having to re-write your program a
few times.

A word on testing
Part of the task of this assignment is to think of your own test cases to see if your program
meets the specified requirements. You should not rely on the short sample above as your entire
test suite. Of course, if your program's behaviour does not even match even the given sample,
this likely indicates serious deficiencies which you need to address before submitting.

Sample datafile
Use the datafile within our Unix environment at the following path:

~lhiraki/open/ccps393/medslist

Simply use this path as the input file for your program. While hard-coding the path and name of
the datafile is not normally recommended, please go ahead and hard-code this path for ease of
marking. Do not have your program prompt the user to enter a filename, etc.

Note:
1. Your program must read this data file from the path given above. Do not make a local
copy in your home directory.
2. Your program must run from any directory on this Unix system (portable). Do not make
path references to files or directories within your home directory.

Grading Scheme
Grading credit is intended to reflect the value to the customer. If your program has a few bugs
and is delivered "as-is" to the customer. How much value does it still offer to the customer, and
how much do you think the customer would want to pay?

Ask yourself these questions:


1. If your loved one could be treated with a particular drug, but a computer program did not
always find all matches, how valuable is such a program?
2. If a computer program sometimes displays the wrong drug dose (3 instead of 30, etc.),
how valuable is such a program?
Please note: Programs are expected to be free from syntax errors and should not "bomb".
Programs which generate syntax errors or terminate abnormally will not be eligible for partial
credit, even if a few parts "sort-of" work.
Tier Tier Requirements Mark out of 5

0 ● duly submitted in the required manner (correct format, correct 1


computer system, etc.) -- customer delivery
● written in Unix bash
● no fatal errors (e.g. program bombs, terminates abnormally)
● rudimentary functionality toward solving required problem
(looping, attempted search of key field, user dialog, etc.)
● no use of awk, sed, perl, or other text processing utilities
● complete comprehensive section (explanation of learning and
difficulties)

1 ● Critical requirement: search is correctly restricted to med 2


code field (no false matches (hits))
● code actually restricts search to key field (not grep line)
● at most one off-by-one error

2 ● correct and complete output (see name and corresponding 3


data)
● reports all matches in file (not just first hit; no missing matches)
● code searches key field but has minor technical error (* special
cases but don't want to give away solution)

3 ● no control flow errors (prompting sequence matches given 4


sample, no prompting for file name, etc.)
● continually prompts for med code (not just a single enquiry)
● continually prompts/re-prompts for name or dose in case of
user error
● operates directly on given data file (i.e. no local or secondary
copies, no modified versions of the data file)

4 Perfect or almost perfect 5


● search is case-sensitive
● complete and accurate academic integrity statement
● clean up temporary files (if used)
● adheres to Style Guide (See D2L -> Content -> Assignments ->
Style Guide) showing awareness of software maintenance cost
control
● program is directly executable with appropriate permissions
No more than one issue with:
● filename of program as requested in instructions
● errors in title block
● missing or inaccurate citations
● missing or incorrect separator character for output formatting
● missing "not found" message if no hits in database
● uses self-describing variable names ($result, $operand, etc.
NOT $a, $b, $c, etc.)
● shebang line #!/bin/bash missing or not the first line of the file

You need to meet all requirements of a lower tier before being eligible for a higher tier. If you
meet all Tier 1 requirements and most of the Tier 2 requirements, you are still at only Tier 1.
Even if you had all the Tier 4 requirements met, but did not meet Tier 2, you would still be at Tier
1.

Programs are expected to be free from syntax errors. Programs will be tested on the TMU SCS
(moon) system. Programs with compile problems are not ready for submission and will receive
zero.

Missing the customer presentation will result in a one-level Tier reduction.

Grading Notes
Recall principle: Client value. How useful is your program at the nursing station of a hospital?

Example 1

Student's program works fine with no technical deficiencies but is missing the comprehensive
section. Result: Tier 0 not achieved. Overall mark is 0/5.
Example 2

Student's program produces a false match (outside key field). The search was not restricted to
the key field. There are no other technical deficiencies. Result: Tier 0 achieved. Overall mark is
1/5.

Example 3

Student's program output is incomplete in listing all matches (e.g. only 2 of expected 3 matching
drugs shown). Result: Tier 1. Overall mark is 2/5.

Example 4

Student's program correctly restricts search to key field and produces correct and complete
output, but allows only one enquiry per run or does not allow user to make multiple attempts at
the G/D prompt. Result: Tier 2. Overall mark is 3/5.

Example 5

Student's program includes display of wrong columns (e.g. drug dose shown as 3 instead of 30).
This is the only error. Code correctly restricts search (no false or missing matches); control flow
and prompting are complete and correct. Result: Tier 1. Overall mark is 2/5.

Example 6

Student's program meets all functional requirements, but is missing some title block information
and the shebang line (#!/bin/bash). Result: Tier 3. Overall mark is 4/5.

Example 7

Student's program meets the Tier 2 requirements but the student does not attend the customer
presentation by the due date. Result: Tier 1 (one level reduction). Overall mark is 2/5.
Submission instructions
1. Name your file "search" (not search.sh, midterm_prog, medication, etc.)
2. Please follow the instructions in D2L (Content-> Assignments -> Unix moon submission
instructions).

You might also like