How to use EndDate method of testresult Package

Best Testkube code snippet using testresult.EndDate

store.go

Source:store.go Github

copy

Full Screen

1package store2import (3 "bz.moh.epi/godatatools/age"4 "bz.moh.epi/godatatools/models"5 "context"6 _ "embed"7 "encoding/json"8 "fmt"9 "go.mongodb.org/mongo-driver/bson"10 "go.mongodb.org/mongo-driver/bson/primitive"11 mn "go.mongodb.org/mongo-driver/mongo"12 "go.mongodb.org/mongo-driver/mongo/options"13 "time"14)15type Store struct {16 Database string17 URI string18 Client *mn.Client19 Connect func(context.Context) error20 Disconnect func(ctx context.Context) error21}22const personCollection = "person"23const outbreakCollection = "outbreak"24const labCollection = "labResult"25const accessTokenCollection = "accessToken"26const userCollection = "user"27//go:embed locs2.json28var rawLocations []byte29type CasesById struct {30 Id string31 Cases []models.Case32}33func New(uri, database string) (Store, error) {34 client, err := mn.NewClient(options.Client().ApplyURI(uri))35 if err != nil {36 return Store{}, MongoConnectionErr{37 Reason: "failed to create mongo client",38 Inner: err,39 }40 }41 return Store{42 Database: database,43 URI: uri,44 Client: client,45 Connect: client.Connect,46 Disconnect: client.Disconnect,47 }, nil48}49func (s *Store) FindCasesByOutbreak(ctx context.Context, ID string, startDate, endDate *time.Time) ([]models.Case, error) {50 var cases []models.Case51 if startDate.After(*endDate) {52 return cases, fmt.Errorf("startDate must be before endDate")53 }54 collection := s.Client.Database(s.Database).Collection(personCollection)55 filter := bson.M{56 "outbreakId": ID,57 "$and": bson.A{58 bson.M{"createdAt": bson.M{59 "$gte": startDate}},60 bson.M{"createdAt": bson.M{61 "$lt": endDate.Add(time.Hour * 24)}},62 }}63 cursor, err := collection.Find(ctx, filter)64 if err != nil {65 return cases, MongoQueryErr{66 Reason: "error searching for cases by outbreakId",67 Inner: err,68 }69 }70 if err := cursor.All(ctx, &cases); err != nil {71 curr := cursor.ID()72 return cases, MongoQueryErr{73 Reason: fmt.Sprintf("failed to decode the result of cases for the outbreak: %s curr: %v", ID, curr),74 Inner: err,75 }76 }77 var result []models.Case78 for _, c := range cases {79 if c.Questionnaire.BhisNumber != nil {80 c.Bhis = c.Questionnaire.BhisNumber[0].Value81 }82 result = append(result, c)83 }84 return result, nil85}86// FindCasesByPersonIds will find all the cases for the corresponding person ids.87func (s *Store) FindCasesByPersonIds(ctx context.Context, IDs []string) (map[string]*models.LabTestCase, error) {88 var indexDB = make(map[string]*models.LabTestCase)89 collection := s.Client.Database(s.Database).Collection(personCollection)90 locations := make(map[string]models.AddressLocation)91 err := json.Unmarshal(rawLocations, &locations)92 if err != nil {93 return indexDB, MongoQueryErr{94 Reason: "failed to unmarshal locations",95 Inner: err,96 }97 }98 filter := bson.M{99 "_id": bson.M{"$in": IDs},100 "deleted": false,101 }102 cursor, err := collection.Find(ctx, filter)103 if err != nil {104 return indexDB, MongoQueryErr{105 Reason: "error searching for persons by ids",106 Inner: err,107 }108 }109 defer cursor.Close(ctx)110 for cursor.Next(ctx) {111 var person models.LabTestCase112 if err = cursor.Decode(&person); err != nil {113 return indexDB, MongoQueryErr{114 Reason: "error decoding person from mongo",115 Inner: err,116 }117 }118 // Find location119 addresses := person.Addresses120 if len(addresses) > 0 {121 //location, err := s.FindLocation(ctx, addresses[0].LocationId)122 location := locations[addresses[0].LocationId]123 if err == nil {124 person.Location = &location125 }126 }127 indexDB[person.ID] = &person128 }129 return indexDB, nil130}131// FindCasesByReportingDate returns the cases reported in the specified date for the designated outbreak.132func (s *Store) FindCasesByReportingDate(ctx context.Context, outbreakID string, reportingDate time.Time) ([]models.Case, error) {133 collection := s.Client.Database(s.Database).Collection(personCollection)134 filter := bson.M{"outbreakId": outbreakID, "dateOfReporting": reportingDate}135 var cases []models.Case136 cursor, err := collection.Find(ctx, filter)137 if err != nil {138 return cases, MongoQueryErr{139 Reason: fmt.Sprintf("mongo error querying for cases on reporting date: %v for outbreak: %s", reportingDate, outbreakID),140 Inner: err,141 }142 }143 if err := cursor.All(ctx, &cases); err != nil {144 return cases, MongoQueryErr{145 Reason: fmt.Sprintf("mongo error decoding cases for reporting date: %v and outbreakId: %s", reportingDate, outbreakID),146 Inner: err,147 }148 }149 return cases, nil150}151// ListOutbreaks lists all the current outbreaks152func (s *Store) ListOutbreaks(ctx context.Context, outbreakIDS []string) ([]models.Outbreak, error) {153 collection := s.Client.Database(s.Database).Collection(outbreakCollection)154 var outbreaks []models.Outbreak155 cursor, err := collection.Find(ctx, bson.M{"_id": bson.M{"$in": outbreakIDS}})156 if err != nil {157 return outbreaks, MongoQueryErr{158 Reason: "error listing outbreaks",159 Inner: err,160 }161 }162 if err := cursor.All(ctx, &outbreaks); err != nil {163 return outbreaks, MongoQueryErr{164 Reason: "failed to decode the list of outbreaks",165 Inner: err,166 }167 }168 return outbreaks, nil169}170// OutbreakById returns an outbreak that has the specified id171func (s *Store) OutbreakById(ctx context.Context, ID string) (models.Outbreak, error) {172 collection := s.Client.Database(s.Database).Collection(outbreakCollection)173 var outbreak models.Outbreak174 filter := bson.M{"_id": ID}175 result := collection.FindOne(ctx, filter)176 if result == nil {177 return outbreak, MongoNoResultErr{178 Reason: fmt.Sprintf("no outbreak found with id: %s", ID),179 Inner: nil,180 }181 }182 if err := result.Decode(&outbreak); err != nil {183 return outbreak, MongoQueryErr{184 Reason: fmt.Sprintf("mongo: could not decode outbreak with id: %s", ID),185 Inner: err,186 }187 }188 return outbreak, nil189}190// LabTestsForCases returns a list of RawLabTest for cases provided in the caseIds191func (s *Store) LabTestsForCases(ctx context.Context, caseIds []string) ([]models.RawLabTest, error) {192 collection := s.Client.Database(s.Database).Collection(labCollection)193 filter := bson.M{"personId": bson.M{"$in": caseIds}, "deleted": false}194 var labTests []models.RawLabTest195 cursor, err := collection.Find(ctx, filter)196 if err != nil {197 return labTests, MongoQueryErr{198 Reason: fmt.Sprintf("mongo error querying lab tests for caseIds %v", caseIds),199 Inner: err,200 }201 }202 if err := cursor.All(ctx, &labTests); err != nil {203 return labTests, MongoQueryErr{204 Reason: fmt.Sprintf("mongo error decoding lab tests for caseIds: %v", caseIds),205 Inner: err,206 }207 }208 return labTests, nil209}210// LabTestsByCaseName retrieves the lab tests for a case that matches the first & last names.211func (s *Store) LabTestsByCaseName(ctx context.Context, firstName, lastName string, outbreakIDs []string) ([]models.LabTest, error) {212 var rawLabTests []models.RawLabTest213 var labTests []models.LabTest214 /// find cases by first & last names.215 personCol := s.Client.Database(s.Database).Collection(personCollection)216 firstNameRegex := primitive.Regex{Pattern: firstName, Options: "i"}217 lastNameRegex := primitive.Regex{Pattern: lastName, Options: "i"}218 filter := bson.M{219 "firstName": bson.M{"$regex": firstNameRegex},220 "lastName": bson.M{"$regex": lastNameRegex},221 "outbreakId": bson.M{"$in": outbreakIDs},222 }223 var cases []models.Case224 cursor, err := personCol.Find(ctx, filter)225 if err != nil {226 return labTests, MongoQueryErr{227 Reason: fmt.Sprintf("mongo error querying for cases records for %s %s", firstName, lastName),228 Inner: err,229 }230 }231 if err := cursor.All(ctx, &cases); err != nil {232 return labTests, MongoQueryErr{233 Reason: fmt.Sprintf("mongo error querying case records for %s %s", firstName, lastName),234 Inner: err,235 }236 }237 // Retrieve the lab tests for every case238 var caseIds []string239 for _, c := range cases {240 caseIds = append(caseIds, c.ID)241 }242 if len(caseIds) == 0 {243 return labTests, nil244 }245 rawLabTests, testsErr := s.LabTestsForCases(ctx, caseIds)246 if testsErr != nil {247 return labTests, MongoQueryErr{248 Reason: fmt.Sprintf("failed to fetch lab tests for %s %s", firstName, lastName),249 Inner: testsErr,250 }251 }252 for i, _ := range rawLabTests { //nolint:gofmt,gosimple253 labTests = append(labTests, RawLabTestToLabTest(rawLabTests[i], findCaseInCases(rawLabTests[i].PersonId, cases)))254 }255 return labTests, nil256}257// RawLabTestToLabTest converts a RawLabTest to a LabTest258func RawLabTestToLabTest(test models.RawLabTest, person models.Case) models.LabTest {259 labFacility := models.LabFacilities[test.OutbreakID]260 status, err := models.ParseLabTestStatus(test.Status)261 if err != nil {262 status = "N/A"263 }264 testType, testTypeErr := models.ParseLabTestType(test.TestType)265 if testTypeErr != nil {266 testType = "N/A"267 }268 testResult, testResultErr := models.ParseLabTestResult(test.Result)269 if testResultErr != nil {270 testResult = "N/A"271 }272 personAge := age.AgeAt(person.Dob, time.Now())273 if test.DateTesting != nil {274 personAge = age.AgeAt(person.Dob, *test.DateTesting)275 }276 var gender = person.Gender277 if gender == "LNG_REFERENCE_DATA_CATEGORY_GENDER_MALE" {278 gender = "Male"279 }280 if gender == "LNG_REFERENCE_DATA_CATEGORY_GENDER_FEMALE" {281 gender = "Female"282 }283 labTest := models.LabTest{284 ID: test.ID,285 LabName: labFacility.Name,286 PersonType: test.PersonType,287 DateSampleTaken: test.DateSampleTaken,288 DateSampleDelivered: test.DateSampleDelivered,289 DateTesting: test.DateTesting,290 DateOfResult: test.DateOfResult,291 SampleIdentifier: test.SampleIdentifier,292 SampleType: test.SampleType,293 TestType: testType,294 Result: testResult,295 Status: status,296 OutbreakID: test.OutbreakID,297 TestedFor: test.TestedFor,298 CreatedAt: test.CreatedAt,299 CreatedBy: test.CreatedBy,300 UpdatedAt: test.UpdatedAt,301 Person: models.Person{302 ID: person.ID,303 FirstName: person.FirstName,304 LastName: person.LastName,305 Gender: gender,306 Dob: person.Dob,307 Age: personAge,308 Documents: person.Documents,309 },310 LabFacility: labFacility,311 }312 return labTest313}314// RawLabTestToLabReport converts a RawLabTest to a LabReport315func RawLabTestToLabReport(test models.RawLabTest, person models.LabTestCase) models.LabTestReport {316 labFacility := models.LabFacilities[test.OutbreakID]317 status, err := models.ParseLabTestStatus(test.Status)318 if err != nil {319 status = "N/A"320 }321 testType, testTypeErr := models.ParseLabTestType(test.TestType)322 if testTypeErr != nil {323 testType = "N/A"324 }325 testResult, testResultErr := models.ParseLabTestResult(test.Result)326 if testResultErr != nil {327 testResult = "N/A"328 }329 labTest := models.LabTestReport{330 ID: test.ID,331 LabName: labFacility.Name,332 PersonType: test.PersonType,333 DateSampleTaken: test.DateSampleTaken,334 DateSampleDelivered: test.DateSampleDelivered,335 DateTesting: test.DateTesting,336 DateOfResult: test.DateOfResult,337 SampleIdentifier: test.SampleIdentifier,338 SampleType: test.SampleType,339 TestType: testType,340 Result: testResult,341 Status: status,342 OutbreakID: test.OutbreakID,343 TestedFor: test.TestedFor,344 CreatedAt: test.CreatedAt,345 CreatedBy: test.CreatedBy,346 UpdatedAt: test.UpdatedAt,347 UpdatedBy: test.UpdatedBy,348 Person: models.LabTestCase{349 ID: person.ID,350 FirstName: person.FirstName,351 LastName: person.LastName,352 MiddleName: person.MiddleName,353 Gender: person.Gender,354 Dob: person.Dob,355 VisualID: person.VisualID,356 Bhis: person.Bhis,357 ReportingDate: person.ReportingDate,358 CreatedAt: person.CreatedAt,359 CreatedBy: person.CreatedBy,360 Occupation: person.Occupation,361 Classification: person.Classification,362 DateBecameCase: person.DateBecameCase,363 DateOfOnset: person.DateOfOnset,364 RiskLevel: person.RiskLevel,365 RiskReason: person.RiskReason,366 Outcome: person.Outcome,367 DateOfOutcome: person.DateOfOutcome,368 Addresses: person.Addresses,369 Documents: person.Documents,370 },371 LabFacility: labFacility,372 }373 return labTest374}375// LabTestById searches for a lab test that has the specified id.376func (s *Store) LabTestById(ctx context.Context, id string) (models.LabTest, error) {377 labCol := s.Client.Database(s.Database).Collection(labCollection)378 filter := bson.D{{"_id", id}} //nolint:govet379 var rawLabTest models.RawLabTest380 err := labCol.FindOne(ctx, filter).Decode(&rawLabTest)381 if err != nil {382 return models.LabTest{}, MongoQueryErr{383 Reason: "LabTestById() error",384 Inner: err,385 }386 }387 personCol := s.Client.Database(s.Database).Collection(personCollection)388 personFilter := bson.D{{"_id", rawLabTest.PersonId}} //nolint:govet389 var person models.Case390 personErr := personCol.FindOne(ctx, personFilter).Decode(&person)391 if personErr != nil {392 return models.LabTest{}, MongoQueryErr{393 Reason: "LabTestById() error querying person",394 Inner: personErr,395 }396 }397 labTest := RawLabTestToLabTest(rawLabTest, person)398 return labTest, nil399}400func findCaseInCases(caseId string, cases []models.Case) models.Case {401 var person models.Case402 for i, _ := range cases { //nolint:gofmt,gosimple403 if caseId == cases[i].ID {404 person = cases[i]405 break406 }407 }408 return person409}410// FindLabTestsByDateRange returns all lab tests that occurred between two dates411func (s *Store) FindLabTestsByDateRange(ctx context.Context, startDate, endDate *time.Time, outbreakIDs []string) ([]models.LabTestReport, error) {412 var rawLabTests []models.RawLabTest413 var labTests []models.LabTestReport414 if startDate.After(*endDate) {415 return labTests, fmt.Errorf("startDate must be before endDate")416 }417 filter := bson.M{418 "deleted": false,419 "$and": bson.A{420 bson.M{"createdAt": bson.M{"$gte": startDate}},421 bson.M{"createdAt": bson.M{"$lt": endDate.Add(time.Hour * 24)}},422 bson.M{"outbreakId": bson.M{"$in": outbreakIDs}},423 },424 }425 labCol := s.Client.Database(s.Database).Collection(labCollection)426 cursor, err := labCol.Find(ctx, filter)427 if err != nil {428 return labTests, MongoQueryErr{429 Reason: "failed to fetch lab results",430 Inner: err,431 }432 }433 if err := cursor.All(ctx, &rawLabTests); err != nil {434 return labTests, MongoQueryErr{435 Reason: fmt.Sprintf("error serializing lab tests from the db for ranges: %v, %v", startDate, endDate),436 Inner: err,437 }438 }439 var personIds []string440 for i := range rawLabTests {441 personIds = append(personIds, rawLabTests[i].PersonId)442 }443 cases, err := s.FindCasesByPersonIds(ctx, personIds)444 if err != nil {445 return labTests, MongoQueryErr{446 Reason: "failed to fetch persons for lab tests",447 Inner: err,448 }449 }450 for i := range rawLabTests {451 personID := rawLabTests[i].PersonId452 person := cases[personID]453 if person != nil {454 labTests = append(labTests, RawLabTestToLabReport(rawLabTests[i], *person))455 }456 }457 return labTests, nil458}...

Full Screen

Full Screen

pregnancy.go

Source:pregnancy.go Github

copy

Full Screen

1package labs2import (3 "database/sql"4 "fmt"5 "time"6 log "github.com/sirupsen/logrus"7)8const (9 layoutISO = "2006-01-02"10)11type testRequestItem struct {12 PatientId int13 EncounterId int14 TestRequestId int15 TestRequestItemId int16 TestName string17 TestResult string18 ReleasedTime *time.Time19 DateOrderReceivedByLab *time.Time20}21// findCurrentTestRequestItems finds all test requests in a given encounter. This is used when22// searching for a pregnant woman's test results during pregnancy.23func (d *Labs) findCurrentTestRequestItems(patientId int, lmp *time.Time) ([]testRequestItem, error) {24 if lmp == nil {25 return []testRequestItem{}, nil26 }27 //Extend the search range to a year after lmp, to make sure we also capture lab tests during labor28 endDate := lmp.Add(time.Hour * 24 * 7 * 52)29 stmt := `SELECT p.patient_id,30 e.encounter_id,31 tri.test_request_item_id,32 tr.test_request_id,33 tri.released_time,34 tr.order_received_by_lab_time,35 t.name36 FROM acsis_hc_patients p37 INNER JOIN acsis_adt_encounters e ON p.patient_id=e.patient_id 38 --AND encounter_type IN ('M', 'B')39 INNER JOIN acsis_lab_test_requests tr ON tr.encounter_id=e.encounter_id40 INNER JOIN acsis_lab_test_request_items tri ON tr.test_request_id=tri.test_request_id41 INNER JOIN acsis_lab_tests t ON tri.test_id=t.test_id42 WHERE p.patient_id=$1 AND tr.order_received_by_lab_time BETWEEN $2 AND $3`43 var testRequests []testRequestItem44 rows, err := d.AcsisDb.Query(stmt, patientId, lmp.Format(layoutISO), endDate.Format(layoutISO))45 if err != nil {46 return nil, fmt.Errorf("error retrieving test request items from acsis: %+v", err)47 }48 defer rows.Close()49 for rows.Next() {50 var t testRequestItem51 err := rows.Scan(&t.PatientId,52 &t.EncounterId,53 &t.TestRequestItemId,54 &t.TestRequestId,55 &t.ReleasedTime,56 &t.DateOrderReceivedByLab,57 &t.TestName)58 if err != nil {59 return nil, fmt.Errorf("error scanning test request item from acsis: %+v", err)60 }61 testRequests = append(testRequests, t)62 }63 return testRequests, nil64}65type testResult struct {66 Id int67 PatientId int68 TestRequestId int69 TestRequestItemId int70 ReleasedTime *time.Time71 DateOrderReceivedByLab *time.Time72 EncounterId int73 TestName string74 TestResult string75 TestLabel string76}77func (d *Labs) findTestResults(patientId int, ri []int) ([]testResult, error) {78 stmt := `79 SELECT 80 a.test_result_id,81 altr.test_request_id,82 altri.test_request_item_id,83 altri.released_time,84 altr.order_received_by_lab_time,85 e.encounter_id,86 alt.name as test,87 aludli.name as result,88 a.label89 FROM acsis_hc_patients p90 INNER JOIN acsis_adt_encounters AS e ON e.patient_id = p.patient_id91 INNER JOIN acsis_lab_test_requests altr on e.encounter_id = altr.encounter_id 92-- AND encounter_type='M'93 INNER JOIN acsis_lab_test_request_items altri on altr.test_request_id = altri.test_request_id94 INNER JOIN acsis_lab_tests alt on altri.test_id = alt.test_id95 INNER JOIN acsis_lab_test_request_results_collected altrrc on altri.test_request_item_id = altrrc.test_request_item_id96 INNER JOIN acsis_lab_test_results a on altrrc.test_result_id = a.test_result_id97 INNER JOIN acsis_lab_user_defined_list_items aludli on altrrc.user_defined_list_value = aludli.user_defined_list_item_id98 WHERE p.patient_id=$199 AND altr.test_request_id=$2100 AND e.active IS TRUE101 ORDER BY altr.last_modified_time DESC;102`103 var results []testResult104 rows, err := d.AcsisDb.Query(stmt, patientId, ri)105 if err != nil {106 return nil, fmt.Errorf("error retrieving test results for a test request items from acsis: %+v", err)107 }108 defer rows.Close()109 for rows.Next() {110 var r testResult111 err := rows.Scan(112 &r.Id,113 &r.TestRequestId,114 &r.TestRequestItemId,115 &r.ReleasedTime,116 &r.DateOrderReceivedByLab,117 &r.EncounterId,118 &r.TestName,119 &r.TestResult,120 &r.TestLabel)121 if err != nil {122 return nil, fmt.Errorf("error scanning test results when fetching test results from acsis: %+v", err)123 }124 results = append(results, r)125 }126 return results, nil127}128type testSample struct {129 TestSampleId sql.NullInt32130 CollectedTime *time.Time131 TestRequestItemId int132 TestRequestId int133}134func (d *Labs) findTestSamples(tr testRequestItem) (*testSample, error) {135 stmt := `136 SELECT 137 alts.test_sample_id,138 alts.collected_time139 FROM acsis_lab_test_request_specimen_types altrst140 INNER JOIN acsis_lab_test_request_items altri ON altri.test_request_item_id=$1141 LEFT JOIN acsis_lab_test_samples alts ON alts.test_request_specimen_type_id=altrst.test_request_specimen_type_id142 WHERE altrst.test_request_id=$2143 ORDER BY alts.collected_time144 LIMIT 1;145`146 row := d.AcsisDb.QueryRow(stmt, tr.TestRequestItemId, tr.TestRequestId)147 var s testSample148 err := row.Scan(&s.TestSampleId, &s.CollectedTime)149 switch err {150 case sql.ErrNoRows:151 return nil, nil152 case nil:153 s.TestRequestId = tr.TestRequestId154 s.TestRequestItemId = tr.TestRequestItemId155 return &s, nil156 default:157 return nil, fmt.Errorf("error retrieving lab sample info from acsis: %+v", err)158 }159}160func findLabResultIndex(rs []LabResult, id int) int {161 for i, v := range rs {162 if v.Id == id {163 return i164 }165 }166 return -1167}168func assignSamplesToResults(results []LabResult, samples []testSample) []LabResult {169 for _, s := range samples {170 for _, r := range results {171 if s.TestRequestItemId == r.TestRequestItemId {172 r.DateSampleTaken = s.CollectedTime173 }174 }175 }176 // Deduplicate results177 var r []LabResult178 for _, result := range results {179 index := findLabResultIndex(r, result.Id)180 if index < 0 {181 r = append(r, result)182 }183 }184 return r185}186// FindTestsDuringPregnancy returns all the tests conducted during a woman's pregnancy.187// Since we also need the date the sample was collected, the query gets more complicated.188// So we have to issue multiple queries to retrieve separate parts of the information.189// 0. Find the latest anc encounter.190// 1. Find all test request items.191// 2. Find test results for each test request item192// 3. Find the samples for each test request item193// 4. Create the response that will merge the data from all these queries.194func (d *Labs) FindLabTestsDuringPregnancy(patientId int, lmp *time.Time) ([]LabResult, error) {195 if lmp == nil {196 return nil, fmt.Errorf("error while retrieving lab tests during pregnancy details from acsis")197 }198 testItems, err := d.findCurrentTestRequestItems(patientId, lmp)199 if err != nil {200 return nil, fmt.Errorf("error finding current test request items from acsis when retrieving lab tests during pregnancy: %w", err)201 }202 log.WithFields(log.Fields{"testItems": testItems}).Info("test request Items")203 var labResults []LabResult204 var testRequestItemIds []int205 for _, ti := range testItems {206 testRequestItemIds = append(testRequestItemIds, ti.TestRequestItemId)207 }208 testResults, err := d.findTestResults(patientId, testRequestItemIds)209 for _, r := range testResults {210 result := LabResult{211 Id: r.Id,212 PatientId: patientId,213 TestName: fmt.Sprintf("%s - %s", r.TestName, r.TestLabel),214 TestResult: r.TestResult,215 TestRequestId: r.TestRequestId,216 TestRequestItemId: r.TestRequestItemId,217 ReleasedTime: r.ReleasedTime,218 DateOrderReceivedByLab: r.DateOrderReceivedByLab,219 DateSampleTaken: nil,220 ResultDate: nil,221 }222 labResults = append(labResults, result)223 }224 var testSamples []testSample225 for _, t := range testItems {226 sample, err := d.findTestSamples(t)227 if err != nil {228 return nil, fmt.Errorf("error finding test samples from when retrieving lab tests during prengnacy from acsis: %+v", err)229 }230 if sample != nil {231 testSamples = append(testSamples, *sample)232 }233 }234 results := assignSamplesToResults(labResults, testSamples)235 return results, nil236}...

Full Screen

Full Screen

queries.go

Source:queries.go Github

copy

Full Screen

...9type Input struct {10 Page int `json:"page"`11 TimeRange struct {12 StartDate string `json:"startDate"`13 EndDate string `json:"endDate"`14 } `json:"timeRange"`15 PerPage int `json:"perPage"`16}17type graphqlQuery struct {18 OperationName string `json:"operationName"`19 Query string `json:"query"`20 Variables map[string]interface{} `json:"variables"`21}22const cypressDateFormat = "2006-01-02"23func createMetricRequest(projectID string, from time.Time, to time.Time, size int) (io.Reader, error) {24 const graphql = `query RunsList($projectId: String!, $input: ProjectRunsConnectionInput) {25 project(id: $projectId) {26 id27 name28 ...FlakyRateEmptyStateProject29 30 runs(input: $input) {31 totalCount32 nodes {33 id34 ...RunsListItem35 }36 }37 }38 }39 40 fragment FlakyRateEmptyStateProject on Project {41 id42 isUsingRetries43 shouldUpdateCypressVersion544 }45 46 fragment RunsListItem on Run {47 id48 status49 buildNumber50 51 totalPassed52 totalFailed53 totalPending54 totalSkipped55 totalMutedTests56 startTime57 totalDuration58 scheduledToCompleteAt59 parallelizationDisabled60 cancelledAt61 totalFlakyTests62 project {63 id64 }65 ci {66 provider67 ciBuildNumberFormatted68 }69 70 commit {71 branch72 authorEmail73 }74 testResults(input: { perPage: 500 }) {75 totalCount76 nodes {77 id78 ...TestOverview79 }80 }81 }82 83 fragment TestOverview on TestResult {84 id85 titleParts86 isFlaky87 isMuted88 state89 duration90 instance {91 id92 ...DrawerRunInstance93 spec {94 id95 shortPath96 }97 }98 }99 100 fragment DrawerRunInstance on RunInstance {101 id102 status103 duration104 completedAt105 group {106 id 107 name108 }109 os {110 ...SpecOs111 }112 browser {113 ...SpecBrowser114 }115 }116 117 fragment SpecOs on OperatingSystem {118 name119 version120 }121 122 fragment SpecBrowser on BrowserInfo {123 name124 version125 } 126`127 variables := Input{128 Page: 1,129 TimeRange: struct {130 StartDate string "json:\"startDate\""131 EndDate string "json:\"endDate\""132 }{133 StartDate: from.Format(cypressDateFormat),134 EndDate: to.Format(cypressDateFormat),135 },136 PerPage: size,137 }138 query := graphqlQuery{139 OperationName: "RunsList",140 Query: graphql,141 Variables: map[string]interface{}{142 "projectId": projectID,143 "input": variables,144 },145 }146 rawJsonQuery, err := json.Marshal(query)147 if err != nil {148 return nil, err...

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 t := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)4 end := t.AddDate(0, 0, 7*2)5 fmt.Printf("End Date: %s6", end.Format("2006-01-02"))7}8Recommended Posts: Golang | time.Time.Sub() Method9Golang | time.Time.Add() Method10Golang | time.Time.Format() Method11Golang | time.Time.UTC() Method12Golang | time.Time.Local() Method13Golang | time.Time.Unix() Method14Golang | time.Time.UnixNano() Method15Golang | time.Time.Round() Method16Golang | time.Time.Truncate() Method17Golang | time.Time.Date() Method18Golang | time.Time.Clock() Method19Golang | time.Time.Day() Method20Golang | time.Time.Month() Method21Golang | time.Time.Year() Method22Golang | time.Time.Hour() Method23Golang | time.Time.Minute() Method24Golang | time.Time.Second() Method25Golang | time.Time.Nanosecond() Method26Golang | time.Time.Zone() Method27Golang | time.Time.Weekday() Method28Golang | time.Time.After() Method29Golang | time.Time.Before() Method30Golang | time.Time.Equal() Method31Golang | time.Time.IsZero() Method32Golang | time.Time.In() Method33Golang | time.Time.MarshalBinary() Method34Golang | time.Time.MarshalJSON() Method35Golang | time.Time.MarshalText() Method36Golang | time.Time.String() Method37Golang | time.Time.Unix() Method

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 t.StartTime = time.Now()4 t.EndTime = time.Now()5 fmt.Println(t.EndDate())6}7import (8func main() {9 t.StartTime = time.Now()10 t.EndTime = time.Now()11 fmt.Println(t.EndDate())12}13import (14func main() {15 t.StartTime = time.Now()16 t.EndTime = time.Now()17 fmt.Println(t.EndDate())18}19import (20func main() {21 t.StartTime = time.Now()22 t.EndTime = time.Now()23 fmt.Println(t.EndDate())24}25import (26func main() {27 t.StartTime = time.Now()28 t.EndTime = time.Now()29 fmt.Println(t.EndDate())30}31import (32func main() {33 t.StartTime = time.Now()34 t.EndTime = time.Now()35 fmt.Println(t.EndDate())36}37import (38func main() {39 t.StartTime = time.Now()40 t.EndTime = time.Now()41 fmt.Println(t.EndDate())42}43import (44func main() {

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 t.EndDate()4 fmt.Println(t.EndDate())5}6import "fmt"7func main() {8 t.EndDate()9}10import "fmt"11func main() {12 t.EndDate()13}14import "fmt"15func main() {16 t.EndDate()17}18import "fmt"19func main() {20 t.EndDate()21}22import "fmt"23func main() {24 t.EndDate()25}26import "fmt"27func main() {28 t.EndDate()29}30import "fmt"31func main() {32 t.EndDate()33}34import "fmt"35func main() {36 t.EndDate()37}38import "fmt"39func main() {40 t.EndDate()41}42import "fmt"43func main() {44 t.EndDate()45}46import "fmt"47func main() {48 t.EndDate()49}

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 tr.StartDate = time.Date(2019, 2, 12, 0, 0, 0, 0, time.UTC)4 tr.EndDate = time.Date(2019, 2, 12, 0, 0, 0, 0, time.UTC)5 fmt.Println(tr.StartDate)6 fmt.Println(tr.EndDate)7}8import (9func main() {10 tr.StartDate = time.Date(2019, 2, 12, 0, 0, 0, 0, time.UTC)11 tr.EndDate = time.Date(2019, 2, 12, 0, 0, 0, 0, time.UTC)12 fmt.Println(tr.StartDate)13 fmt.Println(tr.EndDate)14}15import (16func main() {17 tr.StartDate = time.Date(2019, 2, 12, 0, 0, 0, 0, time.UTC)18 tr.EndDate = time.Date(2019, 2, 12, 0, 0, 0, 0, time.UTC)19 fmt.Println(tr.StartDate)20 fmt.Println(tr.EndDate)21}22import (23func main() {24 tr.StartDate = time.Date(2019, 2, 12, 0, 0, 0, 0, time.UTC)25 tr.EndDate = time.Date(2019, 2, 12, 0, 0, 0, 0, time.UTC)26 fmt.Println(tr.StartDate)27 fmt.Println(tr.EndDate)28}29import (

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 t := testresult{testid: 1, testname: "test1", teststatus: "pass", endtime: time.Now()}4 fmt.Println("End Date: ", t.EndDate())5}6import (7func main() {8 t := testresult{testid: 1, testname: "test1", teststatus: "pass", endtime: time.Now()}9 fmt.Println("End Date: ", t.EndDate())10}11import (12func main() {13 t := testresult{testid: 1, testname: "test1", teststatus: "pass", endtime: time.Now()}14 fmt.Println("End Date: ", t.EndDate())15}16import (17func main() {18 t := testresult{testid: 1, testname: "test1", teststatus: "pass", endtime: time.Now()}19 fmt.Println("End Date: ", t.EndDate())20}

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 testresult := NewTestResult("Test1", "Passed", time.Now())4 endDate := testresult.EndDate()5 fmt.Println(endDate)6}

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 testresult.EndDate()4 fmt.Println(testresult.Result)5}6The import statement is used to import the packages which are present in the remote repositories. The import statement is used to import the packages which are present in the remote repositories. The import

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful